4

The mini-document

\documentclass[12pt,openany,oneside]{book}
\usepackage{titletoc}
\usepackage{lipsum}
\titlecontents{part}[3pc]{\addvspace{3pc}\filcenter}
{\sffamily\bfseries PART \thecontentslabel\\*[.2pc]\large}
{\sffamily\bfseries\large}{}[\addvspace{.5pc}]


\title{Title}
\date{}
\author{pythonee}

\begin{document}
\maketitle

\frontmatter
\tableofcontents
\chapter{Front One}
\lipsum[1]

\mainmatter
\part{Introduction}
\chapter{history}
\lipsum

\backmatter
\chapter{Back One}
\lipsum[1]

\end{document} 

The Toc output look like: output

Now I want to make the space between \frontmatter and \mainmatter equals to \frontmatter and\mainmatter` in Toc.

By the way. Why the PART doesn't display in TOC. I have customized it with titletoc.

vertical spaces between chapter should be compact

2
  • I don't understand your first request; can you please explain in more detail what you want to achieve? Commented May 4, 2012 at 1:36
  • @GonzaloMedina In simple terms, just for this case. I want to add spaces between 1 history and Back One. I want to make it equals to the space between Front one and "I Introduction".
    – pythonee
    Commented May 4, 2012 at 2:03

1 Answer 1

6

For the second issue, you need to use the newparttocpackage option for titlesec and \titleformat for \part to make \titlecontents{part}... behave as expected (I find this somehow surprising; using scrbook instead of book this is not necessary, so I don't know if this was intentional by design).

For the spacing issue, you can redefine \backmatter as implemented in book.cls to add the desired vertical space.

Now that an additional request has been made in a comment to this answer, you can use \titlecontents to format the chapter entries.

Here's a complete example:

\documentclass[12pt,openany,oneside]{book}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc}
\usepackage{lipsum}

\titleformat{\part}[display]
  {\centering\Huge\bfseries}{\partname~\thepart}
  {1em}{\normalfont\bfseries}

\titlecontents{part}[3pc]{\addvspace{3pc}\filcenter}
  {\sffamily\bfseries\MakeUppercase{\partname}~\thecontentslabel\\*[.2pc]\large}
  {\sffamily\bfseries\large}{}[\addvspace{3pc}]

\titlecontents{chapter}[0em]{}
  {\bfseries\chaptername~\thecontentslabel\hspace{1em}}
  {\bfseries}
  {\hfill\bfseries\contentspage}

\makeatletter
\renewcommand\backmatter{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \addtocontents{toc}{\protect\addvspace{3pc}}
  \@mainmatterfalse}
\makeatother

\title{Title}
\date{}
\author{pythonee}

\begin{document}
\maketitle

\frontmatter
\tableofcontents
\chapter{Front One}
\lipsum[1]

\mainmatter
\part{Introduction}
\chapter{history}
\lipsum
\chapter{Some more history}
\lipsum

\backmatter
\chapter{Back One}
\lipsum[1]

\end{document}

enter image description here

6
  • Thank you for your answer, But if I can do this in my own style file, I think that would be better idea. I don't want to add toc line one by one. And How can I make 1 history to chapter 1 history.
    – pythonee
    Commented May 4, 2012 at 2:51
  • @pythonee please see my updated answer. Commented May 4, 2012 at 3:05
  • Yes, I want to add the vertical spacing. And your output is really what I want. But I think if I can remove **\addtocontents{toc}{\protect\addvspace{3pc}} **. And add vertical spacing between \mainmatter and \backmatter on my style file. That will be better.
    – pythonee
    Commented May 4, 2012 at 3:09
  • @pythonee: answer updated. Is it something like that what you want? Commented May 4, 2012 at 3:16
  • Misunderstanded. I have updated my question. The chapters in one part should be compact.
    – pythonee
    Commented May 4, 2012 at 3:29

You must log in to answer this question.

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