Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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} 
share|improve this question

1 Answer 1

up vote 7 down vote accepted

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

share|improve this answer
    
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 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 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 at 18:56
    
@LatexQuest please see my updated answer. –  Gonzalo Medina Jul 24 at 20:07
    
Thank you so much! –  LatexQuest Jul 24 at 20:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.