# Missing \endgroup inserted when using \mint in caption?

I'm using minted for code syntax highlighting in my document and it's been working great:

In my caption, I want to refer to some variables and format them:

\begin{figure}
\inputminted{js}{figures/consistency-variables.js}
\caption{\mint{js}|ConsistencyVariables|}
\label{fig:consistency-variables}
\end{figure}


I tried \caption{\mint{js}|ConsistencyVariables|}, but got an error:

Missing \endgroup inserted.


Can I use \mint in \caption at all? Are there any workarounds?

• \mint is like \verb and can not be used in the argument to another command. – David Carlisle May 18 '18 at 6:42
• Would you get anything different from \texttt{ConsistencyVariables}? – egreg May 18 '18 at 6:56
• Have you tried \mintinline? \mint is just a shortcut command for a single-line minted environment. \mintinline is meant for inline use, and usually works where \verb won't as long as you don't need %, #, or unpaired {}. – G. Poore May 18 '18 at 15:46
• @G.Poore thank you \mintinline works! yay! – Zening Qu May 19 '18 at 4:34
• @G.Poore Would you like to add an answer? – CarLaTeX Jun 22 '18 at 12:57

What you want is \mintinline. \mint is just a shortcut command for a single-line minted environment, which isn't what you usually want in a caption. \mintinline is meant for inline use, and usually works where \verb won't as long as you don't need %, #, or unpaired {}.