28

I have an issue I cannot explain to myself. Here is the code:

\documentclass{scrartcl}

\usepackage{tikz}

\begin{document}
\newcommand{\tikzmark}[4][]{\begin{tikzpicture}\node[inner sep=1pt,outer sep=0pt,font=#4] (#2) {#3#1}; \end{tikzpicture}}
\newcommand{\oct}[2][]{\tikzmark[#1]{oct_#2}{'#2}{\itshape}}

\begin{tabular}{c|c|c|c|c|c|c|c|c|c}
    &\oct{0}    &\oct{1}    &\oct{2}    &\oct{3}    &\oct{4}    &\oct{5}    &\oct{6}    &\oct{7}    & \\ \hline
\end{tabular}

\end{document}

This is the resulting table: enter image description here

Why is the 7 jumping out of the baseline?

2
  • 3
    Note that the modern version of \tikzmarknode (which is what you'd want to use here) as provided by the tikzmark library has the baseline option already included. Commented Dec 17, 2021 at 15:32
  • 1
    So \usetikzlibrary{tikzmark} plus \newcommand{\oct}[1]{\tikzmarknode{oct_#1}{\itshape{'#1}}} works. Commented Dec 22, 2021 at 8:04

3 Answers 3

35

To answer the question why the italic 7 of Latin Modern is shifted upwards although it has no descender: It actually has an invisible descender, that is, its bounding box has the same depth as the italic 4. The other italic numbers don't have this feature (or is it a bug?).

\documentclass{article}
\usepackage[margin=15mm]{geometry}
\usepackage{showcharinbox, anyfontsize}

\begin{document}
\begin{center}

\ShowCharInBox{\fontsize{200}{210}\selectfont 6}
\vskip 1cm
\ShowCharInBox{\fontsize{200}{210}\selectfont 4}
\vskip 1cm
\ShowCharInBox{\fontsize{200}{210}\selectfont 7}

\newpage

\ShowCharInBox{\fontsize{200}{210}\selectfont\textit{6}}
\vskip 1cm
\ShowCharInBox{\fontsize{200}{210}\selectfont\textit{4}}
\vskip 1cm
\ShowCharInBox{\fontsize{200}{210}\selectfont\textit{7}}

\end{center}
\end{document}

enter image description here

enter image description here


Thanks to @Robert for adding the following quote of Knuth (at the very end of cm85.bug):

I absolutely guarantee that the TFM files will never change again. (Otherwise I would consider zeroing the depth of italic 7, which I admit is strange... we can live with it.)

It is important that the TeX base does not change (execpt from bug fixes), because it is the very basis for frameworks that are much more complex. Therefore even minor changes in the TeX base can easily lead to errors in higher-level code. Obviously this descender is not considered a bug, at least not a serious one.

To this, I add a quote from TeX FAQ:

Knuth has declared that he will do no further development of TeX; he will continue to fix any bugs that are reported to him (though bugs are rare). This decision was made soon after TeX version 3.0 was released;

3
  • 14
    Weird, indeed. Here's what Knuth has to say about it (at the very end of cm85.bug): I absolutely guarantee that the TFM files will never change again. (Otherwise I would consider zeroing the depth of italic 7, which I admit is strange... we can live with it.)
    – Robert
    Commented Dec 17, 2021 at 0:27
  • 2
    @Jasper can you incorporate the link and quote of Knuth? I think this nails it and I don't really get, why it was so important to not change the TFM with such an apparent issue.
    – TobiBS
    Commented Dec 17, 2021 at 10:13
  • Amazing! I'd not heard this before! Thank you so much! :) Commented Dec 17, 2021 at 19:50
20

This will align the baselines of the nodes.

\documentclass{scrartcl}

\usepackage{tikz}

\begin{document}
\newcommand{\tikzmark}[4][]{\begin{tikzpicture}[baseline=(#2.base)]
  \node[inner sep=1pt,outer sep=0pt,font=#4] (#2) {#3#1}; 
\end{tikzpicture}}
\newcommand{\oct}[2][]{\tikzmark[#1]{oct_#2}{'#2}{\itshape}}

\begin{tabular}{c|c|c|c|c|c|c|c|c|c}
    &\oct{0}    &\oct{1}    &\oct{2}    &\oct{3}    &\oct{4}    &\oct{5}    &\oct{6}    &\oct{7}    & \\ \hline
\end{tabular}

\end{document}

demo

1
  • 1
    Thank you @John for an explanation what I can do to fix the issue for any font. However I was really interested to see, why the 7 is jumping and hence I upvote your answer, but still accept Jaspers answer.
    – TobiBS
    Commented Dec 17, 2021 at 10:15
4

It is worth noting that the Latin Modern fonts -- a (very close!) clone of the Computer Modern fonts -- do fix the unfortunate "non-bug bug" in the Computer Modern Italic 7 glyph.

enter image description here

\documentclass{scrartcl}
\usepackage{lmodern} % <-- new
\usepackage{tikz}
    
\newcommand{\tikzmark}[4][]{\begin{tikzpicture}\node[inner sep=1pt,outer sep=0pt,font=#4] (#2) {#3#1}; \end{tikzpicture}}
\newcommand{\oct}[2][]{\tikzmark[#1]{oct_#2}{'#2}{\itshape}}

\begin{document}

\begin{tabular}{c|c|c|c|c|c|c|c|c|c}
&\oct{0}    &\oct{1}    &\oct{2}    &\oct{3}    
&\oct{4}    &\oct{5}    &\oct{6}    &\oct{7}    & \\ \hline
\end{tabular}

\end{document}

You must log in to answer this question.

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