我对以下代码的行为感到非常奇怪
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htb]
\centering \includegraphics[width=.5\textwidth]{normal_dichte}
\caption{Dichten von Normalverteilungen} \label{fig:normal}
\end{figure}
\begin{figure}[htb]
\centering \includegraphics[width=.5\textwidth]{exponential_dichte}
\caption{Dichten von Exponentialverteilungen}\label{fig:exponential}
\end{figure}
\begin{figure}[htb]
\centering \includegraphics[width=.5\textwidth]{chi_3}
\caption{Dichten einer $\chi^2$-Verteilung}\label{fig:chi}
\end{figure}
Abbildungen~\ref{fig:normal},~\ref{fig:exponential} und~\ref{fig:chi}.
\end{document}
当我编译此文件时,第三张图片未包含在内,并被\ref{fig:chi}
报告为未定义的引用。我得到以下输出:
Running `LaTeX' on `problem2' with ``pdflatex -synctex=1 -file-line-error problem2.tex''
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./problem2.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty
(/usr/share/texlive/texmf-dist/tex/generic/babel/switch.def)
(/usr/share/texlive/texmf-dist/tex/generic/babel-german/ngerman.ldf
(/usr/share/texlive/texmf-dist/tex/generic/babel-german/ngermanb.ldf
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.def
(/usr/share/texlive/texmf-dist/tex/generic/babel/txtbabel.def)))))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def)))
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def)
(./problem2.aux)
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
LaTeX Warning: Reference `fig:chi' on page 1 undefined on input line 19.
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map} <./normal_dichte.png> <./
exponential_dichte.png>] [2]
Overfull \vbox (10.0pt too high) has occurred while \output is active
(./problem2.aux)
LaTeX Warning: There were undefined references.
如果我做以下三件事中的任何一件事,问题就会消失:
- 注释掉
\usepackage[ngerman]{babel}
。前两张图片在第1页,第三张图片在第2页,引用没有问题。 - 将宽度减小到
.4\textwidth
。然后所有三张图片都可以放在一页上,问题就消失了。 - 我也在 Overleaf 上尝试了 Tex Live 2021,原始代码可以很好地编译。
有没有办法让原始代码运行而无需更改我的 Tex Live 版本?