該程式碼是根據發布的解決方案構建的這裡。我正在嘗試建議的方法重複的解決方案。我有兩個問題:
我不確定如何使用這種新方法讓箭頭指向文字“自由變數”,並且
與原始矩陣相比,括號似乎更短且更接近數字。
您能幫我解決繪製箭頭指向文字的問題以及修復括號的顯示方式嗎?
這就是我希望的最終結果,謝謝!
這是代碼:
\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}