1

Can you please help me identify what is wrong with my coding? I've searched online for solutions but I couldn't find a working one. Before, I used article for my \documentclass to complete my thesis. Now, they required me to use revtex4-2 as the \documentclass. So, I modified some of the lines from the coding but it keeps on giving me errors probably because some of the packages don't work in the revtex4-2 class but I couldn't figure out what.

Here is my preamble for the coding:

\documentclass[%  
 aip,  
% jmp,  
% bmf,  
% sd,  
% rsi,  
cp,  % Conference Proceedings  
 amsmath,amssymb,%nobibnotes,  
% preprint,%  
 reprint,%  
%author-year,%  
%author-numerical,%  
]{revtex4-2}

\usepackage{graphicx}% Include figure files
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
%\usepackage[mathlines]{lineno}% Enable numbering of text and display math
%\linenumbers\relax % Commence numbering lines

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%% Loads a Times-like font. You can also load
%% {newtxtext,newtxtmath}, but not {times},
%% {txfonts} nor {mathtpm} as these packages
%% are obsolete and have been known to cause problems.
\usepackage{mathptmx}

\usepackage{paralist}
\usepackage{natbib}
\usepackage[figuresright]{rotating}
\usepackage{lscape}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{calc}
\usepackage{slashbox}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{setspace}
\usepackage{color}
\usepackage[hmarginratio=2:3]{geometry}
\usepackage{epstopdf}
\usepackage{afterpage}
\usepackage{changepage}
\usepackage[table]{xcolor}
\usepackage{makecell}
\usepackage{mathtools}
\usepackage{algorithmic}
\usepackage[section]{algorithm}
\usepackage{float}
\usepackage{placeins}
\usepackage{afterpage}
\usepackage{url}
\allowdisplaybreaks
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\newcommand{\dv}{\mid}
\newcommand{\ndv}{\nmid}
\citestyle{apa}
\renewcommand{\baselinestretch}{1.5}

\begin{document}

Here's the error notification:

! Extra \endgroup.
\document -> \endgroup
\document@inithook \true@sw {}\UseOneTimeHook {begindo...

Sorry if my information isn't enough because I'm still new here. I don't know what else to provide you with. Thank you so much in advance for your help.

Azmadi M
  • 11
  • 3
  • probably mixed version dates of latex/packages. Ensure that everything is up-to-date. If you use miktex update in user and admin mode in the miktex console. – Ulrike Fischer Nov 14 '21 at 11:13
  • I already updated it from the MiKTeX Console but the error is still there. – Azmadi M Nov 14 '21 at 12:00
  • Run a small document which loads only the class. It the errors show the complete log file – Ulrike Fischer Nov 14 '21 at 14:40
  • Welcome, @AzmadiM! I'd like to iterate upon @UlrikeFischer's comment: at the very top of your document, try adding the \listfiles command. When compiling the document, it will display the versions of all the used packages, along with the version of the document class. In that console output, what version is mentioned for revtex4-2.cls? Is it anything other than 4.2e? On my device, it says revtex4-2.cls 2020/10/03 4.2e (https://journals.aps.org/revtex/ for documentation). The answer at https://tex.stackexchange.com/a/565864/256551 is the reason I ask about this version. – Miriam Briskman Nov 14 '21 at 14:59
  • Hello @MiriamBriskman. Sorry for the late reply. I have looked on it like what you said. The one on my device says "\revtex4-2.cls Document Class: revtex4-2 2018/12/26/16:06:17 4.2b (https://journals.aps.org/re vtex/ for documentation)" How to update to 4.2e? I think it is the problem. – Azmadi M Nov 14 '21 at 22:40
  • @AzmadiM, this is OK! Just to confirm: when you open the MiKTeX console, and go to the Updates tab on the left-hand side, do you see revtex as one of the available updates (after you click on Check for updates? You may need to scroll a bit to find it if it is there.) If yes, confirm that the version of revtex under the Available column is 4.2e, and proceed with the installation by clicking on Update Now [You may uncheck other packages from being installed.] Let me know if this is not the case, as we can alternatively do a manual install. – Miriam Briskman Nov 15 '21 at 01:51
  • Hello @MiriamBriskman No the revtex isn't available for update since I already updated it before I posted the question here. It says "There are currently no updates available" I'm not sure whether the version I updated before is the 4.2e though. – Azmadi M Nov 15 '21 at 15:49
  • Hi @AzmadiM. Thank you! I see. You can check the current version of revtex inside the Console by clicking on the Packages tab on the left side. On that page, enter revtex into the search (filter) bar, and click on the small funnel icon to see the results for revtex. Afterward, right-click revtex and choose "Package Information". You will then see the version of the currently-installed revtex package. Is that version number 4.2e or 4.2b, as you saw earlier during compilation? – Miriam Briskman Nov 15 '21 at 16:18
  • Hey there @MiriamBriskman I've checked on the package information. The version number is 4.2e. – Azmadi M Nov 15 '21 at 21:09
  • @AzmadiM, thank you very much for your reply! It is great to hear that 4.2e is installed inside your user's account. Could you, please, also re-open the MiKTeX console, but this time by right-clicking and choosing Run as administrator``, and check the version ofrevtexthere too? As @UlrikeFischer explained,MiKTeXinstalls packages separately for each user, but some packages are installed for all the users. As such, we need to ensure that the version ofrevtexis4.2e``` in that general installation or, if not, update it. Let me know what you see. – Miriam Briskman Nov 15 '21 at 22:31
  • I created a document containing only Hello with your preamble. I got an error about not having the slashbox package. It turns out that the slashbox package has been superseded by the diagmac2 package. So I commented out the \usepackage{slashbox} line and added \usepackage{diagmac2} and I got no errors. – Máté Wierdl Nov 17 '21 at 12:48
  • @MiriamBriskman Sorry again for the late reply, I was on a flight yesterday. I already ran MikTex Console & checked on the revtex information as you told me before & the version is 4.2e as well. – Azmadi M Nov 17 '21 at 18:11
  • Thank you for the response @MátéWierdl I've edited the \usepackage{slashbox} out & replaced it with \usepackage{diagmac2} yet I still have the same error. – Azmadi M Nov 17 '21 at 18:11
  • Here's a link to a screen capture of my Console output tab in TeXworks regarding the errors. I don't know if it helps but who knows you might see something I don't.

    https://drive.google.com/file/d/1JTrhPZpZUXssA24g_49pMOTQTSb4dFPz/view

    – Azmadi M Nov 17 '21 at 18:42
  • Hi @AzmadiM; thank you very much for your reply and for letting us know. The interesting aspect in the situation is that the \listfiles command shows that 4.2b is the version, while the MiKTeX Console shows it's 4.2e. The pdfLaTeX compiler in the video you took uses libraries at C:\Users\madie\AppData\Local\Programs\MiKTeX\. However, inside the MiKTeX Console under Settings > Directories, what Path is displayed for Install, User? This question's intention is to rule out the case of multiple installs of MiKTeX. – Miriam Briskman Nov 17 '21 at 19:05
  • Hello @MiriamBriskman It's in the same path. C:\Users\madie\AppData\Local\Programs\MikTeX Yep I agree I found it weird since you pointed out in your comment about the \listfiles command. It's 4.2b in the Console output but in MikTex Console, it's 4.2e. I downloaded the template from this website. https://math.upm.edu.my/icmss2022/index.php/call-for-papers/template-for-abstract/ – Azmadi M Nov 17 '21 at 19:17
  • I also tried running the code at Overleaf. The online editor managed to compile my PDF but it's in landscape mode instead of portrait mode. If you don't mind me asking, do you have any idea on how to change the orientation? That aside, there's an error about the "Extra \endgroup" as well. Also, I would like to point out that there's a package called "revtex4" other than "revtex" in the MikTeX Console's Packages tab too & the category is listed as \Uncategorized. Is this normal or it is probably the cause of error. – Azmadi M Nov 17 '21 at 19:22
  • @AzmadiM, I see. Thank you! When you copy the preamble into a new TeX document, and make the body be as short as \begin{document} Foo \end{document}, does the compilation of that new document produce the same Extra \endgroup error? Try the method at https://tex.stackexchange.com/a/354/256551 to change orientation. I too see the revtex4 package as uncategorized on my device as you do, so most likely it is not related to the error. – Miriam Briskman Nov 17 '21 at 19:30
  • @MiriamBriskman There isn't any error but it says "Sorry, but "MikTeX Compiler Driver" did not succeed." Also, there are two warnings:

    Class revtex4-2 Warning: Repair the float package.

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

    – Azmadi M Nov 17 '21 at 19:42
  • Does the new TeX document needs to be in the same folder as before? I've copied the new TeX file into the folder with the original file & it gave the same error. @MiriamBriskman The previous comment is when the new file is outside of the original file's folder. – Azmadi M Nov 17 '21 at 19:49
  • @AzmadiM, thank you very much for your reply! The compilation video from your previous comment shows that the revtex library (revtex4-2.cls) at the location C:\Users\madie\Dropbox/PC/Downloads/FYP/TO BE PUBLISHED/ConfTemplate-20211114T010429X-001 was used during compilation. However, the revtex library that should be used must be the one at C:\Users\madie\AppData\Local\Programs\MiKTeX\tex/latex/revtex\. As such, can you (temporarily) move the FYP folder from Downloads to a different folder, and then re-compile the doc? What does the console show? – Miriam Briskman Nov 17 '21 at 21:06
  • In addition, if the C:\Users\madie\Dropbox/PC/Downloads/FYP/TO BE PUBLISHED/ConfTemplate-20211114T010429X-001 folder is where you are trying to run the document from, could you remove the revtex4-2.cls files from this folder away to a different temporary folder? If your current folder contains revtex4-2.cls, it will be used instead of the updated MiKTeX version of revtex. Perhaps, this "local" copy of revtex4-2.cls is the reason for the error, which also explains the different error messages across the different folders. – Miriam Briskman Nov 17 '21 at 21:13
  • Where is the whole latex file? I only see the preamble in the post without anything beyond \begin{document}. – Máté Wierdl Nov 18 '21 at 02:21
  • Hello @MátéWierdl I think the error is mainly caused by the preamble because I managed to run the same latex coding beyond the \begin{document} before but now it has errors since I've changed the \documentclass . Besides, I wasn't sure if it's okay to share the whole latex file here. I've already solved the error by the way because of the revtex4-2.cls is in the folder that I'm working with probably because it is outdated? – Azmadi M Nov 18 '21 at 05:18
  • 1
    Hello @MiriamBriskman you're a lifesaver! I've fixed it thank you so much! Yes, the revtex4-2.cls is the reason for the error. I've removed it from the folder I'm working with & it works wonder after that. I didn't realize the compiler uses the revtex4-2.cls in that folder. Maybe it is outdated since I downloaded it from the website. Thank you so much again for a very helpful guidance for the past few days. Sorry if I wasn't replying fast enough. – Azmadi M Nov 18 '21 at 05:21
  • @AzmadiM, this is so great to hear! Congratulations on successfully solving the issue, and best of luck with writing your thesis work! The underlying issue was extremely delicate and, therefore, difficult to find, but you did it! With your permission, I will outline the path towards the solution, including the attempts that were made and the attempt that eventually succeeded, as an answer to the question. Hopefully, it will help other TeX users who encounter a similar issue. Good luck! – Miriam Briskman Nov 18 '21 at 06:29

1 Answers1

2

First, we describe what action eliminated the error and then explain how we discovered the source of the error.


Solution

The folder where the TeX document was located contained a copy of an old version of the revtex class document, revtex4-2.cls. During compilation, this old package was loaded by pdfLaTeX, which caused the ! Extra \endgroup. error to appear.

Removing the local copy of revtex4-2.cls away from the folder eliminated the error and let the document compile smoothly after the removal.


Diagnosing the Issue

The TeX document uses revtex4-2 as the \documentclass.

The error

! Extra \endgroup.
\document -> \endgroup
\document@inithook \true@sw {}\UseOneTimeHook {begindo...

which was generated during compilation, is produced when a revtex4-2 version older than 4.2e is loaded. This error is asked upon and answered by my2cts at Extra \endgroup error with RevTeX after update.

In general, to remove the error, one should proceed to update the package version. In MiKTeX, for example, the update should be done both at the user level and at the administrator level, as the answer by Ulrike Fischer to How should one maintain and update a MiKTeX installation? thoroughly explains.

However, the solution was not as easy as updating the package.

The MiKTeX Console showed that the currently installed version was 4.2e, the most recent version of the package and that there are no pending updates for the package.

Nonetheless, including the command \listfiles at the top of the document, led to the following metadata output about the package:

\revtex4-2.cls Document Class: revtex4-2 2018/12/26/16:06:17 4.2b (journals.aps.org/revtex/ for documentation)

The loading of this older version (4.2b) of the revtex package into pdfLaTeX, given the verified installation of the newest version, indicated the presence of an older class document file elsewhere on the device.


Searching for the old-version class document file

The log file showed that the majority of the loaded packages during compilation are in

C:\Users\madie\AppData\Local\Programs\MiKTeX\tex/latex

It was confirmed via the MiKTeX Console (under Settings > Directories) that MiKTeX installs user packages at the above directory.

However, the document class revtex4-2.cls was loaded from the external-to-the-installation directory

C:\Users\madie\Dropbox/PC/Downloads/FYP/TO BE PUBLISHED/ConfTemplate-20211114T010429X-001

It turned out this is the directory where the TeX file under question is placed.

pdfLaTeX used this local, old-version copy of revtex4-2.cls instead of the MiKTeX-installed version, because a copy of a .tex, .sty, .cls, etc. file that is located in the same folder as the TeX document overshadows the 'official' file in the installation path.


Thanks

I would like to thank Azmadi, the writer of the question, for the responsiveness and the provision of the details that were crucial for detecting the issue.

The precious advice of Ulrike Fischer on confirming that the package was updated on MiKTeX, on the correct manner to execute updates, and on the great suggestion of reducing the TeX file to a minimal working example aided significantly in the error-finding process.

The recommendation of Máté Wierdl to replace the outdated slashbox package with diagmac2 will undoubtedly eliminate errors and warnings related to the former package. Thank you very much for your input.

Miriam Briskman
  • 479
  • 2
  • 11