2

I have made a table and in it, I have to use the multirow package for the headers. Works fine when there are two lines but it y-overflows when there are three. I tried increasing the space in each row with \setlength\extrarowheight but that just increased the cell and the overflow remained.

Here are a few pictures:

Table image, source code shown below

How do I solve this?

Here is the source for the table:

\documentclass[11pt,a4paper]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[h!]
    \centering
        \caption{OVERFLOW}
        \bgroup
        \def\arraystretch{1.5}%
            \begin{tabular}{|c|c|c|c|c|c|c|c|}
            \hline
            \multirow{2}{*}{
                \begin{tabular}[c]{@{}c@{}}Extension\\
                $x/\mathrm{cm}$\end{tabular}} & 
            \multicolumn{5}{c|}{
                \begin{tabular}[c]{@{}c@{}}Distance travelled \\
                $s_{i}/\mathrm{cm}$\end{tabular}} & 
            \multirow{2}{*}{
                \begin{tabular}[c]{@{}c@{}}Avg. distance\\
                $s/\mathrm{cm}$\end{tabular}} & 
            \multirow{2}{*}{
                \begin{tabular}[c]{@{}c@{}}Uncertainty in\\
                avg. distance\\ $\Delta s/\pm \mathrm{cm}$\end{tabular}} \\ 
                \cline{2-6} & 
            Trial 1 & Trial 2 & Trial 3 & Trial 4 & Trial 5 &  &  \\ 
            \hline
            \end{tabular}
        \egroup
    \end{table}
\end{document}
  • \multiline ?. – David Carlisle Mar 12 '17 at 20:04
  • My bad. The multirow package – David Simon Tetruashvili Mar 12 '17 at 20:05
  • also your example has two \documentclass commands and no document environment, it presumably did not produce the image shown. – David Carlisle Mar 12 '17 at 20:18
0

Edit:

With using makecell package for define multi-line multi-row cell, I obtain:

enter image description here

In table instead to increase \arraystretch I use gaped cells from makecell package:

\documentclass[11pt,a4paper]{article}
\usepackage{makecell, multirow}
\usepackage{siunitx}

\begin{document}
    \begin{table}[h!]
    \centering
\caption{OVERFLOW}
\setcellgapes{5pt}
\makegapedcells

\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multirowcell{3}{Extension\\ \si{x/cm}}
    &   \multicolumn{5}{c|}{\makecell{Distance travelled \\ \si{s_{i}/cm}}} 
        &   \multirowcell{3}{Avg. distance\\ \si{cm} } 
            &   \multirowcell{3}[1ex]{Uncertainty in\\
                                      avg. distance\\ 
                                      \si{\Delta s/\pm cm}}}  \\
        \cline{2-6} &
    Trial 1 & Trial 2 & Trial 3 & Trial 4 & Trial 5 &  &  \\
    \hline
    \end{tabular}
    \end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.