使用标签会导致大量警告

使用标签会导致大量警告

在我的文档中,我使用了许多对引理/定理等的引用,它们都按预期工作。这包括一些自定义命令。但是,每次我引用文档中的一个标签时,我都会收到 1 到 5 个 LaTeX 警告。
此外,MWE 的编译大约需要 4 秒钟,考虑到文件很小,这比我预期的要多(这不是这个问题的重点,但我认为它可能有用)。
这 13 个警告还不算太糟,但在我的主文档中,我目前有 90 个这样的与标签相关的警告,这使得很难找到其他警告。

这是 MWE

\documentclass{article}
\usepackage{amsmath, amsthm, amssymb}
\usepackage[shortlabels]{enumitem}
\usepackage{hyperref}
\usepackage[capitalize,nameinlink]{cleveref}

\newtheorem{remark}{Remark}

% custom labels
\makeatletter
\newcommand\mylabel[2][]{\phantomsection\def\@currentlabelname{#1}\label{#2}}
\makeatother

\newcommand{\crefdetail}[2]{\hyperref[#1]{\namecref{#1}~\labelcref*{#1}~\ref*{#2}}}


\begin{document}
    
    \begin{remark} \label{label}
        Label
    \end{remark}
    
    \begin{remark} \mylabel[myLabel]{mylabel}
        myLabel
    \end{remark}
    
    \begin{remark} \label{label_detail_main}$ $
        \begin{enumerate}[(i)]
            \item \label{label_detail_sub1} Text
            \item \label{label_detail_sub2} Text
        \end{enumerate}
    \end{remark}
    
    Here I reference \cref{label},  % line 34
    \nameref{mylabel},              % line 35
    $\crefdetail{label_detail_main}{label_detail_sub1}$ and   % line 36
    $\crefdetail{label_detail_main}{label_detail_sub2}$.      % line 37

\end{document}

形成了本文件

在此处输入图片描述

以及这些警告



labels_log.tex 34 LaTeX Warning: Reference `label' on page 1 undefined on input line 34.

labels_log.tex 35 LaTeX Warning: Reference `mylabel' on page 1 undefined on input line 35.

labels_log.tex 36 LaTeX Warning: Hyper reference `label_detail_main' on page 1 undefined on input line 36.

labels_log.tex 36 LaTeX Warning: Reference `label_detail_main' on page 1 undefined on input line 36.

labels_log.tex 36 LaTeX Warning: Reference `label_detail_main' on page 1 undefined on input line 36.

labels_log.tex 36 LaTeX Warning: Reference `label_detail_sub1' on page 1 undefined on input line 36.

labels_log.tex 37 LaTeX Warning: Hyper reference `label_detail_main' on page 1 undefined on input line 37.

labels_log.tex 37 LaTeX Warning: Reference `label_detail_main' on page 1 undefined on input line 37.

labels_log.tex 37 LaTeX Warning: Reference `label_detail_main' on page 1 undefined on input line 37.

labels_log.tex 37 LaTeX Warning: Reference `label_detail_sub2' on page 1 undefined on input line 37.

labels_log.tex  LaTeX Warning: There were undefined references.

labels_log.tex  LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

labels_log.tex  Package rerunfilecheck Warning: File `labels_log.out' has changed. Rerun to get outlines right or use package `bookmark'.

我也得到了这个控制台输出,如果有帮助的话

This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.3)
entering extended mode
(H:/Studium/BA/MWEs/labels_log.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18>
(C:\Program Files\MiKTeX 2.9\tex/latex/base\article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(C:\Program Files\MiKTeX 2.9\tex/latex/base\size10.clo))
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amsmath.sty
For additional information on amsmath, use the `?' option.
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amstext.sty
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amsgen.sty))
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amsbsy.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amsopn.sty))
(C:\Program Files\MiKTeX 2.9\tex/latex/amscls\amsthm.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\amssymb.sty
(C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\amsfonts.sty))
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/enumitem\enumitem.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\hyperref.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/ltxcmds\ltxcmds.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/iftex\iftex.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/pdftexcmds\pdftexcmds.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/infwarerr\infwarerr.sty))
(C:\Program Files\MiKTeX 2.9\tex/latex/graphics\keyval.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/kvsetkeys\kvsetkeys.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/kvdefinekeys\kvdefinekeys.
sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/pdfescape\pdfescape.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/hycolor\hycolor.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/letltxmacro\letltxmacro.sty)
 (C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/auxhook\auxhook.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/kvoptions\kvoptions.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\pd1enc.def)
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\hyperref-langpatches.def)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/intcalc\intcalc.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/etexcmds\etexcmds.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\puenc.def)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/url\url.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/bitset\bitset.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/bigintcalc\bigintcalc.sty)
) (C:\Program Files\MiKTeX 2.9\tex/latex/base\atbegshi-ltx.sty))
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\hpdftex.def
(C:\Program Files\MiKTeX 2.9\tex/latex/base\atveryend-ltx.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/rerunfilecheck\rerunfilechec
k.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/uniquecounter\uniquecounte
r.sty)))
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/cleveref\cleveref.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/l3backend\l3backend-pdftex.d
ef)
No file labels_log.aux.
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\nameref.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/refcount\refcount.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/gettitlestring\gettitlestr
ing.sty)) (C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\umsa.fd)
(C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\umsb.fd)

LaTeX Warning: Reference `label' on page 1 undefined on input line 34.

LaTeX Warning: Reference `mylabel' on page 1 undefined on input line 35.

LaTeX Warning: Hyper reference `label_detail_main' on page 1 undefined on input
 line 36.

LaTeX Warning: Reference `label_detail_main' on page 1 undefined on input line 
36.

LaTeX Warning: Reference `label_detail_main' on page 1 undefined on input line 
36.

LaTeX Warning: Reference `label_detail_sub1' on page 1 undefined on input line 
36.

LaTeX Warning: Hyper reference `label_detail_main' on page 1 undefined on input
 line 37.

LaTeX Warning: Reference `label_detail_main' on page 1 undefined on input line 
37.

LaTeX Warning: Reference `label_detail_main' on page 1 undefined on input line 
37.

LaTeX Warning: Reference `label_detail_sub2' on page 1 undefined on input line 
37.

[1{C:/Users/Leo/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}]
(labels_log.aux)

LaTeX Warning: There were undefined references.

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

Package rerunfilecheck Warning: File `labels_log.out' has changed.
(rerunfilecheck)                Rerun to get outlines right
(rerunfilecheck)                or use package `bookmark'.

 )<C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmbx10.pfb><C:/Pr
ogram Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr10.pfb><C:/Program Fil
es/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmti10.pfb>
Output written on labels_log.pdf (1 page, 37672 bytes).
SyncTeX written on labels_log.synctex.gz.
Transcript written on labels_log.log.
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.3)
entering extended mode
(H:/Studium/BA/MWEs/labels_log.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18>
(C:\Program Files\MiKTeX 2.9\tex/latex/base\article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(C:\Program Files\MiKTeX 2.9\tex/latex/base\size10.clo))
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amsmath.sty
For additional information on amsmath, use the `?' option.
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amstext.sty
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amsgen.sty))
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amsbsy.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/amsmath\amsopn.sty))
(C:\Program Files\MiKTeX 2.9\tex/latex/amscls\amsthm.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\amssymb.sty
(C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\amsfonts.sty))
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/enumitem\enumitem.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\hyperref.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/ltxcmds\ltxcmds.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/iftex\iftex.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/pdftexcmds\pdftexcmds.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/infwarerr\infwarerr.sty))
(C:\Program Files\MiKTeX 2.9\tex/latex/graphics\keyval.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/kvsetkeys\kvsetkeys.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/kvdefinekeys\kvdefinekeys.
sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/pdfescape\pdfescape.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/hycolor\hycolor.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/letltxmacro\letltxmacro.sty)
 (C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/auxhook\auxhook.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/kvoptions\kvoptions.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\pd1enc.def)
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\hyperref-langpatches.def)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/intcalc\intcalc.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/etexcmds\etexcmds.sty)
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\puenc.def)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/url\url.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/bitset\bitset.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/bigintcalc\bigintcalc.sty)
) (C:\Program Files\MiKTeX 2.9\tex/latex/base\atbegshi-ltx.sty))
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\hpdftex.def
(C:\Program Files\MiKTeX 2.9\tex/latex/base\atveryend-ltx.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/rerunfilecheck\rerunfilechec
k.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/uniquecounter\uniquecounte
r.sty)))
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/cleveref\cleveref.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/l3backend\l3backend-pdftex.d
ef) (labels_log.aux)
(C:\Program Files\MiKTeX 2.9\tex/latex/hyperref\nameref.sty
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/latex/refcount\refcount.sty)
(C:\Users\Leo\AppData\Roaming\MiKTeX\2.9\tex/generic/gettitlestring\gettitlestr
ing.sty)) (labels_log.out) (labels_log.out)
(C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\umsa.fd)
(C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\umsb.fd) [1{C:/Users/Leo/AppDat
a/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] (labels_log.aux) )<C:/Program Fil
es/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmbx10.pfb><C:/Program Files/MiKTe
X 2.9/fonts/type1/public/amsfonts/cm/cmmi10.pfb><C:/Program Files/MiKTeX 2.9/fo
nts/type1/public/amsfonts/cm/cmr10.pfb><C:/Program Files/MiKTeX 2.9/fonts/type1
/public/amsfonts/cm/cmti10.pfb>
Output written on labels_log.pdf (1 page, 49761 bytes).
SyncTeX written on labels_log.synctex.gz.
Transcript written on labels_log.log.

答案1

我正在使用处理工具pdfLaTeX+MakeIndex+BibTeX。将其更改为仅pdfLaTeX解决了两个问题(不必要的警告和较长的编译时间)。

相关内容