Latex:參考標籤圖中的各個圖像

Latex:參考標籤圖中的各個圖像

可能的重複:
為什麼環境的標籤必須出現在標題之後?

我目前有:

\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}

這將創建一個類似於以下內容的頁面:

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

然後我使用 smartref 套件引用它:

\paragraph{blah blah blah \cref{accumst}, blah blah blah \cref{accumdy}} 不幸的是,accumdy引用了頂部圖像(圖 1)並accumst引用了上一節的編號...

如何讓 \label{} 來查看 wrapfigure 包含兩個圖像?

答案1

要注意的是, 應該\label在 後面\caption。因此,將標籤放在標題後面以使其正確。

\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}

在此輸入影像描述

相關內容