エントリ間の増分を示すためにテーブルに注釈を付ける

エントリ間の増分を示すためにテーブルに注釈を付ける

私は、連続するエントリ間の変更を示す注釈付きの表をタイプセットする方法を探しています。以下の (雑な、手作りの) 画像が、私が考えているものを示しています。追加されたエントリは、表のエントリの「間」に表示されることに注意してください。表が、図のように水平に並んでいるか、垂直に並んでいるかは特に気にしません。

ここに画像の説明を入力してください

理想的には、提案できるソリューションはどれも、次の図に示すように反復できる必要があります。

ここに画像の説明を入力してください

しない差異が自動的に計算される必要があり、実際はそうでないほうが望ましいです。

私が尋ねていることが明確であることを願います。喜んで説明させていただきます。

編集:マークアップしたい表は次のとおりです。

\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 nodesTiの使用例はこちらZ. 入力を節約するためにループを使用しますが、もちろんこれは必須ではありません。

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

結果は次のとおりです。

ここに画像の説明を入力してください

現時点では、視覚的にはあまり魅力的ではありませんが、これがあなたが求めているものに対して有効なアプローチであると思われる場合は、アイデアを試して改良することができます。

もちろん、2 番目の差分の行も作成できます。

関連情報