23

Don't understand why this piece won't compile fluently. TeX file as following:

\begin{figure}
\centering
\includegraphics[width=\textwidth]{chapter2/epjb/groups_0.pdf}
\caption{\label{fig:epjbgroups} Schematic diagram indicating the presence of          coalescence
and fragmentation processes, for a population of $N=15$ objects
dynamically partitioned into clusters. The size of cluster $i$ is
$s_i=2$, while the size of cluster $j$ is $s_j=6$ etc. The
fragmentation process exhibits the richest range of possibilities,
given the combinatorial number of ways in which a cluster can in
principle be divided. There are many possible realizations of the
objects themselves, e.g.  humans, animals, macromolecules, though
for simplicity we show them as humans.}
\end{figure}

the output of pdfLaTeX is:

!Extra }, or forgotten \endgroup.
\color@endbox ->egroup
1.118 \end{figure}

?

Don't understand where the extra } come from.

MWE:

\newcommand{\papers}{umthesis}

\documentclass[letterpaper,12pt,oneside,onecolumn,final,openany,pdftex]{\papers/umdiss}

\usepackage{cite}
\usepackage{epstopdf}
\usepackage{amsmath,amssymb,nicefrac}
\usepackage{psfrag}
\usepackage{subfigure}
\usepackage{url}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{pifont}
\usepackage{boxedminipage}
\usepackage{amssymb}
\usepackage{bbm}
\usepackage{float}
\usepackage{lscape}
\usepackage{amsfonts}
\usepackage{helvet}
\usepackage{amsxtra}
\usepackage{multirow}
\usepackage{titletoc}
\usepackage{algpseudocode}
\usepackage{lastpage}
\usepackage{verbatim}
\usepackage{graphicx}


\begin{document}

\begin{figure}
\centering
\includegraphics[width=\textwidth]{groups_0.pdf}
\caption{\label{fig:epjbgroups} blablabla}
\end{figure}

\end{document} 

problem still exist. So please someone help me to check the \usepackage? Many thanks.

4
  • 9
    after the \caption the } is missing!
    – user2478
    Commented Mar 30, 2012 at 16:46
  • 12
    These are much too many packages for a minimal working example. Deleting those which are irrelevant for the error will not only make the example simpler, but is already an important step in finding the answer! Commented Mar 30, 2012 at 18:53
  • 2
    With a umdiss.cls found on the net, I get only a warning relative to psfrag (which is incompatible with pdftex)
    – egreg
    Commented Mar 30, 2012 at 21:20
  • 1
    I now merged your original question "Extra }, or forgotten \endgroup" error which was migrated with this one. This copied all comments and answer over here. Your two user accounts on StackOverflow and here actually should have been connected, allowing you to edit your old question. For some reason this didn't happened. You might have used a different email address etc. for both accounts. Commented Mar 31, 2012 at 14:12

10 Answers 10

17
!Extra }, or forgotten \endgroup.
\color@endbox ->egroup
1.118 \end{figure}

As others have said the snippet you gave works without error in the standard classes (which is why we always ask for a complete example). However the error you show used to be common:

In 1993 when LaTeX2e was introduced figures (and other box commands) had modified definitions to support colour (which requires an extra group layer for technical reasons)

So, the error you show makes me suspect that you are using a class or package that is assuming an old (positively ancient:-) LaTeX2.09 definition of the figure environment without the extra colour groups, and another part of the code you are using is assuming the colour groups are there and so you get a group mis-match.

5
  • 2
    The use of \usepackage{comment} and \excludecomment, attempting to remove figures triggered this for me.
    – jozxyqk
    Commented Jun 25, 2014 at 4:51
  • 1
    Is there a list of packages that are known to assume the ancient definition of figures environment?
    – wilx
    Commented Feb 19, 2015 at 22:50
  • 1
    @wilx no any package that is known about would have been fixed by now, this can only happen if some document comes out of cold storage and hasn't been used for 20 years and then is used with a current latex. Commented Feb 19, 2015 at 22:56
  • I have ! Extra }, or forgotten \endgroup in xxx { @x+1 } in between \begin{codeblock} and \end{codeblock}. How to correctly escape the @?
    – pmor
    Commented Mar 31, 2023 at 11:19
  • @pmor don't ask questions as comments on old answers, ask a new question. You need to provide an example. Presumably codeblock is defined in some package, and that also defines @x+1 to mean something. By default @x+1 is just text producing "@x+1" so has no "escape" Commented Mar 31, 2023 at 11:26
10

I don't know if this helps because I was trying to solve the same problem. After one hour of head banging, I figured out that if you remove \usepackage{rotating} this particular error goes away. However, an alternative is probably needed to take care of the removal of the rotating package.

[Update]: This error for me was generated as result of using XThesis.sty that had issues in the definition of \@xfloat. After removing the whole definition of \@xfloat the error is gone. HTH others encountering similar problem.

5

I had the same issue. In my case the problem was that in a previous run the .out was corrupted somehow. Deleting this file and rerunning the pdflatex command solved the issue.

1
  • 1
    Had this same issue but in Overleaf, in case anyone here is dealing with that the solution was to use the "Compile from scratch" option.
    – Kai
    Commented Apr 28, 2021 at 14:08
1

I also got this error. I was trying to make multiple subfigures appear on a landscape page using the pdflscape package like this:

\begin{figure}
\landscape

I found the proper way to do it here, here and here by importing the rotating package with \usepackage{rotating} in the preamble and instead of using \landscape doing this:

\begin{sidewaysfigure}
1

To add to the (seemingly endless) list of causes for which this error occurs, in my case it was because some @article entries in the.bib file were inserted without a journal field. Converting them to @misc fixed the issue.

1

The error mentioned by the OP happens frequently with latexdiff. See also a Google Search.

For me to successfully run latexdiff on Windows in TeXStudio with a complex document, I needed to do the following:

  1. Run it on command prompt or WSL instead of Powershell (or fix the encoding ad-hoc) https://github.com/ftilmann/latexdiff/issues/195 https://tex.stackexchange.com/a/664627/224861
  2. Follow https://tex.stackexchange.com/a/579662/224861 in editing the latexdiff executable file to replace \hspace{0pt} with \hskip0pt (or do this manually ad-hoc)
  3. Then follow a combination of How to insert submatches from regular expression in TexStudio and https://stackoverflow.com/a/67874863/13697228 to replace quotes (") with the appropriate beginning and end marks (in my case, `` and '', respectively) image Make sure Reg button is pushed Find:
    "([^}]*)"
    
    Replace:
    ``\1''
    
    Click Replace all button (red, double downward arrow)
1
  • See my edits. Including mostly because I think people looking to solve Extra }, or forgotten \endgroup in the context of latexdiff will probably come across the OP's post.
    – Sterling
    Commented Nov 10, 2022 at 3:15
0

It seems this error has different sources of occurrences. After an hour of tedious work, I found that this happens because I was using the following package.

\usepackage[utf8x]{inputenc}

The error disappeared after commenting this line; you might want to take care of this package by other methods. Hope this helps someone with the same issue.

0

I also got this error. Seems like a linebreak in a flushright environment was not necessary.

before

\begin{flushright}
  \includegraphics{pdfinclude/mark.pdf}\\
\end{flushright}

after

\begin{flushright}
  \includegraphics{pdfinclude/mark.pdf}
\end{flushright}
1
  • Sorry, but this is surely not a solution. Whether you add \\ or not the output is exactly the same.
    – egreg
    Commented Sep 22, 2020 at 9:51
0

When using the siunitx package, defining formatted column in a tabular environment such as

\documentclass[a4paper]{article}
\usepackage{booktabs,array}
\usepackage{float}
\begin{document}

    \begin{table}
        \begin{tabular}{|s|s|}
        -4.365 &5.6959
        126.010 &6.4998
        \end{tabular}
    \end{table}
\end{document}

gave this error “Extra }, or forgotten \endgroup” . This was resolved by using capital s, i.e. S for defining the columns.

\documentclass[a4paper]{article}
\usepackage{booktabs,array}
\usepackage{float}
\begin{document}

    \begin{table}
        \begin{tabular}{|S|S|}
        -4.365 &5.6959
        126.010 &6.4998
        \end{tabular}
    \end{table}
\end{document}
-1

I met this issue when I use \includegraphics. Solved by add:

\usepackage[pdftex]{graphicx}

You must log in to answer this question.

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