修改命令以获取替代图表列表

修改命令以获取替代图表列表

我想要一个经过修改的\listoffigures命令(名为\mlistoffigures),它从一个额外的命令(名为)中获取为图形打印的文本。您能帮我定义这两个命令吗?如果也适用于图形(如) \extracommand,那将很有用。\extracommandnon-floatcaptionof

我的MWE如下:

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{duckuments}

\captionsetup[subfigure]{list=true}

\begin{document}

\listoffigures
\mlistoffigures %command to be defined

%
%Desired output of \mlistoffigures (using \extracommand{}):
% 1. Fig. 1
% 2. Fig. 2
%    a Fig. 2a
%    b Fig. 2b

\begin{figure}
\centering
\includegraphics{example-image-a}
\label{fig:alef}
\caption[Alef figure.]{Alef.}
\extracommand{Fig. 1} %command to be defined
\end{figure}

\begin{figure}
    \begin{subfigure}[]{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{example-image-b}
    \label{fig:bet}
    \caption[Bet figure.]{Bet.}
    \extracommand{Fig. 2a}
    \end{subfigure}
    
    \begin{subfigure}[]{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{example-image-c}
    \label{fig:gimel}
    \caption[Gimel figure.]{Dalet.}
    \extracommand{Fig. 2b}
    \end{subfigure}

    \caption[Bet + gimel figure.]{Bet + gimel.}
    \extracommand{Fig. 2}
\end{figure}

\end{document}

答案1

编辑

我认为这个答案符合 OP 的要求,正如他在我之前的交流评论中所说的那样。

% mlofprob.tex  SE 597456   EDITED VERSION WORKS !!!!!!!!!!!!!!!!!!!!!!!!

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{duckuments}

\usepackage{comment}

\captionsetup[subfigure]{list=true}

\usepackage{tocloft}
\newcommand{\listmfiguresname}{M List of Figures}
\newlistof{extracmd}{mlf}{\listmfiguresname}

\newcommand{\extracommand}[2]{%
  \addtocontents{mlf}{#1: Figure #2\par}
}

\begin{document}

\listoffigures
\listofextracmd

\begin{figure}
\centering
\includegraphics{example-image-a}
%\label{fig:alef}
\caption[Alef figure.]{Alef.}
\label{fig:alef}
\extracommand{example-image-a}{\ref{fig:alef}}
\end{figure}

\begin{figure}
    \begin{subfigure}[]{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{example-image-b}
 %   \label{fig:bet}
    \caption[Bet figure.]{Bet.}
    \label{fig:bet}
    \extracommand{example-image-b}{\ref{fig:bet}}
    \end{subfigure}
    
    \begin{subfigure}[]{\textwidth}
    \centering
    \includegraphics[width=\textwidth]{example-image-c}
%    \label{fig:gimel}
    \caption[Gimel figure.]{Dalet.}
    \label{fig:gimel}
    \extracommand{example-image-c}{\ref{fig:gimel}}
    \end{subfigure}

    \caption[Bet + gimel figure.]{Bet + gimel.}
\end{figure}

\end{document}

在此处输入图片描述

** ORIGINAL POSTING**

Not an answer but it shows what I tried. After your above comment I did not understand the basics of what you are after. I tried for a new `listof...` but after some failures I gave up (although I'm sure that it is possible) ---time constraints came into this. 

I thought that perhaps what you needed was just to list the figure numbers. Below I have done that by using `\ref{<fig-label>}`. I had to modify your original code as `\label` has to come after `\caption`.

 

        % mlofprob.tex  SE 597456   DIDN'T WORK!!!!!!!!!!!!!!!!!!!!!!!!
    
    \documentclass{article}
    \usepackage{graphicx}
    \usepackage{caption}
    \usepackage{subcaption}
    \usepackage{duckuments}
    
    \usepackage{comment}
    
    \captionsetup[subfigure]{list=true}
    
    \begin{comment}
    \usepackage{tocloft}
    \newcommand{\listmfiguresname}{M List of Figures}
    \newlistof{extracmd}{mlf}{\listmfiguresname}
    
    \end{comment}
    
    \providecommand{\extracommand}[1]{%
      \addcontentsline{mlf}{}{#1}\par
    }
    \renewcommand{\extracommand}[1]{}
    
    
    \begin{document}
    
    \listoffigures
    %\mlistoffigures %command to be defined
    %\listofextracmd
    %
    %Desired output of \mlistoffigures (using \extracommand{}):
    % 1. Fig. 1
    % 2. Fig. 2
    %    a Fig. 2a
    %    b Fig. 2b
    
    \textbf{Figure numbers}
    
    \ref{fig:alef}
    
    \ref{fig:bet}
    
    \ref{fig:gimel}
    
    
    \begin{figure}
    \centering
    \includegraphics{example-image-a}
    %\label{fig:alef}
    \caption[Alef figure.]{Alef.}
    \label{fig:alef}
    \extracommand{Fig. 1} %command to be defined
    \end{figure}
    
    \begin{figure}
        \begin{subfigure}[]{\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example-image-b}
     %   \label{fig:bet}
        \caption[Bet figure.]{Bet.}
        \label{fig:bet}
        \extracommand{Fig. 2a}
        \end{subfigure}
        
        \begin{subfigure}[]{\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example-image-c}
    %    \label{fig:gimel}
        \caption[Gimel figure.]{Dalet.}
        \label{fig:gimel}
        \extracommand{Fig. 2b}
        \end{subfigure}
    
        \caption[Bet + gimel figure.]{Bet + gimel.}
        \extracommand{Fig. 2}
    \end{figure}
    
    \end{document}

相关内容