1

I'm trying to compile

\begin{figure}[H]
    \centering
    % Subfig 1
    \subfigure[$K=50$]{
      \includegraphics[width=0.32\textwidth]{1.png}}
    % Subfig 2
    \subfigure[$K=200$]{
      \includegraphics[width=0.32\textwidth]{2.png}}
    % Subfig 3
    \subfigure[$K=500$]{
      \includegraphics[width=0.32\textwidth]{3.png}}
    \caption{bla bla ({\color{magenta}\begin{tikzpicture}\draw [thick,dash pattern={on 7pt off 2pt on 1pt off 2pt}] (0,0) -- (0.75,0);\end{tikzpicture}}), bla bla.} \label{fig:UQ}
\end{figure}

But I have been receiving the following error:

Undefined control sequence.

< argument> {magenta}\begin {tikzpicture}\draw [thick,dash pattern={on 7p... l.37 ... the limited amount of the training data.} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), type I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.

When I remove

({\color{magenta}\begin{tikzpicture}\draw [thick,dash pattern={on 7pt off 2pt on 1pt off 2pt}] (0,0) -- (0.75,0);\end{tikzpicture}})

the error goes away. Is there any ways to keep this line there and fix the error?

1

If you don't need \listoffigures, then try with the below MWE:

\documentclass{book}
\usepackage{subfigure}
\usepackage{xcolor,tikz}
\begin{document}

\begin{figure}
    \centering
    % Subfig 1
    \subfigure[$K=50$]{
      \includegraphics[width=0.32\textwidth]{example-image-a.png}}
    % Subfig 2
    \subfigure[$K=200$]{
      \includegraphics[width=0.32\textwidth]{example-image-a.png}}
    % Subfig 3
    \subfigure[$K=500$]{
      \includegraphics[width=0.32\textwidth]{example-image-a.png}}
    \caption[]{bla bla (\protect{\color{magenta}\begin{tikzpicture}\draw [thick,dash pattern={on 7pt off 2pt on 1pt off 2pt}] (0,0) -- (0.75,0);\end{tikzpicture}}), bla bla.} \label{fig:UQ}
\end{figure}


\end{document}

Note that you didn't mention the class file name what you used, so I used standard book class file....

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.