註釋表格以顯示條目之間的增量

註釋表格以顯示條目之間的增量

我正在尋找一種方法來排版帶有註釋的表格,顯示連續條目之間的變化。下面的(草率的、手工製作的)圖像顯示了我的想法。請注意,新增的條目應出現在表格的條目「之間」。我並不特別在意表格是水平運行(如圖)還是垂直運行。

在此輸入影像描述

理想情況下,您提出的任何解決方案都能夠進行迭代,如下圖所示:

在此輸入影像描述

需要自動計算差異,事實上,如果不是的話,我更願意這樣做。

我希望我的要求是清楚的。我很樂意澄清。

編輯:我想要標記的表是:

\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
\hline
$x$&$0$&$3$&$6$&$9$&$12$&$15$&$18$&$21$&$24$\\
\hline
$f(x)$&$-20$&$-15$&$-8$&$1$&$12$&$25$&$40$&$57$&$76$\\
\hline
\end{tabular}

但我不知道這是否特別有幫助,特別是如果(就像評論中的@cfr)你看不到我的圖像。

答案1

這是一個matrix of math nodes使用 TikZ. 我使用循環來節省打字,但這些當然不是強制性的。

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
  \matrix (m) [inner sep=0pt, draw=gray!75!blue, thick, matrix of math nodes, nodes={inner sep=2.5pt, text width=20pt, align=center}, column 1/.append style={nodes={align=right, text width=25pt}}]
  {
     \strut x&0&3&6&9&12&15&18&21&24\\
     \strut f(x)&-20&-15&-8&1&12&25&40&57&76\\
  };
  \draw [gray!75!blue, semithick] (m.west |- m-1-1.south) -- (m.east |- m-1-1.south) \foreach \i in {1,...,9} { (m.north -| m-1-\i.east) -- (m.south -| m-1-\i.east) };
  \foreach \i [count=\k from 1, count=\j from 3, remember=\j as \jlast (initially 2)] in {5,7,9,11,13,15,17,19}
  \draw [thick, draw=blue!50!cyan]
    ([xshift=1.5pt, yshift=.5pt]m-2-\jlast.south) -- ([yshift=-7.5pt]m-2-\jlast.south east) node (d\k) [below] {$\i$} -- ([xshift=-1.5pt, yshift=.5pt]m-2-\j.south)
    ([xshift=1.5pt, yshift=-.5pt]m-1-\jlast.north) -- ([yshift=7.5pt]m-1-\jlast.north east) node [above] {$3$} -- ([xshift=-1.5pt, yshift=-.5pt]m-1-\j.north)
    ;
  \foreach \i [remember=\i as \ilast (initially 1), count=\k from 3] in {2,...,8}
  \draw [thick, draw=magenta!50!blue]
  ([xshift=1.5pt, yshift=.5pt]d\ilast.south) -- ([yshift=-7.5pt]d\ilast.south -| m-1-\k.center) node [below] {$2$} -- ([xshift=-1.5pt, yshift=.5pt]d\i.south);
\end{tikzpicture}
\end{document}

帶註解的矩陣

答案2

這是您可以建立的起點:

\documentclass{article}

\begin{document}

\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|} \hline
$\Delta x$ & & \multicolumn{2}{|c|}{3} & \multicolumn{2}{|c|}{3}  & \multicolumn{2}{|c|}{3} & \multicolumn{2}{|c|}{3} &   \\  \hline
$x$ & \multicolumn{2}{|c|}{0} & \multicolumn{2}{|c|}{3} & \multicolumn{2}{|c|}{6} & \multicolumn{2}{|c|}{9} & \multicolumn{2}{|c|}{12} \\  \hline
\end{tabular} 

\end{document}

結果是:

在此輸入影像描述

到目前為止,它在視覺上還不是很吸引人,但是如果您認為這可能是您正在尋找的內容的有效方法,您可以嘗試並完善它。

當然,你也可以有一個二階差分的行。

相關內容