为什么当我尝试使用 \autoref 获取方程的引用时只得到“??”

为什么当我尝试使用 \autoref 获取方程的引用时只得到“??”

我用\autoref它来引用论文中的所有内容。我可以毫无问题地获得图像和表格的引用,但当我尝试获取方程的引用时,我得到的只是??

\noindent
Die Standardform eines Optimierungsproblems ist in \autoref{eq:generalOptimization} dargestellt.\\

\begin{align}
f(x)&   \longrightarrow  min/max  & x& =(x_1,x_2,\dots,x_n ) \nonumber  \\
wobei,          \qquad   g_i(x)& \leq 0                      & i& =(1,\dots,m) \label{eq:generalOptimization}\\
                         h_j(x)& = 0                         & j& = (1,\dotsb,p) \nonumber  
\end{align}\\

你能看到我得到了什么吗

您有什么想法可以解决这个问题吗?也许是我正在使用的软件包存在问题:

\usepackage[left=3.2cm, right=2cm, top=3.0cm, bottom=2.19cm,includefoot]{geometry}
\usepackage{blindtext}
\usepackage[]{caption} 
\captionsetup{labelfont=bf,font={sf,footnotesize},format=plain}

\usepackage{amsmath,amssymb}
\usepackage{mathtools}
\usepackage[bitstream-charter]{mathdesign}
\usepackage[T1]{fontenc}
\usepackage{multicol} 
\usepackage{fancyhdr} 
\usepackage{graphicx} 
\usepackage{cite} 
\usepackage[printonlyused]{acronym} 
\usepackage{siunitx }
\usepackage{units} 
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{listings} 
\usepackage{color} 
\usepackage{transparent}
\usepackage{subfig}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage[intoc]{nomencl}
\usepackage{setspace}
\usepackage{microtype}
\usepackage{appendix}
\usepackage{wrapfig} 
\usepackage{pdfpages}
\usepackage{pgfplots}




\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,shapes.geometric}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!10]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text badly centered, text width=3cm,  draw=black, , fill=green!10]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=0.5cm,text badly centered, draw=black, fill=blue!10]
\tikzstyle{decision} = [diamond, text badly centered, text width=2cm, draw=black, fill=green!30, inner sep=0pt]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{invisible}=[coordinate]

\usepackage{epstopdf}
\DeclareGraphicsExtensions{.eps,.jpg,.png}


\usepackage{setspace} 
 \usepackage{cleveref}

 %============================================


 \makeatletter
 \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
 \hbox{}
 \thispagestyle{empty}
 \newpage
 \if@twocolumn\hbox{}\newpage\fi\fi\fi}
 \makeatother

 %==========================================


\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\definecolor{gray}{rgb}{0.95,0.95,0.95}

\lstset{frame=tb,   
  backgroundcolor=\color{gray},  
  frame=single,   
  language=c,
  aboveskip=5mm,
  belowskip=5mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle=\scriptsize\ttfamily,
  numbers=left,
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  numberstyle=\tiny\color{black}, 
  breaklines=true,
  breakatwhitespace=true
  tabsize=3
}

%% PDF metadata
\usepackage{hyperref} 
\makeatletter
\@ifpackageloaded{hyperref}{%
\hypersetup{%
    pdftitle = {b},
    pdfsubject = {Ermittlung hochaufloesender Motor-Lastkollektive in unterschiedlichen Kundennutzungsprofilen},
    pdfkeywords = { automotive, testing, belastungskollektive,kundennuntzungsprofil},
    pdfauthor = {Juan Mauricio Toro Ramos },
    pdfcreator = \LaTeX,
    pdfproducer= {a},

}
}{}

\makeatother
\hypersetup{ 
    colorlinks=true,%
    linkcolor=black,%
    citecolor=blue,%
    unicode%
}

%===================================

\usepackage[acronym,toc,shortcuts]{glossaries}

%=======================

答案1

您也\usepackage{mathtools}需要(改进公式内的非数学排版)。\begin{align}...\end{align}\text{}

但主要问题是\usepackage{hyperref}\autoref工作。编译两次,看看效果。

编辑:这个解决方案的第一个版本是在 OP 添加他的“MWE”之前发布的,但现在很明显,包含cleveref包的错误位置是导致问题的原因(Mico 已经对此发表了评论)

cleveref是必须包含包的罕见情况之一 \usepackage{hyperref}以使交叉引用正确。

\documentclass[12pt]{article}
\usepackage[ngerman]{babel}
\usepackage{mathtools}
\usepackage{hyperref}
\usepackage{cleveref}

\begin{document}

\noindent
Die Standardform eines Optimierungsproblems ist in \autoref{eq:generalOptimization} dargestellt.

\begin{align}
f(x)&   \longrightarrow  min/max  & x& =(x_1,x_2,\dots,x_n ) \nonumber  \\
\text{wobei}          \qquad   g_i(x)& \leq 0                      & i& =(1,\dots,m) \label{eq:generalOptimization}\\
h_j(x)& = 0                         & j& = (1,\dotsb,p) \nonumber  
\end{align}

\end{document}

在此处输入图片描述

相关内容