1

I make a lot of diagrams and other illustrations in TikZ, and I've discovered a need to give them reference numbers - is there a good way to do this?

3
  • 1
    Normally you put them in figure environments and number those. If this does not apply to your documents, could you perhaps explain their structure more clearly?
    – user121799
    Jul 4 '19 at 8:48
  • @marmot I tried figure, briefly, but it made the actual tikzpicture disappear, so I didn't pursue it. Maybe I should try harder.
    – j4nd3r53n
    Jul 4 '19 at 9:23
  • It does not make the picture disappear, but figures are by default floats, so they may get moved to another page. If a figure really disappears, you have either very strange settings, or the picture is too large, or both.
    – user121799
    Jul 4 '19 at 9:25
2

The float package allows to create new environments which can be numbered:

\documentclass{article}

\usepackage{tikz}
\usepackage{float}

\newfloat{Diagram}{htbp}{dia}

\begin{document}

\begin{Diagram}
\centering
\begin{tikzpicture}
\draw (0,0) circle (1);
\end{tikzpicture}
\caption{text}
\end{Diagram}


\end{document}
1
  • This seems to be just the thing - thanks.
    – j4nd3r53n
    Jul 4 '19 at 10:54

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.