3
    \documentclass[german=false,thesistype=master, nolistoffigures,
     nolistoftables]{tubsthesis}

     \usepackage{booktabs} 
     \usepackage{colortbl}
     \usepackage[nottoc]{tocbibind}
     \usepackage{enumitem}
     \usepackage[english]{babel}
     \usepackage{graphicx}
     \usepackage{subfigure}
     \usepackage{chemmacros,environ}

     % in older versions there is no \IfChemCompatibilityT
     \providecommand\IfChemCompatibilityT[3]{}

     % load the `reactions' module in newer versions:
     \IfChemCompatibilityT{>=}{5.0}{
     \usechemmodule{reactions}
      }

     % redefine the environments:
     \RenewEnviron{reaction}
     {\begin{equation}\expandafter\ch\expandafter{\BODY}\end{equation}}
     \RenewEnviron{reaction*}
     {\begin{equation*}\expandafter\ch\expandafter{\BODY}\end{equation*}}
     \RenewEnviron{reactions}
     {\begin{align}\expandafter\ch\expandafter{\BODY}\end{align}}
     \RenewEnviron{reactions*}
     {\begin{align*}\expandafter\ch\expandafter{\BODY}\end{align*}}
     %\usechemmodule{reactions}
     %\usepackage{cleveref}
    \chemsetup{modules={all}}
     \usepackage{longtable}
     \usepackage{tabu}
    \usepackage{siunitx}
     %%%%%%%%%%% Mathemodus
    \usepackage{amssymb}
    \usepackage{amsmath}
    \numberwithin{equation}{section}
    \usepackage[parfill]{parskip}
    \usepackage{romannum} 
    \usepackage{ragged2e,array,longtable}
   \usepackage{hyperref}
    \usepackage[%
    nonumberlist, % keine Seitenzahlen anzeigen
    automake,%
    xindy={language=german-din},% Sortiert Einträge im Verzeichnis
    acronym, % Abkürzungsverzeichnis erstellen
    nomain, % kein Glossar
    translate=babel,%
    nogroupskip,% Vertikaler Spalt
    toc,% Verlinkung im Inhaltsverzeichnis
    section=chapter,%
    ]{glossaries}

% Code were error occurs
 
 \underline{\parbox{\linewidth}{\textbf{Overall redox reaction}}}  
 \begin{reactions}     
16 Li + S8 &<=> 8 Li2S\label{reac:Overall} 
\intertext{\underline{\parbox{\linewidth}{\textbf{Anode reaction}}}} 
Li &<=> Li+ + e-\label{reac:Li}
\end{reactions}
\underline{\parbox{\linewidth}{\textbf{Cathode reactions}}} \begin{minipage}[t]{0.4\textwidth}
    \begin{center}
    \textit{Electrochemical reactions}\\    
    \end{center}
\begin{reactions}       
S8 + 2 e- &<=> S8^{2-} \label{reac:S82}
% 
S8^{2-} + 2 e- &<=> 2 S4^{2-} \label{reac:S42} \\   
S42^{2-} + 2 e- &<=> 2 S2^{2-} \label{reac:S22} \\
S22^{2-} + 2 e- &<=> 2 S2^{2-}\label{reac:S2}                   
\end{reactions} 
\end{minipage}%
 \begin{minipage}[t]{0.6\textwidth}
    \begin{center}
    \textit{Precipitation/dissolution reactions}\\  
    \end{center}
 \begin{reactions}
   S8 \lqd &<=> S8 \sld  \label{reac:S8s} \\
   2 Li+ + S2^{2-} \lqd &<=> Li2S2 \sld \label{reac:Li2S2} \\
   2 Li+ + S2- \lqd &<=> Li2S \sld    \label{reac:Li2S} \\
   Li2S2 \sld  + 2 Li+ + 2 e- \lqd &<=> 2 Li2S  \sld \label{reac:2_Li2S}  
\end{reactions} 
\end{minipage}  \\

...

Unfortunately, the labels in the minipages give errors whilst compiling:

'! Undefined control sequence.
<argument> reac:S\chemformula 
                              _subscript:n {8}\chemformula _subscript:n {2}
l.144 ...ral working principle}{equation.2.1.3}{}}'

I hope that is enough to present my problem (this is the first question i am asking on stack exchange) When I comment out the labels in the minipages and only leave in the first two labels, everything works fine. The problem also occurs without changing the reference numbers.

1
  • 1
    Welcome to TeX.SE. In the code, you have forgotten to include \begin{document} in your document.
    – Tanvir
    May 12 at 5:15
4

Your code can be reduced to the following, much shorter example which still produces an error message upon compiling:

\documentclass{report}
\usepackage{chemmacros}
\chemsetup{modules={all}}

\begin{document}
  \begin{reactions}       
    S8 + 2 e-       &<=> S8^{2-}   \label{reac:S82}              
  \end{reactions} 
\end{document}

To fix this, surround the \label with a set of " ... ":

\documentclass{report}
\usepackage{chemmacros}
\chemsetup{modules={all}}

\begin{document}
  \begin{reactions}       
    S8 + 2 e-       &<=> S8^{2-}   "\label{reac:S82}"              
  \end{reactions} 
\end{document}

See also: Section "8. Escaped Input" of the chemformula manual.

Applying this to your example, we end up with the following MWE, which should compile without error messages:

\documentclass{report}

\usepackage{chemmacros}
\chemsetup{modules={all}}


\begin{document}
\noindent\underline{\parbox{\linewidth}{\textbf{Overall redox reaction}}}  
\begin{reactions}     
  16 Li + S8 &<=> 8 Li2S   \label{reac:Overall} 
  \intertext{\underline{\parbox{\linewidth}{\textbf{Anode reaction}}}} 
  Li         &<=> Li+ + e- \label{reac:Li}
\end{reactions}
\underline{\parbox{\linewidth}{\textbf{Cathode reactions}}}
\begin{minipage}[t]{0.4\textwidth}
  \centering
    \textit{Electrochemical reactions}
  \begin{reactions}       
    S8 + 2 e-       &<=> S8^{2-}   "\label{reac:S82}"\\
    S8^{2-} + 2 e-  &<=> 2 S4^{2-} "\label{reac:S42}" \\   
    S42^{2-} + 2 e- &<=> 2 S2^{2-} "\label{reac:S22}" \\
    S22^{2-} + 2 e- &<=> 2 S2^{2-} "\label{reac:S2}"                   
  \end{reactions} 
\end{minipage}%
\begin{minipage}[t]{0.6\textwidth}
  \centering
    \textit{Precipitation/dissolution reactions}
  \begin{reactions}
    S8 \lqd                           &<=> S8 \sld{}     "\label{reac:S8s}" \\
    2 Li+ + S2^{2-} \lqd              &<=> Li2S2 \sld{}  "\label{reac:Li2S2}" \\
    2 Li+ + S2- \lqd                  &<=> Li2S \sld{}   "\label{reac:Li2S}" \\
    Li2S2 \sld{}  + 2 Li+ + 2 e- \lqd &<=> 2 Li2S \sld{} "\label{reac:2_Li2S}"  
  \end{reactions} 
\end{minipage}  

\end{document}

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.