0

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

enter image description here

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?

| improve this question | | | | |
  • 3
    \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
  • 2
    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
2

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 {}.

| improve this answer | | | | |

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.