2

When I'm trying to use \ce{CH4} in the title with documentclass beamer, I get an Undefined control sequence error.

The following is an (almost) minimum (not) working example:

\documentclass{beamer}
\listfiles
\usepackage{mhchem}
\title{\ce{CH4}}
\begin{document}
\begin{frame}
\ce{CH4}
\end{frame}
\end{document}

After running pdflatex mini, this is the output written to stdout+stderr (mini.log is too long for a Stack Exchange post). Is there any workaround or otherwise that I can use to typeset chemical formulas in my title?

(My actual use case is in the title of a poster)

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
(./mini.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 78 languages loaded.
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamer.cls
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasercs.s
ty)
Document Class: beamer 2013/12/02 3.33 A class for typesetting presentations (r
cs-revision 332bfd3ce558)

(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasemodes
.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasedecod
e.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaseoptio
ns.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/graphics/keyval.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/geometry/geometry.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
 (/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/ifxetex/ifxetex.sty
)) (/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/base/size11.clo)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/pgf/basiclayer/pgfcore
.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/graphics/graphicx.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/graphics/graphics.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/graphics/trig.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/latexconfig/graphics.c
fg)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/oberdiek/infwarerr.s
ty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/oberdiek/ltxcmds.sty
))))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/pgf/systemlayer/pgfsys
.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/pgf/utilities/pgfrcs.s
ty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfuti
l-common.tex
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfuti
l-common-lists.tex))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfuti
l-latex.def
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/ms/everyshi.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfrcs
.code.tex))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfs
ys.code.tex
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfkey
s.code.tex
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfkey
sfiltered.code.tex))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgf.
cfg)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfs
ys-pdftex.def
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfs
ys-common-pdf.def)))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfs
yssoftpath.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfs
ysprotocol.code.tex))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/xcolor/xcolor.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/latexconfig/color.cfg)
)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
re.code.tex
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmath.cod
e.tex
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathcalc
.code.tex
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathutil
.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathpars
er.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunc
tions.code.tex
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunc
tions.basic.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunc
tions.trigonometric.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunc
tions.random.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunc
tions.comparison.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunc
tions.base.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunc
tions.round.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunc
tions.misc.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunc
tions.integerarithmetics.code.tex)))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfloa
t.code.tex))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
repoints.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
repathconstruct.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
repathusage.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
rescopes.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
regraphicstate.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
retransformations.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
requick.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
reobjects.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
repathprocessing.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
rearrows.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
reshade.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
reimage.code.tex
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
reexternal.code.tex))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
relayers.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
retransparency.code.tex)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfco
repatterns.code.tex)))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/pgf/utilities/xxcolor.
sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/oberdiek/atbegshi.st
y)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/hyperref/hyperref.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/oberdiek/hobsub-hype
rref.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/generic/oberdiek/hobsub-gene
ric.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/oberdiek/kvoptions.sty
) (/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/hyperref/pd1enc.def)

(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/latexconfig/hyperref.c
fg) (/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/url/url.sty)

Package hyperref Message: Stopped early.

)

Package hyperref Message: Driver (autodetected): hpdftex.

(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/hyperref/hpdftex.def
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/oberdiek/rerunfilechec
k.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaserequi
res.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasecompa
tibility.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasefont.
sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/amsfonts/amsfonts.sty)
)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/sansmathaccent/sansmat
haccent.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/filehook/filehook.sty)
))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasetrans
lator.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/translator/tran
slator.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/translator/tran
slator-language-mappings.tex)))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasemisc.
sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasetwosc
reens.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaseoverl
ay.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasetitle
.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasesecti
on.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaseframe
.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaseverba
tim.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaseframe
size.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaseframe
components.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasecolor
.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasenotes
.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasetoc.s
ty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasetempl
ates.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaseauxte
mplates.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaseboxes
.sty)))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbaselocal
structure.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/tools/enumerate.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasenavig
ation.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasetheor
ems.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/amsmath/amstext.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/amscls/amsthm.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/beamerbasetheme
s.sty))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/themes/theme/be
amerthemedefault.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/themes/font/bea
merfontthemedefault.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/themes/color/be
amercolorthemedefault.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/themes/inner/be
amerinnerthemedefault.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/beamer/themes/outer/be
amerouterthemedefault.sty)))
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/mhchem/mhchem.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/base/ifthen.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/tools/calc.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/oberdiek/twoopt.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/expl3.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3names.sty
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3bootstrap.s
ty)) (/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/etex-pkg/etex.sty
)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3basics.sty)
 (/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3expan.sty)
 (/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3tl.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3seq.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3int.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3quark.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3prg.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3clist.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3token.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3prop.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3msg.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3file.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3skip.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3keys.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3fp.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3box.sty)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3coffins.sty
) (/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3color.sty
)
(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3luatex.sty)

(/home/gerrit/software/texlive/2013/texmf-dist/tex/latex/l3kernel/l3candidates.
sty))

Package mhchem Warning: You did not specify a 'version' option for the mhchem
(mhchem)                package. If you are about to create a new document,
(mhchem)                please write \usepackage[version=3]{mhchem} in your
(mhchem)                preamble in order to use the most recent version of
(mhchem)                mhchem.

)
! Undefined control sequence.
\mhchem@ce ...ate {s}\chardef \mhchem@ce@substate 
                                                  =0\relax \mhchem@ce@result...
l.4 \begin{document}

? No pages of output.
Transcript written on mini.log.
3

\ce works in the title if you don't define the title until after \begin{document}. Also, the package author very strongly suggests you use the [version=3] option when loading the package.

\documentclass{beamer}
\usepackage[version=3]{mhchem}
\begin{document}
\title{\ce{CH4}}
\titlepage
\begin{frame}
\ce{CH4}
\end{frame}
\end{document}
  • Hmm. Although it solves the problem posted in the question, it has side-effects for the layout of the poster I'm trying to make. – gerrit Dec 1 '14 at 23:22
  • Perhaps you could ask a separate question related to the poster layout, although an MWE might be difficult. – erik Dec 1 '14 at 23:25
  • I will probably do that. Indeed, I have a working example but it's not very minimal... – gerrit Dec 1 '14 at 23:35
  • If you need some text to demonstrate the problem, the lipsum or blindtext packages are very helpful. – erik Dec 1 '14 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.