让表格标题“换行”到另一行

让表格标题“换行”到另一行

我有以下内容

\documentclass[review]{elsarticle}
\usepackage{booktabs}
\usepackage{array,multirow}

\begin{document}

\begin{table}[!h]
\centering
\small
\renewcommand{\arraystretch}{1.2}
\caption{\label{tbl:table_label}Table description}
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}lccccc}
\hline \hline
{} & \multicolumn{3}{c}{Lattice Parameter} & Layer Separation \\
\cmidrule{2-4} 
Type of work & a ({\AA}) & b ({\AA}) & c ({\AA}) & ({\AA}) & Ref.  \\
\hline
\rule{2pt}{0pt}\rule{0pt}{12pt}This & a & b & c & \# & $^{a}$  \\
\rule{2pt}{0pt}That & a & b & c & \# & $^{a}$  \\
\rule{2pt}{0pt}And & a & b & c & \# & $^{a}$  \\
\rule{2pt}{0pt}The & a & b & c & \# & $^{a}$  \\
\rule{2pt}{0pt}Other & a & b & c & \# & $^{a}$  \\
\hline \hline
\end{tabular*}
\end{table}

\end{document}

产生

在此处输入图片描述

我的问题是,我想让单词“Separation”位于“Layer”下方,但不增加当前标题的总高度。我尝试使用\multirow或定义\newcolumntype,但无济于事。作为 LaTeX 新手,在此先感谢您。

答案1

垂直空间似乎非常大,但这是选项的效果review

除了字体之外,最终的打印输出将是

在此处输入图片描述

而且,很有可能,文字编辑会将\arraystretch1.2 的重新定义删除,从而导致

在此处输入图片描述

这是一个可能的解决方法:请注意,我删除了该review选项以确保标题适合最终的打印输出。

\documentclass[
  %review
]{elsarticle}
\usepackage{booktabs}
\usepackage{array}

\begin{document}

\begin{table}[!h]
\centering
\renewcommand{\arraystretch}{1.2}
\small
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}\hspace{\tabcolsep}}lccccc}
\toprule
  & \multicolumn{3}{c}{Lattice Parameter}
  & \smash{% the vertical extent will not be seen
      \renewcommand{\arraystretch}{1}%
      \begin{tabular}[t]{@{}c@{}}Layer \\ Separation\end{tabular}%
    } \\
\addlinespace[2.5pt]
\cmidrule{2-4} 
\addlinespace[2.5pt]
Type of work & a ({\AA}) & b ({\AA}) & c ({\AA}) & (\AA) & Ref.  \\
\midrule
This & a & b & c & \# & $^{a}$  \\
That & a & b & c & \# & $^{a}$  \\
And & a & b & c & \# & $^{a}$  \\
The & a & b & c & \# & $^{a}$  \\
Other & a & b & c & \# & $^{a}$  \\
\bottomrule
\end{tabular*}

\caption{\label{tbl:table_label}Table description}

\end{table}

\end{document}

在此处输入图片描述

根据设置的参数,elsarticle他们很可能希望在表格下方添加表格标题。

答案2

\Shortunderstack使用来自`stackengine 的命令的解决方案:

\documentclass{elsarticle}

\usepackage{booktabs}
\usepackage[usestackEOL]{stackengine}
\usepackage{amsmath}
\begin{document}

\begin{table}
  \centering
  \caption{Table caption}
  \begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} l *{5}{c}}
    \toprule
    & \multicolumn{3}{c}{Lattice Parameter} &%\cellset{\renewcommand{\arraystretch}{0.5}}
     \setstackgap{S}{0pt}\smash[b]{\Shortunderstack {Layer\\Separation\\(\AA)}} \\
    \cmidrule{2-4}
    Type of work & a (\AA) & b (\AA) & c (\AA) & & Ref. \\
    \midrule
    This & a & b & c & \# & $^{a}$ \\
    That & a & b & c & \# & $^{a}$ \\
    And & a & b & c & \# & $^{a}$ \\
    The & a & b & c & \# & $^{a}$ \\
    Other & a & b & c & \# & $^{a}$ \\
    \bottomrule
  \end{tabular*}
\end{table}

\end{document} 

在此处输入图片描述

答案3

无需使用任何附加包,只需将该特定标题项设置在其自己的标题项内tabular

在此处输入图片描述

\documentclass{elsarticle}

\usepackage{booktabs}

\begin{document}

\begin{table}
  \centering
  \caption{Table caption}
  \begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} l *{5}{c}}
    \toprule
    & \multicolumn{3}{c}{Lattice Parameter} & 
      \begin{tabular}[b]{@{}c@{}} Layer \\ Separation \end{tabular} \\
    \cmidrule{2-4} 
    Type of work & a (\AA) & b (\AA) & c (\AA) & (\AA) &  Ref.   \\
    \midrule
    This         &    a    &    b    &    c    &   \#  & $^{a}$  \\
    That         &    a    &    b    &    c    &   \#  & $^{a}$  \\
    And          &    a    &    b    &    c    &   \#  & $^{a}$  \\
    The          &    a    &    b    &    c    &   \#  & $^{a}$  \\
    Other        &    a    &    b    &    c    &   \#  & $^{a}$  \\
    \bottomrule
  \end{tabular*}
\end{table}

\end{document}

答案4

您可能喜欢\multicolumn用两行来写单元格的内容:

\documentclass{elsarticle}
\usepackage{booktabs, makecell, tabularx}

\begin{document}
    \begin{table}
    \centering
\caption{Table caption}
  \begin{tabular*}{\linewidth}{l @{\extracolsep{\fill}} l *{5}c}
    \toprule
                & \multicolumn{3}{c}{\makecell[b]{Lattice\\ Parameters}}
                                                &   \makecell[b]{Layer\\ Separation}                                
                                                        &       \\
    \cmidrule {2-4}
Type of work    & a (\AA) & b (\AA) & c (\AA)   & (\AA) &  Ref.  \\
    \midrule
Longer type name
                &    a    &    b    &    c      &   \#  & $^{a}$ \\
That            &    a    &    b    &    c      &   \#  & $^{a}$ \\
And             &    a    &    b    &    c      &   \#  & $^{a}$ \\
The             &    a    &    b    &    c      &   \#  & $^{a}$ \\
Other           &    a    &    b    &    c      &   \#  & $^{a}$ \\
    \bottomrule
\end{tabular*}
    \end{table}
\end{document}

在此处输入图片描述

相关内容