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?
\usepackage{etoolbox}\robustify\arlidimer. – Ulrike Fischer Jan 30 '18 at 22:42*.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:14pittetd.clsheavily redefines\contentslineto work withhyperrefwhich likely accounts for the problem. – Alan Munn Jan 31 '18 at 00:29