我的文档中有表格,由于文本较长,我使用了 tabulary。现在我遇到了问题。因为它不支持设置中间位置。我现在该怎么办?更换我的 tabulary 包?
\documentclass[a4paper]{article}
\usepackage{tabulary}
\begin {document}
\begin {table}[h]
\centering
\label{t4}
\renewcommand{\arraystretch}{1.5}
\begin{tabulary}{\textwidth}{RCCCC}
A long title that is wrapped on several lines & A long title that is wrapped on several lines & A long title that is wrapped on several lines \\
\hline
A random text & 1 & 0.025 \\
\hline
A quite long random text (wrapped on 3 lines) & 2 & 2 \\
\hline
A quite long random text (wrapped on 3 lines) & 2 & 2 \\
\hline
\end{tabulary}
\end{table}
\end{document}
答案1
尝试一下这个tabu
包。
\documentclass[a4paper]{article}
\usepackage{tabu}
\begin{document}
\begin {table}[h]
\centering
\tabulinesep = 3pt
\begin{tabu}to \linewidth{X[1, r, m]*2{X[1, c, m]}}
A long title that is wrapped on several lines & A long title that is wrapped on several lines & A long title that is wrapped on several lines \\
\hline
A random text & 1 & 0.025 \\
\hline
A quite long random text (wrapped on 3 lines) & 2 & 2 \\
\hline
A quite long random text (wrapped on 3 lines) & 2 & 2 \\
\hline
\end{tabu}
\end{table}
\end{document}
(来源:新艾网)
答案2
另一种解决方案是声明两种新的列类型:\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
和\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}
。您可以通过 C{width} 和 R{width} 手动调整宽度。
平均能量损失
\documentclass[a4paper]{article}
\usepackage{tabularx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}
\begin{document}
\begin{table}[h]
\centering
\label{t4}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{R{3cm}C{3cm}C{3cm}}
A long title that is wrapped on several lines & A long title that is wrapped on several lines & A long title that is wrapped on several lines \\
\hline
A random text & 1 & 0.025 \\
\hline
A quite long random text (wrapped on 3 lines) & 2 & 2 \\
\hline
A quite long random text (wrapped on 3 lines) & 2 & 2 \\
\hline
\end{tabular}
\end{table}
\end{document}