Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass{report}
- usepackage{etoolbox} % or xpatch
- makeatletter
- % initial definitions of the part info (name and number)
- defthisparttitle{}defthispartnumber{}
- defthischaptertitle{}defthischapternumber{}
- newtoggle{noFigs}
- newtoggle{noTabs}
- apptocmd{@chapter}{gdefthischaptertitle{#1}gdefthischapternumber{thechapter}globaltoggletrue{noFigs}}{}{}
- apptocmd{@part}{gdefthisparttitle{#1}gdefthispartnumber{thepart}globaltoggletrue{noFigs}globaltoggletrue{noTabs}}{}{}
- % the figure environment does the job: the first time it is used after a chapter command, it writes the information of the chapter to the LoF
- AtBeginDocument{%
- AtBeginEnvironment{figure}{%
- iftoggle{noFigs}{
- addtocontents{lof}{protectcontentsline{part}%
- {protectnumberline{thisparttitle}}{}{3.2em} }
- addtocontents{lof}{protectcontentsline {chapter}%
- {protectnumberline {thischapternumber} {thischaptertitle}}{}{} }
- globaltogglefalse{noFigs}
- }{}
- }%
- AtBeginEnvironment{table}{%
- iftoggle{noTabs}{
- addtocontents{lot}{protectcontentsline{part}%
- {protectnumberline{thisparttitle}}{}{} }
- addtocontents{lot}{protectcontentsline {chapter}%
- {protectnumberline {thischapternumber} {thischaptertitle}}{}{} }
- globaltogglefalse{noTabs}
- }{}
- }%
- }
- makeatother
- begin{document}
- tableofcontents
- listoffigures
- part{The first}
- chapter{Introduction with no Figures}
- chapter{Test Chapter with Figures}
- begin{figure}
- caption{caption text}
- end{figure}
- begin{figure}
- caption{caption text}
- end{figure}
- chapter{Test Chapter with no Figures}
- part{The second}
- chapter{Another Test Chapter with Figures}
- begin{figure}
- caption{caption text}
- end{figure}
- begin{figure}
- caption{caption text}
- end{figure}
- begin{figure}
- caption{caption text}
- end{figure}
- begin{figure}
- caption{caption text}
- end{figure}
- begin{figure}
- caption{caption text}
- end{figure}
- end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement