3

I am using the revtex4-2 class file for the first time to compile my .tex file. However, I am getting the following compilation error:

! Undefined control sequence.
<argument> \AddToHook 
                      {begindocument/before}{\document@inithook }
l.211   }

Here is a minimal working example.

\documentclass[aps,prl]{revtex4-2}
\begin{document}
This is APS RevTex 4.2 document class.
\end{document}

I have previously used revtex4-0 as well as revtex4-1 without any issue. I have recently installed revtex4.2e in my system. However, I am unable to figure out the problem I am facing with this latest RevTeX class.

Below is the log file.

This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013/Debian) (format=xelatex 2019.1.4)  19 DEC 2020 19:38
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**main
(./main.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 78 languages loaded.
(./revtex4-2.cls
Document Class: revtex4-2 2020/10/03 4.2e (https://journals.aps.org/revtex/ for
 documentation)
 Copyright (c) 2019 American Physical Society.
 mailto:[email protected]
 Licensed under the LPPL:
http://www.ctan.org/tex-archive/macros/latex/base/lppl.txt
 Arthur Ogawa <arthur_ogawa at sbcglobal dot net>
 Based on work by David Carlisle <david at dcarlisle.demon.co.uk>
 Version (4.2d,4.2e): Modified by Mark Doyle and Phelype Oleinik
 .
ltxutil[2020/10/03 4.2e utilities package (portions licensed from W. E. Baxter 
web at superscript.com)]
! Undefined control sequence.
<argument> \AddToHook 
                      {begindocument/before}{\document@inithook }
l.211   }
         
? x
 
Here is how much of TeX's memory you used:
 78 strings out of 493918
 768 string characters out of 6150564
 52172 words of memory out of 5000000
 3498 multiletter control sequences out of 15000+600000
 3640 words of font info for 14 fonts, out of 8000000 for 9000
 1144 hyphenation exceptions out of 8191
 14i,0n,10p,147b,10s stack positions out of 5000i,500n,10000p,200000b,80000s
No pages of output.
6
  • Please add a minimal working example to your question. Dec 19, 2020 at 7:46
  • 3
    Sounds as if you have an old latex. Dec 19, 2020 at 8:22
  • Welcome to TeX.SE. Which TeX distribution is installed on your system, and when did you update it most recently?
    – Mico
    Dec 19, 2020 at 8:37
  • The error is weird indeed, because usages of \AddToHook in revtex4-2 are guarded by conditionals that check if LaTeX is new enough... There is something really strange in your document. Your example compiles fine for me both in a recent and in an old system. Can you please show the .log file? Dec 19, 2020 at 11:17
  • 1
    Hm... You're using a really old system (TeXLive 2013) with a new RevTeX, and that indeed breaks. Give me a minute Dec 19, 2020 at 11:44

1 Answer 1

7

This happens because the line in RevTeX that checks your version of LaTeX:

\rvtx@ifformat@geq{2020-10-01}%
  {<code for new LaTeX>}
  {<code for old LaTeX>}

uses the date in the format yyyy-mm-dd, but this date format was only added to LaTeX in 2017, but your version is from 2013, and it only supports dates in the format yyyy/mm/dd, so the test above fails and it tries to execute the <code for new LaTeX> instead.

While RevTeX isn't updated again to use the old date format, use this patch to teach your version of LaTeX the new date format (and please update your TeX system!). The patch must be added before the \documentclass line:

% Patch to make old LaTeX understand dates in yyyy-mm-dd format
\makeatletter
\@ifundefined{@parse@version@dash}{%
\def\@parse@version#1{\@parse@version@0#1}
\def\@parse@version@#1/#2/#3#4#5\@nil{%
\@parse@version@dash#1-#2-#3#4\@nil}
\def\@parse@version@dash#1-#2-#3#4#5\@nil{%
  \if\relax#2\relax\else#1\fi#2#3#4 }
}{}
\makeatother

% document
\documentclass[aps,prl]{revtex4-2}
\begin{document}
This is APS RevTex 4.2 document class.
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .