我有一个 .text 作业,其中包含大量图像和表格,这些图像和表格在图形和表格下方有清晰的编号,但是当我在文本中引用这些图像和表格时,不会显示表格或图形的编号,而是显示两个问号符号。我在方程式中没有遇到这个问题,我该如何解决它?
我在下面写代码;
\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
带有图形示例的代码;
\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}
答案1
您需要将\label
命令放在后面(或里面)\caption
(我还必须添加一个\title
才能编译您的代码)
与问题无关,但\begin{center}...\end{center}
最好使用它\centering
来避免在图形环境内避免额外的垂直空间。
\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
\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
\numberwithin{equation}{section} %Hace que la primera tabla de cada
\title{text}
\begin{document}
\maketitle
\section{section 1}
\subsection{title}
Equation \ref{foo}
Es es un ejemplo podemos ver la Figura \ref{etiqueta_archivo}.
\begin{figure}[!htbp]
%\begin{center}
\centering
\includegraphics[scale=0.45]{example-image-duck}
%\end{center}
\caption{dedescripcion figura.}\label{etiqueta_archivo}
\end{figure}
\begin{equation}
a^{2} + b^{2} = c^{2}
\label{foo}
\end{equation}
\end{document}