0

The \ref command for one of my figures is outputtig question marks ("??") instead of the reference, but it's working fine for the other figures.

Code:

\documentclass[10pt,a4paper]{article}

\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage[labelfont=bf]{caption}
\usepackage{tikz}
\usepackage{calc}
\usepackage{array}
\usepackage{multirow}
\usepackage{listings}
\usepackage{framed}
\usepackage{lmodern}

\lstset{
basicstyle=\ttfamily,
columns=fullflexible,
frame=single,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
}

\usepackage{float}
\usepackage{xcolor}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{array}

\newcolumntype{L}[1]{> 
{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{> 
{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{> 
{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\usepackage{makecell}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{ragged2e}
\usepackage{amssymb}
\usepackage{longtable}
\usepackage{graphicx}


\usepackage{chngcntr}
\counterwithin{figure}{section}
\counterwithin{equation}{section}

\newcommand\ddfrac[2]{\frac{\displaystyle #1}{\displaystyle #2}}


\usetikzlibrary{calc}
\usetikzlibrary{quotes, angles, arrows}

\newcommand{\degre}{\ensuremath{^\circ}}

\begin{document}

The ``proof'' from the Journal of Irreproducible Results breaks down at the very last equality: if we construct a figure following the instructions given in that text, the segment $\overline{AD}$ will always land on the left of both $\overline{AD}$ and %
$\overline{AP}$---see figure \ref{quadrilateral}---, and thus $x\neq\angle PAD-\angle PAB$, but $x=360\degre-\angle PAD-\angle PAB$. In fact, the figure shown in the problem statement is incorrect, since it corresponds to a quadrilateral whose $|\overline{AD}|\neq|\overline{BC}|$ %
(see figure \ref{bad-figure}), while the ``proof'' requires  $|\overline{AD}|=|\overline{BC}|$ in order to work.

\begin{figure}
\caption{...}
\label{quadrilateral}
\end{figure}

\begin{figure}
\label{bad-figure}
\caption{...}
\end{figure}

\end{document}

Output:

file output

Any idea why?

1
  • 4
    The label must be after \caption, not before, i.e \caption{...}\label{bad-figure}
    – user31729
    Mar 15, 2018 at 19:20

1 Answer 1

1

As @ChristianHupfer said, \label must go after the \caption of the figure you're referring to.

2
  • The @... notification does not work in a post, only in a comment ;-) Actually, \label before \caption works,but you will get something different what you not request -- depending on the code that is before your \label
    – user31729
    Mar 15, 2018 at 19:25
  • @ChristianHupfer Yep, I put a link to your profile as a mediocre solution...
    – Anakhand
    Mar 15, 2018 at 19:27

Not the answer you're looking for? Browse other questions tagged .