14

How can I customize chapter style like below picture? enter image description here

Thank you in advance.

Jalil
  • 471

2 Answers2

25

One possibility, using TikZ and the epigraph package; the rounded corner rectangle on top was produced using the pgf library qrr.shapes.openrectangle written by Qrrbrbirlbel in his answer to Tikz shape similar to rectangle with selective drawing of borders (the link to the library can be found in the answer linked):

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{fourier}
\usepackage{tikz}
\usepackage{epigraph}
\usepgflibrary{qrr.shapes.openrectangle}

\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\definecolor{myblueiii}{RGB}{199,234,253}

\tikzset{
mynode/.style={
  rounded corners=30pt,
  shape=open rectangle,
  open rectangle fill=myblueii,
  open rectangle sides=#1,
  }
}

\titleformat{\chapter}[display]
  {\normalfont\huge\sffamily}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
  \node[
    anchor=west,
    rectangle,
    minimum height=4cm,
    text width=\paperwidth,
    xshift=-\the\dimexpr\oddsidemargin+1in\relax,
    outer sep=0pt,
    fill=myblueiii] (titlerect) {};
  \node[
    anchor=south west,
    xshift=2cm,
    text width=\textwidth] 
    at ([yshift=5pt]titlerect.south west) {\fontsize{30}{36}\selectfont#1};
  \node[
    mynode=nw,
    anchor=south east,
    fill=myblueii,
    inner xsep=1.5cm,
    outer sep=0pt,
    font=\color{white},
    minimum height=30pt] 
    at (current page.east|-titlerect.north)
     {\bfseries\MakeUppercase{\chaptertitlename}\ \thechapter};
  \end{tikzpicture}%
  }
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\huge\sffamily}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
  \node[
    anchor=west,
    rectangle,
    minimum height=4cm,
    text width=\paperwidth,
    xshift=-\the\dimexpr\oddsidemargin+1in\relax,
    outer sep=0pt,
    fill=myblueiii] (titlerect) {};
  \node[
    anchor=south west,
    xshift=2cm,
    text width=\textwidth] 
    at (titlerect.south west) {\Huge#1};
  \end{tikzpicture}%
  }
\titlespacing*{\chapter}
  {0pt}{-20pt}{60pt}

\setlength\beforeepigraphskip{1.5\baselineskip}
\setlength\afterepigraphskip{2\baselineskip}
\setlength\epigraphwidth{6.8cm}
\setlength\epigraphrule{0pt}
\renewcommand\epigraphsize{\large}
\renewcommand\textflush{flushright}

\let\oldepigraph\epigraph \renewcommand\epigraph[2]{%
  \oldepigraph{\color{mybluei}\itshape #1}{#2}}


\begin{document}

\chapter{From the Ground Up!}
\epigraph{In theory there is no difference \\ between theory and practice. \\ In practice there is.}{Lawrence ``Yogui'' Berra,1925 \\ New York Yankees baseball player}
\chapter*{A test unnumbered chapter}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • 2
    +1 very nice! It might be nice to make the epigraph command format automatically, perhaps using \let\oldepigraph\epigraph\renewcommand{\epigraph}[2]{\oldepigraph{\color{mybluei}\itshape #1}{#2}} – cmhughes Feb 13 '14 at 22:38
  • @cmhughes Thanks! You're right about \epigraph; I've incorporated the suggestion to my answer. – Gonzalo Medina Feb 13 '14 at 23:24
  • 3
    You love doing chapter designs right? Looks gr8 by the way. I will study your code to make some improvements on my own. – azetina Feb 13 '14 at 23:39
  • 1
    @azetina Thanks. You're right, I can't resist a question about sectional units design :-) – Gonzalo Medina Feb 13 '14 at 23:42
  • i wrote a tikz code for upper right rounded corner box beacause i dont want to use \usepgflibrary{qrr.shapes.openrectangle} – Jalil Feb 15 '14 at 15:11
  • @Jalil Great! Yes, using your method you can avoid using the library. Well done! – Gonzalo Medina Feb 15 '14 at 15:31
  • For network stumblers, to use \usepgflibrary{qrr.shapes.openrectangle} check http://tex.stackexchange.com/questions/187193/how-to-install-tikz-pgf-libraries – Konstantinos Mar 27 '15 at 22:18
  • @GonzaloMedina please i use this but i have an error message: Command \widering already defined – Vrouvrou Aug 15 '17 at 21:19
3

'I wrote a tikz code for upper right rounded corner box because i don't want to use

\usepgflibrary{qrr.shapes.openrectangle}

this is my code:

\documentclass{book}

\usepackage{tikz}
\usetikzlibrary{positioning,calc,backgrounds}
\definecolor{mybluei}{RGB}{0,173,239}

\newcommand{\newtab}[2]{%
\begin{tikzpicture}
    \node[inner sep=2mm,text=white] (#1) {#2};
    \begin{scope}[on background layer]
        \draw[fill=mybluei] 
        ($ (#1.north east) $) 
        --($ (#1.north west) $)
        to[out=180,in=90]  ([xshift=-1cm]$(#1.south west) $)
          -- ($ (#1.south east) $)
          -- cycle;
    \end{scope}
\end{tikzpicture}% 
}

\begin{document}
\newtab{test}{CHAPTER 1}
\newtab{test}{This is another test} 
\newtab{test}{This is yet another test}
\end{document}

enter image description here

Jalil
  • 471
  • +1. To avoid extra (two possibly undesired blank spaces) add % just after the opening brace in the definition, as in \newcommand{\newtab}[2]{% and after \end{tikzpicture}, as in \end{tikzpicture}%. – Gonzalo Medina Feb 15 '14 at 15:33
  • @GonzaloMedina, when the font size is larger in the box, then we have a box with larger height. I want to calculate the height of the box to obtain radius of circle precisely. I used "let" and "in" tikz commands: let \p= ($ (#1.north) - (#1.south) $) in arc(90,180,{\veclin(\x,\y)} but i countered with an error. – Jalil Feb 15 '14 at 16:45
  • You can measure the height + depth of a string using some lengths and \settoheight and \settodepth: \newlength\StrHt \newlength\StrDp \settoheight\StrHt{\Huge Abcp} \settodepth\StrDp{\Huge Abcp} \addtolength\StrHt{\StrDp}; after this,\StrHthas the total height (height+depth) of the string Abcp in\Huge` size. If you have additional doubts, please consider opening a fresh new question. – Gonzalo Medina Feb 15 '14 at 17:08