3

Consider the following table in my memoir article:

\documentclass{memoir}

\begin{document}

\begin{table*}[ht]
    \scriptsize
    \centering
        \begin{tabular}{l p{2.5cm} p{9cm}}
            \toprule
                No. & Alpha & Beta \tabularnewline
                \cmidrule{1-3}
                1 & Lorem ipsum dolor & Lorem ipsum dolor \\[0.2cm]
                2 & Lorem ipsum dolor & Lorem ipsum dolor \\[0.2cm]
                3 & Lorem ipsum dolor & Lorem ipsum dolor \\[0.2cm]
                4 & Lorem ipsum dolor sit amet & Lorem ipsum dolor \\[0.2cm]
                5 & Lorem ipsum dolor & Lorem ipsum dolor \\[0.2cm]
                6 & Lorem ipsum dolor sit amet & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor \\[0.2cm]
                7 & Lorem ipsum dolor & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor \\
            \bottomrule
        \end{tabular}
        \centering
        \caption{Bla}
        \label{tab:bla}
\end{table*}

\end{document}

This will give the following table:

enter image description here

What I don't like about this table is that [0.2cm] seems to be ignored for rows 4 and 6 because they have cells that require a line break. My suspicion is that the line break exceeds 0.2cm so there won't be any vertical space between rows 4-5 and 6-7.

If I use the article class with the following code, this behavior seems to change:

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{table*}[ht]
    \scriptsize
    \centering
        \begin{tabular}{l p{2.5cm} p{9cm}}
            \toprule
                No. & Alpha & Beta \tabularnewline
                \cmidrule{1-3}
                1 & Lorem ipsum dolor & Lorem ipsum dolor \\[0.2cm]
                2 & Lorem ipsum dolor & Lorem ipsum dolor \\[0.2cm]
                3 & Lorem ipsum dolor & Lorem ipsum dolor \\[0.2cm]
                4 & Lorem ipsum dolor sit amet & Lorem ipsum dolor \\[0.2cm]
                5 & Lorem ipsum dolor & Lorem ipsum dolor \\[0.2cm]
                6 & Lorem ipsum dolor sit amet & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor \\[0.2cm]
                7 & Lorem ipsum dolor & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor \\
            \bottomrule
        \end{tabular}
        \centering
        \caption{Bla}
        \label{tab:bla}
\end{table*}

\end{document}

Now, at least for row 6, the 0.2cm vertical space is considered. enter image description here

How can I ensure that the vertical space of 0.2cm between rows will be considered in the memoir class? Should I increase it to 0.4cm for rows 4 and 6?

Finally, why is the behavior different when using the article class and the booktabs package?

3
  • The spacing seems to come from memoir autoloading the tabularx package. If you load tabularx in the article example (and make sure the margins are the same), the spacings seems the same (I've set it to 0.5cm to be more noticable).
    – daleif
    Commented May 17 at 8:37
  • @daleif array rather than tabularx actually, but yes. Commented May 17 at 8:40
  • @DavidCarlisle right, that makes more sense
    – daleif
    Commented May 17 at 8:41

2 Answers 2

9

The difference in the last column (so row 6) is due to array package (try loading that with article) to see the difference. Tthe handling of [] for the final strut of a p column is tricky, actually best is to not use [] at all and use the booktabs command \addlinespace

enter image description here

\documentclass{memoir}
%\documentclass{article}
%\usepackage{array}
%\usepackage{booktabs}
\begin{document}

\begin{table*}[ht]
    \scriptsize
    \centering
        \begin{tabular}{l p{2.5cm} p{9cm}}
            \toprule
                No. & Alpha & Beta \tabularnewline
                \cmidrule{1-3}
                1 & Lorem ipsum dolor & Lorem ipsum dolor \\
             \addlinespace[0.2cm]
                2 & Lorem ipsum dolor & Lorem ipsum dolor \\
             \addlinespace[0.2cm]
                3 & Lorem ipsum dolor & Lorem ipsum dolor \\
             \addlinespace[0.2cm]
                4 & Lorem ipsum dolor sit amet & Lorem ipsum dolor \\
             \addlinespace[0.2cm]
                5 & Lorem ipsum dolor & Lorem ipsum dolor \\
             \addlinespace[0.2cm]
                6 & Lorem ipsum dolor sit amet & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor \\
             \addlinespace[0.2cm]
                7 & Lorem ipsum dolor & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor \\
            \bottomrule
        \end{tabular}
        \centering
        \caption{Bla}
        \label{tab:bla}
\end{table*}

\end{document}
4
  • Thanks a lot! 0.2cm is now printed in the first column though. I guess it should be \addlinespace[0.2cm], right?
    – John Doe
    Commented May 17 at 8:47
  • @JohnDoe oops!! I need coffee sorry:-) yes I'll fix Commented May 17 at 8:54
  • Alright, perfect! Thanks a lot. Greatly appreciated.
    – John Doe
    Commented May 17 at 8:54
  • 1
    @JohnDoe try now Commented May 17 at 8:56
1

If you willing to use `tabularray package, the code for your table can be a bit shorter and simpler:

\documentclass{memoir}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
    \begin{table*}[ht]
    \scriptsize
\begin{tblr}{colspec  = {l X[0.3,l] X[l]},
             row{3-Y} = {rowsep=5pt}  % set distance between rows in table body
             }
    \toprule
No. & Alpha & Beta          \\
    \midrule 
1 & Lorem ipsum dolor & Lorem ipsum dolor \\
2 & Lorem ipsum dolor & Lorem ipsum dolor \\
3 & Lorem ipsum dolor & Lorem ipsum dolor \\
4 & Lorem ipsum dolor sit amet & Lorem ipsum dolor \\
5 & Lorem ipsum dolor & Lorem ipsum dolor \\
6 & Lorem ipsum dolor sit amet & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor \\
7 & Lorem ipsum dolor & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor \\
    \bottomrule
\end{tblr}
\caption{Bla}
\label{tab:bla}
    \end{table*}
\end{document}

enter image description here

You must log in to answer this question.

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