我正在撰写一篇要提交给 Esevier Journal 的论文,但在将表格放入超出文本宽度的文本宽度中时遇到了问题。我将给出 MWE 如下:
\documentclass[preprint, authoryear]{elsarticle}
\usepackage[colorlinks=true,linkcolor=black, citecolor=blue, urlcolor=blue]{hyperref}
\journal{Journal of Transportation Research, Part E}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{textcomp}
\usepackage{url}
\usepackage{amstext}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\usepackage{tikz}
\usepackage{lettrine}
\allowdisplaybreaks
\usepackage[export]{adjustbox}
\usepackage{ragged2e}
\usepackage{subfig}
\usepackage{float}
\usepackage{url}
\urlstyle{same}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\bibliographystyle{elsarticle-harv}
%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{Introduction}\label{sec: intro}
Text text Text textText textText textText textText textText text
Text textText textText textText textText text Text textText textText textText textText textText textText textText textText textText textText textText textText textText text
\begin{table}[H]
\caption{Computational Results: Case I, $P_{1}$}
\label{tab: Case I, P1}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|}\hline
Weight Legend & AVG. Time $(s)$ & Cost ($\$1E6$) & \multicolumn{2}{c|}{Risk (pp $1E6$)} & No. of Trains\\ \hline
{} & {} & {} & X & Y & {} \\ \hline
Case A: $\alpha = 1.00$ , $\beta = 0.00$& 2.06 & 0.96 & 1.80 & 2.16 & 19 \\ \hline
Case B: $\alpha = 0.90$ , $\beta = 0.10$ & 39.8 & 0.97 & 1.75 & 2.13 & 19 \\ \hline
Case C: $\alpha = 0.80$ , $\beta = 0.20$ & 53.06 & 0.97 & 1.75 & 2.13 & 19 \\ \hline
Case D: $\alpha = 0.70$ , $\beta = 0.30$ & 44.72 & 1.01 & 1.75 & 1.93 & 23 \\ \hline
Case E: $\alpha = 0.60$ , $\beta = 0.40$ & 40.92 & 1.12 & 1.75 & 1.93 & 23 \\ \hline
Case F: $\alpha = 0.50$ , $\beta = 0.50$ & 39.8 & 1.12 & 1.67 &1.93 & 23 \\ \hline
Case G: $\alpha = 0.40$ , $\beta = 0.60$ & 36.22 & 1.12 & 1.67 & 1.93 & 23 \\ \hline
Case H: $\alpha = 0.30$ , $\beta = 0.70$ & 41.21 & 1.12 & 1.67 & 1.93 & 23 \\ \hline
Case I: $\alpha = 0.20$ , $\beta = 0.80$ & 34.43 & 1.20 & 1.60 & 1.93 & 26 \\ \hline
Case J: $\alpha = 0.10$ , $\beta = 0.90$ & 32.87 & 1.25 & 1.60 & 1.91 & 28 \\ \hline
Case K: $\alpha = 0.00$ , $\beta = 1.00$ & 17.96 & 1.62 & 1.60 & 1.91 & 41 \\ \hline
\end{tabular}
\end{center}
\end{table}
\justify Text text Text textText textText textText textText textText text
Text textText textText textText textText text Text textText textText textText textText textText textText textText textText textText textText textText textText textText text
\end{document}
如果您能帮助我将表格放入文本宽度块中,我将不胜感激。
答案1
像这样?
编辑:
- 您的表格有宽的列标题。为了使它们更短,我建议借助
makecell
包中的宏将它们分成两行makecell
- 为了更好地格式化数字(按小数点对齐),我建议使用
S
包中的列类型siunitx
- 这些包
url
应该hyperref
在序言中最后加载 - 在第二个例子中,我展示了一种替代方法:
- 将第一列重新组织为三列,标题为“case”、“$\alpha$”和“$\beta$”
- 对于部分列标题位于
multirow
单元格中 - 删除垂直线
- 而不是
\hline
使用来自包的规则booktabs
\documentclass[preprint]{elsarticle}
%\documentclass[preprint, authoryear]{elsarticle}
%\usepackage{lineno}
%\modulolinenumbers[5]
\journal{Journal of Transportation Research, Part E}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{textcomp}
\usepackage{amstext}
\usepackage{amssymb}
\usepackage{amsmath}
%% \numberwithin{equation}{subsection}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\usepackage{tikz}
\usepackage{lettrine}
\allowdisplaybreaks
\usepackage[export]{adjustbox}
\usepackage{ragged2e}
\usepackage{subfig}
\usepackage{float}
\usepackage{booktabs}
\usepackage{makecell} % new
\usepackage{tabularx}
%\usepackage{array} % loaded by makecell and/or by tabularx
\usepackage{siunitx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{url}
\urlstyle{same}
\usepackage[colorlinks=true,linkcolor=black, citecolor=blue, urlcolor=blue]{hyperref}
%% `Elsevier LaTeX' style
\bibliographystyle{elsarticle-harv}
%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{Introduction}\label{sec: intro}
Text text Text textText textText textText textText textText text
Text textText textText textText textText text Text textText textText textText textText textText textText textText textText textText textText textText textText textText text
\begin{table}[htb]
\caption{Computational Results: Case I, $P_{1}$}
\label{tab: Case I, P1}
\centering
\begin{tabular}{|c| S[table-format=2.2]|
*{3}{S[table-format=1.2]|}
S[table-format=2.0]|}
\hline
Weight Legend
& {\makecell{AVG.\\ Time $(s)$}}
& {\makecell{Cost\\ ($\$1E6$)}}
& \multicolumn{2}{c|}{\makecell{Risk\\ (persons $1E6$)}}
& {\makecell{No. of\\ Trains}} \\ \hline
Cases & & & {Propane} & {Butane} & \\ \hline
A: $\alpha = 1.00$ , $\beta = 0.00$ & 2.06 & 0.96 & 1.80 & 2.16 & 19 \\ \hline
B: $\alpha = 0.90$ , $\beta = 0.10$ & 39.8 & 0.97 & 1.75 & 2.13 & 19 \\ \hline
C: $\alpha = 0.80$ , $\beta = 0.20$ & 53.06 & 0.97 & 1.75 & 2.13 & 19 \\ \hline
D: $\alpha = 0.70$ , $\beta = 0.30$ & 44.72 & 1.01 & 1.75 & 1.93 & 23 \\ \hline
E: $\alpha = 0.60$ , $\beta = 0.40$ & 40.92 & 1.12 & 1.75 & 1.93 & 23 \\ \hline
F: $\alpha = 0.50$ , $\beta = 0.50$ & 39.8 & 1.12 & 1.67 & 1.93 & 23 \\ \hline
G: $\alpha = 0.40$ , $\beta = 0.60$ & 36.22 & 1.12 & 1.67 & 1.93 & 23 \\ \hline
H: $\alpha = 0.30$ , $\beta = 0.70$ & 41.21 & 1.12 & 1.67 & 1.93 & 23 \\ \hline
I: $\alpha = 0.20$ , $\beta = 0.80$ & 34.43 & 1.20 & 1.60 & 1.93 & 26 \\ \hline
J: $\alpha = 0.10$ , $\beta = 0.90$ & 32.87 & 1.25 & 1.60 & 1.91 & 28 \\ \hline
K: $\alpha = 0.00$ , $\beta = 1.00$ & 17.96 & 1.62 & 1.60 & 1.91 & 41 \\ \hline
\end{tabular}
\end{table}
Text text Text textText textText textText textText textText text
Text textText textText textText textText text Text textText textText textText textText textText textText textText textText textText textText textText textText textText text
\end{document}
附录: 或者像这样(我喜欢):
\documentclass[preprint]{elsarticle}
%\documentclass[preprint, authoryear]{elsarticle}
%\usepackage{lineno}
%\modulolinenumbers[5]
\journal{Journal of Transportation Research, Part E}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{textcomp}
\usepackage{amstext}
\usepackage{amssymb}
\usepackage{amsmath}
%% \numberwithin{equation}{subsection}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\usepackage{tikz}
\usepackage{lettrine}
\allowdisplaybreaks
\usepackage[export]{adjustbox}
\usepackage{ragged2e}
\usepackage{subfig}
\usepackage{float}
\usepackage{booktabs}
\usepackage{makecell, multirow}
\usepackage{tabularx}
%\usepackage{array}
\usepackage{siunitx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{url}
\urlstyle{same}
\usepackage[colorlinks=true,linkcolor=black, citecolor=blue, urlcolor=blue]{hyperref}
%% `Elsevier LaTeX' style
\bibliographystyle{elsarticle-harv}
%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{Introduction}\label{sec: intro}
Text text Text textText textText textText textText textText text
Text textText textText textText textText text Text textText textText textText textText textText textText textText textText textText textText textText textText textText text
\begin{table}[htb]
\caption{Computational Results: Case I, $P_{1}$}
\label{tab: Case I, P1}
\centering
\begin{tabular}{c
*{2}{S[table-format=1.2]}
S[table-format=2.2]
*{3}{S[table-format=1.2]}
S[table-format=2.0]
}
\toprule
\multicolumn{3}{c}{Weight Legend}
& {\multirow{2}{*}{\makecell{AVG.\\ Time $(s)$}}}
& {\multirow{2}{*}{\makecell{Cost\\ ($\$1E6$)}}}
& \multicolumn{2}{c}{\makecell{Risk (persons $1E6$)}}
& {\multirow{2}{*}{\makecell{No. of\\ Trains}}} \\
\cmidrule{1-3}
\cmidrule{6-7}
Case & {$\alpha$} & {$\beta$}& & & {Propane} & {Butane} & \\
\midrule
A & 1.00 & 0.00 & 2.06 & 0.96 & 1.80 & 2.16 & 19 \\
B & 0.90 & 0.10 & 39.8 & 0.97 & 1.75 & 2.13 & 19 \\
C & 0.80 & 0.20 & 53.06 & 0.97 & 1.75 & 2.13 & 19 \\
D & 0.70 & 0.30 & 44.72 & 1.01 & 1.75 & 1.93 & 23 \\
E & 0.60 & 0.40 & 40.92 & 1.12 & 1.75 & 1.93 & 23 \\
F & 0.50 & 0.50 & 39.8 & 1.12 & 1.67 & 1.93 & 23 \\
G & 0.40 & 0.60 & 36.22 & 1.12 & 1.67 & 1.93 & 23 \\
H & 0.30 & 0.70 & 41.21 & 1.12 & 1.67 & 1.93 & 23 \\
I & 0.20 & 0.80 & 34.43 & 1.20 & 1.60 & 1.93 & 26 \\
J & 0.10 & 0.90 & 32.87 & 1.25 & 1.60 & 1.91 & 28 \\
K & 0.0 & 01.00 & 17.96 & 1.62 & 1.60 & 1.91 & 41 \\
\bottomrule
\end{tabular}
\end{table}
Text text Text textText textText textText textText textText text
Text textText textText textText textText text Text textText textText textText textText textText textText textText textText textText textText textText textText textText text
\end{document}