I want to write an extended figure caption section, and wondered if I could get LaTeX to do most of the hard work for me.
Ideally, it would take the form of a function, let say \extcaption
, that we could use within a float, like
\begin{figure}
\includegraphics{example-image-a.pdf}
\caption{Important things.}
\extcaption{Less important things.}
\label{fig:bigA}
\end{figure}
and that we could print with
\printextcaptions
and that would return
Figure 1.1, page 2: Less important things.
Anyway to do it? Here is a MWE:
\documentclass[a4paper,10pt]{report}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage[titles]{tocloft}
\begin{document}
\chapter{A chapter}
\section{A section}
\begin{figure}
\includegraphics{example-image-a.pdf}
\caption{Picture of a big A}
%\extcaption{This picture is magnificent}
\label{fig:bigA}
\end{figure}
\begin{figure}
\includegraphics{example-image-b.pdf}
\caption[This picture is horrible]{Picture of a big B}
%\extcaption{This picture is horrible.}
\label{fig:bigB}
\end{figure}
%\printextcaptions
\end{document}
The best result I got was by setting a new list with the tocloft
package
\newlistof[section]{extfig}{efc}{Extended figure captions}
\newcommand{\extcaption}[1]{%
\refstepcounter{extfig}
\par\noindent\textbf{\theextfig #1}
\addcontentsline{efc}{extfig}{\protect\numberline{\theextfig}#1}\par}
\renewcommand{\theextfig}{}
But this prints a new chapter while I want nothing, it does not print the extended caption in the format the way I want, and does not read the label of the figure (or table) float, so I would have to set everything manually.
\thefigure
instead of\theextfig
to the file. – cfr Nov 22 '15 at 3:49locloft
? – cfr Nov 22 '15 at 3:52tocloft
? It can be obtained from ctan: ctan.org/pkg/tocloft – HcN Nov 22 '15 at 3:58\makeatletter \newwrite\@efcwrite \immediate\openout\@efcwrite\jobname.efc \newcommand\extcaption[1]{% \par\noindent\textbf{#1}% \protected@write\@efcwrite{}{\figurename{} \thefigure: #1\par}} \makeatother
Unfortunately, I don't know how to read it - only write it. – cfr Nov 22 '15 at 4:30