1

I noticed that the tabular environment produces surplus vertical space on top of \baselineskip (as does LaTeX by default but that part can be avoided by using \offinterlineskip):

\documentclass{article}

\begin{document}
    \offinterlineskip
    \fontsize{40pt}{40pt}\selectfont

    No vertical spacing (bars touch):\\\textbar\\\textbar

    \begin{tabular}{l}
        Tabular produces vertical space:\\\textbar\\\textbar
    \end{tabular}
\end{document}

enter image description here

How can I make tabular omit that vertical space? Seems I have not found the proper length to set yet...


To add to the accepted answer:

Turns out most of the confusion was due to the issue described in a follow-up question, see https://tex.stackexchange.com/a/410251/152311

The font size of 40 pt I used in the example to highlight the issue unfortunately shows the problem of not fully scalable fonts at its worst and introduces a large vertical spacing even for normal text which I tried to suppress with \offinterlineskip subsequently. This command does not affect the tabular environment in the same way, though.

It turns out the "fix" is as simple as adding the fix-cm package or using a scalable font like lmodern:

\documentclass{scrartcl}
\usepackage{lmodern}

\begin{document}
%   \offinterlineskip
\fontsize{40pt}{40pt}\selectfont

No vertical spacing (bars touch):\\\textbar\\\textbar

\begin{tabular}{l}
    Tabular produces vertical space:\\\textbar\\\textbar
\end{tabular}
\end{document}

Note the sudden increase in font size (not properly visible in the screenshots due to different scaling unfortunately).

The bars are almost touching also in the tabular example now (help on how to remove the remaining difference would be appreciated but is mostly academic now).

Using \fontsize{40pt}{80pt}\selectfont causes the behavior I desired initially (e.g. a proper double line spacing in the text and the tabular).

1

Tables follow different rules. A strut is added at each line (.7\baselineskip above the base line and .3\baselineskip below). This is modified by a factor \arraystretch. It can be redefined to zero:

\documentclass{article}
\begin{document}
    \renewcommand*{\arraystretch}{0}
    \begin{tabular}{l}
        Tabular without vertical space:\\\textbar\\\textbar
    \end{tabular}
\end{document}

Result

  • Thanks, that answers my question but the long-term goal is to be able to set what CSS calls the line-height property on the tabular - redefining \arraystretch to zero prevents this (it will always be zero). – Patrick Storz Jan 13 '18 at 18:57
  • @EduardBraun The default value of \arraystretch is 1. It can be redefined to other values. But keep in mind, LaTeX tables work differently from CSS. – Heiko Oberdiek Jan 13 '18 at 19:01
  • Yeah, I'm struggling with this a bit right now... I had assumed \fontsize{40pt}{40pt} in the example above would put my lines directly next to each other and fontsize{40pt}{60pt} would be like setting line-height:1.5; in CSS - apparently it is not. I'll have to read up on that a bit before maybe asking a more targeted question. – Patrick Storz Jan 13 '18 at 19:06

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.