1

There ist a great answer and solution to this question by Christian Hupfer, BUT it does not work with KOMA-Scriptwhich is a pity.

The question is how to get several listof in one document?

\documentclass{scrbook}

\usepackage{xparse}
\usepackage{xpatch}
\usepackage{caption}
\usepackage{blindtext}


% Do not a driver counter, i.e. a resetting counter for those two counter fellows here:
\newcounter{lofcntr}
\newcounter{lotcntr}


\NewDocumentCommand{\clearcontents}{}{%
  \stepcounter{lofcntr}% We don't need labels here, I suppose?
  \stepcounter{lotcntr}%
  \setcounter{figure}{0}
  \setcounter{table}{0}
}

\AtBeginDocument{%
  \stepcounter{lofcntr}% 
  \stepcounter{lotcntr}%
}


\makeatletter
% Store the definition of \ext@figure etc. first
\let\latex@ext@figure\ext@figure
\let\latex@ext@table\ext@table

\AtBeginDocument{%
\xpretocmd{\caption}{%
  % Prepend the extension with the number of the current list of ...
  \def\ext@figure{\number\value{lofcntr}\latex@ext@figure}
  \def\ext@table{\number\value{lotcntr}\latex@ext@table}
}{\typeout{Worked!}}{\typeout{Failed miserably!}}
}


\xpatchcmd{\listoffigures}{%
  \@starttoc{lof}%
}{%
  \@starttoc{\number\value{lofcntr}lof}%
}{\typeout{Patch success}}{\typeout{Patch failure}}

\xpatchcmd{\listoftables}{%
  \@starttoc{lot}%
}{%
  \@starttoc{\number\value{lotcntr}lot}%
}{\typeout{Patch success}}{\typeout{Patch failure}}

\makeatother



\begin{document}
\tableofcontents
\listoffigures
\listoftables


\captionof{figure}{Some figure caption for 1st lof}
\captionof{figure}{Some figure caption for 1st lof}
\captionof{figure}{Some figure caption for 1st lof}
\captionof{figure}{Some figure caption for 1st lof}

\captionof{table}{Some table caption for 1st lot}
\captionof{table}{Some table caption for 1st lot}
\captionof{table}{Some table caption for 1st lot}
\captionof{table}{Some table caption for 1st lot}

\clearcontents
\listoffigures
\listoftables


\captionof{figure}{Some figure caption for 2nd lof}
\captionof{figure}{Some figure caption for 2nd lof}
\captionof{figure}{Some figure caption for 2nd lof}
\captionof{figure}{Some figure caption for 2nd lof}


\captionof{table}{Some table caption for 2nd lot}
\captionof{table}{Some table caption for 2nd lot}
\captionof{table}{Some table caption for 2nd lot}
\captionof{table}{Some table caption for 2nd lot}
\end{document}

The problem is that the names of the lists are not display correctly and set to a new page (common behaviour?!): enter image description here

enter image description here

Is it possible to get rid of the heading at all and that it won't start on a new page?


Edit: I’d be happy to work with a different code as well. At least it works with KOMA and is as easy to adopt as the one above.

2
  • Why don't you use \DeclareNewTOC to define another LoF with another extension? Then you can either change \ext@figure or you can define another figure environment using option float of \DeclareNewTOC. Something like this has been shown in: Mit einem aktuellen KOMA-Script geht alles viel einfacher for a separate appendix LoF (and LoT and ToC). Aug 23, 2017 at 9:21
  • @Schweinebacke Thanks for the link. This looked promising but as far as I see it requires to create a new DeclareNewTOC for each listoffigures. Since I will have numerous listoffigures that approach looks like too much manual work. Aug 23, 2017 at 12:49

1 Answer 1

3

Here is a suggestion using both the linked answer by Christian and the suggestion on the KOMA-Script website for additional LoFs. If the LoF should not start a new page it should not be chapter. So you have to use option listof=leveldown.

\documentclass[%
  listof=totoc,% ToC entry for all LoFs and similar lists
  listof=leveldown]% LoF and similar lists as section instead chapter
{scrbook}
\usepackage{xparse}
\usepackage{blindtext}% only for dummy text

\newcounter{lofcntr}

\makeatletter
\NewDocumentCommand{\clearlof}{}{%
  \stepcounter{lofcntr}%
  \setcounter{figure}{0}%
  \DeclareNewTOC
    [listname=\protect\listfigurename]
    {\number\value{lofcntr}lof}%
  \renewcommand*{\ext@figure}{\number\value{lofcntr}lof}%
}
\makeatother

\AtBeginDocument{\clearlof}

\begin{document}
\tableofcontents
\chapter{First Chapter}
\listoffigures
\captionof{figure}{Some figure caption for 1st lof}
\captionof{figure}{Some figure caption for 1st lof}

\chapter{Secound Chapter}
\clearlof
\listoffigures
\captionof{figure}{Some figure caption for 2nd lof}
\captionof{figure}{Some figure caption for 2nd lof}

\chapter{Third Chapter}
\clearlof
\listoffigures
\captionof{figure}{Some figure caption for 3nd lof}
\captionof{figure}{Some figure caption for 3nd lof}
\end{document}

enter image description here

enter image description here

But if you need more than 12 additional LoFs you will get the

No room for a new \write.

error. Note, that your MWE has the same limitation even if a standard class is used.

If you need more LoFs you can load KOMA-Script package scrwfile (alpha-status).

\documentclass[
  listof=totoc,% ToC entry for all LoFs and similar lists
  listof=leveldown% LoF and similar lists as section instead chapter
]{scrbook}
\usepackage{xparse}
\usepackage{scrwfile}% if there are more than 12 additional aux files needed
\usepackage{blindtext}% only for dummy text

\newcounter{lofcntr}

\makeatletter
\NewDocumentCommand{\clearlof}{}{%
  \stepcounter{lofcntr}%
  \setcounter{figure}{0}%
  \DeclareNewTOC
    [listname=\protect\listfigurename]
    {\number\value{lofcntr}lof}%
  \renewcommand*{\ext@figure}{\number\value{lofcntr}lof}%
}
\makeatother

\AtBeginDocument{\clearlof}% then the default lof is not used

\ExplSyntaxOn
\NewDocumentCommand\examplelofs{m}% only for dummy LoFs
  {
    \int_do_until:nNnn
      {\value{lofcntr}} = {#1}
      {
        \chapter{A~chapter}
        \clearlof
        \listoffigures
        \captionof{figure}{Some~figure~caption~for~\number\value{lofcntr}nd~lof}
        \captionof{figure}{Some~figure~caption~for~\number\value{lofcntr}nd~lof}
      }
  }
\ExplSyntaxOff

\begin{document}
\tableofcontents
\chapter{First chapter}
\listoffigures
\captionof{figure}{Some figure caption for 1st lof}
\captionof{figure}{Some figure caption for 1st lof}

\examplelofs{20}
\end{document}
2
  • Thank you! That works fine. However as I found out with \usepackage{morewrites} I could do more than 40 individual lof. Is that not a recommended workflow? EDIT: It seems like \usepackage{scrwfile} is loaded by default?! Aug 24, 2017 at 13:18
  • scrwfile is not loaded by default, but it is part of the KOMA-Script bundle. Maybe package morewrites is an alternative to scrwfile.
    – esdd
    Aug 24, 2017 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .