我想要做的是制作一个如下所示格式的表格。目前,列的宽度不同,表格对于页面来说太宽了。它看起来如下:
我想做的是
1)将表格设置为与文本一样宽,以便它占据边距内的最大空间
2)设置包含结果的第2、3、4列宽度相同。
\begin{table}[H] \centering \caption{X} \label{X}
\begin{tabular}{cccc}
\textbf{References} & \textbf{Results 1} & \textbf{Results 2} & \textbf{Results 3} \\\hline\hline
Author (Year)
&
Answer Answer
&
Answer Answer Answer Answer
&
\begin{tabular}{c}
Answer Answer Answer Answer Answer Answer \\
Answer Answer Answer \\
\end{tabular}
\\\hline
Author (Year) &
\begin{tabular}{c}
Answer \\
Answer \\
\end{tabular}
&
Answer Answer
&
\begin{tabular}{c}
Answer Answer Answer \\
Answer Answer Answer \\
\end{tabular}
\\\hline
Author (Year) &
\begin{tabular}{c}
Answer \\
Answer \\
Answer \\
\end{tabular}
&
\multicolumn{2}{c}{Answer Answer Answer Answer Answer Answer Answer Answer }
\\\hline
\end{tabular}
\end{table}
答案1
无需tabularx
嵌套表格:
\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs, tabularx}
\usepackage[skip=1ex]{caption}
\begin{document}
\begin{table}[htb]
\caption{X}
\label{X}
\begin{tabularx}{\linewidth}{@{} l *{3}{>{\centering\arraybackslash}X} @{}}
\toprule
\textbf{References} & \textbf{Results 1} & \textbf{Results 2} & \textbf{Results 3} \\
\midrule
Author (Year)
& Answer Answer
& Answer Answer Answer Answer
& Answer Answer Answer Answer Answer Answer
Answer Answer Answer \\
\midrule
Author (Year)
& Answer
Answer
& Answer Answer
& Answer Answer Answer
Answer Answer Answer \\
\midrule
Author (Year)
& Answer
Answer
Answer
& \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep\relax
\centering\arraybackslash}X}{%
Answer Answer Answer Answer Answer Answer Answer Answer } \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
我宁愿使用左对齐,而不是水平居中的单元格文本,即而不是>{\centering\arraybackslash}X
使用>{\raggedright\arraybackslash}X