The following code is adapted from here The idea is to create a book with two parts (containing problems and solutions) which have equal (numbered) chapter and (unnumbered) section headings. In order to keep the toc small, the page numbers for both parts should appear side-by-side in the toc (due to the very similar structure in both parts). Furthermore, the sections (although not numbered) should appear in the toc and the page heads. Here are the problems left based on the MWE below:

• The page number for solution sections don't appear in the toc (only '??' appear)
• The page numbers of chapters and sections don't seem to be (vertically) aligned correctly, especially in the case where some solutions are on a page >= 100 (3-digits). This certainly comes from the \hspace between the page numbers of problems and their solutions in \titlecontents below. (It seems that a table-like toc would be the way to go to ensure right-alignment of the page numbers, but I didn't manage to get this to work).

How can these two issues be fixed?

\documentclass{scrbook}

\usepackage{lipsum}
\usepackage{scrlayer-scrpage}
\usepackage{titletoc}
\usepackage{hyperref}

% TOC
% {section}, [left], {above}, {before with label (left side)}, {before wo label
% (left side)}, {filler and page}, [after]
{\hfill\contentspage\hspace{5.4em}\pageref{\thecontentslabel}\hspace*{-1.4em}}

\begin{document}
\pdfbookmark[0]{\contentsname}{toc}
\tableofcontents% without number; add bookmark on level 0
\chapter{Chapter A problems}\label{chap:1}
\lipsum[1-100]
\lipsum[101-200]

\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}% remove toc entries after this line
\chapter{Chapter A solutions}\label{2}
\lipsum[201-300]
\lipsum[301-400]
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}% display contents (down to subsections) in toc again
\end{document}

• Why using titletoc with a KOMA class? Oct 2, 2015 at 0:02
• Because of the \titlecontents commands (?) Oct 2, 2015 at 4:15
• Well, of course. My comment was meant to indicate that titletoc might not be fully compatible with KOMA classes (titlesec is not). With KOMA classes, I think, one should use tocstyle (from the same author of the classes). Oct 2, 2015 at 14:10
• This is also discussed on the KOMA-Script website, see komascript.de/node/1971
– esdd
Oct 3, 2015 at 16:41
• yes, that was me -- I decided to post it there as well, as I know Markus Kohm a bit but am not sure whether he reads tex.stackexchange. Of course I provide a full solution once it's working as expected. Oct 3, 2015 at 18:54