Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Possible Duplicate:
Why does an environment's label have to appear after the caption?

I currently have:

\begin{wrapfigure}{R}{0.3\textwidth}
    \vspace{-20pt}
    \begin{center}
        \includegraphics[width=0.3\textwidth]{images/accumstatic}
        \label{accumst}
    \end{center}
    \vspace{-20pt}
    \caption{Accum static picture}
    \vspace{10pt}
    \begin{center}
        \includegraphics[width=0.3\textwidth]{images/accumdynamic}
        \label{accumdy}
    \end{center}
    \vspace{-20pt}
    \caption{Accum dynamic picture}
\end{wrapfigure}

This creates a page that looks something like:

lorum ipsum trees freasa lorum ipsum trees freasa
lorum ipsum trees freasa lorum ##################
lorum ipsum trees freasa lorum #                #
lorum ipsum trees freasa lorum #     Fig.1      #
lorum ipsum trees freasa lorum #                #
lorum ipsum trees freasa lorum ##################
lorum ipsum trees freasa lorum #                #
lorum ipsum trees freasa lorum #     Fig.2      #
lorum ipsum trees freasa lorum #                #
lorum ipsum trees freasa lorum ##################
lorum ipsum trees freasa lorum ipsum trees freasa

I then reference it using the cleverref package:

\paragraph{blah blah blah \cref{accumst}, blah blah blah \cref{accumdy}} Unforutantely accumdy references the top image (Fig.1) and accumst references the previous section number...

How do I get \label{} to see that wrapfigure contains two images?

share|improve this question

migrated from stackoverflow.com Aug 22 '12 at 14:27

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Werner, Harish Kumar, Marco Daniel, percusse, cgnieder Aug 23 '12 at 14:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
This is a common problem in referencing captions with labels. You must place the \label after the \caption. See Why does an environment's label have to appear after the caption? –  Werner Aug 22 '12 at 14:34
    
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. –  Werner Aug 22 '12 at 14:38

1 Answer 1

up vote 1 down vote accepted

It should be noted that the \label should come after the \caption. Hence put the label after the caption to get it right.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig,lipsum,cleveref}
%------------------------------------------
\begin{document}
This is where the table goes with text wrapping around it. You may
embed tabular environment inside wraptable environment and customize as you like.
%------------------------------------------
\begin{wrapfigure}{R}{0.3\textwidth}
    \vspace{-20pt}
    \begin{center}
        \includegraphics[width=0.3\textwidth]{images/accumstatic}            
    \vspace{-20pt}
    \caption{Accum static picture}\label{accumst}
    \end{center}
    \vspace{10pt}
    \begin{center}
        \includegraphics[width=0.3\textwidth]{images/accumdynamic}            
    \vspace{-20pt}
    \caption{Accum dynamic picture}\label{accumdy}
    \end{center}
\end{wrapfigure}
%------------------------------------------
This is where the table goes with text wrapping around it. You may
embed tabular environment inside wraptable environment and customize as you like. This is where the table goes with text wrapping around it. You may
embed tabular environment inside wraptable environment and customize as you like. This is where the table goes with text wrapping around it.
%
\lipsum[2-7]

\paragraph{blah blah blah \cref{accumst}, blah blah blah \cref{accumdy}} 
%------------------------------------------
\end{document}

enter image description here

share|improve this answer
    
Thank you -- sorry it took so long for me to vote correct –  tetris11 Aug 31 '12 at 16:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.