所有图片均参见图 1

所有图片均参见图 1

我有以下问题,文本中的所有图都被称为图 1,但是当我单击图 1 时,它指的是正确的图(即图 1、图 2、图 3)。

我的main.tex:

\documentclass[11pt, a4paper, english]{article}



\usepackage{ae,aecompl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}


\allowdisplaybreaks
\usepackage[low-sup]{subdepth}

\usepackage{epsfig,epsf}
\usepackage{graphicx}
\usepackage{endnotes}
\usepackage[english]{babel}

\usepackage{lscape}
\usepackage[super]{nth}
\usepackage{adjustbox}
\usepackage{rotating}
\usepackage{appendix}

\usepackage[onehalfspacing]{setspace}

\usepackage{multirow}
\usepackage{booktabs}
\usepackage{titling}
\usepackage{subfigure}
\usepackage{natbib}

\usepackage{verbatim}
\usepackage{pdflscape}
\usepackage{chngcntr}
\usepackage{array}
%
\usepackage[shadow,colorinlistoftodos,disable]{todonotes}                % use the option: "disable" to switch off the printing of the comments!
%\usepackage[shadow,colorinlistoftodos]{todonotes}       % option: disable is on => comments hidden
\newcommand{\CT}[1]{\todo[size=\tiny,color=green!40]{#1}}          % Christian
\newcommand{\LD}[1]{\todo[size=\tiny,color=blue!20]{#1}}         % Libor
\definecolor{myurlcolor}{rgb}{0,0,0.55}
\usepackage[pdftitle={Learning from Law Enforcement}, pdfauthor={Libor Dusek and Christian Traxler}, pdfstartview={FitH}, colorlinks=true, hyperfootnotes=false, linkcolor=black, citecolor=black, urlcolor=myurlcolor]{hyperref}

\usepackage[compact,noindentafter]{titlesec}
\titlespacing\section{0pt}{*2.75}{*1.2}
\titlespacing\subsection{0pt}{*2.25}{*1.0}

\topmargin-1cm \topskip0.1cm \headsep0.1cm
\setlength{\footnotesep}{8pt}
\setlength{\parskip}{2.5pt plus 1.75pt minus 1.75pt}

\setlength{\unitlength}{2cm} \setlength{\textwidth}{12.4cm} % JEEA

\setlength{\oddsidemargin}{-2pt} \setlength{\evensidemargin}{11pt} % JEEA
\setlength{\topmargin}{-10pt} \setlength{\textheight}{23.75cm}
%

%
\interfootnotelinepenalty=6000
\clubpenalty=8000
\widowpenalty=12000
\hyphenpenalty=9000
\exhyphenpenalty=10000

\renewcommand{\baselinestretch}{2} % JEEA
\usepackage{amsfonts} % JEEA
\usepackage{amssymb} % JEEA
\usepackage{amsmath} % JEEA
\usepackage{indentfirst} % JEEA



\begin{document}



% -------------------------


%%\newpage
\input{03_Predictions}

\input{30_Figures}


\end{document}

03_Predictions.tex:

\section{Theoretical Framework} \label{sec:predictions}
\enlargethispage*{0.5cm}

This should be Figure 1 but it is Figure~\ref{fig:updating-illu1}. This should be Figure 2 but it is Figure~\ref{fig:rd_ticketed}. This should be Figure 3 but it is Figure~\ref{fig:rd-main-cut1}.

30_图形.tex:




\section*{Figures}
%


\begin{figure}[ht!]

    \centering
    \includegraphics[width=0.485\textwidth]{FIG/_updating_fine_top_comp.pdf}
    \includegraphics[width=0.485\textwidth]{FIG/_updating_coarse_v2_top_wo_comp.pdf}\\
    \includegraphics[width=0.485\textwidth]{FIG/_updating_fine_bottom_comp.pdf}
    \includegraphics[width=0.485\textwidth]{FIG/_updating_coarse_v2_bottom_wo_comp.pdf}\\
    

    {\scriptsize \caption{BLABLA}}

    \label{fig:updating-illu1}
\end{figure}

\clearpage



\begin{figure}[ht!]
\let\center\empty
\let\endcenter\relax
\centering

      %


\begin{subfigure}[Enforcement Cutoff]{
      \includegraphics[width=0.65\textwidth]{FIG/1B2_RD_ticketed_a4_f4.png}}
      \end{subfigure}
      \vspace{0.25cm}
%
      \begin{subfigure}[High-fine Cutoff]{
      \includegraphics[width=0.65\textwidth]{FIG/11B2_RD_treated_high_a4_f4.png}}
      \end{subfigure}
%
{\scriptsize
\caption{BLABLA}}

\label{fig:rd_ticketed}
\end{figure}




\clearpage

% ---------------------------------------------------------------------------------




\begin{figure}[ht!]
\let\center\empty
\let\endcenter\relax
\centering

      

  \begin{adjustbox}{center}
  \parbox{1.1\textwidth}{\lineskip=0pt
    \begin{subfigure}[Speeding, enforcement cutoff]{%{.6\textwidth}
          \includegraphics[width=0.55\textwidth]{FIG/1B2_RD_speeding_a4_f4.png}}
    \end{subfigure}%
    \begin{subfigure}[Speeding, high-fine cutoff]{%{.6\textwidth}
          \includegraphics[width=0.55\textwidth]{FIG/11B2_RD_speeding_a4_f4.png}}
    \end{subfigure}
    \begin{subfigure}[Speed, enforcement cutoff]{%{.6\textwidth}
          \includegraphics[width=0.55\textwidth]{FIG/1B2_RD_relspeedm_a4_f4.png}}
    \end{subfigure}%
    \begin{subfigure}[Speed, high-fine cutoff]{%{.6\textwidth}
         \includegraphics[width=0.55\textwidth]{FIG/11B2_RD_relspeedm_a4_f4.png}}
     \end{subfigure}}
  \end{adjustbox}
%
{\scriptsize \caption{BLABLA}}
\label{fig:rd-main-cut1}%
\end{figure}

你能帮我吗?我该如何修复它?非常感谢。

答案1

您的代码存在一些问题。我创建了一个 MWE,这是一个基于您给出的代码的最小工作示例,减少了所有不需要的包调用以解决此问题。

您的代码中的主要问题是(另请参阅问题的评论):

  • 必须\lable直接关注命令\caption
  • epsfepsfig现在已经过时了。
  • 也不要做\let\center\empty\let\endcenter\relax
  • \usepackage{ae,aecompl}:这两个软件包在 1990 年就过时了
  • 使用 {\scriptsize \caption{BLABLA}} 不是一个好主意,因为这样脚本大小永远不会应用于标题(在排版标题之前会重置大小),但更糟糕的是,外部括号设置隐藏了\label应该拾取的数据。因此,您反而会点击最新的可引用内容,也许是带有数字 1 的部分。
  • 而是使用geometry手动设置边距...

使用以下 MWE

\documentclass[11pt, a4paper, english]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage[demo]{graphicx}% <==========================================

\usepackage{adjustbox}
\usepackage{subfigure}
%
\usepackage[shadow,colorinlistoftodos,disable]{todonotes}                % use the option: "disable" to switch off the printing of the comments!
%\usepackage[shadow,colorinlistoftodos]{todonotes}       % option: disable is on => comments hidden
\newcommand{\CT}[1]{\todo[size=\tiny,color=green!40]{#1}}          % Christian
\newcommand{\LD}[1]{\todo[size=\tiny,color=blue!20]{#1}}         % Libor
\definecolor{myurlcolor}{rgb}{0,0,0.55}
\usepackage[%
  pdftitle={Learning from Law Enforcement}, 
  pdfauthor={Libor Dusek and Christian Traxler}, 
  pdfstartview={FitH}, colorlinks=true, hyperfootnotes=false, 
  linkcolor=black, citecolor=black, urlcolor=myurlcolor
]{hyperref}


\begin{document}

%\input{03_Predictions}
\section{Theoretical Framework}\label{sec:predictions}
\enlargethispage*{0.5cm}

This should be Figure 1 but it is Figure~\ref{fig:updating-illu1}. 
This should be Figure 2 but it is Figure~\ref{fig:rd_ticketed}. 
This should be Figure 3 but it is Figure~\ref{fig:rd-main-cut1}.

%\input{30_Figures}
\section*{Figures}

\begin{figure}[ht!]
  \centering
  \includegraphics[width=0.485\textwidth]{FIG/_updating_fine_top_comp.pdf}
  \includegraphics[width=0.485\textwidth]{FIG/_updating_coarse_v2_top_wo_comp.pdf}\\
  \includegraphics[width=0.485\textwidth]{FIG/_updating_fine_bottom_comp.pdf}
  \includegraphics[width=0.485\textwidth]{FIG/_updating_coarse_v2_bottom_wo_comp.pdf}\\
  \caption{BLABLA1}\label{fig:updating-illu1}
\end{figure}

\clearpage

\begin{figure}[ht!]
  \centering
  \begin{subfigure}[Enforcement Cutoff]{
    \includegraphics[width=0.65\textwidth]{FIG/1B2_RD_ticketed_a4_f4.png}}
  \end{subfigure}
  \vspace{0.25cm}
  \begin{subfigure}[High-fine Cutoff]{
    \includegraphics[width=0.65\textwidth]{FIG/11B2_RD_treated_high_a4_f4.png}}
  \end{subfigure}
  \caption{BLABLA2}\label{fig:rd_ticketed}
\end{figure}

\clearpage

\begin{figure}[ht!]
  \centering
  \begin{adjustbox}{center}
  \parbox{1.1\textwidth}{\lineskip=0pt
    \begin{subfigure}[Speeding, enforcement cutoff]{%{.6\textwidth}
          \includegraphics[width=0.55\textwidth]{FIG/1B2_RD_speeding_a4_f4.png}}
    \end{subfigure}%
    \begin{subfigure}[Speeding, high-fine cutoff]{%{.6\textwidth}
          \includegraphics[width=0.55\textwidth]{FIG/11B2_RD_speeding_a4_f4.png}}
    \end{subfigure}
    \begin{subfigure}[Speed, enforcement cutoff]{%{.6\textwidth}
          \includegraphics[width=0.55\textwidth]{FIG/1B2_RD_relspeedm_a4_f4.png}}
    \end{subfigure}%
    \begin{subfigure}[Speed, high-fine cutoff]{%{.6\textwidth}
         \includegraphics[width=0.55\textwidth]{FIG/11B2_RD_relspeedm_a4_f4.png}}
     \end{subfigure}}
  \end{adjustbox}
\caption{BLABLA3}\label{fig:rd-main-cut1}%
\end{figure}

\end{document}

你得到了想要的结果:

生成的 pdf

相关内容