1

I would like the contents of a cell in a row span several lines. I have the following 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}

In order to achieve that I had to create a new row with other entries in that row empty. As a result the values do not get centered. I tried to implement text wrapping according to the solution provided in: Solution

Since I'm using some cls files to write my thesis, it is messing up this solution. The required files are in my dropbox: Support files

0

1 Answer 1

1

You can do that with the makecell package, which allows for line breaks in cells and a common formatting, through the\thead and \makecell commands.

I propose another, looking better, solution, with only horozontal rules of different thickness, with the booktabs package.

Finally I added some improvements to your table (unbreakable thin space between number and %, endash for ranges of numbers and emdash for empty cells).

\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} 

enter image description here

3
  • The text was too close to each other but I just found out that it can be controlled by the option[-1ex]. There is an extra curly brace in Source \[-1ex] sample }& \thead{Type} &\thead{ Effect on the\[-1ex]total yield} \\ on both implementations. Otherwise it works great! Thanks. May 19, 2016 at 1:45
  • That probably depends on some parameter values in your preamble. You can change the value of [0.5ex] in multiline cells to a greater value. For me, [-1ex] that I first tested was too much. Change it ad libitum.
    – Bernard
    May 19, 2016 at 1:47
  • Let me add I initially tried to change the value of \linespread for these cells (globally) to have a simpler code, but it doesn't work, probably due to the class file.
    – Bernard
    May 19, 2016 at 1:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .