Awhile back, I learned how to measure the y coordinate in my pdf. I've recently run into a combination of parbox, tcolorbox, and XeLaTeX that is giving me bad results.
In the following example, \showheight{uniqueLabel} prints its height in the page (after a second compilation). "Mark 2" is the anomalous result, and seems to depend on what happens after that line.
% !TEX program = XeLaTeX
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\newcounter{marks}
\makeatletter
\newcommand{\showheight}[1]{%
\stepcounter{marks}
This line (mark \arabic{marks}) is
\ifcsname myyloc#1\endcsname% 4718592 sp/in = 65536 sp/pt * 72 pt/in
\the\numexpr10*\csname myyloc#1\endcsname/4718592\relax/10
\else%
??
\fi%
inches from the bottom of the page
%\strut
\pdfsavepos%
\write@auxout{\protect\gdef\string\myyloc#1{\the\pdflastypos}}%
}
\makeatother
\begin{document}
\showheight{before} % mark 1
\begin{tcolorbox}
\showheight{inbox}\ % mark 2
\parbox[t]{\linewidth}{\lipsum[1-3]}% Mark 2 is 3.5 inches from the bottom
%\parbox{\linewidth}{\lipsum[1-3]} % Mark 2 is 6.1 inches from the bottom
%\parbox[b]{\linewidth}{\lipsum[1-3]} % Mark 2 is 8.6 inches from the bottom
%\lipsum[1-3] % Mark 2 is 8.6 inches from the bottom
%\mbox{}\[-\baselineskip] % fixes the measuring problem, causes underfull hbox
\end{tcolorbox}
\showheight{after} % mark 3
\end{document}
Shows that
(Why do I have a parbox inside of a tcolorbox? For better or worse, because I was using some of the answers to this question.)
How can I make sure that the y coordinate is correctly measured? Or should I not be having a parbox within a tcolorbox?
