4

I am trying to define a custom chapter style like this one (\documentclass{book}):

The closest I found is to use

\usepackage[Glenn]{fncychap}

which produces:

I have created the picture in an image editor, so ignore fonts.

1
  • I would try combination of titlesec and TikZ.
    – a user
    Jun 6, 2014 at 13:08

1 Answer 1

8

One option using titlesec and TikZ:

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{tikz}

\titleformat{\chapter}[display]
  {\normalfont\Large\bfseries}
  {}
  {0pt}
  {%
    \begin{tikzpicture}
    \node[draw,thick,rounded corners=15pt,,text width=\the\dimexpr\textwidth-12pt\relax,inner ysep=10pt]
      (chaptitle) 
      {%
        \\\parbox{3cm}{\centering\Huge \thechapter}%
        \parbox{\dimexpr\linewidth-3cm\relax}{#1}%
      };
    \node[anchor=west,fill=white] 
      at ([xshift=15pt]chaptitle.north west) {\chaptertitlename};
    \end{tikzpicture}%
  }
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\Large\bfseries}
  {}
  {0pt}
  {%
    \begin{tikzpicture}
    \node[draw,thick,rounded corners=15pt,,text width=\the\dimexpr\textwidth-12pt\relax,inner ysep=10pt]
      (chaptitle) 
      {#1};
    \end{tikzpicture}%
  }

\begin{document}

\chapter*{Test unnumbered chapter}
\chapter{Test numbered chapter}

\end{document}

An image for an un numbered chapter:

enter image description here

An image for a numbered chapter:

enter image description here

2
  • The following error is raised: 'You can't use `\dimexpr' in restricted horizontal mode \chapter*{Test unnumbered chapter}'.
    – hola
    Jun 7, 2014 at 12:39
  • 1
    @pushpen.paul You need to update your packages (specially PGF/TikZ to version 3.10). In the meantime I changed the code and this new version should work with old versions of TikZ. Jun 9, 2014 at 0:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .