IEEE Class File 'ieee.cls' Error When Using PGF and Friends (root cause is the color package)

I have to use the IEEE class file which can be found here:

http://mocha-java.uccs.edu/ieee/

There you can download the class file itself (ieee.cls) and a demo tex file called ieeecls.tex. When I load the pgfplots package then I get the following error

! Too many }'s. \color@endbox ->\color@endgroup \egroup l.811 \end{figure}

I saw that there are other posts regarding this problem, the best help is

Why do I get an error "Too many }'s" when using package rotating

in my opinion. It is anweserd by Stefan Kottwitz. The solution doesn't help in my case. The solution from Stefan is:

There are classes and style files, which define the macro \@xfloat in a way which can cause exactly this error. In this case, consider removing/redefining this macro, or using a different class

\makeatletter
\let\latex@xfloat=\@xfloat
\def\@xfloat #1[#2]{%
\latex@xfloat #1[#2]%
\def\baselinestretch{1}
\@normalsize\normalsize
\normalsize
}
\makeatother


I cannot add a minimal working example here - but you can download the two files needed as decribed above.

I already filed a bug report to IEEE but I don't think they will reply in time.

• Are you sure you don't want to use the ieeetran class included with most distributions instead? – Mike Renfro Jan 18 '15 at 20:57
• @MikeRenfro: No I am not. The paper we want to apply for leads the the class fiel I mentioned in the question. But I can ask if I can also use the class you propose. But I still think the problem is also relevant for others. Thanks for your feedback! – Dr. Manuel Kuehner Jan 18 '15 at 21:04
• If the pgf problem doesn't occur in ieeetran, then it's a bug in a less-known and less-used class. Also, you might be able to use the standalone class to make PDF graphics for inclusion into the main document. – Mike Renfro Jan 18 '15 at 21:06
• @MikeRenfro: I had the same idea. But I want to make sure I use the same font and column width and so on. My plan was to produce the diagram and then use the external function of pgf and just use the standalone pdf afterwards for the submission. – Dr. Manuel Kuehner Jan 18 '15 at 21:10
• Is column width an issue for a standalone graphic? And can't you just ensure you set up the fonts in the preamble so they match? [I actually had a graphic today which not only refused to be externalised, it refused to be \input without messing up. In the end, I just produced it separately.] – cfr Jan 18 '15 at 21:41

You used to see that error quite a bit when the color package was introduced back in 1994, but you would normally expect that any class file that has been used in the last 20 years would have been updated by now.

The ieee class re-instates the LaTeX2.09 float handler so removes support for the ! float option, for color (which causes the error message) and any fixes added since LaTex2e came out.

If you really must use this class, you can re-instate lateX2e's float handling (here I've used the version from fixltx2e),

\documentclass{ieee}
\usepackage{color}

\makeatletter
\def\@xfloat #1[#2]{%
\@nodocument
\def \@captype {#1}%
\def \@fps {#2}%
\@onelevel@sanitize \@fps
\def \reserved@b {!}%
\ifx \reserved@b \@fps
\else
\ifx \@fps \@empty
\fi
\fi
\ifhmode
\@bsphack
\@floatpenalty -\@Mii
\else
\@floatpenalty-\@Miii
\fi
\ifinner
\@parmoderr\@floatpenalty\z@
\else
\@next\@currbox\@freelist
{%
\@tempcnta \sixt@@n
\expandafter \@tfor \expandafter \reserved@a
\expandafter :\expandafter =\@fps
\do
{%
\if \reserved@a h%
\ifodd \@tempcnta
\else
\fi
\fi
\if \reserved@a t%
\@setfpsbit \tw@
\fi
\if \reserved@a b%
\@setfpsbit 4%
\fi
\if \reserved@a p%
\@setfpsbit 8%
\fi
\if \reserved@a !%
\ifnum \@tempcnta>15
\fi
\fi
}%
\@tempcntb \csname ftype@\@captype \endcsname
\multiply \@tempcntb \@xxxii
\global \count\@currbox \@tempcnta
}%
\@fltovf
\fi
\global \setbox\@currbox
\color@vbox
\normalcolor
\vbox \bgroup
\hsize\columnwidth
\@parboxrestore
\@floatboxreset
}

\makeatother
\begin{document}

\begin{figure}
\fbox{x}
\caption{zzz}
\end{figure}

\end{document}

• Thanks a lot! I forwarded the answer to the ieee class file maintainer. It's amazing how much the TeX specialist know here. – Dr. Manuel Kuehner Jan 19 '15 at 13:15
• @ManuelKuehner yes well I did write the color package that broke this, so I might be expected to know about it even if it was a long while ago:-) – David Carlisle Jan 19 '15 at 13:21