2 列文章中的多列表格

2 列文章中的多列表格

我似乎无法理解 LaTeX 中的表格。我试图在文档中设置多个有 2 列的表格。我试图将表格保持在文章的单个列中,但似乎存在重叠,并且表格从每页的开头开始,而不是停留在我希望它们所在的部分。我应该让这些表格跨越两列吗?

表格与第二列重叠

\documentclass[twoside,twocolumn]{article}
\usepackage{amsmath,siunitx,booktabs,lipsum,cuted,capt-of}
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt]{geometry} 
\usepackage[hang, small,labelfont=bf,up,textfont=it,up]{caption} 
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage{booktabs}
\setlength{\arrayrulewidth}{0.25mm}
\setlength{\tabcolsep}{9pt}
\renewcommand{\arraystretch}{1.5}

\begin{document}
\section*{Results}
\begin{table}[ht]
\setlength{\tabcolsep}{9pt}
\begin{tabular*}{\linewidth}{@{}p{\dimexpr.4\linewidth-
\tabcolsep}p{\dimexpr.6\linewidth-\tabcolsep}@{}@{}p{\dimexpr.4\linewidth-\tabcolsep}p{\dimexpr.6\linewidth-\tabcolsep}@{}@{}p{\dimexpr.4\linewidth-\tabcolsep}@{}}
\toprule 
Compound & Theoretical Yield (g) & Experimental Yield (g) & Percent Yield & Percent Composition of Total Product \\
\midrule
Total Final Product & 2.90 & 1.6853 & 58.1 & \\
2-methyl-2-butene & 2.60 & 1.56 & & 92.60756 \\
2-methyl-1-butene & 0.30 & 0.12 & &7.39244 \\
\bottomrule %inserts single line
\caption{GC parameters on}
\label{table:2} % is used to refer this table in the text
\end{table}

\end{document}

答案1

要在双列文档中排版全宽表格,您必须使用环境table*。请注意,LaTeX 始终将table*环境(以及figure*环境)放在页面顶部。

您的表格有五列。五个单元格标题中有三个很长,必须换行。我建议您对第 2 列至第 5 列使用tabularx环境和居中版本的X列类型。对于第 1 列,请使用基本l列类型。

在此处输入图片描述

补充说明:鉴于实验产量(以克为单位)的测量精度似乎不超过 3 位数字,以 7 位数字的精度报告百分比产量近乎荒谬。我认为,报告“92.6%”和“7.4%”(或者,如果你坚持,“92.61%”和“7.39%”)更符合事物的精神。

\documentclass[twoside,twocolumn]{article}
\usepackage{amsmath,siunitx,booktabs,cuted,capt-of}
\usepackage[hmarginratio=1:1,top=32mm,
            columnsep=20pt]{geometry} 
\usepackage[hang, small, labelfont={bf,up},
                         textfont ={it,up}]{caption} 
\usepackage[utf8]{inputenc}
\usepackage{tabularx,ragged2e} % <-- new
\newcolumntype{C}{>{\Centering\arraybackslash}X}

\begin{document}
\section*{Results}

\begin{table*}  % will be placed at top of a page
\begin{tabularx}{\linewidth}{@{} l CCCC @{}}
\toprule 
Compound & Theoretical Yield (g) & Experimental Yield (g) & Percent Yield & Percent Composition of Total Product \\
\midrule
Total Final Product & 2.90 & 1.6853 & 58.1 \\[1ex]
2-methyl-2-butene   & 2.60 & 1.56   & &   92.60756 \\
2-methyl-1-butene   & 0.30 & 0.12   & &    7.39244 \\
\bottomrule
\end{tabularx}
\caption{GC parameters on}
\label{table:2}
\end{table*}

\end{document}

附录,由 OP 发布的后续查询引发:如果这是我的文档,我会将编辑工作重点放在简化和精简表格材料上,以便将其放在单个列中。例如,以下内容。

在此处输入图片描述

\documentclass[twoside,twocolumn]{article}
\usepackage{amsmath,siunitx,booktabs}
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt]{geometry}
\usepackage[hang, small, labelfont={bf,up},
                         textfont ={it,up}]{caption}
\usepackage[utf8]{inputenc}
\usepackage{tabularx,ragged2e} % <-- new
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}

\begin{document}
\section*{Results}

\begin{table} [h!]
\setlength\tabcolsep{2pt} % default: 6pt
\small
\begin{tabularx}{\columnwidth}{@{} l CCC @{}}
\toprule
& \multicolumn{2}{c}{Yield} \\
\cmidrule(lr){2-3}
Compound & Theoretical & Experimental & Percent of total\\
& (g) & (g) \\
\midrule
Total Final Product & 2.90 & 1.68 &  \\[0.5ex]
2-methyl-2-butene   & 2.60 & 1.56 & 92.6 \\
2-methyl-1-butene   & 0.30 & 0.12 & \phantom{0}7.4 \\
\bottomrule
\addlinespace
\end{tabularx}
Yield ratio, experimental to theoretical: 58.1\%.
\caption{GC parameters on \dots}
\label{table:2}
\end{table}

\end{document} 

答案2

另一种可能性是交换行和列,使用tabularx并使用一些参数:

\documentclass[twoside,twocolumn]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage[hmarginratio=1:1, top=32mm, columnsep=20pt, showframe]{geometry}
\usepackage[hang, small,labelfont=bf,up,textfont=it,up]{caption}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage{booktabs, cuted,capt-of, tabularx, makecell}
\setlength{\arrayrulewidth}{0.25mm}
\setlength{\tabcolsep}{9pt}
\renewcommand{\arraystretch}{1.5}

\begin{document}

\section*{Results}

\begin{table}[ht]
\small
\setlength{\tabcolsep}{4pt}
\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash\RaggedRight}m{#1}}
\begin{tabularx}{\linewidth}{@{}X*{3}{c}@{}}
\toprule
 & \multicolumn{3}{c}{Compound} \\
 \cmidrule{2-4}
 & \makecell{Total Final\\ Product} & \makecell[r]{2-methyl\\-2-butene} & \makecell[r]{2-methyl\\-1-butene} \\
\midrule
Theoretical Yield (g) & 2.90 & 2.60 & 0.30 \\
 Experimental Yield (g) &1.6853 & 1.56 & 0.12 \\
 Percent Yield &58.1 & &\\
 \makebox[\hsize][l]{Percent Composition} \makebox[\hsize][l]{of Total Product} & & 92.60756 & 7.39244 \\
\bottomrule %inserts single line
\end{tabularx}
\caption{GC parameters on}
\label{table:2} % is used to refer this table in the text
\end{table}

\end{document}&

在此处输入图片描述

相关内容