マトリックスセルを強調表示し、テキストのあるセルから矢印を向ける

マトリックスセルを強調表示し、テキストのあるセルから矢印を向ける

このコードは投稿されたソリューションから構築されていますここ私は、重複したソリューション2つの問題があります:

  1. この新しいアプローチでは、矢印を「自由変数」というテキストに向ける方法がわかりません。

  2. 元のマトリックスと比較すると、括弧は短くなり、数字に近いように見えます。

テキストを指す矢印を描画する際の問題と、括弧の表示方法を修正するのを手伝っていただけますか?

これが私が最終結果に望んでいるものです。ありがとうございます。

ここに画像の説明を入力してください

コードは次のとおりです:

\documentclass[11pt]{book}

\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{xcolor}
\definecolor{ocre}{RGB}{0,173,239}

\usepackage{blkarray}

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

\usepackage{tikz}

\usetikzlibrary{arrows,matrix,positioning,fit}
\tikzset{%
  highlight/.style={rectangle,rounded corners,fill=ocre!50,draw,
    fill opacity=0.5,thick,inner sep=0pt}
}
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,
  baseline=(#1.base)] \node (#1) {#2};}
%
\newcommand{\Highlight}[1][submatrix]{%
    \tikz[overlay,remember picture]{
    \node[highlight,fit=(left.north west) (right.south east)] (#1) {};}
}

\begin{document}

\[
\begin{blockarray}{ccccc}
x_{1} & x_{2} & x_{3} & x_{4} &  \\
\begin{block}{[cccc|c]}
  1 & 0 & \tikzmark{left}{-1} & 0 & 0 \\
  0 & 1 & 2 & 0 & 0 \\
  0 & 0 & \tikzmark{right}{0} & 1 & 0 \\
\end{block}
\end{blockarray} 
\] 
\Highlight[new1] 

\tikz[overlay,remember picture] {
  \draw[->,thick,red,dashed] (new1)  node [pos=0.66,above,text width = 2cm] {\emph{free \\ variable};
}}

\end{document} 

答え1

「自由変数」ノードを移動する必要があります。矢印は自動的に追従します。

\documentclass[11pt]{book}

\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{xcolor}
\definecolor{ocre}{RGB}{0,173,239}

\usepackage{blkarray}

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

\usepackage{tikz}

\usetikzlibrary{arrows,matrix,positioning,fit}
\tikzset{%
  highlight/.style={rectangle,rounded corners,fill=ocre!50,draw,
     fill opacity=0.5,thick,inner sep=0pt}
}
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,
  baseline=(#1.base)] \node (#1) {#2};}
%
\newcommand{\Highlight}[1][submatrix]{%
     \tikz[overlay,remember picture]{
     \node[highlight,fit=(left.north west) (right.south east)] (#1) {};}
}

\begin{document}

\[
\begin{blockarray}{ccccc}
x_{1} & x_{2} & x_{3} & x_{4} &  \\
\begin{block}{[cccc|c]}
  1 & 0 & \tikzmark{left}{-1} & 0 & 0 \\
  0 & 1 & 2 & 0 & 0 \\
  0 & 0 & \tikzmark{right}{0} & 1 & 0 \\
\end{block}
\end{blockarray} 
\] 
\Highlight[new1] 

\tikz[overlay,remember picture] {
  \node[below=(.5cm of new1), xshift=1.5cm, red,font=\itshape, name=free1] {\shortstack{free \\ variable};}}
\tikz[overlay,remember picture] \draw[->] (free1) to[out=180,in=270] (new1);

\end{document} 

ここに画像の説明を入力してください

関連情報