Is there a general formula for offsets of this kind?
Or is this a minor bug in the compiler used?
The version of pdfTeX (pdflatex
) is 1.40.24.
This book states that \parbox[c]{width}{text}
vertically aligns the box so that the baseline of the outer text and the baseline of the inner text's middle line coincide.
However, they do not.
The following minimal working example is composed to illustrate the mentioned issue.
\documentclass[class=article, 12pt,
border=1bp]
{standalone}
\usepackage[utf8]{inputenc}
\def\myrule#1{\rule[-.3\normalbaselineskip]
{#1}
{\normalbaselineskip}}
\begin{document}
\parbox[t]{1ex}{%
\myrule{1ex}\\\myrule{1ex}\\\myrule{1ex}}%
\myrule{1ex}%
\parbox[b]{1ex}{%
\myrule{1ex}\\\myrule{1ex}\\\myrule{1ex}}%
\myrule{1ex}%
\parbox[c]{1ex}{%
\hspace*{.5ex}\myrule{.5ex}\\%
\myrule{1ex}\\%
\hspace*{.5ex}\myrule{.5ex}}%
\end{document}
Here is the rendering of the MWE showing a slight offset between the two baselines. The offset is approximately .007\normalbaselineskip
.
Additionally, the generated PDF file contains the following lines:
q
1 0 0 1 1 29.892 cm
0 0 5.147 14.446 re f
Q
q
1 0 0 1 1 15.446 cm
0 0 5.147 14.446 re f
Q
q
1 0 0 1 1 1 cm
0 0 5.147 14.446 re f
Q
q
1 0 0 1 6.147 29.892 cm
0 0 5.147 14.446 re f
Q
q
1 0 0 1 11.295 58.783 cm
0 0 5.147 14.446 re f
Q
q
1 0 0 1 11.295 44.337 cm
0 0 5.147 14.446 re f
Q
q
1 0 0 1 11.295 29.892 cm
0 0 5.147 14.446 re f
Q
q
1 0 0 1 16.442 29.892 cm
0 0 5.147 14.446 re f
Q
q
1 0 0 1 24.163 44.437 cm
0 0 2.574 14.446 re f
Q
q
1 0 0 1 21.589 29.991 cm
0 0 5.147 14.446 re f
Q
q
1 0 0 1 24.163 15.545 cm
0 0 2.574 14.446 re f
Q
Therefore, the expected y-coordinate of a corner should be 29.892 pt, but it is 0.099 pt higher.
\leavevmode
before the color cmd[c]
(which is the default) always loses baseline alignment