我有 4 个并排的表格,我想在每个表格底部添加标题。每当我尝试添加标题时,它都会破坏对齐,表格就会乱七八糟。
我该如何解决这个问题?
我目前拥有的:
\begin{document}
\begin{table}[ht]
\begin{tabular}[t]{ |c| }
\hline
Variety \\ [0.5ex]
\hline
bramsley\_seedling \\
cox\_orange\_group \\
egremont\_russet \\
braeburn \\
gala \\
other\_early\_season \\
other\_late\_season \\
other\_mid\_season \\
\hline
\end{tabular}
\quad
\begin{tabular}[t]{ |c| }
\hline
Variety \\ [0.5ex]
\hline
conference \\
doyenne\_du\_comice \\
other \\
\hline
\end{tabular}
\quad
\begin{tabular}[t]{ |c| }
\hline
Variety \\ [0.5ex]
\hline
topped\_washed \\
\hline
\end{tabular}
\quad
\begin{tabular}[t]{ |c| }
\hline
Variety \\ [0.5ex]
\hline
red \\
savoy \\
summer\_autumn\_pointed \\
white \\
round\_green\_other \\
\hline
\end{tabular}
\end{table}
\end{document}
答案1
像这样?
\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage{subcaption}
\usepackage{tabularray}
\begin{document}
\begin{table}[ht]
\centering
\begin{subtable}[t]{0.22\textwidth}\centering
\begin{tblr}[t]{hline{1,2,Z}={solid}, vlines,
colspec={c},
row{1}={font=\bfseries}
}
Variety \\
bramsley\_seedling \\
cox\_orange\_group \\
egremont\_russet \\
braeburn \\
gala \\
other\_early\_season \\
other\_late\_season \\
other\_mid\_season \\
\end{tblr}
\caption{}
\end{subtable}%
\quad
\begin{subtable}[t]{0.22\textwidth}\centering
\begin{tblr}[t]{hline{1,2,Z}={solid}, vlines,
colspec={c},
row{1}={font=\bfseries}
}
Variety \\
conference \\
doyenne\_du\_comice \\
other \\
\end{tblr}
\caption{}
\end{subtable}%
\quad
\begin{subtable}[t]{0.2\textwidth}\centering
\begin{tblr}[t]{hline{1,2,Z}={solid}, vlines,
colspec={c},
row{1}={font=\bfseries}
}
Variety \\
topped\_washed \\
\end{tblr}
\caption{}
\end{subtable}%
\quad
\begin{subtable}[t]{0.28\textwidth}\centering
\begin{tblr}[t]{hline{1,2,Z}={solid}, vlines,
colspec={c},
row{1}={font=\bfseries}
}
Variety \\
red \\
savoy \\
summer\_autumn\_pointed \\
white \\
round\_green\_other \\
\end{tblr}
\caption{}
\end{subtable}
\end{table}
\end{document}
或者
\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage[skip=1ex, labelfont=bf]{caption}
\usepackage{tabularray}
\begin{document}
\begin{table}[ht]
\centering
\begin{minipage}[t]{0.22\textwidth}\centering
\begin{tblr}[t]{hline{1,2,Z}={solid}, vlines,
colspec={c},
row{1}={font=\bfseries}
}
Variety \\
bramsley\_seedling \\
cox\_orange\_group \\
egremont\_russet \\
braeburn \\
gala \\
other\_early\_season \\
other\_late\_season \\
other\_mid\_season \\
\end{tblr}
\caption{}
\end{minipage}%
\quad
\begin{minipage}[t]{0.22\textwidth}\centering
\begin{tblr}[t]{hline{1,2,Z}={solid}, vlines,
colspec={c},
row{1}={font=\bfseries}
}
Variety \\
conference \\
doyenne\_du\_comice \\
other \\
\end{tblr}
\caption{}
\end{minipage}%
\quad
\begin{minipage}[t]{0.2\textwidth}\centering
\begin{tblr}[t]{hline{1,2,Z}={solid}, vlines,
colspec={c},
row{1}={font=\bfseries}
}
Variety \\
topped\_washed \\
\end{tblr}
\caption{}
\end{minipage}%
\quad
\begin{minipage}[t]{0.28\textwidth}\centering
\begin{tblr}[t]{hline{1,2,Z}={solid}, vlines,
colspec={c},
row{1}={font=\bfseries}
}
Variety \\
red \\
savoy \\
summer\_autumn\_pointed \\
white \\
round\_green\_other \\
\end{tblr}
\caption{}
\end{minipage}
\end{table}
\end{document}
如您所见,表格使用了tabularray
包。顺便说一句,您可以考虑表格主体上下文的左对齐。在这种情况下,表格中的列规范可以是:
\begin{tblr}[t]{hline{1,2,Z}={solid}, vlines,
colspec={l},
row{1}={c, font=\bfseries}
}