# Why is the 7 (Computer Modern italic) jumping out of the baseline in this code?

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:

Why is the 7 jumping out of the baseline?

• 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. Dec 17, 2021 at 15:32
• So \usetikzlibrary{tikzmark} plus \newcommand{\oct}[1]{\tikzmarknode{oct_#1}{\itshape{'#1}}} works. Dec 22, 2021 at 8:04

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}

\end{document}


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 quite important that noting the TeX base changes (execpt from bug fixes), because today TeX is the very basis for frameworks that are much more complex. Therefore even minor changes in the TeX base can very easily lead to serious problems and errors in higher-level code.

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;

• 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.) Dec 17, 2021 at 0:27
• @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. Dec 17, 2021 at 10:13
• Amazing! I'd not heard this before! Thank you so much! :) Dec 17, 2021 at 19:50

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}


• 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. Dec 17, 2021 at 10:15