1

I have two appendices. The first one contains only tables, while the second one has tables, figures and schemes. At the begin of each appendix I want the list of tables/figures to show up. I know how to do this, if there is only one list of tables/figures for the whole appendix. I followed Markus Kohm's guideline for that. This works fine with a single list, but not with my modifications for multiple lists. In addition for the second appendix, I want the tables, figures and schemes listed combined in one "appendix B list".

So, what I want it to look like is this:

Appendix A

Content

Table A.1 Table in Appendix A

Table A.2 Table in Appendix A

Appendix B

Content

Table B.1 Table in Appendix B

Figure B.1 Figure in Appendix B

Scheme B.1 Scheme in Appendix B

Table B.2 Table in Appendix B

This is what I thought should work, but which does not give the desired output:

\documentclass[listof=totoc]{scrbook}
\usepackage{tocbasic}

\newcommand{\entrynumberwithprefix}[2]{%
    \csname listof#1entryname\endcsname\ #2%
}%
\newlength{\loftnumwidth}
\setlength{\loftnumwidth}{5em}

\DeclareTOCStyleEntry[%
    entrynumberformat=\entrynumberwithprefix{lot},
    numwidth=\loftnumwidth,%
    indent=0pt,
]{tocline}{table}

\DeclareTOCStyleEntry[%
    entrynumberformat=\entrynumberwithprefix{lof},
    numwidth=\loftnumwidth,%
    indent=0pt,
]{tocline}{figure}

\DeclareNewTOC[%
    type=scheme,%
    types=schemes,%
    float,%
    floattype=4,% 
    name=Scheme,%
    tocentrynumberformat=\entrynumberwithprefix{los},
    tocentrynumwidth=\loftnumwidth,%
    tocentryindent=0pt,
]{los}

% new lists for appendices
\DeclareNewTOC[%
    listname={Content of Appendix A},%
]{lotA}

\DeclareNewTOC[%
    listname={Tables in Appendix B},%
]{lotB}

\DeclareNewTOC[%
    listname={Content of Appendix B},%
]{lofB}

\DeclareNewTOC[%
    listname={Schemes in Appendix B},%
]{losB}

\makeatletter
\newcommand*{\useappendixtocs}{%
    \setcounter{figure}{0}%
    \setcounter{table}{0}%
    \KOMAoptions{listof=leveldown}
    \renewcommand*{\ext@table}{lotA}%
    \renewcommand*{\ext@figure}{lotB}%
    \renewcommand*{\ext@figure}{lofB}%
    \renewcommand*{\ext@figure}{losB}%
}
\g@addto@macro\appendix{
    \useappendixtocs
}
\makeatother

\begin{document}
\tableofcontents
\listoffigures
\listoftables
\listofschemes

\chapter{Main Document}
\begin{table}
    \caption{Table in main document.}
\end{table}

\begin{figure}
    \caption{Figure in main document.}
\end{figure}

\begin{scheme}
    \caption{Scheme in main document.}
\end{scheme}

\appendix
\chapter{First appendix with tables only}
\listoftoc{lotA}

\begin{table}
    \caption{Table in appendix A.}
\end{table}


\chapter{Second appendix with figures, tables and schemes}
\listoftoc{lofB}%

\begin{table}
    \caption{Table in appendix B.}
\end{table}

\begin{figure}
    \caption{Figure in appendix B.}
\end{figure}

\begin{scheme}
    \caption{Scheme in appendix B.}
\end{scheme}

\begin{table}
    \caption{Table in appendix B.}
\end{table}

\end{document}
  • 1
    scrbook loads package tocbasic automatically. – esdd Apr 22 '18 at 18:37
1

Here is a suggestion:

\documentclass[
  listof=totoc,
  listof=flat% <- added
]{scrbook}

\newcommand{\entrynumberwithprefix}[2]{%
    \csname listof#1entryname\endcsname\ #2%
}%

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithprefix{lof}
]{tocline}{figure}
\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithprefix{lot}
]{tocline}{table}

\DeclareNewTOC[%
  type=scheme,%
  types=schemes,
  float,%
  floattype=4,%
  name=Scheme,%
  tocentryentrynumberformat=\entrynumberwithprefix{los},% <- option name changed
  counterwithin=chapter,% <- added
]{los}


\makeatletter
\newcommand\listofapp{%
  \DeclareNewTOC[%
    listname={Content of Appendix \thechapter},%
    setup=leveldown% <- needs KOMA-Script version 3.25
  ]{app\thechapter}%
  \unsettoc{app\thechapter}{totoc}%
  \renewcommand{\ext@figure}{app\thechapter}%
  \renewcommand{\ext@table}{app\thechapter}%
  \renewcommand{\ext@scheme}{app\thechapter}%
  \listoftoc{app\thechapter}%
}
\makeatother

\begin{document}
\tableofcontents
\listoffigures
\listoftables
\listofschemes

\chapter{Main Document}
\begin{table}
  \caption{Table in main document.}
\end{table}
\begin{figure}
  \caption{Figure in main document.}
\end{figure}
\begin{scheme}
  \caption{Scheme in main document.}
\end{scheme}

\appendix
\chapter{First appendix with tables only}
\listofapp
\begin{table}
  \caption{Table in appendix A.}
\end{table}

\chapter{Second appendix with figures, tables and schemes}
\listofapp
\begin{table}
  \caption{Table in appendix B.}
\end{table}
\begin{figure}
  \caption{Figure in appendix B.}
\end{figure}
\begin{scheme}
  \caption{Scheme in appendix B.}
\end{scheme}
\begin{table}
  \caption{Table in appendix B.}
\end{table}
\end{document}

Run three times to get:

enter image description here

enter image description here

enter image description here

enter image description here

Note that option setup for \DeclareNewTOC is introduced in KOMA-Script version 3.25. With former KOMA-Script versions you have to remove it and to add \setuptoc{app\thechapter}{leveldown}.

  • Thank you! I get error message for setup=leveldown in your code. But it works when I comment it out and add it with \KOMAoptions. I'd like to thank you for your improvements of my code, too. I didn't know that flat can be applied to LoFT. I added it to the definition of listofapp, because I have already set listof=graduated to have a graduated ToC. (I left it out in the MWE.) I also recognized the warning to tocentrynumberformat, but thought this is a bug, because tocentryentrynumberformat seemed odd to me. – Lysanne Apr 22 '18 at 19:49
  • setup=leveldown was introduced in KOMA-Script version 3.25 (current on CTAN and in MiKTeX2.9 and TL2018pretest). listof=gratuated only affects lists with owner=float like LOF, LOT and the new defined TOCs by \DeclareNewTOC (because owner=float is default). If you want to have a graduated TOC use toc=gratuated, but this is the default setting. – esdd Apr 22 '18 at 20:07
  • I just had a look in KOMA documentation. I can use toc=graduated and your suggestion with listof=flat to get seperate designs for ToC and LoFT. – Lysanne Apr 22 '18 at 20:07
  • 1
    Option entrynumberformat of \DeclareTOCStyleEntry can be used by \RedeclareSectionCommand etc. with prefix toc as tocentrynumberformat and by DeclareNewTOC with prefix tocentry which results in tocentryentrynumberformat ;-) – esdd Apr 22 '18 at 20:10
  • Thank you! Concerning KOMA version. I freshly installed TeXlive 2017. It has KOMA 3.24 and says no updates available. I think updates might be frozen before release of TeXlive2018 in June or so??? I will check the option with the new version again as soon as I have it. – Lysanne Apr 22 '18 at 20:12

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.