[Tex/LaTex] Modifying list of tables/images

table of contentstitletoc

I'd like to customize the list of figures and tables with a similar design to this:

Modifying mini-toc content

Does somebody know how to do a similar design for a list of tables/images?

Best Answer

titletoc package can also be used to customize the list of figures and tables. From the documentation of \dottedcontents and \titlecontents commands:

"section" is the section name without backslash: part, chapter, section, etc. figure and table are allowed, too. (The backlash is omitted because we are dealing with the concept and not the \part, \section, etc. macros themselves. Furthermore, figure and table are environments.)

You can easily adapt the code in the mentioned answer to get the desired result:

\titlecontents{figure}
  [0em]{\vspace*{2\baselineskip}}
  {\parbox{4.5em}{%
    \hfill\Huge\sffamily\bfseries\color{myred}\thecontentspage}%
   \vspace*{-2.3\baselineskip}\leftbar\textsc{\small Figure~\thecontentslabel}\\\sffamily}
  {}{\endleftbar}

enter image description here


EDIT 1:

For further customization, you can extract the value of current chapter from the macro \thecontentslabel, e.g.:

\makeatletter
\titlecontents{figure}
  [0em]{\vspace*{2\baselineskip}}
  {\parbox{4.5em}{%
    \hfill\Huge\sffamily\bfseries\color{myred}\thecontentspage}%
   \vspace*{-2.3\baselineskip}\leftbar 
   \textsc{\small \chaptername~\expandafter\@car\thecontentslabel\@nil\ // %
     Figure~\thecontentslabel}\\\sffamily}
  {}{\endleftbar}
\makeatother

EDIT 2:

You can insert any kind of material into a lof via \addtocontents. E.g., you can define a command \updatemylof invoked after a \chapter to insert a title into your lof which is formatted like a section. Maybe you can customize this approach to your needs. Code:

\documentclass{book}
\usepackage{xcolor,framed,titletoc,lmodern}

\definecolor{myred}{RGB}{127,0,0}
\definecolor{myyellow}{RGB}{169,121,69}

\renewenvironment{leftbar}{%
  \def\FrameCommand{%
    \hspace{6em}%
    {\color{myyellow}\vrule width 2pt depth 6pt}%
    \hspace{1em}%
  }%
  \MakeFramed{\parshape 1 0cm \dimexpr\textwidth-6em\relax\FrameRestore}\vskip2pt\relax
  }
 {\endMakeFramed}

\titlecontents{chapter}
  [0em]{\vspace*{2\baselineskip}}
  {\parbox{4.5em}{%
    \hfill\Huge\sffamily\bfseries\color{myred}\thecontentspage}%
   \vspace*{-2.3\baselineskip}\leftbar
   \textsc{\small\chaptername~\thecontentslabel}\\\sffamily}
  {}{\endleftbar}
\titlecontents{section}
  [8.4em]
  {\sffamily\contentslabel{3em}}{}{}
  {\hspace{0.5em}\nobreak\itshape\color{myred}\contentspage}
\titlecontents{subsection}
  [8.4em]
  {\sffamily\contentslabel{3em}}{}{}  
  {\hspace{0.5em}\nobreak\itshape\color{myred}\contentspage}

\titlecontents{figure}
  [0em]{\vspace*{2\baselineskip}}
  {\parbox{4.5em}{%
    \hfill\Huge\sffamily\bfseries\color{myred}\thecontentspage}%
   \vspace*{-2.3\baselineskip}\leftbar
   \textsc{\small Figure~\thecontentslabel}\\\sffamily}
  {}{\endleftbar}

\newcommand*\updatemylof{%
  \addtocontents{lof}{\protect\section*{Chapter~\thechapter}}%
}

\begin{document}

\tableofcontents
\listoffigures

\chapter{Beginning to learn design with \LaTeX}
\section{This is a test section}
\subsection{Long subsection title and some other text to span more
  than one line}

\newpage\setcounter{page}{123}% just for the example

\chapter{Beginning to learn design with HTML and some other text to
  span more than one line in the ToC}
\updatemylof

\section{This is a test section}
\subsection{Long subsection title and some other text to span more
  than one line}

\cleardoublepage
\begin{figure}\caption{Caption of figure}\end{figure}
\clearpage
\begin{figure}\caption{Caption of figure}\end{figure}

\chapter{Further learning}
\updatemylof

\begin{figure}\caption{Caption of figure}\end{figure}
\begin{figure}\caption{Caption of figure}\end{figure}

\end{document}

enter image description here