1

I'm using minipage to keep 2 figures side by side. My problem now is, when trying to reference to those figures, only referencing the first one works. The second one will give me a ?? in the output instead.

+EDIT: for some reason running the example code I noticed that neither reference is working. In my original document the first one is working, the second one isn't. The code is exactly the same... I'm super-confused hah.

\documentclass[11pt,a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage[onehalfspacing]{setspace}
\usepackage {caption}
\usepackage {hyperref}
\usepackage{fontspec}
\usepackage{parskip}
\usepackage[section]{placeins}
\setmainfont{Calibri}


\begin{document}

\begin{figure} [hbt!]
\centering
\begin {minipage}{0.45\textwidth}
    \centering
    \includegraphics [width=0.8\textwidth]{0a1} 
    \caption{Der Aufschluss}
    \label {fig:0a1}
\end{minipage}
\begin {minipage}{0.45\textwidth}
    \centering
    \includegraphics [width=0.9\textwidth]{1a1} 
    \caption{Gesteine}
    \label {fig:1a1}
\end{minipage}
\end{figure}

Referencing figure \ref{0a1} works but referencing figure \ref{1a1} gives me ?? in the output.

\end{document}


4
  • 1
    In your example, the labels are fig:0a1 and fig:1a1, but you try to add references using 0a1 and 1a1. If I replace \ref{0a1} with \ref{fig:0a1} and \ref{1a1} with \ref{fig:1a1}, both references appear correctly on the output.
    – Vincent
    Commented Nov 16, 2020 at 17:48
  • ouch. Beginner mistake... Thanks! Commented Nov 16, 2020 at 17:49
  • 1
    In your MWE you use labels like \label{fig:0a1} but you use \ref{0a1}, which of course does not exist. You have to \label{lab}` and \ref{lab} not \ref{somethingelse}. Commented Nov 16, 2020 at 17:51
  • Off-topic: package hyperref had to be, with rare exceptions as cleveref, loaded last in preamble.
    – Zarko
    Commented Nov 16, 2020 at 17:54

0

You must log in to answer this question.

Browse other questions tagged .