# How to refer to a figure created by tikzpicture in paper body?

I am relatively new with LaTeX. I created an image by

\begin{figure}
\begin{tikzpicture}
....
\end{figure}
\end{tikzpicture}


I just don't know how to refer it in paper body by \ref{compression}, but this command displays the subsection number instead of the figure number.

-
Welcome to TeX.SX! Could you please post a minimal working example (or at least provide more detail where you add the \label in your code)? Also, you can use backticks or indent blocks with four spaces to format them as code. –  krlmlr Mar 25 '12 at 13:26
I would suggest you read up on first time LaTeX use, for example via Wiki LaTeX which is a good resource, amongst others. –  zeroth Mar 25 '12 at 13:27
your code snippet won't compile as is- you've ended the figure before ending the tikzpicture –  cmhughes Mar 25 '12 at 16:07

without any actual code this one's pretty hard to diagnose, but first and foremost i'd change the code you did include to

\begin{figure}
\begin{tikzpicture}

\end{tikzpicture}
\caption{My Empty Figure}
\label{compression}
\end{figure}

I'd say look at Figure~\ref{compression}, but there's nothing in it.


which should allow you to refer to compression in the text as i did.

EDIT:

added the needed caption, as egreg pointed out.

-
Without a \caption command the \label won't refer to the figure. –  egreg Mar 25 '12 at 14:27
@egreg whoops! i suppose i should have put together a mwe for myself... –  aeroNotAuto Mar 25 '12 at 14:32
@egreg i just came across ArteLaTeX.pdf and introtex.pdf on your website and it made my day. i don't know any yet, but i'll be starting italian in the fall. when i can hold a relevant conversation about LaTeX in italian, i will consider my mastery of the language complete lol. –  aeroNotAuto Mar 25 '12 at 14:41
The first is not mine, but both books try to be accurate both in LaTeX and Italian. :) If you pass by the chat we can discuss about them. –  egreg Mar 25 '12 at 14:44