1

I've created this simplified TOC based on this amazing post.

MWE:

%XeLaTeX
\documentclass[11pt]{book}

\usepackage[
    paperwidth=8in,
    paperheight=10in,
    inner=0.5in,
    outer=0.5in,
    bindingoffset=0.25in,
    top=0.75in,
    bottom=1.25in,
    twoside,
    %showframe
    ]{geometry} 


% https://tex.stackexchange.com/a/35835/121944, basis of this ToC design
\usepackage{framed}
\usepackage[compact,pagestyles,clearempty]{titlesec}
\usepackage{titletoc}
\usepackage{etoolbox}

% % %
\patchcmd{\tableofcontents}{\contentsname}{\rmfamily\contentsname}{}{}

\renewenvironment{leftbar}
  {\def\FrameCommand{\hspace{26.75em}%
    {\vrule width 2pt depth 3pt}\hspace{1em}}%
    \MakeFramed{\parshape 1 0cm \dimexpr\textwidth-6em\relax\FrameRestore}\vskip2pt%
  }
 {\endMakeFramed}

\titlecontents{part}
  [0em]{\vspace*{0.3\baselineskip}}
  {\parbox{14.8em}{% mainmatter
    \hfill\huge\rmfamily\bfseries}%
   \vspace*{-2.4\baselineskip}\leftbar\MakeUppercase{\normalsize{Part~}\thecontentslabel}\\\normalsize\rmfamily}
  {\parbox{14.5em}{% frontmatter
    \hfill\Large\rmfamily\bfseries}%
   \vspace*{-1.95\baselineskip}\leftbar\MakeUppercase{\normalsize{Part~}\thecontentslabel}\\\normalsize\rmfamily}
  {\endleftbar}
% % %

\titlecontents{chapter}
  [0em]{\vspace*{0.3\baselineskip}}
  {\parbox{14.8em}{% mainmatter
    \hfill\huge\rmfamily\bfseries\thecontentspage}%
   \vspace*{-2.4\baselineskip}\leftbar\textsc{\normalsize{Story~}\thecontentslabel}\\\normalsize\rmfamily}
  {\parbox{14.5em}{% frontmatter
    \hfill\Large\rmfamily\bfseries\thecontentspage}%
   \vspace*{-1.95\baselineskip}\leftbar\normalsize\rmfamily}
  {\endleftbar}
% % %


\makeatletter\@addtoreset{chapter}{part}\makeatother%

\begin{document}

\pagestyle{empty}
\renewcommand*\contentsname{\hfill Contents \hfill}
\tableofcontents%
\thispagestyle{empty}

\frontmatter


\chapter{Introduction}
\chapter{More Intro}

\part{The first part}

\mainmatter


\chapter{First}
\chapter{Second}
\chapter{Third}
\chapter{Fourth}
\chapter{Fifth}


\addtocontents{toc}{\protect\newpage}
\part{Another part}

\chapter{First}
\chapter{Second}
\chapter{Third}
\chapter{Fourth}
\chapter{Fifth}    

\end{document}

Why does PART I split over two lines? The setup is the same for the chapters, yet they don't split over two lines. Also, is it possible to get rid of the bar completely for \part?

enter image description here

2

This looks like some sort of incompatibility between book and titletoc (or rather, a strange design of book)...

What is written to the .toc for the \part is:

\contentsline {part}{I\hspace {1em}The first part}{v}

while for a chapter is:

\contentsline {chapter}{\numberline {1}First}{1}

(notice the \numberline). Then if you add a \show before \thecontentslabel you'll see that it's empty, and the next thing your definition of \titlecontents does is a \\, thus the line is broken just after Part~.

This difference roots form the definitions of \chapter and \part. To fix this you have to inject the \numberline in the definition of \part so that titletoc can detect what is \thecontentslabel, otherwise it will think that the number belongs to the title of the section. Since you're already loading etoolbox you can do:

\makeatletter
\patchcmd\@part
  {\thepart}
  {\protect\numberline{\thepart}}
  {}{\FAIL}
\makeatother

and the output will be:

PART I
The first part

As for the left bar, I propose a rather bodgey solution, to avoid messing up the alignments: define a Hiddenleftbar, identical to the leftbar, but without the rule, and use this one for the \part. The \part entry will still be aligned with the rest of the entries, but will not have the vertical rule.

The output:

enter image description here

Full code:

\documentclass[11pt]{book}

\usepackage[
    paperwidth=8in,
    paperheight=10in,
    inner=0.5in,
    outer=0.5in,
    bindingoffset=0.25in,
    top=0.75in,
    bottom=1.25in,
    twoside,
    %showframe
    ]{geometry} 


% https://tex.stackexchange.com/a/35835/121944, basis of this ToC design
\usepackage{framed}
\usepackage[compact,pagestyles,clearempty]{titlesec}
\usepackage{titletoc}
\usepackage{etoolbox}

\makeatletter
\patchcmd\@part
  {\thepart}
  {\protect\numberline{\thepart}}
  {}{\FAIL}
\makeatother

% % %
\patchcmd{\tableofcontents}{\contentsname}{\rmfamily\contentsname}{}{}

\renewenvironment{leftbar}
  {\def\FrameCommand{\hspace{26.75em}%
    {\vrule width 2pt depth 3pt}\hspace{1em}}%
    \MakeFramed{\parshape 1 0cm \dimexpr\textwidth-6em\relax\FrameRestore}\vskip2pt%
  }
 {\endMakeFramed}

\newenvironment{Hiddenleftbar}
  {\def\FrameCommand{\hspace{26.75em}%
    \hspace{\dimexpr1em+2pt}}%
    \MakeFramed{\parshape 1 0cm \dimexpr\textwidth-6em\relax\FrameRestore}\vskip2pt%
  }
 {\endMakeFramed}

\titlecontents{part}
  [0em]{\vspace*{0.3\baselineskip}}
  {\parbox{14.8em}{% mainmatter
    \hfill\huge\rmfamily\bfseries}%
   \vspace*{-2.4\baselineskip}\Hiddenleftbar\MakeUppercase{\normalsize{Part~}\thecontentslabel}\\\normalsize\rmfamily}
  {\parbox{14.5em}{% frontmatter
    \hfill\Large\rmfamily\bfseries}%
   \vspace*{-1.95\baselineskip}\Hiddenleftbar\MakeUppercase{\normalsize{Part~}\thecontentslabel}\\\normalsize\rmfamily}
  {\endHiddenleftbar}
% % %

\titlecontents{chapter}
  [0em]{\vspace*{0.3\baselineskip}}
  {\parbox{14.8em}{% mainmatter
    \hfill\huge\rmfamily\bfseries\thecontentspage}%
   \vspace*{-2.4\baselineskip}\leftbar\textsc{\normalsize{Story~}\thecontentslabel}\\\normalsize\rmfamily}
  {\parbox{14.5em}{% frontmatter
    \hfill\Large\rmfamily\bfseries\thecontentspage}%
   \vspace*{-1.95\baselineskip}\leftbar\normalsize\rmfamily}
  {\endleftbar}
% % %


\makeatletter\@addtoreset{chapter}{part}\makeatother%

\begin{document}

\pagestyle{empty}
\renewcommand*\contentsname{\hfill Contents \hfill}
\tableofcontents%
\thispagestyle{empty}

\frontmatter


\chapter{Introduction}
\chapter{More Intro}

\part{The first part}

\mainmatter


\chapter{First}
\chapter{Second}
\chapter{Third}
\chapter{Fourth}
\chapter{Fifth}


\addtocontents{toc}{\protect\newpage}
\part{Another part}

\chapter{First}
\chapter{Second}
\chapter{Third}
\chapter{Fourth}
\chapter{Fifth}

\end{document}

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.