带扩展字段的图题

带扩展字段的图题

已知的特点\caption是:

\caption[Text for the list of figures]{Text under the figure} 
\label{fig:theReference}

目标是包含更多参数\caption并将这些参数显示在表格中

\begin{tabular}{ | m{3cm} | m{4cm}| m{4cm} | m{4cm} |} 
\hline
Fig number & Diplay here the text for the list of figures & Display here the text under the figure & Display here other text which is a new argument for the caption \\
\hline
\ref{fig:theReference} & How to? & How to? & How to? \\
\hline
\end{tabular}

在此处输入图片描述

答案1

某种自动化

\documentclass[a4paper, 12pt]{article}
\usepackage{mwe}
\usepackage{array}
\usepackage{xparse}

\makeatletter
\def\tableau{}
\NewDocumentCommand{\mycaption}{mO{#3}mO{#3}}{%\mycaption{label}[caption for lof (default = caption)]{caption}[optional other text (default = caption)]
    \caption[#2]{#3}
    \label{#1}
    \g@addto@macro{\tableau}{\ref{#1} & #2 & #3 & #4\tabularnewline}
}
\makeatother
%
\begin{document}
    \listoffigures
    \section*{Introduction}
    \begin{figure}[h!]
        \centering
        \includegraphics[width=.7\linewidth]{example-image}
        \mycaption{fig:theReference}[Text for the list of figures]{Text under the figure}[Other text]
    \end{figure}

    \begin{figure}[h!]
        \centering
        \includegraphics[width=.7\linewidth]{example-image-a}
        \mycaption{fig:theReferencea}[Text for the list of figures a]{Text under the figure a}
        %           \label{fig:theReference}
    \end{figure}

    \begin{tabular}{|m{3cm}|m{4cm}|m{4cm}|m{4cm}|} 
        \hline
        Fig number & Diplay here the text for the list of figures & Display here the text under the figure & Display here other text which is a new argument for the caption \\
        \hline
        \tableau
    \end{tabular}
\end{document}

相关内容