![获取单个图形文件的标题编号](https://linux22.com/image/433687/%E8%8E%B7%E5%8F%96%E5%8D%95%E4%B8%AA%E5%9B%BE%E5%BD%A2%E6%96%87%E4%BB%B6%E7%9A%84%E6%A0%87%E9%A2%98%E7%BC%96%E5%8F%B7.png)
我想列出乳胶文档图表的标题编号。我的 MWE 如下:
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\includegraphics{fig_alef.jpg}
\label{fig:fig_alef}
\caption{Alef.}
\end{figure}
\begin{figure}
\centering
\includegraphics{fig_bet.jpg}
\label{fig:fig_bet}
\caption{Bet.}
\end{figure}
\begin{figure}
\begin{subfigure}[]{\textwidth}
\centering
\includegraphics[width=\textwidth]{fig_gimel.jpg}
\label{fig:fig_gimel}
\caption{Gimel.}
\end{subfigure}
\begin{subfigure}[]{\textwidth}
\centering
\includegraphics[width=\textwidth]{fig_dalet.jpg}
\label{fig:fig_dalet}
\caption{Dalet.}
\end{subfigure}
\caption{Gimel + dalet.}
\end{figure}
\appendix
\renewcommand{\thefigure}{A\arabic{figure}}
\setcounter{figure}{0}
\begin{figure}
\centering
\includegraphics{fig_he.jpg}
\label{fig:fig_he}
\caption{He.}
\end{figure}
\end{document}
期望的输出是这样的:
\label{fig:fig_alef}: Figure 1
\label{fig:fig_bet}: Figure 2
\label{fig:fig_gimel}: Figure 3 [perhaps with (a) - not so important]
\label{fig:fig_dalet}: Figure 3 [perhaps with (b) - not so important]
\label{fig:fig_he}: Figure A1
是否可以以某种方式提取图形标签和标题编号之间的对应关系?
答案1
您想要的大部分内容都由 完成\listoffigures
。您可以使用 的可选参数来控制内容\caption
。您还可以修改\l@figure
(目前仅调用\@dottedtocline
)。
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{duckuments}% remove ASAP
\captionsetup[subfigure]{list=true}
\begin{document}
\listoffigures
\newpage
\begin{figure}
\centering
\includegraphics{example-image-a}
\label{fig:fig_alef}
\caption[\figurename~\thefigure]{Alef.}
\end{figure}
\begin{figure}
\centering
\includegraphics{example-image-b}
\label{fig:fig_bet}
\caption[\figurename~\thefigure]{Bet.}
\end{figure}
\begin{figure}
\begin{subfigure}[]{\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-c}
\label{fig:fig_gimel}
\caption[\figurename~\thefigure\thesubfigure]{Gimel.}
\end{subfigure}
\begin{subfigure}[]{\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image}
\label{fig:fig_dalet}
\caption[\figurename~\thefigure\thesubfigure]{Dalet.}
\end{subfigure}
\caption[\figurename~\thefigure]{Gimel + dalet.}
\end{figure}
\appendix
\renewcommand{\thefigure}{A\arabic{figure}}
\setcounter{figure}{0}
\begin{figure}
\centering
\includegraphics{example-image-duck}
\label{fig:fig_he}
\caption[\figurename~\thefigure]{He.}
\end{figure}
\end{document}
这显示了如何从头开始创建图形列表。请注意,条目的顺序与\modcaption
s 的顺序相同。
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{duckuments}% remove ASAP
\captionsetup[subfigure]{list=true}
\makeatletter
\newcommand{\listofmodfigures}{\section*{List of Figures}\@starttoc{lom}}
\newcommand{\modcaption}[1]% #1 = content
{\addcontentsline{lom}{modfigure}{\thefigure #1}}
\newcommand{\l@modfigure}[2]{\vskip \z@ \@plus.2\p@
\noindent\parbox{\textwidth}{\leftskip=1.4em\relax
\rightskip=\@pnumwidth
\hskip-\leftskip\figurename~{#1}\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill\nobreak
\rlap{\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #2}}}%
\par}
\makeatother
\begin{document}
\listofmodfigures
\newpage
\begin{figure}
\centering
\includegraphics{example-image-a}
\label{fig:fig_alef}
\caption{Alef.}\modcaption{}
\end{figure}
\begin{figure}
\centering
\includegraphics{example-image-b}
\label{fig:fig_bet}
\caption{Bet.}\modcaption{}
\end{figure}
\begin{figure}
\begin{subfigure}[]{\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-c}
\label{fig:fig_gimel}
\caption{Gimel.}\modcaption{\thesubfigure}
\end{subfigure}
\begin{subfigure}[]{\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image}
\label{fig:fig_dalet}
\caption{Dalet.}\modcaption{\thesubfigure}
\end{subfigure}
\caption{Gimel + dalet.}\modcaption{}
\end{figure}
\appendix
\renewcommand{\thefigure}{A\arabic{figure}}
\setcounter{figure}{0}
\begin{figure}
\centering
\includegraphics{example-image-duck}
\label{fig:fig_he}
\caption{He.}\modcaption{}
\end{figure}
\end{document}