# \part Heading style

I'm using \documentclass{book}. I like to redefine my \part style to sth similar to the one in the picture below. So, I like when I use part I get sth similiar to pic below with "Part" instead of chapter on top and a gray rectangle with a number inside. Any ideas how to do that?

• This is possibly generated by titlesec package – user31729 Jul 23 '14 at 19:39
• Christian, can you give me a MWC?! – LatexQuest Jul 24 '14 at 8:29
• I am sorry, but I don't know MWC. If you mean an example, both Herbert and Bernard provided nice answers, I can't top at all – user31729 Jul 24 '14 at 12:05

\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[table]{xcolor}
\makeatletter
%\renewcommand\thepart{\arabic{part}}
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
\else
\fi
\markboth{}{}%
\reset@font
\parindent \z@
\vspace*{10\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}p{\dimexpr\hsize-2.1cm}@{}}\hline
& \Huge\itshape\rule{0pt}{1.5\ht\strutbox}#1\endtabular}%
}%
\cleardoublepage
%  \vskip 100\p@
}
\makeatother

\begin{document}
\part{Books in \LaTeX}

\end{document}


• very nice! I like it a lot. But, I want to be a bit different. 1) Right now in the TOC, I get "I Part I: ..." whereas it should be "Part I: ..." the first number should be dropped. 2) The next page after the part should also be fully empty, right now I get a header line with a number. It should be just a number in the middle of the page and fully empty. 3) I do like to add a quote after the title of part in the same page. Can we pull the heading a bit higher and then add epigraph below that? Thanks a lot! – LatexQuest Jul 24 '14 at 9:30
• did you see my question? I appreciate if you help on that. – LatexQuest Jul 24 '14 at 16:47

Another solution using the ebgaramond font and its lettrine initials. I've tried to make the code as generic as possible, but some parameters (used in raisebox mainly) may depend on the font. I also tried to make the result as close as possible to the O.P.'s picture, plus some colour. The formatting of part titles is made with titlesec.

Added: I managed to add epigraphs on part pages, with the environ and etoolbox packages. The command to be used is \thispartepigrah{text}{source}. It set a boolean withepi to true that allows an epigraph to be displayed as an optional argument to \titleformat, then resets withepi to false. The epigraph command itself is captured through a fake environment, PartEpigraph.

    \documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage[garamond]{mathdesign}
\usepackage{garamondx}%%
\usepackage[x11names]{xcolor}
\usepackage{graphicx}
\usepackage{etoolbox}
\usepackage{epigraph}
\usepackage{environ}

\setlength\epigraphwidth{0.5\linewidth}
\newbool{withepi}
\NewEnviron{PartEpigraph}
{\global\let\mypartepigraph\BODY}%
\newcommand\thispartepigraph[2]{%
\setbool{withepi}{true}%
\begin{PartEpigraph}
\epigraph{#1}{#2}
\end{PartEpigraph}}%

\usepackage{geometry}
\usepackage{titlesec}%[newparttoc]
\usepackage{lettrine}
\renewcommand\LettrineFontHook{\fontfamily{EBGaramondInitials-TLF}\color{titlecolour}}
%

\setlength\fboxrule{0.6pt}
\colorlet{titlecolour}{DarkSeaGreen4!80}
\newlength\labelframewd
\settowidth{\labelframewd}{~\footnotesize\textsc{part}~}

\newsavebox\partlabelbox%

\newcommand\partlabel{%
\makebox[0pt]{\fcolorbox{titlecolour}{titlecolour}{%
\raisebox{8.4ex}[0pt]{\rlap{\hspace{-\fboxsep}\resizebox*{\dimexpr\labelframewd+2\fboxsep\relax}{!}{\color{titlecolour}\lsstyle\scshape\scriptsize{part}}}}%
\usebox{\partlabelbox}}}
\hskip-\fboxsep\color{titlecolour}{\raisebox{-9ex}{\fbox{\phantom{\usebox{\partlabelbox}}}}}
}%

\titleformat{\part}[display]{}
{%
\sbox{\partlabelbox}{\raisebox{0pt}[7ex][27ex]{\resizebox{\labelframewd}{!}{\hfill\color{white}{\arabic{part}}\hfill}}}
\smash{\partlabel}}%
{6ex}
{\thispagestyle{empty}{\color{titlecolour}\titlerule[\fboxrule]}\vskip2.5ex\hspace*{3\labelframewd}\fontsize{32}{40}\itshape}%
[\ifbool{withepi}{\vspace{4\baselineskip}\mypartepigraph\global\setbool{withepi}{false}}{}]

\titlespacing{\part}{0pt}{1.25\baselineskip}{10\baselineskip}
\renewcommand*\thepart{\arabic{part}}

\begin{document}

\thispartepigraph{For the Snark \emph{was} a Boojum,  you see.}{Lewis Carroll     --- \emph{The Hunting of the Snark}}

\part{Books in \LaTeX}

\lettrine{T}{ext} text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.

\end{document}


• Thanks! I actually need a \part style not a \chapter style. I need the heading design on top of the page as you gave and an epigraph below that, not text on that page and of course another fully empty page after that. Could you please modify it that way? – LatexQuest Jul 24 '14 at 16:50
• @LatexQuest: I updated my answer to a part instead of a chapter, and also the possibilty of epigraphs, to be introduced with a thispartepigraph{…}{…} command just before \part{…}. – Bernard Jul 26 '14 at 23:13