Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation bug: Extra }, or forgotten \endgroup #33

Closed
batchenRothenberg opened this issue May 11, 2020 · 19 comments
Closed

Compilation bug: Extra }, or forgotten \endgroup #33

batchenRothenberg opened this issue May 11, 2020 · 19 comments

Comments

@batchenRothenberg
Copy link

While trying to compile the template using
latexmk -xelatex thesis
as you suggest, I get the following error:
"[22] [21] [20] [19] [18] [17] [16] [15] (thesis.aux (main/intro.aux)
(main/prelims.aux) (main/mainchap1.aux) (main/conclusion.aux)
(main/appendix1.aux)
! Extra }, or forgotten \endgroup.
l.41 \egroup"
If I simply press enter to move on, I get more errors.
Here is the full output I get:
out.txt

I am running Windows 10 with Miktex 2.9 and Latexmk version 4.69a.

Help will be much appreciated :)

@eyalroz
Copy link
Owner

eyalroz commented May 12, 2020

Hmm. My working assumption would be one of two things:

  1. You inadvertently made some change to the document yourself.
  2. Something - possibly a package - in your TeX distribution is broken.

... as the thesis template builds fine for many other people. Assuming you have verified the issue is not option (1.) - it's probably an issue with MikTeX. That doesn't mean I won't try to do anything about it - I just need to find the time.

In the mean while - can you please try it with TeXLive on your Windows 10?

@eyalroz
Copy link
Owner

eyalroz commented Oct 16, 2020

Closing due to lack of a reply to my question.

@eyalroz eyalroz closed this as completed Oct 16, 2020
@soronpo
Copy link

soronpo commented Jan 4, 2021

I can confirm this issue happened to me (Windows 7, MikTek 2.9)
@eyalroz please reopen this.
In trial and error I found out that the reversal of the page order somehow causes this. If commented out then everything compiles fine (with the hebrew part unreversed, of course).

@soronpo
Copy link

soronpo commented Jan 4, 2021

Update:
I ended up compiling it without changes, while forcing it and ignoring the errors. The PDF looks fine despite this.
latexmk -xelatex -silent -f thesis
So this may be possible for a workaround or removing \reversepageorder and \resumenormalpageorder from misc\iitthesis.cls and manually hacking on the final PDF before submission.

@eyalroz
Copy link
Owner

eyalroz commented Jan 4, 2021

So... perhaps some kind of MikTeX bug then?

@soronpo
Copy link

soronpo commented Jan 5, 2021

Maybe. I don't understand the latex macro syntax, but to me the reverse page mechanism looks hacky. Maybe it's out of spec.

@batchenRothenberg
Copy link
Author

Sorry for disappearing into thin air. Looking at the dates I now understand why: I gave birth the day after your massage was sent :)
Anyway, I ended up using the template on Overleaf, which is based on this one but is slightly different.
I had to delete some hack to the babel package that is no longer necessary and instead is now causing an error (it wouldn't compile unless I removed it)
The reversing of the pages works fine there.

I know that this isn't helping for my original question (making it work on Windows), but I found Overleaf to be a convenient solution.

@eyalroz
Copy link
Owner

eyalroz commented Jan 5, 2021

@soronpo : You're assuming that there's a spec...

My problem in wanting to work on this is that I need a Windows environment to reproduce. So I need to set up a VM, install stuff, etc. Will try to get to it. Reopening for now.

@eyalroz eyalroz reopened this Jan 5, 2021
@galiasn
Copy link

galiasn commented Feb 6, 2021

Encountered a similar problem (Extra }, or forgotten \egroup), using overleaf.
Changing to 2018 TeX Live version (or older) seems to resolve the compilation errors.

@eyalroz
Copy link
Owner

eyalroz commented Feb 6, 2021

@galiasn : Thanks for reporting this. If you feel like trying to pinpoint the issue - it seems the culprit piece of code is:

\textenglish{\texttt{\textbackslash{}textenglish\{\}}}

but of course, with the relevant document class and style files included. I would try to "whittle down" the contents of the template until only this is left, then start removing unnecessary styles. Finally I'd try to switch to the article document class and see if you get the same thing.

@bmag
Copy link

bmag commented May 24, 2021

I can confirm that with the template out-of-the-box, the "Extra } ..." bug happens with TeX Live 2019 and 2020 on Overleaf, but doesn't happen with TeX Live 2018. Also, I can confirm the same bug happens on a local Ubuntu 20.04 machine with TeX Live 2019. The necessary steps to get a working TeX Live environment to debug are simple (for anyone familiar with virtual machines):

  1. install Ubuntu 20.04
  2. in a terminal: sudo apt update && sudo apt upgrade
  3. in a terminal: sudo apt install texlive-full culmus

I managed to whittle down the template and still get a bug related to page-order-reversal, however the error message changed. Create a directory with the files main.tex and iitthesis.cls with the content below, then run latexmk -xelatex main.tex. The error I encountered was "! Missing } inserted." after \end{document} (I think) - see latexmk_output.txt. Using TeX Live 2018 is an acceptable solution for my specific case.

%% filename: main.tex
\documentclass{iitthesis}

\begin{document}

\reversepageorder
\begin{hebrew}
\texthebrew{תקציר}
\newpage
\end{hebrew}
\resumenormalpageorder

\end{document}
%% filename: iitthesis.cls

\def\filename{iitthesis}
\def\fileversion{v0.9}
\def\filedate{2017/09/18}
\NeedsTeXFormat{LaTeX2e}
\edef\iitthesis@TechnionIITThesis{%
\filedate\space\fileversion\space - Technion IIT Thesis}
\ProvidesClass{\filename}[\iitthesis@TechnionIITThesis]

%--------------------------------

\RequirePackage{etoolbox}

%--------------------------------

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}

\ProcessOptions\relax

\LoadClass[a4paper,11pt,twoside,openright]{report}

%--------------------------------

\RequirePackage{enumitem}
\RequirePackage{fontspec}
\RequirePackage{geometry} % Note: must be loaded before bidi
\RequirePackage{setspace}
\RequirePackage{atbegshi}

%--------------------------------

\RequirePackage{polyglossia}
\setmainlanguage{english} % Palestine was under British rule after all
\IfFileExists{bidi.sty}{}{\ClassError{\filename}{The bidi package is not available for loading}{}}
\AtEndPreamble{
 \setotherlanguage[numerals=arabic,calendar=gregorian]{hebrew}
 \newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
 % These next two lines fix an issue with equation numbering parentheses;
 % see: https://tex.stackexchange.com/a/141437/5640
 \def\maketag@@@#1{\hbox{\m@th\normalfont\LRE{#1}}}
 \def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip)}}
}

%--------------------------------

\newcommand*{\flipmargins}{%
  \clearpage
  \setlength{\@tempdima}{\oddsidemargin}%
  \setlength{\oddsidemargin}{\evensidemargin}%
  \setlength{\evensidemargin}{\@tempdima}%
  \if@reversemargin
    \normalmarginpar
  \else
    \reversemarginpar
  \fi
}

% see http://tex.stackexchange.com/q/21703/5640

\newif\ifRP%
\newbox\RPbox%
\setbox\RPbox\vbox{\vskip1pt}%
\AtBeginShipout{%
  \ifRP
    \AtBeginShipoutDiscard%
    \global\setbox\RPbox\vbox{\unvbox\RPbox
      \box\AtBeginShipoutBox\kern\c@page sp}%
  \fi
}%
\renewcommand{\RPtrue}{%
  \clearpage
  \ifRP\RPfalse\fi
  \global\let\ifRP\iftrue
}%
\let\reversepageorder=\RPtrue%
\renewcommand{\RPfalse}{%
  \clearpage
  \global\let\ifRP\iffalse
  \setbox\RPbox\vbox{\unvbox\RPbox
    \def\protect{\noexpand\protect\noexpand}%
    \@whilesw\ifdim0pt=\lastskip\fi
      {\c@page\lastkern\unkern\shipout\lastbox}%
  }%
}%
\let\resumenormalpageorder=\RPfalse%

%--------------------------------

\endinput

@eyalroz
Copy link
Owner

eyalroz commented May 24, 2021

I'll try this out with a recent TeXLive version (2021 is out apparently), and see.

@eyalroz
Copy link
Owner

eyalroz commented May 25, 2021

Confirmed with TL 2021. Since this is beyond my TeX skills, I'll consult Tex.SX. For now, here's a reduced testcase:

\documentclass{article}
\usepackage{atbegshi}

\makeatletter
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{french}

\newif\ifRP%
\newbox\RPbox%
\setbox\RPbox\vbox{\vskip1pt}%
\AtBeginShipout{%
  \ifRP
    \AtBeginShipoutDiscard%
    \global\setbox\RPbox\vbox{\unvbox\RPbox
      \box\AtBeginShipoutBox\kern\c@page sp}%
  \fi
}%
\renewcommand{\RPtrue}{%
  \clearpage
  \ifRP\RPfalse\fi
  \global\let\ifRP\iftrue
}%
\let\reversepageorder=\RPtrue%
\renewcommand{\RPfalse}{%
  \clearpage
  \global\let\ifRP\iffalse
  \setbox\RPbox\vbox{\unvbox\RPbox
    \def\protect{\noexpand\protect\noexpand}%
    \@whilesw\ifdim0pt=\lastskip\fi
      {\c@page\lastkern\unkern\shipout\lastbox}%
  }%
}%
\let\resumenormalpageorder=\RPfalse%
\makeatother

\begin{document}

\reversepageorder
\begin{french}
Fou
\newpage
\end{french}
\resumenormalpageorder
\end{document}

@eyalroz
Copy link
Owner

eyalroz commented May 28, 2021

By the way, @batchenRothenberg , when you get this error... what happens if you press Enter?

eyalroz pushed a commit that referenced this issue Jun 26, 2021
…and `\egroup`'s into the `.aux` file.
@eyalroz
Copy link
Owner

eyalroz commented Jun 26, 2021

Everyone: Please try out the fix branch, polyglossia-fix-2021, and report here whether this resolved the problem for you, and which TeXLive version you were using.

Also, before actually compiling with the new version, make sure you've run make clean to remove any auxiliary files from previous attempts.

@eyalroz
Copy link
Owner

eyalroz commented Jun 26, 2021

Ok, this doesn't fully resolve the issue, it seems. But we're getting closer. See this bug I just filed against polyglossia.

@ohadeytan
Copy link

ohadeytan commented Oct 4, 2021

This is still an issue on Arch Linux with TexLive 2021 (on both branches).
The workaround latexmk -xelatex -silent -f thesis of @soronpo is compiling.

@eyalroz
Copy link
Owner

eyalroz commented Oct 4, 2021

@ohadeytan : Thanks for pointing that out. One of the polyglossia people says he should have time to work on this soon.

@eyalroz
Copy link
Owner

eyalroz commented Dec 7, 2021

This issue is now resolved with the trunk version of the polyglossia package. Instructions on using the newer polyglossia version:

  1. Download the latest version of polyglossia, e.g. in this zip file.
  2. Determine your TEXMFHOME directory, e.g. by running kpsewhich -var-value TEXMFHOME, or your TeX distributions configuration tool. On a Unix-like system, this may be something like: ~/texmf/ (i.e. $HOME/texmf). Lets call this directory $TEXMFHOME
  3. Extract the contents tex/ subdirectory from within the zip file into $TEXMFHOME/tex/latex/polyglossia-dev.
  4. Clean all intermediate files for your document (make clean should do that if you're using the example document which comes with this document class).
  5. Build the document again (make if you're using the example document which comes with this document class).

That should do it. Alternatively - wait for the next TeXLive release, which should hopefully include this newer polyglossia version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants