1

I have a solution for \pageref, but for top/middle/bottom of the page; however, with IEEEtran, \maketitle interferes with determining the top-left corner of the text area as a reference position.

You will see the problem in this MWE: Without \maketitle, \location shows the vertical distance to the beginning of the text area; however, with \maketitle, it shows the vertical distance to the beginning of the text are after the \maketitle block, although I would expect \AtBeginDocument to be executed first. I can add \hspace{0}pt before \zsavepos{loc:ref} to force LaTeX into horizontal mode, and the results appear to be correct then. However, this adds an empty page to output that I cannot get rid of without impacting positions again.

\documentclass{IEEEtran}

\usepackage[savepos]{zref}
\AtBeginDocument{%
%   \hspace{0pt}%
    \zsavepos{loc:ref}}

\usepackage{calc}
\newcounter{counter}
\newlength{\diff}
\newcommand{\location}{%
    \hspace{0pt}%
    \stepcounter{counter}%
    \zsavepos{here\thecounter}%
    \setlength{\diff}{\zposy{loc:ref}sp-\zposy{here\thecounter}sp}%
    \the\diff}

\title{A long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long title}

\usepackage[columnwise,switch]{lineno}
\linenumbers
\usepackage{pgffor}
\begin{document}
%   \maketitle

    \foreach \n in {1,...,58}{\location

    }
\end{document}
| improve this question | | | | |
1

Is this a good solution? It seems to work for me:

\documentclass{IEEEtran}

\usepackage{atbegshi}
\usepackage[savepos]{zref}
\AtBeginShipoutFirst{\zsavepos{loc:ref}}

\usepackage{calc}
\newcounter{counter}
\newlength{\diff}
\newcommand{\location}{%
    \hspace{0pt}%
    \stepcounter{counter}%
    \zsavepos{here\thecounter}%
    \setlength{\diff}{\zposy{loc:ref}sp-\zposy{here\thecounter}sp}%
    \the\diff}

\title{A long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long title}

\usepackage{pgffor}
\begin{document}
   \maketitle

    \foreach \n in {1,...,58}{\location

    }
\end{document}
| improve this answer | | | | |

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.