我制作了一个表格,在其中,我必须使用包multirow
来设置标题。当有两行时工作正常,但当有三行时,它会 y 溢出。我尝试增加每行的空间,\setlength\extrarowheight
但这只是增加了单元格,溢出仍然存在。
以下是一些图片:
我该如何解决这个问题?
以下是该表的来源:
\documentclass[11pt,a4paper]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[h!]
\centering
\caption{OVERFLOW}
\bgroup
\def\arraystretch{1.5}%
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{
\begin{tabular}[c]{@{}c@{}}Extension\\
$x/\mathrm{cm}$\end{tabular}} &
\multicolumn{5}{c|}{
\begin{tabular}[c]{@{}c@{}}Distance travelled \\
$s_{i}/\mathrm{cm}$\end{tabular}} &
\multirow{2}{*}{
\begin{tabular}[c]{@{}c@{}}Avg. distance\\
$s/\mathrm{cm}$\end{tabular}} &
\multirow{2}{*}{
\begin{tabular}[c]{@{}c@{}}Uncertainty in\\
avg. distance\\ $\Delta s/\pm \mathrm{cm}$\end{tabular}} \\
\cline{2-6} &
Trial 1 & Trial 2 & Trial 3 & Trial 4 & Trial 5 & & \\
\hline
\end{tabular}
\egroup
\end{table}
\end{document}
答案1
编辑:
通过使用makecell
定义多行多列单元格的包,我获得:
在表格中,为了增加,\arraystretch
我使用来自makecell
包的间隙单元格:
\documentclass[11pt,a4paper]{article}
\usepackage{makecell, multirow}
\usepackage{siunitx}
\begin{document}
\begin{table}[h!]
\centering
\caption{OVERFLOW}
\setcellgapes{5pt}
\makegapedcells
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multirowcell{3}{Extension\\ \si{x/cm}}
& \multicolumn{5}{c|}{\makecell{Distance travelled \\ \si{s_{i}/cm}}}
& \multirowcell{3}{Avg. distance\\ \si{cm} }
& \multirowcell{3}[1ex]{Uncertainty in\\
avg. distance\\
\si{\Delta s/\pm cm}}} \\
\cline{2-6} &
Trial 1 & Trial 2 & Trial 3 & Trial 4 & Trial 5 & & \\
\hline
\end{tabular}
\end{table}
\end{document}