1

I have a set of pretty simple LaTeX documents that can compile on one Windows 10 machine and not on another. The same MiKTeX packages are installed on both and both have similar settings. The version of latex seems to be the difference.

One the machine where compilation fails, "latex --version" gives

MiKTeX-pdfTeX 4.1 (MiKTeX 20.11)

Whereas on the machine where compilation works, I get

MiKTeX-pdfTeX 4.0.1 (MiKTeX 20.7)

And here is the last snippet of the compilation log:

("C:\Users\username\AppData\Local\Programs\MiKTeX\tex/latex/etoolbox\etoolbox.sty"
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
 (C:/texmf\tex/latex/misc\etex.sty
Package: etex 1998/03/26 v2.0 eTeX basic definition package (PEB)
\et@xins=\count104
)
\etb@tempcnta=\count105
)
(C:/texmf\tex/latex/oberdiek\centernot.sty
Package: centernot 2010/03/29 v1.2 Centers the not symbol horizontally (HO)
)
\tx@cntz=\count106

("C:\Users\username\AppData\Local\Programs\MiKTeX\tex/generic/binhex\binhex.tex")
\tx@Isdigit=\count107
\tx@IsAlNum=\count108
\tx@tA=\toks31
\tx@tB=\toks32
\tx@su=\read2

! Undefined control sequence.
\AtEndPreamble ->\AddToHook 
                            {begindocument/before}
l.305 \AtEndPreamble
                    {%
? 
! Emergency stop.
\AtEndPreamble ->\AddToHook 
                            {begindocument/before}
l.305 \AtEndPreamble
                    {%

Based on what I can surmise, newtxmath.sty contains a \AtEndPreamble command, which is where the error gets triggered because \AddToHook is not defined. I believe \AddToHook is a newish LaTeX command included in the 2020 Fall release. Why is that undefined on the system with MiKTeX 20.11 but the document compiles just fine with the older version?

How do I go about troubleshooting where things might have gone wrong?

I've tried uninstalling and reinstalling a fresh version of MiKTeX, but that doesn't seem to help. I'm not sure how to install previous versions of MiKTeX so for now the only way I can compile this document is to use the older computer.

4
  • That's strange, because \AtEndPreamble is only defined to use \AddToHook if your version of LaTeX contains that command... Can you show the full log, please? Dec 9 '20 at 1:09
  • Here's the full log: pastebin.com/Ay59208m
    – D Yong
    Dec 9 '20 at 1:15
  • 2
    Your LaTeX format is from 2009! (LaTeX2e <2009/09/24>), but you are trying to load a 2020 version of etoolbox: you should really not do that. Either update your system or use the old version of etoolbox. This is happening because the 2009 LaTeX doesn't understand the date separated with dashes 2020-10-01, then your new etoolbox thinks it's on a new LaTeX and uses the new definitions. Dec 9 '20 at 1:25
  • 1
    Thanks for pointing that out. I discovered an old texmf root directory that had very old things in it. Time to do some spring cleaning!
    – D Yong
    Dec 9 '20 at 3:48
0

copy the patch code in the very beginning of your texfile. It fits for me!

% 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

the reference: revtex4-2.cls error with an older TeX distribution

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.