2

Someone stumbled on a strange problem and asked my for help. She had a tabular environment and wanted to increase the vertical spacing between the table lines. I advised her to use \\[1.2ex] if she desired so. To my absolut astonishment, this did only work for the first line, every other \\[1.2ex] was ignored without any warning or error message.

I was able to boil this down to loading the array package.

This is an MWE, which will produce the requested results

\documentclass[draft]{scrartcl}
\usepackage[ngerman]{babel}             % 1) German Orthography
\usepackage[T1]{fontenc}                % 2) Output font encoding
% \usepackage{array}                      % 3) More Control over table layouts
% \newcolumntype{H}{>{\footnotesize}c}
\begin{document}
\begin{tabular}{@{} llp{10cm} @{}}
  % \multicolumn{1}{@{} H}{Nummer} & \multicolumn{1}{H}{Name} & \multicolumn{1}{H@{}}{Inhalt}\\
  Nr. & Name & Inhalt \\
  1 & Einleitung & Kontext, Problem und Aufgabenstellung, Ziele\\[2ex]
  2 & Theorie & Stand der Technik, Möglichkeiten der Versuchsumsetzung, vorangehende Versuche, Vor- und Nachteile, Absehbare Probleme\\[2ex]
  3 & Versuchsaufbau & Konkrete Umsetzung, Material und Aufbau, Randbedingungen, beteiligte Personen\\[2ex]
  4 & Durchführung & Durchführen des Versuches und Sammeln von Messdaten, Dokumentation, Fehlerquellen\\[2ex]
  5 & Auswertung & Analyse der Messdaten, Mathematische Berechnungen (Konfidenzintervall, Fehlerfortpflanzung, \dots), Was bedeuten Ergebnisse für Versuch\\[2ex]
  6 & Interpretation & Wie können Ergebnisse zukünftige Forschung beeinflussen, Wurde Ziel erreicht?\\[2ex]
  7 & Fazit & Zusammenfassung aller vorherigen Kapitel, abschließende Bewertung\\[2ex]
\end{tabular}
\end{document}

(To make the point visually more clear, the above MWE uses \\[2ex] instead of \\[1.2ex]. The size of the additional vertical space has no influence on this problem.)

The result looks like this: Table, where all lines have additional vertical space

Now, slightly change the above example by loading the package array.

\documentclass[draft]{scrartcl}
\usepackage[ngerman]{babel}             % 1) German Orthography
\usepackage[T1]{fontenc}                % 2) Output font encoding
\usepackage{array}                      % 3) More Control over table layouts
% \newcolumntype{H}{>{\footnotesize}c}
\begin{document}
\begin{tabular}{@{} llp{10cm} @{}}
  % \multicolumn{1}{@{} H}{Nummer} & \multicolumn{1}{H}{Name} & \multicolumn{1}{H@{}}{Inhalt}\\
  Nr. & Name & Inhalt \\
  1 & Einleitung & Kontext, Problem und Aufgabenstellung, Ziele\\[2ex]
  2 & Theorie & Stand der Technik, Möglichkeiten der Versuchsumsetzung, vorangehende Versuche, Vor- und Nachteile, Absehbare Probleme\\[2ex]
  3 & Versuchsaufbau & Konkrete Umsetzung, Material und Aufbau, Randbedingungen, beteiligte Personen\\[2ex]
  4 & Durchführung & Durchführen des Versuches und Sammeln von Messdaten, Dokumentation, Fehlerquellen\\[2ex]
  5 & Auswertung & Analyse der Messdaten, Mathematische Berechnungen (Konfidenzintervall, Fehlerfortpflanzung, \dots), Was bedeuten Ergebnisse für Versuch\\[2ex]
  6 & Interpretation & Wie können Ergebnisse zukünftige Forschung beeinflussen, Wurde Ziel erreicht?\\[2ex]
  7 & Fazit & Zusammenfassung aller vorherigen Kapitel, abschließende Bewertung\\[2ex]
\end{tabular}
\end{document}

And the result will change dramatically: Faulty table, where only the first line show additional vertical space.

As you can see, only the first \\[2ex] was executed, while every other \\[2ex] was silently ignored. The log file does not give any warning or error.

This example was produced on TeXLive of end 2021, using array.sty in version v2.5c

\ProvidesPackage{array}[2020/10/01 v2.5c Tabular extension package (FMi)] Using lualatex instead of pdflatex makes no difference at all.

(Removing packages babel and fontenc will change the outcome in the expected way: problems with Umlauts. Trying this with an english text, without package babel and fontenc still has the same problem. I haven't found any hint in the array manual either.)

5
  • Both of your examples don't compile properly since the booktabs is missing. Since you already seem to use said package, why not replace \\[2ex] with \\ \addlinespace?
    – leandriis
    Mar 3 at 8:57
  • Probably related: tex.stackexchange.com/q/232331/134144
    – leandriis
    Mar 3 at 8:59
  • You can also use something like \renewcommand\arraystretch{1.2} or \extrarowheight2ex to avoid mess with the low format of every table.
    – Fran
    Mar 3 at 9:34
  • @leandriis Thank you for your comment. I edited the MWEs and removed the remains of the booktabs package.
    – Jan
    Mar 4 at 11:07
  • @Fran thank you for your comment. But I think, loading the array package shouldn't do such harm. Shouldn't it?
    – Jan
    Mar 4 at 11:17

1 Answer 1

1

I don't know why array package do such harm, however for adding more vertical spaces around cells contents is better to use dedicated packages for adding vertical space above/below cells contents. For example the makecell package, which define macro \makegapedcells:

\documentclass[draft]{scrartcl}
\usepackage[ngerman]{babel}             % 1) German Orthography
\usepackage[T1]{fontenc}                % 2) Output font encoding
\usepackage{makecell}                   % 3) More Control over table layouts
\setcellgapes{5pt}
\makegapedcells

\begin{document}
    \begin{tabular}{@{} llp{10cm} @{}}
Nr. & Name 
        & Inhalt        \\           
  1 & Einleitung 
        & Kontext, Problem und Aufgabenstellung, Ziele  \\
  2 & Theorie 
        & Stand der Technik, Möglichkeiten der Versuchsumsetzung, vorangehende Versuche, Vor- und Nachteile, Absehbare Probleme   \\
  3 & Versuchsaufbau 
        & Konkrete Umsetzung, Material und Aufbau, Randbedingungen, beteiligte Personen \\
  4 & Durchführung 
        & Durchführen des Versuches und Sammeln von Messdaten, Dokumentation, Fehlerquellen \\
  5 & Auswertung 
        & Analyse der Messdaten, Mathematische Berechnungen (Konfidenzintervall, Fehlerfortpflanzung, \dots), Was bedeuten Ergebnisse für Versuch    \\
  6 & Interpretation 
        & Wie können Ergebnisse zukünftige Forschung beeinflussen, Wurde Ziel erreicht? \\
  7 & Fazit 
        & Zusammenfassung aller vorherigen Kapitel, abschließende Bewertung
\end{tabular}
\end{document}

enter image description here

or the cellspace package, which define macros

    \setlength\cellspacetoplimit{...}
    \setlength\cellspacebottomlimit{...}

For using them in selected columns you need extend column specification with option S (default, but you can rename it according to table specific) or C, if in table is used S columns defined in the siunitx package.

In your case the MWE can be:

\documentclass[draft]{scrartcl}
\usepackage[ngerman]{babel}             % 1) German Orthography
\usepackage[T1]{fontenc}                % 2) Output font encoding
\usepackage{cellspace}        % better, than {} aren't necessary
    \setlength\cellspacetoplimit{5pt}
    \setlength\cellspacebottomlimit{5pt}
    
\begin{document}
    \begin{tabular}{@{} Sl S l S{p{10cm}} @{}}
% table body is the same as before
\end{tabular}
\end{document}

enter image description here

But you may liked tabularray package, which has defined (among others) command rowsep by which you can simple change spaces between table rows. In example below is for third column used X column type which cause that table width is equal to \textwidth (similarly if the tabularx table would be used):

\documentclass[draft]{scrartcl}
\usepackage[T1]{fontenc}                
\usepackage[ngerman]{babel}
\usepackage{tabularray}

\begin{document}
\noindent\begin{tblr}{
               colspec = {@{} l l X[j] @{}},
              row{2-Z} = {rowsep=5pt}, % add space between table body rows
                 }
% table body is the same as before
\end{tblr}
\end{document}

Result is similar as before:

enter image description here

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.