我正在使用 IEEEtran 类编写一个 tex 文件。它将文本放在两列中。我有一个表格,我想将其放在两列中。几个单元格内的文本相当大。我希望页面看起来像这样:
请忽略文本下方的红线,因为我是在 MS Word 中准备此示例的。
我知道这个问题似乎很常见。我尝试了这些解决方案,但没有成功:双列模式的页面宽度表格,在两列样式页面中创建表格,如何将全宽表格放在与参考文本相同的双列页面的顶部或底部?
以下是我编写的代码:
\begin{table*}[t]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{|l|l|l|l|}
\hline
Category & Rules & Examples & Links \\ \hline
\multirow{3}{*}{A} & A1A1A1A1A1A1 A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \cline{2-4}
& A1A1A1A1A 1A1 A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \hline
\multirow{4}{*}{B} & A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \hline
\multirow{3}{*}{C} & A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1 & ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 & \href\{something.com/1\}\{something.com/1\} \\ \hline
\end{tabular}
\end{table*}
答案1
为了使表格适合文本块,我建议您使用一个tabularx
环境,X
其中第二列和第三列具有(修改后的)列类型,p
第四列具有(修改后的)列类型;这样,LaTeX 就可以在这些列中插入换行符(如果需要)。(这些\RaggedRight
指令指示 LaTeX 以右对齐模式而不是完全对齐模式排版材料,同时仍允许连字符。)
\documentclass[]{IEEEtran}
\usepackage{tabularx,multirow,ragged2e}
\setlength\extrarowheight{2pt} % for a slightly more "open" look
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\usepackage[colorlinks,allcolors=blue]{hyperref}
\begin{document}
\begin{table*}[t]
%%\centering % redundant
\caption{My caption}
\label{my-label}
\begin{tabularx}{\textwidth}{|l|Y|Y|P{2cm}|} % <-- choose width of 'P' column suitably
\hline
Category & Rules & Examples & Links \\
\hline
\multirow{6}{*}{A}
& A1A1A1A1A 1A1 A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\cline{2-4}
& A1A1A1A1A 1A1 A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\hline
\multirow{8}{*}{B}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\hline
\multirow{6}{*}{C}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\cline{2-4}
& A1A1A1A1A 1A1,A1A1A1A1A1A1A1A 1A1A1A1A1 A1A1A1 A1A1 A1A1 A1A1 A1A1A1A1A1A1A1A1
& ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1 ea1 ea1 e1
& \href{something.com/1}{something.com/1} \\
\hline
\end{tabularx}
\end{table*}
\end{document}