我有以下两列表格,其中一列需要较长的文本,我需要表格适合文本宽度。因此,我使用两列页面样式作为 IEEE 或 ACM 会议。
\begin{table}[h]
\centering
\begin{tabular}{ || l | l || }
\hline \hline
BBBBBBBBBBBBBBB & AAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAA AAAAAAA AAAAA AAAA AA \\ \hline
sssss & dddddddddddddddddddddddddddddddddddd dddddddddddddddddddddd dddddd ddd ddd \\ \hline
\end{tabular}
\label{xxxx}
\caption{zzzzzzzz}
\end{table}
答案1
要使用尽可能多的允许宽度(\columnwidth
),您可以使用 tabularx。
\documentclass{IEEEtran}
\usepackage{tabularx}
\usepackage{lipsum}% MWE only
\begin{document}
\lipsum[1]
\begin{table}[h]
%\centering% no gap to fill
\begin{tabularx}{\columnwidth}{ || l | X || }
\hline \hline
BBBBBBBBBBBBBBB & AAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAA AAAAAAA AAAAA AAAA AA \\ \hline
sssss & dddddddddddddddddddddddddddddddddddd dddddddddddddddddddddd dddddd ddd ddd \\ \hline
\end{tabularx}
\label{xxxx}
\caption{zzzzzzzz}
\end{table}
\lipsum[2]
\end{document}
答案2
添加参数p
以允许单元格中有段落(而不是l
),可以使用中的值调整列的大小p{size}
,如下所示
\begin{table}[h]
\centering
\begin{tabular}{ || p{1in} | p{1in} ||}
%\hline \hline commented out
BBBBBBBBBBBBBBB & AAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAA AAAAAAA AAAAA AAAA AA \\ \hline
sssss & dddddddddddddddddddddddddddddddddddd dddddddddddddddddddddd dddddd ddd ddd \\ \hline
\end{tabular}
\label{xxxx}
\caption{zzzzzzzz}
\end{table}