[Tex/LaTex] tikzpicture within figure caption

tikz-pgf

Has anyone an idea how to use tikzpicture WITHIN a figure caption? What I want is, plot a blue circle withing a figure caption, like:

\begin{figure}[ht]
%...
\caption{CaptionText \begin{tikzpicture} \draw[thick, color=blue, fill=blue] plot[mark=*, mark options={scale=1.3}] (0,0); \end{tikzpicture} CaptionText.}
\end{figure}

Within regular text, this works fine with

RegularText \begin{tikzpicture} \draw[thick, color=blue, fill=blue] plot[mark=*, mark options={scale=1.3}] (0,0); \end{tikzpicture} RegularText

Best Answer

As Jubobs pointed out, this question has already been answered: Using TikZ inside a figure caption. For your situation, I got it to work by adding \protect to the tikz commands:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{figure}[h]
-- This is a figure --
\caption{Figure within caption {\protect\tikz \protect\draw[thick, color=blue, fill=blue] plot[mark=*, mark options={scale=1.3}] (0,0);} }
\end{figure}

\end{document}
Related Question