Last active
December 20, 2015 13:08
-
-
Save agravier/6136084 to your computer and use it in GitHub Desktop.
I modified a few snippets from Tom from http://texblog.org/ to suit my needs. The structured LoT made by the original doesn't work with longtable. Also, it structures by part, not chapter, but if you need chapters, that's easy to change by following to the original: http://texblog.org/2012/01/18/adding-additional-structure-to-the-list-of-figures…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Lists of figures, tables and listings with part headings | |
\usepackage{etoolbox} | |
\makeatletter | |
% Create a flag | |
\providebool{newpartfig} | |
\providebool{newparttab} | |
\providebool{infigure} | |
\providebool{intable} | |
% Fix the \part command to set a flag | |
\newcommand{\saved@part}{} | |
\let\saved@part\part | |
\renewcommand{\part}{% | |
\@ifstar {\saved@part*}{\@dblarg\my@part}} | |
\newcommand*{\my@part}[2][]{% | |
\saved@part[#1]{#2}% | |
\global\setbool{newparttab}{true}% | |
\global\setbool{newpartfig}{true}} | |
% Fix the \caption command to check the flag and insert a LOF line | |
\let\LT@oldmakecaption\LT@makecaption | |
\renewcommand{\LT@makecaption}[3]{% | |
\LT@oldmakecaption{#1}{#2}{#3}% | |
\ifbool{intable}{% | |
\ifbool{newparttab}{% | |
\addtocontents{lot}{\protect\contentsline{part}{% | |
\vskip0pt \hskip20pt Part \thepart \vspace{3pt}}{\protect\relax}{}}% | |
\global\boolfalse{newparttab}% | |
}{}% | |
}{}% | |
} | |
\let\oldcaption\caption | |
\renewcommand{\caption}[2][\shortcaption]{% | |
\def\shortcaption{#2}% | |
\ifbool{intable}{% | |
\ifbool{newparttab}{% | |
\addtocontents{lot}{\protect\contentsline{part}{% | |
\vskip0pt \hskip20pt Part \thepart \vspace{3pt}}{\protect\relax}{}} | |
\global\boolfalse{newparttab} | |
}{}% | |
}{}% | |
\ifbool{infigure}{% | |
\ifbool{newpartfig}{% | |
\addtocontents{lof}{\protect\contentsline{part}{% | |
\vskip0pt \hskip20pt Part \thepart \vspace{3pt}}{\protect\relax}{}}% | |
\global\boolfalse{newpartfig}% | |
}{}% | |
}{}% | |
\oldcaption[#1]{#2}% | |
} | |
% Add in figure/table detection | |
\AtBeginEnvironment{figure}{ | |
\global\booltrue{infigure}% | |
\global\boolfalse{intable}% | |
} | |
\AtBeginEnvironment{table}{ | |
\global\booltrue{intable}% | |
\global\boolfalse{infigure}% | |
} | |
\AtBeginEnvironment{longtable}{ | |
\global\booltrue{intable}% | |
\global\boolfalse{infigure}% | |
} | |
\makeatother |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment