47

When looking closely at some set arithmetic, I realized that all of the three symbols in the following minimum example are rendered here (pdfLaTeX on Portable MiKTeX, Windows 7 x64) at different vertical positions:

\documentclass{article}
\begin{document}
$x \in X$
\end{document}

Magnified screenshot, when viewed in Adobe Acrobat Pro 9 (added red line manually):

$x \in X$

The question: (why) is this as it should be? My naive view would expect at least $x$ and $X$ to share the same baseline.

migrated from tex.meta.stackexchange.com Oct 21 '13 at 17:08

This question came from our discussion, support, and feature requests site for users of TeX, LaTeX, ConTeXt, and related typesetting systems.

  • 8
    Because the fonts were designed before the nano-age. – kiss my armpit Oct 21 '13 at 17:46
  • 22
    The positioning of the baseline (the thin red line) in your graph is not correct. It should just touch the bottom edge of the uppercase-X glyph -- and thus intersect the lower parts of the lowercase-italic-x glyph. It's very common practice in font design to have the glyphs with rounded lower forms (think of o and O) cross the baseline a bit. This is done to make them look like they rest on the same baseline as do the characters with hard lower edges (such as B, D, E, L, Z, and a few more). – Mico Oct 21 '13 at 18:09
  • 14
    @Marienplatz: Of all fonts, the Computer Modern family of typefaces was designed and built in the most precise way, ever. – Khaled Hosny Oct 21 '13 at 20:51
62

This was a design choice, justified by the following: When glyphs have a curved bottom (and are not magnified to giant size) then, visually, they seem to hug the baseline better if their curves slightly undershoot the baseline. Such fine adjustments are everywhere in the Computer Modern fonts used in your example. This also happens when tops are curved: the declared height of a glyph may then be slightly less than the actual extent of the ink.

This explains the fact that $x$ seems to be slightly below the baseline when magnified.

As for the $\in$, math relations are usually designed to be vertically centered on the math axis, an imaginary line that is roughly half an x-height above the baseline. The baseline itself is irrelevant. It could have been chosen to be exactly twice the math axis height, and then it would sit on the baseline, but Knuth chose to make it larger. In my opinion, it would look better if it were a little smaller.

  • 7
    It may be worth noting that having glyphs with rounded lower ends "slightly undershoot the baseline", as you put it, is a very common method in font design. I.e., it's a method that's applied very generally and is thus not specific to the Computer Modern family. – Mico Oct 21 '13 at 18:16
  • 7
    To add to Mico’s comment, it is call overshoot. – Khaled Hosny Oct 21 '13 at 20:41
41

A picture to complete the excellent answer of Dan:

enter image description here

\documentclass{article}
\usepackage[margin=0pt,paperwidth=1.3cm,paperheight=0.8cm]{geometry}
\usepackage{xcolor}
\usepackage{graphicx}

% Draw a line showing a font metric
%  #1 color, #2 vertical position, #3 label
\newcommand{\drawmetric}[3]{%
  \rlap{%
    \color{#1}\rule[#2]{1cm}{0.05pt}%
    \raisebox{#2}{\scalebox{0.3}{\tiny\selectfont\sffamily #3}}%
  }%
}
\newcommand\drawallmetrics{%
  \drawmetric{red}{0pt}{baseline}%
  \drawmetric{blue}{1ex}{x-height}%
  \drawmetric{red}{\fontcharht\font`X}{cap-height}%
  \drawmetric{cyan}{\the\fontdimen22\textfont2}{math axis}%
}

\begin{document}

% Draw the metrics and some math
\noindent\rlap{$x \in X$}\drawallmetrics{}

% Draw the metrics and some text
\noindent\rlap{xoXO}\drawallmetrics{}
\end{document}
  • 3
    not part of what was asked, but it would be interesting to see another rule at the cap height -- it would illuminate the top overshoot of the "O", matching the one at the bottom. – barbara beeton Oct 22 '13 at 7:04
  • @barbarabeeton Good idea. But which "official" length gives this height? – Paul Gaborit Oct 22 '13 at 7:51
  • 2
    i'm not sure that the cap height is one of the defined lengths, and don't have access at the moment to any references. but one could pack the "X" into a box, and set the height for drawing a rule to the height of the box. – barbara beeton Oct 22 '13 at 8:38
  • I updated Paul's diagram (and code) to display some more metrics. (I'm not sure if it was better to update Paul's answer or make my own, but I figured it best not to clutter the page with similar answers.) – godbyk Oct 23 '13 at 1:12
  • 3
    @PaulGaborit Instead of measuring a box you can say \fontcharht\font`X for getting the height of X. – egreg Oct 23 '13 at 8:30

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.