I have a .text homework with lots of images and tables, this ones are well numerated below the figure and table but when I refer these in the text dont show the number of the table or figure instead of two questions mark symbols. I haven't got this problem with the equations, How can I solve it?
I write below the code;
\documentclass[11pt,onside]{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{bm}
\usepackage{upgreek}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{amsmath}
% mathtools for: Aboxed (put box on last equation in align envirenment)
\usepackage{microtype} %improves the spacing between words and letters
%% COLOR DEFINITIONS
\usepackage[svgnames]{xcolor} % Enabling mixing colors and color's call by 'svgnames'
\definecolor{MyColor1}{rgb}{0.2,0.4,0.6} %mix personal color
\newcommand{\textb}{\color{Black} \usefont{OT1}{lmss}{m}{n}}
\newcommand{\blue}{\color{MyColor1} \usefont{OT1}{lmss}{m}{n}}
\newcommand{\blueb}{\color{MyColor1} \usefont{OT1}{lmss}{b}{n}}
\newcommand{\red}{\color{LightCoral} \usefont{OT1}{lmss}{m}{n}}
\newcommand{\green}{\color{Turquoise} \usefont{OT1}{lmss}{m}{n}}
\DeclareMathOperator{\trace}{trace}
\DeclareMathOperator{\diag}{diag}
%% FONTS AND COLORS
% SECTIONS
\usepackage{titlesec}
\usepackage{sectsty}
%%%%%%%%%%%%%%%%%%%%%%%%
%set section/subsections HEADINGS font and color
\sectionfont{\color{MyColor1}} % sets colour of sections
\subsectionfont{\color{MyColor1}} % sets colour of sections
\subsubsectionfont{\color{MyColor1}} % sets colour of sections
%set section enumerator to arabic number (see footnotes markings alternatives)
\renewcommand\thesection{\arabic{section}.} %define sections numbering
\renewcommand\thesubsection{\thesection\arabic{subsection}} %subsec.num.
%define new section style
\newcommand{\mysection}{
\titleformat{\section} [runin] {\usefont{OT1}{lmss}{b}{n}\color{MyColor1}}
{\thesection} {3pt} {} }
% CAPTIONS
\usepackage{caption}
\usepackage{subcaption}
%%%%%%%%%%%%%%%%%%%%%%%%
\captionsetup[figure]{labelfont={color=Turquoise}}
\captionsetup[table]{labelfont={color=Turquoise}}
% !!!EQUATION (ARRAY) --> USING ALIGN INSTEAD
%using amsmath package to redefine eq. numeration (1.1, 1.2, ...)
\renewcommand{\theequation}{\thesection\arabic{equation}}
\makeatletter
\let\reftagform@=\tagform@
\def\tagform@#1{\maketag@@@{(\ignorespaces\textcolor{red}{#1}\unskip\@@italiccorr)}}
\renewcommand{\eqref}[1]{\textup{\reftagform@{\ref{#1}}}}
\makeatother
\usepackage{hyperref}
\hypersetup{colorlinks=true}
% For labeling top of page on every page but first one:
\usepackage{fancyhdr}
\renewcommand{\rmdefault}{phv} % Arial Font
\renewcommand{\sfdefault}{phv} % Arial Font
\begin{document}
\renewcommand{\tablename}{Tabla}
\renewcommand{\figurename}{Figura}
%\renewcommand\thefigure{\arabic{section}.\arabic{figure}} % Genera numeración X.Y
%\renewcommand\thetable{\arabic{section}.\arabic{table}} % Genera numeración X.Y
\numberwithin{figure}{section} %Hace que la primera figura de cada sección X sea X.1
\numberwithin{table}{section} %Hace que la primera tabla de cada sección X sea X.1
\maketitle
The code with an example of figure;
\documentclass[11pt,onside]{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{bm}
\usepackage{upgreek}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{amsmath}
% mathtools for: Aboxed (put box on last equation in align envirenment)
\usepackage{microtype} %improves the spacing between words and letters
%% COLOR DEFINITIONS
\usepackage[svgnames]{xcolor} % Enabling mixing colors and color's call by 'svgnames'
\definecolor{MyColor1}{rgb}{0.2,0.4,0.6} %mix personal color
\newcommand{\textb}{\color{Black} \usefont{OT1}{lmss}{m}{n}}
\newcommand{\blue}{\color{MyColor1} \usefont{OT1}{lmss}{m}{n}}
\newcommand{\blueb}{\color{MyColor1} \usefont{OT1}{lmss}{b}{n}}
\newcommand{\red}{\color{LightCoral} \usefont{OT1}{lmss}{m}{n}}
\newcommand{\green}{\color{Turquoise} \usefont{OT1}{lmss}{m}{n}}
\DeclareMathOperator{\trace}{trace}
\DeclareMathOperator{\diag}{diag}
%% FONTS AND COLORS
% SECTIONS
\usepackage{titlesec}
\usepackage{sectsty}
%%%%%%%%%%%%%%%%%%%%%%%%
%set section/subsections HEADINGS font and color
\sectionfont{\color{MyColor1}} % sets colour of sections
\subsectionfont{\color{MyColor1}} % sets colour of sections
\subsubsectionfont{\color{MyColor1}} % sets colour of sections
%set section enumerator to arabic number (see footnotes markings alternatives)
\renewcommand\thesection{\arabic{section}.} %define sections numbering
\renewcommand\thesubsection{\thesection\arabic{subsection}} %subsec.num.
%define new section style
\newcommand{\mysection}{
\titleformat{\section} [runin] {\usefont{OT1}{lmss}{b}{n}\color{MyColor1}}
{\thesection} {3pt} {} }
% CAPTIONS
\usepackage{caption}
\usepackage{subcaption}
%%%%%%%%%%%%%%%%%%%%%%%%
\captionsetup[figure]{labelfont={color=Turquoise}}
\captionsetup[table]{labelfont={color=Turquoise}}
% !!!EQUATION (ARRAY) --> USING ALIGN INSTEAD
%using amsmath package to redefine eq. numeration (1.1, 1.2, ...)
\renewcommand{\theequation}{\thesection\arabic{equation}}
\makeatletter
\let\reftagform@=\tagform@
\def\tagform@#1{\maketag@@@{(\ignorespaces\textcolor{red}{#1}\unskip\@@italiccorr)}}
\renewcommand{\eqref}[1]{\textup{\reftagform@{\ref{#1}}}}
\makeatother
\usepackage{hyperref}
\hypersetup{colorlinks=true}
% For labeling top of page on every page but first one:
\usepackage{fancyhdr}
\renewcommand{\rmdefault}{phv} % Arial Font
\renewcommand{\sfdefault}{phv} % Arial Font
\begin{document}
\renewcommand{\tablename}{Tabla}
\renewcommand{\figurename}{Figura}
%\renewcommand\thefigure{\arabic{section}.\arabic{figure}} % Genera numeración X.Y
%\renewcommand\thetable{\arabic{section}.\arabic{table}} % Genera numeración X.Y
\numberwithin{figure}{section} %Hace que la primera figura de cada sección X sea X.1
\numberwithin{table}{section} %Hace que la primera tabla de cada sección X sea X.1
\maketitle
\section{section 1}
Es es un ejemplo podemos ver la Figura \ref{etiqueta_archivo}.
\begin{figure}[!htbp]
\label{etiqueta_archivo}
\begin{center}
\includegraphics[scale=0.45]{nnombre_archivo}
\end{center}
\caption{dedescripcion figura.}
\end{figure}
\end{document}

??is the expected output on the first run, have you run latex enough times to resolve the references? – David Carlisle Jan 06 '19 at 18:14\end{document}or any figures provided. – whatisit Jan 06 '19 at 19:41??. Have you considered David Carlisle's comment about compiling more than once as well? – Jan 06 '19 at 20:24\labeland the place where you refer to that label with\refand you should end up with a small one-page document that shows the problem and you can add to your question. If you delete something and the problem goes, then you have found the solution yourself.... – David Carlisle Jan 06 '19 at 23:48