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'm trying to make a chapter header style to mimic the image as follows:

enter image description here

I've got the following code currently, but not sure how to get the line in the middle, and the title of the chapter to be below the chapter number.

\documentclass{book}
\usepackage{titlesec, blindtext, color}

\usepackage{titlesec}
\titleformat{\chapter}{\Huge}{\Large CHAPTER \Huge\thechapter\newline}{0pt}{\Huge}

\begin{document}
    \chapter{Turing Machines}
\end{document}

Also related to this task: I'd like to know if there's any way to selectively customize the font of a section header without having to change the default font of the whole document. I'm using pdflatex on Windows via MiKTeX, and one package I tried - I forget the name of it now, but I think it might have been fontspec - wouldn't work with pdflatex.

share|improve this question
    
fontspec only works with XeTeX and LuaTeX. –  Sašo Živanović Jan 29 '13 at 22:18

2 Answers 2

I have a little code that I took from a German website some times ago (I can not find it to reference sadly). With a little modification it is partially similar to what you are looking for. Maybe it can be a good starting point:

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{xcolor}
\colorlet{chapter}{cyan}

\addtokomafont{chapter}{\color{chapter}}

\makeatletter
\renewcommand*{\chapterformat}{
  \begingroup
  \setlength{\unitlength}{1mm}
    \begin{picture}(40,30)(0,5)
        \setlength{\fboxsep}{0pt}
        \put(0,15){\line(1,0){\dimexpr
                \textwidth-1\unitlength\relax\@gobble}}
            \put(40,15){\makebox(\dimexpr
            \textwidth-20\unitlength\relax\@gobble,\ht\strutbox\@gobble)[l]{
            \ \normalsize\color{cyan}\chapapp~\thechapter\autodot
          }}
    \end{picture}
  \endgroup
}
\makeatother

\begin{document}
    \chapter{Alan Turing}
\end{document}

enter image description here

share|improve this answer
    
It does indeed look similar, but one big difference is the fact that the line doesn't extend to the edge of the page; it only reaches the margins. I'll see if I can get it working though, since it is pretty close. –  agent154 Jan 30 '13 at 1:27
    
@agent154, You are right! I didn't pay attention to the line. But again, I thought it's close enough and can be a starting point. cheers. –  Pouya Jan 30 '13 at 8:54
up vote 0 down vote accepted

I ended up doing this through usage of tikz.

Ignore the text - that's a work in progress, as well as the formatting for it all. But I got the chapter header just how I wanted it, which after playing around turned out to be a bit different than the image above.

enter image description here

\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\usepackage{tikz}

\titleformat{\chapter}
  {\normalfont\sffamily\Huge\scshape}
  {}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=cyan] (0,-1) rectangle
          (\paperwidth,3cm);
        \node[anchor=west,xshift=.21\paperwidth,yshift=-.01\paperheight,rectangle]
              {\color{white}\LARGE CHAPTER \Huge\thechapter};
        \node[anchor=west,xshift=.21\paperwidth,yshift=-.065\paperheight,rectangle]
              {\color{cyan}\Huge\MakeUppercase{#1}};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }
\titlespacing*{\chapter}{0pt}{50pt}{0pt}

\begin{document}
    \chapter{Test}
\end{chapter}

I'm using a custom made class file, so I only included what I think is the bare minimum to get the heading to show... it won't ultimately look exactly like in this image with the spacing and other text positioning.

share|improve this answer

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.