我查看了一些关于垂直对齐表格单元格内容的答案。在我提供的 MWE 中,另一个表格的列中有 4 个表格。这些表格的大小不同,我希望它们都沿单元格底部对齐。
因此,第一列的表格应该与外部表格的底部对齐。
\documentclass{article}
\usepackage{tikz}
\newcommand{\tikzmark}[2][-3pt]{\tikz[remember picture, overlay, baseline=-0.5ex]\node[#1](#2){};}
\tikzset{brace/.style={decorate, decoration={brace}},
brace mirrored/.style={decorate, decoration={brace,mirror}},
}
\newcounter{brace}
\setcounter{brace}{0}
\newcommand{\drawbrace}[3][brace]{%
\refstepcounter{brace}
\tikz[remember picture, overlay]\draw[#1] (#2.center)--(#3.center)node[pos=0.5, name=brace-\thebrace]{};
}
\newcounter{arrow}
\setcounter{arrow}{0}
\newcommand{\drawcurvedarrow}[3][]{%
\refstepcounter{arrow}
\tikz[remember picture, overlay]\draw (#2.center)edge[#1]node[coordinate,pos=0.5, name=arrow-\thearrow]{}(#3.center);
}
\newcommand{\annote}[3][]{%
\tikz[remember picture, overlay]\node[#1] at (#2) {#3};
}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
\begin{tabular}{ | l |}
$3 \times fact(2)$\tikzmark[xshift=0.62em]{d} \\ \hline
$4 \times fact(3)$\tikzmark[xshift=0.6em]{f}\\ \hline
\end{tabular}
&
\begin{tabular}{ | l |}
$2 \times fact(1)$\tikzmark[xshift=0.62em]{1} \\ \hline
$3 \times fact(2)$\tikzmark[xshift=0.6em]{2} \\ \hline
$4 \times fact(3)$\\ \hline
\end{tabular}
&
\begin{tabular}{ | l |}
$1 \times fact(0)$\tikzmark[xshift=0.62em]{3} \\ \hline
$2 \times fact(1)$\tikzmark[xshift=0.62em]{4} \\ \hline
$3 \times fact(2)$\\ \hline
$4 \times fact(3)$\\ \hline
\end{tabular}
&
\begin{tabular}{ | l |}
$fact(0) = 1$\tikzmark[xshift=0.62em]{5} \\ \hline
$1 \times fact(0)$\tikzmark[xshift=0.7em]{6} \\ \hline
$2 \times fact(1)$\\ \hline
$3 \times fact(2)$\\ \hline
$4 \times fact(3)$\\ \hline
\end{tabular}\\ \hline
\end{tabular}
\end{table}
\drawcurvedarrow[bend right=50,-stealth]{f}{d}
\drawcurvedarrow[bend right=50,-stealth]{2}{1}
\drawcurvedarrow[bend right=50,-stealth]{4}{3}
\drawcurvedarrow[bend right=50,-stealth]{6}{5}
\end{document}
答案1
只需使用 [b]
每个表格的选项即可。我借此机会将每个表格fact
置于文本模式,以获得更好的布局:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\tikzmark}[2][-3pt]{\tikz[remember picture, overlay, baseline=-0.5ex]\node[#1](#2){};}
\tikzset{brace/.style={decorate, decoration={brace}},
brace mirrored/.style={decorate, decoration={brace,mirror}},
}
\newcounter{brace}
\setcounter{brace}{0}
\newcommand{\drawbrace}[3][brace]{%
\refstepcounter{brace}
\tikz[remember picture, overlay]\draw[#1] (#2.center)--(#3.center)node[pos=0.5, name=brace-\thebrace]{};
}
\newcounter{arrow}
\setcounter{arrow}{0}
\newcommand{\drawcurvedarrow}[3][]{%
\refstepcounter{arrow}
\tikz[remember picture, overlay]\draw (#2.center)edge[#1]node[coordinate,pos=0.5, name=arrow-\thearrow]{}(#3.center);
}
\newcommand{\annote}[3][]{%
\tikz[remember picture, overlay]\node[#1] at (#2) {#3};
}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
\begin{tabular}[b]{ | l |}
$3 \times \text{fact}(2)$\tikzmark[xshift=0.62em]{d} \\ \hline
$4 \times \text{fact}(3)$\tikzmark[xshift=0.6em]{f}\\ \hline
\end{tabular}
&
\begin{tabular}[b]{ | l |}
$2 \times \text{fact}(1)$\tikzmark[xshift=0.62em]{1} \\ \hline
$3 \times \text{fact}(2)$\tikzmark[xshift=0.6em]{2} \\ \hline
$4 \times \text{fact}(3)$\\ \hline
\end{tabular}
&
\begin{tabular}[b]{ | l |}
$1 \times \text{fact}(0)$\tikzmark[xshift=0.62em]{3} \\ \hline
$2 \times \text{fact}(1)$\tikzmark[xshift=0.62em]{4} \\ \hline
$3 \times \text{fact}(2)$\\ \hline
$4 \times \text{fact}(3)$\\ \hline
\end{tabular}
&
\begin{tabular}[b]{ | l |}
$\text{fact}(0) = 1$\tikzmark[xshift=0.62em]{5} \\ \hline
$1 \times \text{fact}(0)$\tikzmark[xshift=0.7em]{6} \\ \hline
$2 \times \text{fact}(1)$\\ \hline
$3 \times \text{fact}(2)$\\ \hline
$4 \times \text{fact}(3)$\\ \hline
\end{tabular}\\ \hline
\end{tabular}
\end{table}
\drawcurvedarrow[bend right=50,-stealth]{f}{d}
\drawcurvedarrow[bend right=50,-stealth]{2}{1}
\drawcurvedarrow[bend right=50,-stealth]{4}{3}
\drawcurvedarrow[bend right=50,-stealth]{6}{5}
\end{document}