I have a very strange behavior with the following code
\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}
When I compile this, the third picture is not included, and \ref{fig:chi}
is reported as an undefined reference. I get the following output:
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.
The problem goes away if I do any one of the following three things:
- Comment out
\usepackage[ngerman]{babel}
. The first two pictures are on page 1, and the third picture is on page 2, and there is no problem with the references. - Reduce the widths to
.4\textwidth
. Then all three pictures fit on one page and the problem disappears. - I also tried Tex Live 2021 on Overleaf, and there the original code compiles just fine.
Is there a way to get the original code to work without changing my Tex Live version?
babel
is contemporaneous with the version of LaTeX (2020-02-02), there have been quite a few updates tobabel
since then, including one tobabel-german
(2020/07/30), so that might be the cause of the problem. Retrieving the latestbabel
from CTAN and placing it in the directory from which you're running the job (so that you don't lose the "master" version) might help; on the other hand it might not, if the latestbabel
depends on something changed in the core. But you don't want to lose the existing version ofbabel
.[htbp]
and so allow float pages.