我想为我的学生制作一份关于高斯算法的讲义。到目前为止,我已经完成了,除了一件小事。在每个步骤中,我想使用箭头来指示刚刚执行了哪些计算。在算法的末尾,我想强调三角形的形状。它应该看起来像这样:
以下是代码片段
\documentclass[DIN, pagenumber=false, fontsize=11pt, parskip=half]{scrartcl}
\usepackage{tabularx}
\usepackage{systeme}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
\begin{table}[ht!]
\centering
\begin{tabularx}{16cm}{p{1.2cm}|X|X}
\textbf{Schritt} & \textbf{Ausf\"uhrliche Schreibweise} & \textbf{Matrixschreibweise} \\
\hline
1 & \[ \sysdelim| |
\systeme{%
x + 2y +3z = 17,
2x - 3y + 2z = 4,
3x -5y + 4z = 9\,} \] & \[ \begin{pmatrix}1 & 2 & 3 & 17 \\ 2 & -3 & 2 & 4 \\ 3 & -5 & 4 & 9 \end{pmatrix} \] \\
\hline
2 & \[ \sysdelim| |
\systeme{%
x + 2y +3z = 17,
-7y - 4z = -30,
-11y - 5z = -42\,} \] & \[ \begin{pmatrix}1 & 2 & 3 & 17 \\ 0 & -7 & -4 & -30 \\ 0 & -11 & -5 & -42 \end{pmatrix} \] \\
\hline
3 & \[ \sysdelim| |
\systeme{%
x + 2y +3z = 17,
-7y - 4z = -30,
9z = 36\,} \] & \[ \begin{pmatrix}1 & 2 & 3 & 17 \\ 0 & -7 & -4 & -30 \\ 0 & 0 & 9 & 36 \end{pmatrix} \]
\end{tabularx}
\end{table}
\end{document}
答案1
一种可能的解决方案,使用tabularray
包和tikzmark
Ti钾Z 库可以是:
\documentclass {article}
\usepackage {lipsum} % dummy text
\usepackage {tabularray}
\usepackage {tikz}
\usetikzlibrary{tikzmark}
\tikzset
{% styles
plus/.style={midway,right,yshift=#1},
my arrow/.style={-latex,thick,line cap=round,line join=round,shorten >=0.5em,shorten <=0.2em}
}
\definecolor{mygreen}{HTML}{006600}
\begin{document}
\lipsum[1]
\begin{table}[ht]\centering
\caption{with \texttt{tabularray} \& \texttt{tikzmark}.}
\[\begin{tblr}
{% format
colspec ={rrll},
row{4,7} ={abovesep=3ex},
row{5} ={fg=teal},
row{6} ={fg=magenta},
row{9} ={fg=mygreen},
column{1}={rightsep=0.2em},
column{2}={leftsep=0em},
column{4}={leftsep=3em}
}% content
x+2y+3z = & 17 & \tikzmarknode{b1}{\cdot(-2)}
& \tikzmarknode{c1}{\cdot(-3)}\\
2x-3y+2z = & \tikzmarknode{b2}{4}\\
3x-5y+4z = & \tikzmarknode{b3}{9}\\
x+2y+3z = & 17\\
-7y-4z = & -30 & \tikzmarknode{b5}{\cdot(-11)}\\
-11y-5z = & -42 & \tikzmarknode{b6}{\cdot7}\\
\tikzmarknode{a7}{x+2y+3z}= & 17\\
-7y-4z = & -30\\
\tikzmarknode{a9}{9z}= & 36
\end{tblr}\]
\begin{tikzpicture}[remember picture,overlay]
\draw[teal ,my arrow] (b1.east) --++ (2em,0) |- node[teal ,plus=2ex] {$+$} (b2);
\draw[magenta,my arrow] (c1.east) --++ (2em,0) |- node[magenta,plus=4ex] {$+$} (b3);
\draw[mygreen,my arrow] (b5.east) --++ (2em,0) |- node[mygreen,plus=2ex] {$+$} (b6);
\fill[orange,rounded corners=0.4cm,opacity=0.4]
([shift={(-2em,0.8ex)}]a7.north west) -| ([shift={(0.2em,-2.8ex)}]a9.south east) -- cycle;
\end{tikzpicture}
\end{table}
\lipsum[2]
\end{document}
答案2
回答阴影三角形的问题,因为塞巴斯蒂亚诺的评论已经回答了另一个问题:
您可以使用 Tikz 包,您可以将这个存根放在您的表格中。
% \usepackage{tikz} % <--- add to preambule
\begin{tikzpicture}[overlay, remember picture]
\coordinate (x1)at (-3.2,-0.5) ;
\coordinate (x2)at (-3.2,2) ;
\coordinate (x3)at (-6.5,2) ;
\fill[color=yellow,opacity = 0.3] (x1) -- (x2) --(x3);
\end{tikzpicture}
如果您不熟悉 tikz,您可能无法理解我在这里所写的大部分内容。