Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
I would try combination of titlesec and TikZ. –  krnk Jun 6 at 13:08

1 Answer 1

up vote 8 down vote accepted

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

share|improve this answer
    
The following error is raised: 'You can't use `\dimexpr' in restricted horizontal mode \chapter*{Test unnumbered chapter}'. –  pushpen.paul Jun 7 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. –  Gonzalo Medina Jun 9 at 0:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.