我是乳胶新手,所以如果有人问到这个问题,我很抱歉,因为我在 SO 上没有找到这个具体问题。
我有一张表格,想把它放到 2 列页面格式中。完整包的实际链接位于背面,来自发布者在这儿,但我相信我添加了所有包和文档类型。我正在使用本网站生成我的表格。我从中学到这个 SO我需要将其添加*
到表中以使其适合两列,但是,我的表中有一列很长:
\documentclass[11pt,a4paper]{article}
\usepackage{times,latexsym}
\usepackage{url}
\usepackage[T1]{fontenc}
\usepackage{tacl2021v1}
% \setlength\titlebox{10cm} % <- for Option 2 below
%%%% Material in this block is specific to generating TACL instructions
\usepackage{xspace,mfirstuc,tabulary}
\newcommand{\dateOfLastUpdate}{Dec. 15, 2021}
\newcommand{\styleFileVersion}{tacl2021v1}
\newcommand{\ex}[1]{{\sf #1}}
\newif\iftaclinstructions
\taclinstructionsfalse % AUTHORS: do NOT set this to true
\iftaclinstructions
\renewcommand{\confidential}{}
\renewcommand{\anonsubtext}{(No author info supplied here, for consistency with
TACL-submission anonymization requirements)}
\newcommand{\instr}
\fi
%
\iftaclpubformat % this "if" is set by the choice of options
\newcommand{\taclpaper}{final version\xspace}
\newcommand{\taclpapers}{final versions\xspace}
\newcommand{\Taclpaper}{Final version\xspace}
\newcommand{\Taclpapers}{Final versions\xspace}
\newcommand{\TaclPapers}{Final Versions\xspace}
\else
\newcommand{\taclpaper}{submission\xspace}
\newcommand{\taclpapers}{{\taclpaper}s\xspace}
\newcommand{\Taclpaper}{Submission\xspace}
\newcommand{\Taclpapers}{{\Taclpaper}s\xspace}
\newcommand{\TaclPapers}{Submissions\xspace}
\fi
\begin{document}
\begin{table*}
\small
\begin{tabular}{ll}
\textbf{Name} & \textbf{Method} \\
Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, & Some method \\
Reference,Reference & \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
\end{tabular}
\end{table*}
\fi
\end{document}
下列的这个 SO我尝试过,\small
但效果并没有好多少。我看到的一个可能的解决方案是改变行中文本的外观(而不是将一长行分成一行下的多行)。但我不确定如何做到这一点,或者这是否是最好/最简洁的方法。
答案1
您可以使用tabularx
。
\documentclass[twocolumn]{article}
\usepackage{tabularx}
\begin{document}
\begin{table*}
\begin{tabularx}{\linewidth}{Xl}
\textbf{Name} & \textbf{Method} \\
Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, & Some method \\
Reference,Reference & \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
& \\
\end{tabularx}
\end{table*}
\end{document}
这将使表格跨越两列。如果您希望表格只占一列,请使用table
而不是table*
。
答案2
我认为可能有必要允许自动换行两列,而不仅仅是包含更多材料的列。这里有一个建议:加载tabularx
和ragged2e
包并定义一种新的列类型,例如,L
这使得定义所需的相对的列宽。在下面的例子中,我们有
\begin{tabularx}{\textwidth}{@{} L{1.6} L{0.4} @{}}
这意味着 (a) 表格材料跨越文本块的整个宽度,以及 (b)可用的列宽为 1.6:0.4 = 4:1。需要遵守的规则是和相对列宽(此处为:1.6+0.4=2)必须等于类型为 -- 的列数,L
此处为:2。
以下屏幕截图显示了结果表,该表位于页面顶部。
\documentclass[twocolumn]{article}
\usepackage{tabularx,ragged2e}
\newcolumntype{L}[1]{>{\RaggedRight\hsize=#1\hsize}X}
\usepackage{booktabs,lipsum}
\begin{document}
\lipsum[1] % a paragraph of filler text
\begin{table*}
\caption{A two-column table that spans the full width of the text block}
\begin{tabularx}{\textwidth}{@{} L{1.6} L{0.4} @{}}
\toprule
\textbf{Name} & \textbf{Method} \\
\midrule
Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference & Some method \\
\addlinespace
Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference, Reference & Some method \\
\bottomrule
\end{tabularx}
\end{table*}
\lipsum[2-11] % more filler text
\end{document}