0

I'm using \documentclass[12pt,a4paper,twoside]{report} for making a report.

The entire report is divided into two parts. Each part contains chapters. The sample index is as follows.

List of Figures

List of Tables

Part I A

Chapter 1

1.1

Chapter 2

2.1

Part II B

Chapter 1

1.1

Chapter 2

2.1

In the list of figures and list of tables portions, I want to add only the part name in as shown below.

List of Figures

Part I A

1.1 Caption of Figure

2.1 Caption of Figure

Part II B

1.1 Caption of Figure

2.1 Caption of Figure

Please give me necessary solutions to do it.

  • Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. - Related:Splitting list of figures – Bobyandbob Aug 28 '17 at 6:59
  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See minimal working example (MWE). – Henri Menke Aug 28 '17 at 7:34
2

A patch answer by changing \@part a little bit and explicitly adding \addcontentsline with lof instead of toc again.

I have kept the vertical chapter gap in the LoF in order make the elements of figures origination from different chapters more outstanding.

\documentclass{report}

\usepackage{xpatch}
\makeatletter
\xpatchcmd{\@part}{%
  \markboth{}{}% Find a hook in order to append content. 
}{%
  \markboth{}{}%
  \ifnum\c@secnumdepth>-2\relax
  \addcontentsline{lof}{part}{\thepart\hspace{1em}#1}%
  \else
  \addcontentsline{lof}{part}{#1}%
  \fi
}{\typeout{Success}}{\typeout{Patch failure}}
\makeatother

\usepackage{hyperref}

\begin{document}
\tableofcontents
\listoffigures

\part{Number Three -- the Larch}



\chapter{A dummy chapter}
\begin{figure}

\caption{First figure}

\end{figure}


\begin{figure}

\caption{Second figure}

\end{figure}

\part{And now for something completely different}

\begin{figure}

\caption{Third figure}

\end{figure}


\end{document}

enter image description here

1

I adjusted this answer to include the parts and not the chapters in the list of figures:

\documentclass[12pt,a4paper,twoside]{report}
\usepackage{etoolbox}

\makeatletter
\def\thisparttitle{}
\def\thispartnumber{}
\newtoggle{noFigs}
\apptocmd{\@part}{\gdef\thisparttitle{#1}\gdef\thispartnumber{\thepart}\global\toggletrue{noFigs}}{}{}
\AtBeginDocument{\AtBeginEnvironment{figure}{%
  \iftoggle{noFigs}{
    \addtocontents{lof}{\protect\contentsline{part}{\protect\numberline{\thispartnumber}{\thisparttitle}}{}{}}
    \global\togglefalse{noFigs}
  }{}
}}
\makeatother

\begin{document}

\listoffigures

\part{A}
\chapter{First}
\begin{figure}[h]
    \caption{Caption of first figure}
\end{figure}
\chapter{Second}
\begin{figure}[h]
    \caption{Caption of second figure}
\end{figure}

\part{B}
\chapter{First}
\begin{figure}[h]
    \caption{Caption of third figure}
\end{figure}
\chapter{Second}
\begin{figure}[h]
    \caption{Caption of fourth figure}
\end{figure}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.