我有一张表格,我想将表格宽度设置为特定值,例如0.8\columnwidth
。拉伸后,我希望每列的宽度与原始表格中的实际宽度成比例。在搜索后tex.stackexchange.com
,我找到了关于使用表格型或者表格包来拉伸表格宽度,但它们都没有达到我的愿望。
前者实现了这样的效果: 新的列宽都是相同的,与其实际宽度不成比例。
宽度没有拉伸效果。
最小工作示例是:
\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{tabulary}
\begin{document}
\lipsum[1]
% the original table
\begin{table}[h]
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
first column & second column & third column \\
\hline
short & longer longer & longest longest longest \\
\hline
short & longer longer & longest longest longest \\
\hline
\end{tabular}
\end{center}
\end{table}
%table after using tabularx package
\lipsum[2]
\begin{table}[h]
\centering
\begin{tabularx}{\columnwidth}{|X|X|X|}
\hline
first column & second column & third column \\
\hline
short & longer longer & longest longest longest \\
\hline
short & longer longer & longest longest longest \\
\hline
\end{tabularx}
\end{table}
\lipsum[3]
% table after using tabulary
\begin{table}[h]
\begin{center}
\begin{tabulary}{\columnwidth}{|C|C|C|}
\hline
first column & second column & third column \\
\hline
short & longer longer & longest longest longest \\
\hline
short & longer longer & longest longest longest \\
\hline
\end{tabulary}
\end{center}
\end{table}
\end{document}
我使用这两个包的方式有什么问题吗?或者还有其他方法可以实现我想要的吗?提前谢谢您!