# How to include chapters in list of fixmes using KOMA-Script

How can I add the chapter to the \listoffixmes (lox-list) from the {fixme}-Package? I found a lot of solutions for adding the chapter/section to the list of figures / tables / ... but non of them worked (for me) with KOMA-classes.

I think it is no big deal to rebuild a working solution to work with fixme.

Not working KOMA-Class 'Solutions':

This solution Todonotes: group list-of-todos by section breaks the \paragraph{}-Command and I get the Error: Latex Error: ./miniExample.tex:425 Missing number, treated as zero.

Part title in list of figures and tables? has two solutions, Solution 1 Works find but also adds Chapters even when there is no element of that list.

The second Solution by Gonzalo Medina doesn't work at all. But I think this is the right way I have to go ...

Not KOMA-Class 'Solutions':

Include chapters in List of Figures with titletoc? doesn't work with KOMA-classes (Latex Error: ./miniExample.tex:376 Missing \endcsname inserted.)

A Minimal Example:

\documentclass{scrreprt}
\usepackage[draft]{fixme}
\usepackage{etoolbox}

% Code to add the chapter to the listoffixmes ...

\begin{document}

\listoffixmes

\chapter{chapter}
\section{section1}
\fixme{test1}
\subsubsection{subsubsection}
\paragraph{paragraph}
\section{section2}
\chapter{chapter2}
\section{section3}
\fixme{test2}

\end{document}

• Which features of the KOMA classes do you really use that enforces you to use them? – user31729 May 23 '16 at 23:51
• If it is no big deal, why haven't you done it? And if you haven't done it, why do you think it is no big deal? – cfr May 24 '16 at 0:15
• You could ask the author of KOMA-script to provide a hack for scrhack at komascript.de – Johannes_B May 24 '16 at 6:59
• @ChristianHupfer: I use scrPageStyles (and a rather big package heading for my Master Thesis) and if i change srcbook to book i get a bunch of error messages. Until this moment I never had problems with KOMA-Classes, so if there is an other way I would like to keep KOMA-Classes. – Kugelfisch15 May 24 '16 at 7:30
• @cfr: sry I was not clear in that point: If I find a solution that works with KOMA-Classes I think it's no big deal to rebuild it from Figure/Table/... to work with Fixme. But I haven't found any working soltution for KOMA-Classes so far, which does not break other stuff like \paragraph. – Kugelfisch15 May 24 '16 at 7:33

To add the chapters to the List of Corrections you can use

\KOMAoptions{chapteratlists=entry}
\setuptoc{lox}{chapteratlist}
\makeatletter
\renewcommand*{\listoffixmes}{\listoftoc[{\@fxlistfixmename}]{lox}}
\makeatother


Result:

To remove the chapter entries without fixmes you can use this solution of Markus Kohm (German):

% --- Source: http://www.komascript.de/comment/5070#comment-5070 (Markus Kohm)
\makeatletter
\immediate\write\@auxout{\string\chapterhas{\thechapter}{#1}}%
}
\newcommand*{\chapterhas}[2]{%
\global\@namedef{chapterhas@#1@#2}{true}%
}
\if@chaptertolists
\doforeachtocfile{%
\iftocfeature{\@currext}{chapteratlist}{%
\ifundefinedorrelax{chapterhas@\thechapter @\@currext}{%
}{%
}%
}{}%
}%
\fi
}
\makeatother
% ----


This works for all lists controlled by the KOMA-Script package tocbasic with chapter entries in the list.

Note that if you are using hyperref this code must be inserted after package hyperref is loaded. (See the comment of @Kugelfisch15 below this answer.)

Result:

Code:

\documentclass{scrreprt}
\usepackage[draft]{fixme}

\KOMAoptions{chapteratlists=entry}
\setuptoc{lox}{chapteratlist}
\makeatletter
\renewcommand*{\listoffixmes}{\listoftoc[{\@fxlistfixmename}]{lox}}
\makeatother

%\usepackage{hyperref}
% --- Source: http://www.komascript.de/comment/5070#comment-5070 (Markus Kohm)
\makeatletter
\immediate\write\@auxout{\string\chapterhas{\thechapter}{#1}}%
}
\newcommand*{\chapterhas}[2]{%
\global\@namedef{chapterhas@#1@#2}{true}%
}
\if@chaptertolists
\doforeachtocfile{%
\iftocfeature{\@currext}{chapteratlist}{%
\ifundefinedorrelax{chapterhas@\thechapter @\@currext}{%
}{%
}%
}{}%
}%
\fi
}
\makeatother
% ----

\begin{document}
\listoffixmes

\chapter{Chapter with Fixme}
\section{section1}
\fxfatal{test1}
\subsubsection{subsubsection}
\paragraph{paragraph}
\section{section2}

\chapter{Chapter without Fixme}

\chapter{Chapter with Fixme}
\section{section3}
\fxfatal{test2}
\end{document}

• Do you think a fixme.hak is in order? – Johannes_B May 24 '16 at 8:54
• Thanke you a lot! It works perfect. Note to the code: I have to insert this code after \usepackage{hyperref}. If I load hyperref after this code the chapters disappear from the ListOfFixmes. – Kugelfisch15 May 24 '16 at 9:17
• @Johannes_B I am not sure. I think there are also a number of other packages which define their own list too ... – esdd May 24 '16 at 10:23

You could hack \chapterformat to add it, although I don't know what side-effects this might have.

Note that \fixme is deprecated and the package tells you this when you try to use it. Also, KOMA Script is not at all happy about one of the packages - presumably fixme. See the console output for information and recommendations.

\documentclass{scrreprt}
\usepackage[draft]{fixme}
\usepackage{etoolbox}
\apptocmd{\chapterformat}{%
}{\typeout{chapterformat patched OK!}}{\typeout{chapterformat patch failed}}
\begin{document}
\listoffixmes
\chapter{chapter}
\section{section1}
\fxfatal{test1}
\subsubsection{subsubsection}
\paragraph{paragraph}
\section{section2}
\chapter{chapter2}
\section{section3}
\fxfatal{test2}
\end{document}