ho-tex / pdftexcmds

pdftexcmds package for LaTeX
LaTeX Project Public License v1.3c
1 stars 0 forks source link

An undefined \pdfelapsedtime is defined as \relax #5

Closed oberdiek closed 4 years ago

oberdiek commented 4 years ago

The following code defines \pdf@elapsedtime and \pdf@resettimer:

  \def\pdftexcmds@temp#1{%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname
         \expandafter\ifx\csname pdf#1\endcsname\relax\else pdf\fi#1\endcsname\relax
      \pdftexcmds@nopdftex
    \else
      \expandafter\let\csname pdf@#1\expandafter\endcsname
      \csname\expandafter\ifx\csname pdf#1\endcsname\relax\else pdf\fi#1\endcsname
    \fi
  }%
  \pdftexcmds@temp{resettimer}%
  \pdftexcmds@temp{elapsedtime}%

The offending lines:

      \expandafter\let\csname pdf@#1\expandafter\endcsname
      \csname\expandafter\ifx\csname pdf#1\endcsname\relax\else pdf\fi#1\endcsname

It is the good old \csname problem, that it defines an undefined macro as \relax. Fix, as before in the code, is to perform \csname inside a group:

      \begingroup\expandafter\expandafter\expandafter\endgroup
      \expandafter\let\csname pdf@#1\expandafter\endcsname
      \csname\expandafter\ifx\csname pdf#1\endcsname\relax\else pdf\fi#1\endcsname

And with the context from the beginning:

  \def\pdftexcmds@temp#1{%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname
         \expandafter\ifx\csname pdf#1\endcsname\relax\else pdf\fi#1\endcsname\relax
      \pdftexcmds@nopdftex
    \else
      \begingroup\expandafter\expandafter\expandafter\endgroup
      \expandafter\let\csname pdf@#1\expandafter\endcsname
      \csname\expandafter\ifx\csname pdf#1\endcsname\relax\else pdf\fi#1\endcsname
    \fi
  }%
  \pdftexcmds@temp{resettimer}%
  \pdftexcmds@temp{elapsedtime}%

For completness, a test file from a user in mailing list TEX-D-L (2020-06-24, subject "tabu, \relex, \the und \pdfelapsedtime"), who discovered the bug:

\documentclass{article}

\usepackage{pdftexcmds}
\usepackage{tabu}

\begin{document}
\begin{tabu} to \textwidth {|l|X|}
  \hline
  a & b \\\hline
  c & d \\\hline
\end{tabu}
\end{document}

Workaround:

\usepackage{pdftexcmds}
\ifx\pdfelapsedtime\relax
  \let\pdfelapsedtime\UnDeFiNeD
\fi
u-fischer commented 4 years ago

@oberdiek Ah you saw it too ;-) I was just looking how to change it. (But naturally latex packages should better test also against \relax, because of this).

u-fischer commented 4 years ago

fixed in the newest version.