在使用 longtabu 时遇到问题,无法将列设置为表格宽度的百分比。我使用 tabularx 实现了我想要的效果:
\documentclass{report}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\textwidth}{
>{\hsize=.1\hsize}X
>{\hsize=.1\hsize}X
>{\hsize=.1\hsize}X
>{\hsize=.7\hsize}X} % 70% of table width
\hline
\textbf{Time End of Step} &
\textbf{Step} &
\textbf{Event} &
\textbf{Description}
\\ \hline
12:18:52 & 1 & 1 & this is a description for the event \\
12:18:52 & 1 & 1 & this is a description for the event \\
12:18:52 & 1 & 1 & this is a description for the event \\
\end{tabularx}
\end{document}
然后我尝试使用tabu:
\documentclass{report}
\usepackage{longtable,tabu}
\begin{document}
\begin{longtabu} to \textwidth {
>{\hsize=.1\hsize}X
>{\hsize=.1\hsize}X
>{\hsize=.1\hsize}X
>{\hsize=.7\hsize}X} % 70% of table width
\hline \hline
\textbf{Time End of Step} &
\textbf{Step} &
\textbf{Event} &
\textbf{Description}
\\ \hline \hline \hline \hline
12:18:52 & 1 & 1 & this is a description for the event \\
12:18:52 & 1 & 1 & this is a description for the event \\
12:18:52 & 1 & 1 & this is a description for the event \\
\end{longtabu}
\end{document}
因此这会产生错误,提示尺寸太大。有人知道如何在 longtabu 中使用此 hsize 吗?谢谢!
答案1
文档http://mirror.unl.edu/ctan/macros/latex/contrib/tabu/tabu.pdf可以在这里找到。查看完它们之后,我想到了一个解决方案。
\documentclass{report}
\usepackage{longtable,tabu}
\begin{document}
\begin{longtabu} to \textwidth {
X[1,c]
X[1,c]
X[1,c]
X[10,l]}
\hline \hline
\textbf{Time End of Step} &
\textbf{Step} &
\textbf{Event} &
\textbf{Description}
\\ \hline \hline \hline \hline
12:18:52 & 1 & 1 & this is a description for the event \\
12:18:52 & 1 & 1 & this is a description for the event \\
12:18:52 & 1 & 1 & this is a description for the event \\
\end{longtabu}
\end{document}
所以这不是确切的百分比,但对于我的工作来说已经足够了。X[1,c] 表示其系数为 1,其对齐方式为居中。所以在我上面的公式中,系数加起来是 13。所以第一列将是总表格宽度的 1/13(7.6%)。而最后一列将是 10/13(76%)。