我正在使用 ShareLatex,并尝试添加图形的交叉引用,但结果\ref{fig:sampe}
仅显示图像的编号,而不遵循例如“图 1”的格式。我尝试过和figure
,subfigures
结果是一样的。
目前我正在使用以下软件包:
\usepackage{caption}
\usepackage{subcaption}
\usepackage{cleveref}
并且还添加了以下几行:
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand\thesubfigure{(\alph{subfigure})}
有谁知道为什么会发生这种情况?
编辑:我添加了可编译代码。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[noabbrev,capitalize,nameinlink]{cleveref}
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand{\figurename}{Figura}
\renewcommand\thesubfigure{(\alph{subfigure})}
\usepackage[
backend=biber,
sorting=none,
urldate=edtf,
date=edtf,
seconds=true
]{biblatex}
\usepackage{url}
\usepackage{float}
\begin{document}
Some text, here it would have to appear the first reference \cref{fig:test1} , here it would have to appear the seconds reference \cref{fig:nav01_welcome}.
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.5\textwidth]{./images/navigation/nav01_welcome.png}
\caption{Pantalla de bienvenida}
\label{fig:test1}
\end{center}
\end{figure}
\begin{figure}
\centering
\begin{subfigure}[h]{0.48\textwidth}
\centering
\includegraphics[width=\textwidth]{./images/navigation/nav01_welcome.png}
\caption{Arabic numerals}\label{fig:1a}
\label{fig:nav01_welcome}
\end{subfigure}
\quad
\begin{subfigure}[h]{0.48\textwidth}
\centering
\includegraphics[width=\textwidth]{./images/navigation/nav02_welcome.png}
\caption{Arabic numerals}\label{fig:1b}
\end{subfigure}
\caption{Capital Roman numerals}\label{fig:1}
\end{figure}
\end{document}
答案1
如果你加载了cleveref
包,一切就都好了最后的-- 如果您使用\cref
而不是\ref
。
\label
另外两个建议:每个 都不要提供超过一个。并且,如果用替换,第二个环境中的\caption
三个指令可能会被消除。\centering
figure
\quad
\hfill
\documentclass[demo,spanish]{article} % remove 'demo' option in real document
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx,babel,caption,subcaption}
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
%\renewcommand{\figurename}{Figura}
\renewcommand\thesubfigure{(\alph{subfigure})}
% Load "cleveref" last:
\usepackage[noabbrev,capitalize,nameinlink]{cleveref}
\begin{document}
Here's the first cross-reference: \cref{fig:test}.
Here's the second cross-reference: \cref{fig:2a}.
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{./images/navigation/nav01_welcome.png}
\caption{Pantalla de bienvenida}
\label{fig:test}
\end{figure}
\begin{figure}[h]
\begin{subfigure}{0.48\textwidth}
\includegraphics[width=\textwidth]{./images/navigation/nav01_welcome.png}
\caption{Arabic numerals}\label{fig:2a}
\end{subfigure}%
\hfill
\begin{subfigure}{0.48\textwidth}
\includegraphics[width=\textwidth]{./images/navigation/nav02_welcome.png}
\caption{Arabic numerals}\label{fig:2b}
\end{subfigure}
\caption{Capital Roman numerals}\label{fig:2}
\end{figure}
\end{document}