2

I am trying to use mhchem inside the short caption for a number of figures and tables, and it is interfering with the thesis class I'm required to use (pittetd). It only happens when forming the list of tables or figures; if this doesn't need to be generated, there is no problem. More specifically, it only occurs when \bond{....} is present; \ce{} is not the issue.

Here is a MWE:

\let\oldyear\year
\documentclass{pittetd}
\let\setyear\year
\let\year\oldyear

\usepackage{booktabs}

\usepackage[version=4]{mhchem}
\newcommand{\arlidimert}{argon\textemdash{}lithium cation dimer}
\newcommand{\arlidimer}{\ce{Ar\bond{....}Li+}}

\begin{document}
\listoftables

\begin{table}
  \caption[Percentage of ALMO-EDA charge transfer in \arlidimer{} due to higher-order effects]{Percentage of ALMO-EDA charge transfer in \arlidimer{} due to higher-order effects}
  \label{tab:almo-eda-higher-order-pct-of-ct}
  \begin{tabular}{ccc}
    \toprule
                    & \multicolumn{2}{c}{basis set} \\
    BSSE corrected? & def2-SVP    & def2-SVPD   \\
    \midrule
    no              & 24.2        & 17.1        \\
    yes             & 25.0        & 19.4        \\
    \bottomrule
  \end{tabular}
\end{table}

\end{document}

If article is used instead, there's no issue.

The error output from latexmk -pdf mwe.tex:

(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/color.sty
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-cfg/color.cfg))
(/usr/local/texlive/2017/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./mwe_mhchem_in_short_captions.out (./mwe_mhchem_in_short_captions.lot
! Undefined control sequence.
<argument> Ar\bond 
                   {....}Li+
l.1 ...ue to higher-order effects}}{ii}{table.0.1}

When inspecting the *.lot files, the difference is clear. For the article (working) example:

\contentsline {table}{\numberline {1}{\ignorespaces Percentage of ALMO-EDA charge transfer in \ce {Ar\bond {....}Li+}{} due to higher-order effects}}{1}

but for pittetd (not working):

\contentsline {table}{\numberline {1}{\ignorespaces Percentage of ALMO-EDA charge transfer in \ce {Ar\bond {....}Li+}{} due to higher-order effects}}{ii}{table.0.1}

Since it seems to be triggered by \bond, I can't tell what the red herring is, or if something else is going on. Assume I don't understand how the class file works. What is the appropriate fix?

5
  • 1
    Try \usepackage{etoolbox}\robustify\arlidimer. – Ulrike Fischer Jan 30 '18 at 22:42
  • It works. I see that it preserves the command as it passes through the *.lot. Is it just changing when the macro expansion occurs? Why would the environment be different between the two classes? – pentavalentcarbon Jan 30 '18 at 23:14
  • Nevermind, I found tex.stackexchange.com/questions/4736/… and expect it'll probably answer those questions for me. – pentavalentcarbon Jan 30 '18 at 23:16
  • pittetd.cls heavily redefines \contentsline to work with hyperref which likely accounts for the problem. – Alan Munn Jan 31 '18 at 0:29
  • Ok, I'm having trouble getting this working in my non-MWE with a similar error. I'll probably read that question first. – pentavalentcarbon Jan 31 '18 at 1:48
1

Converting the comment into an answer to get it from the unanswered list:

Make the command robust with

\usepackage{etoolbox}
\robustify\arlidimer

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.