8

I know that designing fancy things under latex can sometimes be very difficult. I've designed the following model under powerpoint in 5 minutes, and now I would like to achieve this with latex (I have to use the book class for my document, but I can use all existing package).

So here is the challenge:

Chapter image

How to do the same thing for my latex document?

16

Here's one possibility:

\documentclass{book}
\usepackage[margin=1.5cm,a5paper]{geometry}
\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\usepackage{tikz}
\usepackage{epigraph}
\usepackage{xpatch}
\usepackage{lmodern}
\usepackage{lipsum}

\newlength\ChapWd
\settowidth\ChapWd{\huge\chaptertitlename}

\definecolor{myblue}{RGB}{0,0,122}

\titleformat{\chapter}[display]
  {\normalfont\filcenter\sffamily}
  {\tikz[remember picture,overlay]
    {
    \node[fill=myblue,font=\fontsize{60}{72}\selectfont\color{white},anchor=north east,minimum size=\ChapWd] 
      at ([xshift=-15pt,yshift=-15pt]current page.north east) 
      (numb) {\thechapter};
    \node[rotate=90,anchor=south,inner sep=0pt,font=\huge] at (numb.west) {\chaptertitlename};
    }
  }{0pt}{\fontsize{33}{40}\selectfont\color{myblue}#1}[\vskip10pt\Large***]
\titlespacing*{\chapter}
  {0pt}{50pt}{10pt}


\makeatletter
\xpatchcmd{\ttl@printlist}{\endgroup}{{\noindent\color{myblue}\rule{\textwidth}{1.5pt}}\vskip30pt\endgroup}{}{}
\makeatother

\newcommand\DoPToC{%
\startcontents[chapters]
\printcontents[chapters]{}{1}{\noindent{\color{myblue}\rule{\textwidth}{1.5pt}}\par\medskip}%
}

\setlength\epigraphrule{0pt}
\renewcommand\textflush{flushright}
\renewcommand\epigraphsize{\normalsize\itshape}

\begin{document}

\chapter{Title of the first chapter}
\epigraph{A brainy quote -- Its Author}{}
\DoPToC
\lipsum[4]
\section{A test section}
\lipsum[4]
\subsection{A test subsection}
\lipsum[4]
\subsection{A test subsection}
\lipsum[4]
\section{Another test section}
\lipsum[4]
\section{Yet another test section}
\lipsum[4]
\subsection{A test subsection}
\lipsum[4]
\subsection{A test subsection}
\lipsum[4]

\chapter{Title of the second chapter}
\DoPToC
\lipsum[4]
\section{A test section}
\lipsum[4]
\subsection{A test subsection}
\lipsum[4]
\subsection{A test subsection}
\lipsum[4]
\subsection{A test subsection}
\lipsum[4]
\section{Another test section}
\lipsum[4]
\subsection{A test subsection}
\lipsum[4]
\subsection{A test subsection}
\lipsum[4]

\end{document}

enter image description here

  • The formatting for the chapter headings was produced using the titlesec and TikZ packages.

  • The partial ToCs (with the decorative rules) were obtained using the titletoc package. Simply calling \DoPToC after \chapter{...} produces the partial ToC and its rules.

  • The epigraph package was used for the epigraphs.

  • Is it possible to adjust spacing of the letters of "Chapter" in the corner in order to have the same height as the box ? – Vincent Jul 6 '13 at 15:38
  • @Vincent please see my updated answer. – Gonzalo Medina Jul 6 '13 at 16:06
  • @Vincent You're welcome! I'm glad I could help. – Gonzalo Medina Jul 6 '13 at 16:28
  • Last question: what is the exact role of xpatch ? – Vincent Jul 6 '13 at 16:30
  • 1
    @Vincent in order to automatically obtain the blue rule after the partial ToC I had to patch the internal command \ttl@printlist (from titletoc). The patching was done using \xpatchcmd from the xpatch package. – Gonzalo Medina Jul 6 '13 at 16:32

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.