3

I'm using the code below to redefine my \part style. I want to modify it so that I see "Part I: A Test ... " with \scshape font in the TOC. Right Now, in the TOC I see "I A Test ... ". How should I modify my code?

\documentclass{book}
\usepackage{epigraph}
\usepackage{titlesec}

\makeatletter
\titleformat{\part}[display]
  {\Huge\scshape\filright}
  {\partname~\thepart:}
  {20pt}
  {\thispagestyle{epigraph}}
\makeatother
\setlength\epigraphwidth{.6\textwidth}


\begin{document}

\epigraphhead[450]{Fairy tales are more than true: not because they tell us that     dragons exist, but because they tell us dragons can be beaten.\par\hfill\textsc{C.K. Chesterton}}
\part{A Test Part Title}

\end{document} 
7

Combining and adapting answers to other of your questions (Redefine \part style and \part Heading style) and adding the formatting for the part entries in the ToC, this might be what you're after:

\documentclass{book}
\usepackage[table]{xcolor}
\usepackage{epigraph}

\setlength\epigraphwidth{.6\textwidth}

\makeatletter
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
     \thispagestyle{epigraph}
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\partname~\thepart:\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
  \reset@font
  \parindent \z@ 
  \vspace*{-400\p@}%
  \hbox{%
    \vbox{%
      \hsize=7mm%
      \begin{tabular}{@{}p{7mm}@{}}
        \makebox[7mm]{\scshape\strut\small\partname}\\
        \makebox[7mm]{\cellcolor{black}\Huge\color{white}\bfseries\strut\thepart\rule[-4cm]{0pt}{4cm}}%
      \end{tabular}%
      \makebox(0,0){\put(-10,-100){\fbox{\phantom{\rule[-4cm]{7mm}{4cm}}}}}
      }%
    \kern-2pt
    \vbox to 0pt{%
       \tabular[t]{@{}p{1cm}>{\raggedright\arraybackslash}p{\dimexpr\hsize-2.1cm}@{}}\hline
          & \Huge\itshape\rule{0pt}{1.5\ht\strutbox}#1\endtabular}%
    }%
  \cleardoublepage
%  \vskip 100\p@
}
\makeatother

\begin{document}

\tableofcontents
\cleardoublepage

\epigraphhead[450]{Fairy tales are more than true: not because they tell us that dragons exist, but because they tell us dragons can be beaten.\par\hfill\textsc{C.K. Chesterton}}
\part{A Test Part Title}

\end{document}

The resulting document:

enter image description here

A close-up to the ToC:

enter image description here

Invert the order in which the decorative elements are drawn in the part headings and you can use any color instead of black:

\documentclass[draft]{book}
\usepackage[table]{xcolor}
\usepackage{epigraph}

\setlength\epigraphwidth{.6\textwidth}

\makeatletter
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
     \thispagestyle{epigraph}
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\partname~\thepart:\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
  \reset@font
  \parindent \z@ 
  \vspace*{-400\p@}%
  \hbox{%
    \vbox{%
      \hsize=7mm%
     \makebox(0,0){\put(10,-100){\fbox{\phantom{\rule[-4cm]{7mm}{4cm}}}}}%
     \begin{tabular}{@{}p{7mm}@{}}
        \makebox[7mm]{\scshape\strut\small\partname}\\
        \makebox[7mm]{\cellcolor{gray}\Huge\color{white}\bfseries\strut\thepart\rule[-4cm]{0pt}{4cm}}%
      \end{tabular}%
      }%
    \kern6pt
    \vbox to 0pt{%
       \tabular[t]{@{}p{1cm}>{\raggedright\arraybackslash}p{\dimexpr\hsize-2.55cm}@{}}\hline
          & \Huge\itshape\rule{0pt}{1.5\ht\strutbox}#1\endtabular}%
    }%
  \cleardoublepage
%  \vskip 100\p@
}
\makeatother

\begin{document}

\tableofcontents
\cleardoublepage

\epigraphhead[450]{Fairy tales are more than true: not because they tell us that dragons exist, but because they tell us dragons can be beaten.\par\hfill\textsc{C.K. Chesterton}}
\part{A Test Part Title}

\end{document}

enter image description here

  • This is awesome! Two birds, one stone! Just a question, right now my next page after the \part page is not fully empty. Yours has a number on top, mine has a number and a line. How can I push it to be fully empty? – LatexQuest Jul 24 '14 at 17:50
  • @LatexQuest impossible to tell without seeing the code you are using. How can we know where the line comes from if you don't provide the code that is responsible for it? In any case, loading the emptypage package \usepackage{emptypage} in the preamble might give you what you need. – Gonzalo Medina Jul 24 '14 at 17:54
  • How about a question on your code? Assume I want to use gray color for the upper rectangle instead of black. Then the black lines of the lower rectangle will show up, which wouldn't look nice. Can we set the upper rectangle to appear on a top layer so that the overlapping parts from the lower rectangle disappear? [To see what I mean, simply modify => \cellcolor{gray}. – LatexQuest Jul 24 '14 at 18:56
  • @LatexQuest please see my updated answer. – Gonzalo Medina Jul 24 '14 at 20:07
  • Is it possible to activate line breaks in the \part title? When it is relatively long it starts breaking the words and hyphenating them ... would be nice to be able to put break lines in the middle. – LatexQuest Jul 25 '14 at 7:51

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.