3

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?

tetris11
  • 187
  • 7

1 Answers1

1

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