7

The list of figures/tables in default book class looks like:

Default looking:

List of Figures

1.1 Snapshots .................. 2 1.2 Snapshots .................. 4 1.3 Snapshots .................. 6 2.1 Snapshots .................. 12 2.2 Snapshots .................. 23 2.3 Snapshots .................. 32

What I want to tweak is like:

List of Figures

Figure 1.1 Snapshots .................. 2 Figure 1.2 Snapshots .................. 4 Figure 1.3 A very long caption: blabla blabla blabla .............. 6 % skip = 1em Figure 2.1 Snapshots .................. 12 Figure 2.2 Snapshots .................. 23 Figure 2.3 Snapshots .................. 32

  1. Group Figures/Tables by chapter with a small skip 1 em
  2. Add Figure or Table before each entries.

So how to implement this?

Update 1:

enter image description here

Using the codes by Werner, the Figure and Table are appended to the begin of LOT, LOF entries, however, the captions are not aligned, how to solve this minor issue?

Similar:

KOF
  • 5,019

1 Answers1

4
  1. The default book does insert a gap in the LoF & LoT between every chapter. See the chapter-making macro from book.cls:

    \def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                           \if@mainmatter
                             \refstepcounter{chapter}%
                             \typeout{\@chapapp\space\thechapter.}%
                             \addcontentsline{toc}{chapter}%
                                       {\protect\numberline{\thechapter}#1}%
                           \else
                             \addcontentsline{toc}{chapter}{#1}%
                           \fi
                        \else
                          \addcontentsline{toc}{chapter}{#1}%
                        \fi
                        \chaptermark{#1}%
                        \addtocontents{lof}{\protect\addvspace{10\p@}}% Insert gap in LoF
                        \addtocontents{lot}{\protect\addvspace{10\p@}}% Insert gap in LoT
                        \if@twocolumn
                          \@topnewpage[\@makechapterhead{#2}]%
                        \else
                          \@makechapterhead{#2}%
                          \@afterheading
                        \fi}
    

    If you wish to change this to 1em, you can use etoolbox to patch \@chapter or, without package, copy the definition of \@chapter and replace the \addvspace lengths with 1em. Here's the etoolbox patch:

    \usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
    \makeatletter
    % \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
    \patchcmd{\@chapter}{10\p@}{1em}{}{}% for List of Figures
    \patchcmd{\@chapter}{10\p@}{1em}{}{}% for List of Tables
    \makeatother
    
  2. Adding Figure and Table before your LoF and LoT entries, respectively, follows a similar discussion as can be found in Add the word “Algorithm” before each entry in the List of Algorithms:

    enter image description here

    \documentclass[oneside]{book}
    \newcommand{\myfig}{\begin{figure}\caption{A figure caption}\end{figure}}
    \newcommand{\mytab}{\begin{table}\caption{A table caption}\end{table}}
    \let\oldlistoffigures\listoffigures
    \let\oldlistoftables\listoftables
    \renewcommand{\listoffigures}{%
      \begingroup%
      \let\oldnumberline\numberline%
      \renewcommand{\numberline}{\figurename~\oldnumberline}%
      \oldlistoffigures%
      \endgroup}%
    \renewcommand{\listoftables}{%
      \begingroup%
      \let\oldnumberline\numberline%
      \renewcommand{\numberline}{\tablename~\oldnumberline}%
      \oldlistoftables%
      \endgroup}%
    \begin{document}
    \listoffigures
    \listoftables
    \chapter{A chapter}\myfig\mytab\myfig\mytab\myfig\mytab
    \chapter{A chapter}\myfig\mytab\myfig\mytab\myfig\mytab
    \chapter{A chapter}\myfig\mytab\myfig\mytab\myfig\mytab
    \chapter{A chapter}\myfig\mytab\myfig\mytab\myfig\mytab
    \chapter{A chapter}\myfig\mytab\myfig\mytab\myfig\mytab
    \end{document}
    
Werner
  • 603,163
  • 1
    It works, however, the Figs/Tabs captions are not aligned in terms of vertical position, how to figure this out? – KOF Feb 10 '13 at 16:33
  • Could you figure it out @KOF? – P. Leibner Feb 09 '21 at 17:04
  • @P.Leibner: If you have a similar issue to KOF's in terms of the horizontal alignment/indentation/hang of the entries in the LoF/LoT, please post a new question and provide a complete, minimal example that replicates the results. – Werner Feb 09 '21 at 18:54
  • Thanks @Werner, I ended up solving my issue using the titletoc package. – P. Leibner Feb 10 '21 at 15:01