我想使用以下代码创建一个表格。
\documentclass[journal]{IEEEtran}
\usepackage{tabularx}
\usepackage{booktabs}
\renewcommand{\arraystretch}{1.25}
\noindent\begin{tabularx}{\textwidth} { |
l |
>{\raggedright\arraybackslash}X |
c |
}
\hline
Place/Transition & Explanation & Time \\
\hline
$T_1$ and $T_{2(n+1)}$ & Robot operation which relates to loadlocks. Transition $T_1$ indicates that wafer unloading from the loadlocks and $T_{2(n+1)}$ means that the robot loads the wafer to the loadlocks. & w \\
\hline
item 31 & item 32 & item 33 \\
\hline
\end{tabularx}
结果如下。
问题:(1)如何确保所有表格都适合两列模板?(2)如何在表格中添加更多行?
谢谢。
答案1
我建议您 (a) 将环境宽度设置tabularx
为 ,\columnwidth
并且 (b) 通过将列类型从 切换到 ,允许在第 1 列中换行l
。p
要允许在第 1 列的标题中换行,我建议您更改Place/Transition
为Place\slash Transition
。
在使用 IEEEtran 文档类时,我进一步建议您使用一个包,例如newtxmath
,它提供了 Times Roman数学字体我还尝试通过删除所有垂直线并创建更少但间距适当的水平线,让表格看起来更加开放和吸引人
\documentclass[journal]{IEEEtran}
\usepackage{newtxtext,newtxmath} % Times Roman text and math fonts
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{ragged2e} % for \RaggedRight macro
\newlength\mylen
\settowidth\mylen{Transition} % target width of column 1
\begin{document}
%\renewcommand{\arraystretch}{1.25} % <-- I wouldn't do that
\noindent
\begin{tabularx}{\columnwidth} {@{}
>{\RaggedRight}p{\mylen}
>{\RaggedRight}X
c @{}}
\toprule
Place\slash Transition & Explanation & Time \\
\midrule
$T_1$ and $T_{2(n+1)}$ &
Robot operation which relates to loadlocks. Transition $T_1$ indicates that wafer unloading from the loadlocks, and $T_{2(n+1)}$ means that the robot loads the wafer to the loadlocks. &
$w$ \\
\addlinespace
item 31 & item 32 & item 33 \\
\bottomrule
\end{tabularx}
\end{document}