1

I noticed the abominable chasm of empty space below all characters in my table.

Avert your eyes.

Changing the font, font size and leading did nada. Similar questions had been asked, but I didn't find the same. The 'what TjJ' is in a p column in a longtable, making it an m or b column (from the array package) does nothing visually significant. Adjusting \addtolength\aboverulesep{} and \..\below.., and \midrule[0pt]-ing ruins the coloring scheme, unless I'm using it wrong from the little I'd tried. In MS Paint I measured the distances to the top/bottom from the j, I want those two distances equal, without any extra been put in. Is that even possible?

Is any code example necessary if the abyssal void persists and pervades regardlessly? :

\documentclass{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{l p{1cm}}\hline
foo & bar \\\hline
foo & bar \\\hline
\end{longtable}
\end{document}

Here is an example of the m column with pag font being the same height as the default roman when superpositioned.

dddd

The m,t,b column types vertically align the rest of the columns as if the they're \multirow-s. With the following you can test to see that most (haven't tried all) font families doesn't equal space to the \hlines above/below their longest ascenders/descenders.

\documentclass{article}
\usepackage{array,longtable}
\begin{document}
\fontfamily{pag}\selectfont% select any font really
\begin{longtable}{l p{11cm}}\hline
foo & AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz and this continue to second row \\\hline 
\end{longtable}
    \vspace*{-48.8pt}
    \fontfamily{lmtt}\selectfont% select any font really
    \begin{longtable}{l m{11cm}}\hline
    foo & AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz and this continue to second row \\\hline 
    \end{longtable}
        \vspace*{-48.8pt}
        \fontfamily{ppl}\selectfont% select any font really
        \begin{longtable}{l b{11cm}}\hline
        foo & AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz and this continue to second row \\\hline 
        \end{longtable}
\end{document}
7
  • What happens if you put a \strut in the cell? Please show us a complete document beginning with \documentclass and ending with \end{document} which includes everything (including the packages) necessary to reproduce your issue, but nothing more. Take a look on how to create a minimal working example (MWE) by following that link. – Skillmon Mar 19 '18 at 12:33
  • you seem to be using a font with relatively small descenders without adjusting \strut to match but with no code shown hard to guess. – David Carlisle Mar 19 '18 at 12:34
  • @DavidCarlisle Would redefining the `\strut' height fix the problem, I've never had to use one, so I'm unfamiliar, and the WikiBook isn't helpful – vlg Mar 19 '18 at 13:34
  • Your example doesn't compile and doesn't show the problem. – Ulrike Fischer Mar 19 '18 at 13:37
  • you have not posted any code that shows the problem so how can anyone tell you how to fix it. posting some unrelated code that does not make the posted image does not count as posting an example! – David Carlisle Mar 19 '18 at 13:41
1

If you want to change the spaces, you have to redefine the \strut.

To get an equal distance between the upper line and the highest and the lower line and the deepest character in your font, you can use

\documentclass{article}
\usepackage{longtable,array} % forgot to add array
\showboxdepth2
\begin{document}
\fontfamily{pcr}\selectfont
\newcommand\changestrut{%
  \setbox\strutbox\hbox{%
    \setbox0\hbox{ABCDEFGHJIKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}%
    \skip0\dimexpr\baselineskip-\ht0-\dp0\relax
    \vrule height\glueexpr\ht0+.5\skip0\relax depth\glueexpr\dp0+.5\skip0\relax width0pt
  }%
}
\changestrut
\begin{longtable}{l p{11cm}}\hline
foo & AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz \\\hline 
\end{longtable}
\fontfamily{phv}\selectfont
\changestrut
\begin{longtable}{l p{11cm}}\hline
foo & AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz \\\hline 
\end{longtable}
\end{document}

The output The line \setbox0\hbox{...} can be changed to include all characters you expect to use. You can also try only including "typical" charaters. Then the characters will look more centered, but you may get problems with deep glyphs:

\documentclass{article}
\usepackage{longtable,array} % forgot to add array
\showboxdepth2
\begin{document}
\fontfamily{pcr}\selectfont
\newcommand\changestrut{%
  \setbox\strutbox\hbox{%
    \setbox0\hbox{ABCDE}%
    \skip0\dimexpr\baselineskip-\ht0-\dp0\relax
    \vrule height\glueexpr\ht0+.5\skip0\relax depth\glueexpr\dp0+.5\skip0\relax width0pt
  }%
}
\changestrut
\begin{longtable}{l p{11cm}}\hline
foo & AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz \\\hline 
\end{longtable}
\fontfamily{phv}\selectfont
\changestrut
\begin{longtable}{l p{11cm}}\hline
foo & AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz \\\hline 
\end{longtable}
\end{document}

enter image description here

2
  • This is TeX language, right? Do you learn how to redefine something, like the \strut, over time or is there some resource that you'd recommend? – vlg Mar 19 '18 at 15:39
  • You can read the TeXbook, but most of the time it is better to stay with the LaTeX commands. – Marcel Krüger Mar 19 '18 at 15:55
2

Different fonts have different characteristics. For instance, Computer Modern glyphs have a maximum height of 6.94444pt and maximum depth 1.94444pt, with an x-height of 4.30554pt. On the other hand, Avant Garde has maximum glyph height 7.35498pt, maximum depth 2.14998pt and x-height of 5.46999pt (I'm using the TeX Gyre project clone, Adventor).

The ratio height/depth is similar (3.57 for Computer Modern, 3.42 for Avant Garde), but the x-heights are very different.

Assume you want to typeset a whole document in Avant Garde (Adventor), you have to do at least one adjustment: you need to increase the baseline skip, because of the bigger height and depth: 12pt are not sufficient, because the total height is 9.5pt against 8.88888pt of Computer Modern. This would only leave 2.5pt between a deep glyph on one line and a high one on the next instead of more than 3pt. Let's assume we choose 13pt of baselineskip with \linespread{1.08} (it would actually give 12.96pt).

\documentclass{article}
\usepackage{tgadventor}

\renewcommand{\familydefault}{\sfdefault}
\linespread{1.08}

\begin{document}

\begin{tabular}{l}
\hline
what TjJ \\
\hline
\end{tabular}

\end{document}

enter image description here

Let's do some computations. The two rules are 12.96pt apart; the height of the T is 7.35498pt, the depth of j is 2.14998pt. The baseline is 12.96*0.7=9.072pt from the top rule, leaving about 1.72pt of white space. The baseline is 12.96pt*0.3=3.888pt from the bottom rule, leaving about 1.74pt of white space.

More interestingly, the top rule is 3.6pt from the top of the w, with just less than 0.3pt of difference in white space (0.1mm) which is negligible and makes the main part well centered in the available space.

With alternating colors:

\documentclass{article}
\usepackage{tgadventor}
\usepackage[table]{xcolor}

\renewcommand{\familydefault}{\sfdefault}
\linespread{1.08}

\begin{document}

\rowcolors{1}{black!30}{white}
\begin{tabular}{l}
what TjygJ \\
what TjygJ \\
what TjygJ \\
\end{tabular}

\end{document}

enter image description here

How did I measure the parameters?

\documentclass{article}
\usepackage{tgadventor}

\begin{document}

\sbox0{abcdefghijklmnopqrstuvwxyzABC}

\the\ht0 % max height of Computer Modern glyphs

\the\dp0 % max depth of Computer Modern glyphs

\the\dimexpr1ex % x-height of Computer Modern

\sbox0{\sffamily abcdefghijklmnopqrstuvwxyzABC}

\the\ht0 % max height of Adventor glyphs

\the\dp0 % max depth of Adventor glyphs

{\sffamily\expandafter}\the\dimexpr1ex % x-height of Adventor

\end{document}

enter image description here

2
  • Where from did you gather the various x-heights, max. heights and depths of the fonts? Can you measure any internally? – vlg Mar 19 '18 at 23:37
  • @vlg I added the way I got the lengths. – egreg Mar 20 '18 at 0:04

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.