I am using the command \newcommand\emcpt[1]{{\bfseries #1}}
to emphasize the headings of my figures. I also created a command to facilitate using percentages \newcommand\percent[1]{\qty{#1}{\percent}}
using the siunitx
package. While both commands alone work well (and \percent
in \emcpt
in textmode too), using \percent
inside of \emcpt
inside of \caption
results in the errors ! Argument of \percent has an extra }
and ! Paragraph ended before \percent was complete.
The formatting however is as expected. How can I get rid of the errors?
\documentclass{article}
\usepackage{mwe}
\usepackage[detect-all]{siunitx}
\newcommand\emcpt[1]{{\bfseries #1}}
\newcommand\percent[1]{\qty{#1}{\percent}}
\begin{document}
\begin{figure}
\centering
\includegraphics{example-image}
\caption{\emcpt{Test: \percent{20} }}
\end{figure}
\end{document}