我有下表:
\begin{table}
\centering
\begin{tabular}{|l|l|l|l|l|}
\cline{2-5}
\multicolumn{1}{l|}{} & T_{del}\ vs.\ T_{poi} & T_{del} \ vs.\ Ben & T_{poi} \ vs.\ Ben & Total \\
\hline
ned & & & & \\
\hline
dui & & & & \\
\hline
pil & & & & \\
\hline
kol & & & & \\
\hline
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & & \\
\cline{5-5}
\end{tabular}
\end{table}
我想改变以下几点:
我想通过将其放在
T_{del}\ vs.\ T_{poi}
彼此下方来使其变小。这样列的宽度就会减小。我无法实现这种堆叠,因为当我尝试添加“输入”时整个布局都会被破坏。我有 2 列布局,我想将 2x2 表格放在一列中。我不知道这是否可行?表格将填充小数字。
答案1
使用 `tabularray˛:
\documentclass[twocolumn]{article}
\usepackage{tabularray}
\usepackage{lipsum}
\begin{document}
\lipsum[66]
\begin{table}[ht]
\def\del{\mathrm{del}}
\def\poi{\mathrm{poi}}
\def\Ben{\mathrm{Ben}}
\begin{tblr}{hline{1}={2-Z}{solid}, hline{2-Y}={1-Z}{solid},
vline{1}={2-Y}{solid}, vline{2-X}={1-Y}{solid}, vline{Y-Z}={1-Z}{solid},
colspec = {c *{4}{X[c,m]}},
rowsep = 3pt}
& {$T_{\del}$\\ $\mathrm{vs.~T_{\poi}}$ }
& {$T_{\del}$\\ $\mathrm {vs.~Ben}$ }
& {$T_{\poi}$\\ $\mathrm{vs.~Ben}$ }
& Total \\
ned & & & & \\
dui & & & & \\
pil & & & & \\
kol & & & & \\
& & & & \\
\cline{Z-Z}
\end{tblr}
\end{table}
答案2
\makecell
如果我理解正确的话,你可以从包中断行makecell
。该l
选项使其makecell
左对齐。
\documentclass{article}
\usepackage{makecell}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|l|l|l|l|l|}
\cline{2-5}
\multicolumn{1}{l|}{} & \makecell[l]{$T_{del}$\ vs.\\ $T_{poi}$} & \makecell[l]{$T_{del}$ \ vs.\\ Ben} & \makecell[l]{$T_{poi}$ \ vs.\\ Ben} & Total \\
\hline
ned & & & & \\
\hline
dui & & & & \\
\hline
pil & & & & \\
\hline
kol & & & & \\
\hline
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & & \\
\cline{5-5}
\end{tabular}
\end{table}
\end{document}
答案3
假设您希望第 2 列至第 5 列的宽度相同,同时允许自动换行,我建议您使用环境tabularx
并将其整体宽度设置为\colummwidth
。
\documentclass[twocolumn]{article}
\usepackage{amsmath,tabularx,ragged2e}
\newcolumntype{C}{>{\Centering}X}
\begin{document}
\begin{table}
\setlength{\extrarowheight}{2pt} % for a more open
\begin{tabularx}{\columnwidth}{| l | C | C | C | C |}
\cline{2-5}
\multicolumn{1}{l|}{}
& $T_{\mathrm{del}}$ vs.~$T_{\mathrm{poi}}$
& $T_{\mathrm{del}}$ vs.~Ben
& $T_{\mathrm{poi}}$ vs.~Ben
& Total \\
\hline
ned & & & & \\
\hline
dui & & & & \\
\hline
pil & & & & \\
\hline
kol & & & & \\
\hline
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & & \\
\cline{5-5}
\end{tabularx}
\end{table}
\end{document}