I want to have the reference number of the figure referring to the figure number (1) and not the subsection number (1.1). What shall I do?
Here is the output:
Here is the code:
\documentclass[a4paper, 10pt]{article}
\usepackage{float}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{xcolor}
\usepackage[colorlinks]{hyperref}
\usepackage{lipsum}
\renewcommand{\familydefault}{\sfdefault}
\hypersetup{
colorlinks,
filecolor=magenta,
linkcolor=blue,
citecolor=blue,
urlcolor=cyan,
final
}
\definecolor{myblue}{RGB}{0, 32, 255}
\usepackage{caption}
\usepackage{xurl}
\usepackage{multirow}
\usepackage{multicol}
\begin{document}
\title{\vspace{-2.0cm}
blabla
}
\author{\small Name of author}
\date{\vspace{-3ex}}
\maketitle
\begin{multicols}{2}
\vspace{-1cm}
\section{section 1}
\subsection{subsection 1}%\label{Complexity_of_MR}
\vspace{-0.2cm}
(figure reference
\ref{example-image-a}).
\begin{figure}[H]
\vspace{-0.4cm}
\begin{center}
% \includegraphics[width=0.48\textwidth]{figures/MR_mechanisms_01.png}
\includegraphics[width=0.48\textwidth]{example-image-a}
\end{center}
\caption{caption}
\end{figure}\label{example-image-a}
\noindent
\end{multicols}
\end{document}

\labelinside thefigureenvironment, just after\caption. – Bernard May 24 '22 at 08:34centerto center the figure, replace\begin{center}by\centeringand remove\end{center}. Thecenterenv adds aspace above and below, as doesfigure. BTW: you generally shoulkd not use[H]placement. – daleif May 24 '22 at 08:51\begin{center}. I use the[H]placement so that the figure is positioned exactly where I want inside the text (and does not randomly get moved without[H]). Could you maybe give me then a good alternative for this? – ecjb May 24 '22 at 09:37[H]is a bad idea, it leaves a big gab if the figure does not fit at this exact place. And you do not what the figure right here, you want it here about. Lear ro use the[htbp]placement, and never refer to a figure as below/above, etc always refer to the figure number. – daleif May 24 '22 at 09:52