此代码是根据发布的解决方案构建的这里。我正在尝试重复的解决方案。我有两个问题:
我不知道如何使用这种新方法让箭头指向文本“自由变量”,并且
与原始矩阵相比,括号似乎更短并且更接近数字。
您能帮我解决绘制指向文本的箭头的问题以及修复括号的显示方式吗?
这就是我希望的最终结果,谢谢!:
以下是代码:
\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}