注释表格以显示条目之间的增量

注释表格以显示条目之间的增量

我正在寻找一种方法来排版带有注释的表格,以显示连续条目之间的变化。下面的(粗糙的、手工制作的)图片展示了我的想法。请注意,添加的条目应出现在表格条目“之间”。我并不特别在意表格是水平排列(如图所示)还是垂直排列。

在此处输入图片描述

理想情况下,您提出的任何解决方案都能够进行迭代,如下图所示:

在此处输入图片描述

需要自动计算差异,事实上,如果不是这样,我更希望如此。

我希望我所问的问题清楚。我很乐意为您澄清。

编辑:我想要标记的表格是:

\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使用 TiZ. 我使用循环来节省打字时间,但当然这不是强制性的。

\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}

结果是:

在此处输入图片描述

到目前为止,它在视觉上还不是很有吸引力,但如果您认为这可能是您正在寻找的有效方法,您可以尝试这个想法并改进它。

当然,你也可以用一行来表示二阶差分。

相关内容