Revtex – Revtex Won’t Compile: Missing \begin{document} Error

pdftexrevtex

I am using the documentclass provided by revtex (https://ctan.org/tex-archive/macros/latex/contrib/revtex). It used to work, but I have recently started to get the following error. The document still mostly compiles fine, has a weird \begin{document} at the start. I have tried reinstalling everything, to no avail. I would appreciate any hints, I'm copying the terminal output below. I'm using the newest Ubuntu, revtex, and all packages are upgraded fully.

LaTeX file:

\documentclass{revtex4-2}
\begin{document}
\end{document}

Log file:

This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=pdflatex 2021.8.20)  20 AUG 2021 23:22
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**test.tex
(./test.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-01-09> xparse <2020-03-03>
(/home/daniel/texmf/tex/latex/revtex/revtex4-2.cls
Document Class: revtex4-2 2019/01/18/14:29:48 4.2c (https://journals.aps.org/re
vtex/ 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.2c)
: Modified by Mark Doyle
 .
ltxutil[2019/01/18/14:29:48 4.2c utilities package (portions licensed from W. E
. Baxter web at superscript.com)]
LaTeX Info: Redefining \@centercr on input line 315.
Class revtex4-2 Info: Repairing broken LaTeX eqnarray on input line 365.
\eqncolsep=\skip47
Class revtex4-2 Info: Repairing hyperref-unfriendly LaTeX definition of \mpfoot
note on input line 440.
Class revtex4-2 Info: Repairing broken LateX \@sect on input line 762.
\intertabularlinepenalty=\count177
\@tbpen=\count178
\@arstrutbox@hline=\box47
Class revtex4-2 Info: Repairing broken LaTeX \@xbitor on input line 1793.
ltxfront[2019/01/18/14:29:48 4.2c frontmatter package (AO,DPC,MD)]
\c@affil=\count179
\c@collab=\count180
\absbox=\box48
ltxgrid[2019/01/18/14:29:48 4.2c page grid package (portions licensed from W. E
. Baxter web at superscript.com)]
\c@linecount=\count181
\output@latex=\toks15
\box@size@1=\box49
\box@size@2=\box50
\@protection@box=\box51
\@topmark@saved=\toks16
\footins@saved=\box52
\footins@recovered=\box53
\column@recovered=\box54
\pagesofar=\box55
\footsofar=\box56
\pagegrid@col=\count182

Class revtex4-2 Warning: Failed to recognize \@vspace, \@vspacer, \@no@pgbk, \@
newline, and \\; no patches applied. Please get a more up-to-date class, .

\c@part=\count183
\c@section=\count184
\c@subsection=\count185
\c@subsubsection=\count186
\c@paragraph=\count187
\c@subparagraph=\count188
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\c@figure=\count189
\fbox@1=\box57
\c@table=\count190
\fbox@2=\box58
\c@video=\count191
\fbox@4=\box59
\@bibdataout=\write3
\widetext@top=\box60
\widetext@bot=\box61

Class revtex4-2 Warning: No Society specified, using default society aps.

(/home/daniel/texmf/tex/latex/revtex/aps4-2.rtx
File: aps4-2 2019/01/18/14:29:48 4.2c (https://journals.aps.org/revtex/ for doc
umentation)
Class revtex4-2 Info: RevTeX society APS selected on input line 37.
)

Class revtex4-2 Warning: No journal specified, using default pra.

Class revtex4-2 Info: APS journal PRA selected on input line 7584.

Class revtex4-2 Warning: No type size specified, using default 10.

(/home/daniel/texmf/tex/latex/revtex/aps10pt4-2.rtx
File: aps10pt4-2 2019/01/18/14:29:48 4.2c (https://journals.aps.org/revtex/ for
 documentation)
Class revtex4-2 Info: RevTeX pointsize 10pt selected on input line 36.
)
(/usr/share/texlive/texmf-dist/tex/latex/textcase/textcase.sty
Package: textcase 2019/09/14 v1.00 Text only upper/lower case changing (DPC)
)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip16
Package: url 2013/09/16  ver 3.4  Verb mode for urls, etc.
)
(/usr/share/texlive/texmf-dist/tex/latex/natbib/natbib.sty
Package: natbib 2010/09/13 8.31b (PWD, AO)
\bibhang=\skip50
\bibsep=\skip51
LaTeX Info: Redefining \cite on input line 694.
\c@NAT@ctr=\count192
)
Class revtex4-2 Info: Repairing natbib's \BibitemShut on input line 7588.

(/home/daniel/texmf/tex/latex/revtex/revsymb4-2.sty
Package: revsymb4-2 2019/01/18/14:29:48 4.2c (https://journals.aps.org/revtex/ 
for documentation)
LaTeX Info: Redefining \REV@mathfrak on input line 125.
))
! Extra \endgroup.
\document ->\endgroup 
                      \document@inithook \true@sw {}\UseOneTimeHook {begindo...
l.2 \begin{document}
                    
? 
Class revtex4-2 Info: Unrecognized LaTeX tabular. Please update this document c
lass! (Proceeding with fingers crossed.) on input line 2.
Class revtex4-2 Info: cite was not loaded (OK!) on input line 2.
Class revtex4-2 Info: mcite was not loaded (OK!) on input line 2.
Class revtex4-2 Info: multicol was not loaded (OK!) on input line 2.

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.2 \begin{document}
                    
? 
! Interruption.
\GenericError  ...                                
                                                  \endgroup 
l.2 \begin{document}
                    
? 
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2020-01-29 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count193
\l__pdf_internal_box=\box62
)
No file test.aux.
\openout1 = `test.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.
\openout3 = `testNotes.bib'.

[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./test.aux)

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right .


 ) 
Here is how much of TeX's memory you used:
 2412 strings out of 481252
 33436 string characters out of 5915888
 310120 words of memory out of 5000000
 19413 multiletter control sequences out of 15000+600000
 403430 words of font info for 27 fonts, out of 8000000 for 9000
 14 hyphenation exceptions out of 8191
 54i,4n,60p,203b,110s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on test.pdf (1 page, 13120 bytes).
PDF statistics:
 12 PDF objects out of 1000 (max. 8388607)
 7 compressed objects within 1 object stream
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

Best Answer

As @David Carlisle pointed out in comments this error is caused by having an old version of revtex.

The issue arises because the direct download provided on the APS page (https://journals.aps.org/revtex/revtex-faq#download) gives version 4.2c, and not 4.2e. This can be checked by including \listfiles in the preamble, for example

\documentclass{revtex4-2}
\listfiles
\begin{document}
\end{document}

The error can be fixed by downloading the current version from CTAN instead: https://ctan.org/tex-archive/macros/latex/contrib/revtex

Related Question