1

I'm using a convenience macro (\inputfigure[optional caption]{name}) to add plots created in tikz to my documents. My captions have been using adjectives (red or dashed line) to describe the parts of the plots but I think it would be nicer if I could use the markers instead using tikz within the caption. However, when trying I get errors that only occur when the graphic is passed as an argument to the caption (when testing the graphic in the main text it works as expected).

Depending on how I use tikz I get different errors. With the inline method:

\newcommand{\marker}[1]{\tikz \filldraw[#1] (0,0) circle (1.3pt);}

When \marker{red} is added to the caption (which is sent to \caption in the float environment) tex gives the following error:

! Undefined control sequence. \tikz@deactivatthings ->\def ;

                         {\tikz@nonactivesemicolon }\def :{\tikz@nonact...

l.19 ^^I]{decisionPlot}

And when using the environment method:

\newcommand{\marker}[1]{%
  \begin{tikzpicture}
    \filldraw[#1] (0,0) circle (1.3pt);
  \end{tikzpicture}}

I get:

! Argument of @caption has an extra }.

< inserted text>

          \par

l.22 ^^I]{decisionPlot}

I've run across a `}' that doesn't seem to match anything.

I can't find an extra '}' where I am and simply moving the \marker{red} outside of the caption resolves the error. I've also tried wrapping \marker in curly brackets but still get errors.

(Sorry, I'm struggling to get these block quotes right.)

sn8wman
  • 11
  • 2
    Welcome to TeX-SE! You can put the tikzpicture in a \savebox, then it will be safe to be put in a caption. –  May 07 '19 at 22:02
  • See e.g. https://tex.stackexchange.com/q/487960/121799. –  May 07 '19 at 22:34
  • Welcome to TeX.SX! It looks like this is already solved by the linked posts. For the next time you post, it's geneally better to post a full minimal working example rather than giving code fragments. A MWE should compile and be as small as possible to demonstrate your problem. It's much easier to help you if we have a (close to) working code to start from that shows all of the relevant packages etc that are being used. –  May 08 '19 at 03:08

0 Answers0