我有下表,我用它來教微積分課上的極限(如果您不知道那是什麼,請不要擔心)
\begin{tabular}{l|l}
\bm{x} & \bm{h(x)} \\
\hline
1.9 & 3.61 \\
1.99 & 3.9601 \\
1.999 & 3.9960 \\
1.9999 & 3.9996 \\
\hline
2.0001 & 4.0004 \\
2.001 & 4.004 \\
2.01 & 4.0401 \\
2.1 & 4.41 \\
\hline
\end{tabular}
在課堂上,我指出,當我們沿著第一列向左畫一個箭頭,共四行,並在其底部寫上“2”時,左列中的數字會越來越接近 2(除了我無法在螢幕上繪圖)。
我還指出,當我們向上繪製行(在行的左側)的箭頭時,表格的下半部(左側)變得更接近 2。
右列越來越接近 4,我透過在右列右側繪製向下箭頭等來指出這一點(或者如果我可以在螢幕上繪製)。
如何在這些列的右側或左側的多行上繪製箭頭以顯示數字進展?
答案1
\documentclass{article}
\let\bm\textbf
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}
\begin{document}
\begin{tabular}{cl|lc}
&\bm{x} & \bm{h(x)} \\
\cline{2-3}
\tikzmark{a}&1.9 & 3.61&\tikzmark{aa} \\
&1.99 & 3.9601& \\
&1.999 & 3.9960 &\\
\tikzmark{b}&1.9999 & 3.9996&\tikzmark{bb} \\
\cline{2-3}
&2.0001 & 4.0004& \\
&2.001 & 4.004 & \\
&2.01 & 4.0401& \\
\tikzmark{c}&2.1 & 4.41&\tikzmark{cc} \\
\cline{2-3}
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\draw[->,line width=3pt, color=red] ($(pic cs:a)+(0pt,.5ex)$) to ($(pic cs:b)+(0pt,-.1ex)$);
\node[color=red] at ($(pic cs:b)+(0pt,-1ex)$) {\Large 2};
\draw[->,line width=3pt, color=red] ($(pic cs:c)+(0pt,.5ex)$) to ($(pic cs:b)+(0pt,-2.5ex)$);
\draw[->,line width=3pt, color=red] ($(pic cs:aa)+(0pt,.5ex)$) to ($(pic cs:bb)+(0pt,-.1ex)$);
\node[color=red] at ($(pic cs:bb)+(0pt,-1ex)$) {\Large 4};
\draw[->,line width=3pt, color=red] ($(pic cs:cc)+(0pt,.5ex)$) to ($(pic cs:bb)+(0pt,-2.5ex)$);
\end{tikzpicture}
\end{document}
答案2
如果這是您想要的,那麼以下是我的程式碼,
\documentclass{article}
\usepackage{multirow,tikz,bm}
\def\limitarrow#1{%
\begin{tikzpicture}
\draw[->] (0,1.5) to (0,0.25);
\node at (0,0) {#1};
\draw[->] (0,-1.5) to (0,-0.25);
\end{tikzpicture}}
\begin{document}
\begin{tabular}{l|l|l|l}
& $\bm{x}$ & $\bm{h(x)}$ &\\
\hline
\multirow{8}{*}{\limitarrow{2}} & 1.9 & 3.61 & \multirow{8}{*}{\limitarrow{4}}\\
& 1.99 & 3.9601 & \\
& 1.999 & 3.9960 & \\
& 1.9999 & 3.9996 & \\
\cline{2-3}
& 2.0001 & 4.0004 &\\
& 2.001 & 4.004 &\\
& 2.01 & 4.0401 &\\
& 2.1 & 4.41 &\\
\hline
\end{tabular}
\end{document}