因此,我将图片标记为“图节.图号”,这意味着每个标题的开头分别是“图 1.1”、“图 1.2”和“图 2.1”(如果分别位于第 1 节和第 2 节)。我通过在序言中放入以下内容来实现这一点:
\renewcommand{\thesubfigure}{图 \arabic{部分}.\arabic{子图}}
我使用子图的原因是为了能够在页面上并排显示图。无论如何,当我在实际文本中引用这些图时,例如“请参见图 \ref{label1} 和 \ref{label2}”,实际输出是“请参见图 1.1 和图 1.2”。
我怎样才能在标题中保留“图形”一词,但在文本中引用图形时却隐藏它?
这是一个最小的工作示例:
\documentclass{article}
\usepackage{graphicx, caption}
\usepackage{float} %Needed for the [H] after \begin{figure}. [H] stands for "Here",
i.e., the figures appear in the PDF in the same location as in the TeX code.
\usepackage[labelformat=simple]{subcaption}
\renewcommand{\thesubfigure}{Figure \arabic{section}.\arabic{subfigure}}
\begin{document}
\section{First section}
\section{Second section}
\begin{figure}[H]
\centering
\begin{subfigure}[t]{.45\textwidth}
\begin{center} \includegraphics[scale=0.2]{stars.jpeg} \end{center}
\caption{A picture of the past.}
\label{fig:stars}
\end{subfigure}
~~~
\begin{subfigure}[t]{.45\textwidth}
\begin{center} \includegraphics[scale=0.2]{monkeys.jpeg} \end{center}
\caption{Humans not too long ago.}
\label{fig:primates}
\end{subfigure}
~~~
\begin{subfigure}[t]{.42\textwidth}
\begin{center} \includegraphics[scale=0.16]{lion.jpeg} \end{center}
\caption{Not today Satan.}
\label{fig:predator}
\end{subfigure}
~~~
\begin{subfigure}[t]{.42\textwidth}
\begin{center} \includegraphics[scale=0.16]{blueberry.jpeg} \end{center}
\caption{Is this a blueberry-topped cupcake, or just a cup of blueberries?.}
\label{fig:enigma}
\end{subfigure}
~~~
\end{figure}
As we can see in figures \subref{fig:stars} and \subref{fig:enigma}, I'm not very good at making a minimal working example.
\end{document}
输出结果如下:
答案1
从评论中看来,你根本不知道什么是子图,而是类似
\documentclass{article}
\renewcommand\thefigure{\thesection.\arabic{figure}}
\usepackage{graphicx}
\begin{document}
\section{Zzzzzz}
\begin{figure}[htp]
\begin{minipage}[t]{.33\linewidth}
\centering
\includegraphics[width=.7\linewidth]{example-image-a}
\caption{Zzzzz\label{zza}}
\end{minipage}\hfill
\begin{minipage}[t]{.33\linewidth}
\centering
\includegraphics[width=.7\linewidth]{example-image}
\caption{Zzzzz zzz\label{zzb}}
\end{minipage}\hfill
\begin{minipage}[t]{.33\linewidth}
\centering
\includegraphics[width=.7\linewidth]{example-image-b}
\caption{Zzzzz zzzzzz\label{zzc}}
\end{minipage}
\end{figure}
See figures \ref{zza} to \ref{zzc}
\end{document}