[Tex/LaTex] Custom chapter template

chaptersfncychap

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.

Best Answer

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

Related Question