带有 Booktabs 的表格-无法获得所需结果

带有 Booktabs 的表格-无法获得所需结果

该问题与该帖子(接受的答案)相关: 表格格式

编译下面的代码后我得到了这个结果: 在此处输入图片描述

我尝试了几种替代方法,例如添加反斜杠或“&”符号,但仍然无法获得预期的结果。

提前致谢。

 \documentclass[a4paper,12pt]{scrreprt}
    \usepackage{booktabs} 
    \begin{document}
    \begin{table}
    \centering
    \begin{tabular}{@{} lcccc @{}} % suppress vertical whitespace at start and end
    \toprule
    Company& \multicolumn{3}{c}{Exceedances} & No.\ of Obs.\    \cmidrule(lr){2-4}
    & \multicolumn{2}{c}{Empirical} & Expected\    \cmidrule(lr){2-3} \cmidrule(lr){4-4}
    &standard & standardized\\    % make columns 2 and 3 narrower
    &normal   & Student's-$t$\    \midrule
    Company 1&1&5&9&13\    Company 2&2&6&10&14\    Company 3&3&11&15\    Company 4&4&8&12&16\    \midrule[\heavyrulewidth] % use "thick" \midrule instead of \bottomrule
    \multicolumn{4}{@{}l}{\footnotesize An additional hint about a detail}
    \end{tabular}
    \caption{Here is the caption.}
    \label{labelhere}
    \end{table} 
    \end{document}  

答案1

您必须使用双反斜杠\\来换行。

\documentclass{article}
\usepackage{booktabs} 
\begin{document}
\begin{table}
  \centering
  \begin{tabular}{@{} lcccc @{}}
    \toprule
    Company   & \multicolumn{3}{c}{Exceedances} & No.\ of Obs.  \\
    \cmidrule(lr){2-4}
              & \multicolumn{2}{c}{Empirical}   & Expected      \\
    \cmidrule(lr){2-3}\cmidrule(lr){4-4}
              & standard                        & standardized  \\
              & normal                          & Student's-$t$ \\
    \midrule
    Company 1 & 1 & 5  & 9                      & 13            \\
    Company 2 & 2 & 6  & 10                     & 14            \\
    Company 3 & 3 & 11 & 15                                     \\
    Company 4 & 4 & 8  & 12                     & 16            \\
    \midrule[\heavyrulewidth]
    \multicolumn{4}{@{}l}{\footnotesize An additional hint about a detail}
  \end{tabular}
  \caption{Here is the caption.}
  \label{labelhere}
\end{table} 
\end{document}

在此处输入图片描述

相关内容