I want to add subfigure captions (like "61(a)") in my own list of figures.
My code (see example document below) works fine, but as soon as I load the caption
or subcaption
package additionally my code results in an empty list.
What I need is that my \tableoffigures
command has to get along with the following command:
\usepackage[...,list=true]{subcaption}
Example document:
\documentclass{report}
%\usepackage{caption} %figure caption
%\usepackage[list=true,lofdepth=2]{subcaption} %subfigure caption
\usepackage{longtable,letltxmacro}
\newcounter{fullfigurecounter}
\newcounter{fulltablecounter}
\makeatletter
\newcommand*\@starttof[2]{%
\begingroup
\renewcommand{\arraystretch}{1.5}
% Table format may be changed%%%
\begin{longtable}{|p{2cm}|p{6cm}|p{7cm}|}
% \hline
\multicolumn{3}{c}{}\tabularnewline
\multicolumn{3}{c}{\Large \bfseries #2}\tabularnewline
\multicolumn{3}{c}{}\tabularnewline
% \hline
\multicolumn{3}{c}{}\tabularnewline[0.5ex]
\hline
\large Table No. & \large Title of the Table & \large Source \tabularnewline
\hline
\endhead % Repeating head
\@input{\jobname.#1}% Input the ToF or ToT file
\tabularnewline
\hline
\end{longtable}
\setcounter{table}{0}%
\if@filesw
\expandafter\newwrite\csname tf@#1\endcsname
\immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
\fi
\endgroup
}
\newcommand{\tableoffigures}{%
\cleardoublepage
\@starttof{tof}{Abbildungs- und Quellenverzeichnis}
}%
\newcommand{\tableoftables}{%
\clearpage
\@starttof{tot}{LIST OF TABLES}%
}%
\def\temp@@a{figure}%
\def\temp@@b{table}%
\LetLtxMacro\captionpkg@caption\caption
\newcommand{\writetofline}[3]{%
\ifnum\value{fullfigurecounter} > 1
\tabularnewline
\protect\hline
\fi
\figurename\ #1 & #2 & #3
}
\newcommand{\writetotline}[3]{%
\ifnum\value{fulltablecounter} > 1
\tabularnewline
\protect\hline
\fi
\tablename\ #1 & #2 & #3
}
\RenewDocumentCommand{\caption}{somO{Eigene Darstellung}}{%
\IfBooleanTF{#1}{%
\captionpkg@caption{#3}%
}{%
\ifx\@currenvir\temp@@a
\stepcounter{fullfigurecounter}%
\else
\ifx\@currenvir\temp@@b
\stepcounter{fulltablecounter}%
\fi
\fi
\IfValueTF{#2}{%
\captionpkg@caption[#2]{#3}%
\ifx\@currenvir\temp@@a
\addtocontents{tof}{\writetofline{\thefigure}{#2}{#4}}%
\else
\ifx\@currenvir\temp@@b
\addtocontents{tot}{\writetotline{\thetable}{#2}{#4}}%
\fi
\fi
}{%
\captionpkg@caption{#3}%
\ifx\@currenvir\temp@@a
\addtocontents{tof}{\writetofline{\thefigure}{#3}{#4}}%
\else%
\ifx\@currenvir\temp@@b
\addtocontents{tot}{\writetotline{\thetable}{#3}{#4}}%
\fi
\fi
}%
}%
}
\makeatother
\begin{document}
\tableoffigures
\clearpage
\tableoftables
\clearpage
\chapter{A sample for multicol table of contents}
\begin{table}
\caption[A nice table]{A nice table}[Me!]
\end{table}
\clearpage
\begin{figure}
\caption{Irgendein Bild}
\end{figure}
\begin{figure}
\caption[Die Sonnenblumen]{Irgendein Bild}[Vincent van Gogh]
\end{figure}
\clearpage
\begin{table}[!ht]
\caption[List of $ \theta $ signature]{$\theta$ signature}
\label{theta}
\centering
\begin{tabular}{|c|*{6}{c|}}
\hline
% \backslashbox{$ \boldsymbol{\theta} $}{signature}& \textbf{1} & \textbf{2} & \textbf{3} & \textbf{4} & $ \boldsymbol{\cdots} $ & $ \boldsymbol{t} $\\ \hline
\textbf{1} & 1 & 2 & 3& 4& $ \ldots $ & 1+c \\
\hline
\textbf{4} & 5 & 6 & \multicolumn{3}{c|}{$ \ldots $} & 7\\ \cline{4-5}
\hline
$ \vdots $ & \multicolumn{6}{c|}{$ \ldots $} \\ \cline{2-6}
\hline
\end{tabular}
\end{table}
\ifx\subfigure\undefined\else
\begin{figure}
\begin{subfigure}{.5\linewidth}
\caption[flower]{}
\end{subfigure}
\end{figure}
\begin{figure}\ContinuedFloat
\begin{subfigure}{.5\linewidth}
\caption[animal]{}
\end{subfigure}
\end{figure}
\fi
\end{document}
\caption
only supports environmantsfigure
andtable
but notsubfigure
orsubtable
and also not using\caption
inside another environment inside afigure
ortable
. So I would call is: broken by design.\caption
should never depend on\@currenvir
. Maybe depending on\@captype
could be used, but not to compare it, but for something like\csname the\@captype\endcsname
,\csname fnum@\@captype\endcsname
etc.