1

On a map I used different symbols to indicate different structures. I used this answer to draw on the screenshot of a map website. I defined three types of symbols:

\tikzstyle{ARA} = [blue,regular polygon,regular polygon sides=3, draw, shape border rotate=180,inner sep=0pt,minimum size=10pt,fill=blue]
\tikzstyle{wfluss} = [->,blue,thick]
\tikzstyle{probe} = [red,diamond,draw,inner sep=0pt,minimum size=10pt,fill=red]

I want to have the legend (i.e. the part explaining the symbols) to be in the caption, i.e. that the red and blue symbols are explained in the caption. enter image description here

5

If you put these tikz pictures in \saveboxes, they are safe to use in captions.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\tikzset{ARA/.style={blue,regular polygon,regular polygon sides=3, draw, shape border rotate=180,inner sep=0pt,minimum size=10pt,fill=blue},
probe/.style={red,diamond,draw,inner sep=0pt,minimum size=10pt,fill=red}}
\newsavebox{\nodeARA}
\newsavebox{\nodeprobe}
\sbox\nodeARA{\tikz{\node[ARA]{};}}
\sbox\nodeprobe{\tikz{\node[probe]{};}}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node{\includegraphics{example-image-duck}};
\end{tikzpicture}
\caption{\usebox{\nodeARA} represents \dots while \usebox{\nodeprobe} stands for \dots.
}
\end{figure}
\end{document}

enter image description here

  • 1
    BTW \tikzstyle is deprecated. – user121799 Apr 27 at 19:44
  • Thank you! I will update the code and include this new code. – Max R Apr 27 at 20:03
  • 1
    It also works with \listoffigures, although you lose the spaces after the saveboxes. \usebox gets expanded as bunch of commands ending with \relax. You can fix it using {\usebox\nodeARA} for example. – John Kormylo Apr 27 at 21:53

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.