0

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:

  1. 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.
  2. Reduce the widths to .4\textwidth. Then all three pictures fit on one page and the problem disappears.
  3. 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?

4
  • 1
    Welcome to tex.sx. Assuming that the version of babel is contemporaneous with the version of LaTeX (2020-02-02), there have been quite a few updates to babel since then, including one to babel-german (2020/07/30), so that might be the cause of the problem. Retrieving the latest babel 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 latest babel depends on something changed in the core. But you don't want to lose the existing version of babel. Oct 21, 2021 at 2:35
  • Thanks, Barbara. For the minimal example, putting the latest babel into the working directory does indeed fix the issue. But for the larger project in which the problem occurs this creates a lot of new errors (so probably the new babel does not work well with the old core). Perhaps I'll just have to install TexLive 2021. Oct 21, 2021 at 5:19
  • 1
    graphicx has nothing to do with it. You are loosing a complete float, and it works again if you change the sizes slightly. Try if it works if you use [htbp] and so allow float pages. Oct 21, 2021 at 7:34
  • Thanks, Ulrike. Without the reference to graphicx I found tex.stackexchange.com/questions/556901/… I guess I will just try to avoid pages with nothing but a float. Oct 21, 2021 at 9:00

0

You must log in to answer this question.

Browse other questions tagged .