表格环境中的文本换行问题

表格环境中的文本换行问题

我希望一行中单元格的内容跨越多行。我有以下 MWE:

\begin{table}[b]{
\begin{center}{
\begin{tabular}{|l|c|c|c|c|}
\hline
Source & Value & Affected & Type & Effect on the    \\
       &       & sample   &      & total yield \\
\hline
\hline
Statistical  & 2-14\% & bkg. & bin-by-bin & - \\
Uncertainties in C(i, j) & & & &\\
\hline
Extrapolation & 2-22\% & bkg. & bin-by-bin & - \\
Uncertainties in C(i, j) & & & & \\
\hline
Integrated Luminosity & 2.6\% & signal & norm. & 2.6\%\\
\hline
Muon ID and trigger    & 2\% per muon  & signal & norm. & 4\% \\
efficiency             &               &        &       &     \\
\hline
Track selection and    & 5\% per track & signal & norm. & 10\% \\
isolation efficiency   &               &        &       &     \\
\hline
MC statistical & 2-100\%        & signal   & bin-by-bin & 4-6\%  \\
uncertainties           &               &        &       &   \\
\hline
\end{tabular}
\caption{List of systematics uncertainties and their effect on estimates of the
QCD multijet background and signal.}
\label{tab:systematics}
}
\end{center}
}
\end{table}

为了实现这一点,我必须创建一个新行,并将该行中的其他条目留空。结果,值没有居中。我尝试根据以下解决方案实现文本换行: 解决方案

由于我正在使用一些 cls 文件来撰写论文,因此它弄乱了这个解决方案。所需的文件在我的 dropbox 中: 支持文件

答案1

您可以使用 makecell包来实现这一点,它允许通过\thead\makecell命令在单元格中换行并采用常见的格式。

我建议另一个看起来更好的解决方案,仅使用不同厚度的水平规则和包装booktabs

最后,我对您的表格进行了一些改进(数字和之间不可破坏的细空格%、数字范围的 endash 和空单元格的 emdash)。

\documentclass{ucr}
\usepackage{makecell, booktabs, array}

 \begin{document}

\begin{table}[b]
  \centering
  \renewcommand\cellalign{lc}
  \renewcommand\theadfont{\normalsize}
  \begin{tabular}{|l|c|c|c|c|}
    \hline
    Source                        \\[-1ex]sample }& \thead{Type} &\thead{ Effect on the\\[-1ex]total yield} \\
    \hline
    \hline
    \makecell{Statistical         \\[-1ex]Uncertainties in C(i, j)} & 2--14\,\% & bkg. & bin-by-bin & --- \\
    \hline
    \makecell{Extrapolation       \\[-1ex]Uncertainties in C(i, j)} & 2--22\,\% & bkg. & bin-by-bin & --- \\
    \hline
    Integrated Luminosity         \\
    \hline
    \makecell{Muon ID and trigger \\[-1ex]efficiency} & 2\,\% per muon & signal & norm. & 4\,\% \\
    \hline
    \makecell{Track selection and \\[-1ex]isolation efficiency }& 5\,\% per track & signal & norm. & 10\,\% \\
    \hline
    \makecell{MC statistical      \\[-1ex]uncertainties} & 2--100\,\% & signal & bin-by-bin & 4--6\,\% \\
    \hline
  \end{tabular}
  \caption{List of systematics uncertainties and their effect on estimates of the
  QCD multijet background and signal.}
  \label{tab:systematics}
\end{table}
\begin{table}[b]
  \centering
  \renewcommand\cellalign{lc}
  \renewcommand\theadfont{\normalsize}
  \begin{tabular}{lcccc}
    \toprule
    Source \\[-1ex]  sample }& \thead{Type} &\thead{ Effect on the\\[-1ex]total yield} \\
    \cmidrule(lr){1-5}
    \morecmidrules
    \cmidrule(lr){1-5}
    \makecell{Statistical \\[-1ex]Uncertainties in C(i, j)} & 2--14\,\% & bkg. & bin-by-bin & --- \\
    \addlinespace
    \makecell{Extrapolation       \\[-1ex]%
    Uncertainties in C(i, j)} & 2--22\,\% & bkg. & bin-by-bin & --- \\
    \addlinespace
    Integrated Luminosity         \\
    \addlinespace
    \makecell{Muon ID and trigger \\[-1ex]efficiency} & 2\,\% per muon & signal & norm. & 4\,\% \\
    \addlinespace
    \makecell{Track selection and \\[-1ex]isolation efficiency }& 5\,\% per track & signal & norm. & 10\,\% \\
    \addlinespace
    \makecell{MC statistical      \\[-1ex]uncertainties} & 2--100\,\% & signal & bin-by-bin & 4--6\,\% \\
    \bottomrule
  \end{tabular}
  \caption{List of systematics uncertainties and their effect on estimates of the
  QCD multijet background and signal.}
  \label{tab:systematics}
\end{table}
\end{document} 

在此处输入图片描述

相关内容