Featured Post

We've moved to tex.my!

It’s been great writing on Blogger.com, but we’ve decided to move to a new platform, thanks to some valuable help from a great, great friend...

Saturday, November 7, 2009

Fancy Chapter Headings


If you look at my post that started this series, you might notice that the first page of every chapter in the Grid Computing Cluster report is rather fancy. I've initially got my inspirations from Stefan Kottwitz's post on 'Fancy chapter headings with TikZ'.

Here are the samples of how the chapter pages would look like:





(Download links of the .tex source files are at the end of this post)

The chapter number and title are rendered with TikZ, similar to what's described in Stefan Kottwitz's post. I threw in a background image across the top of the page, and another one at the lower corner, using the wallpaper package.

Just so we can choose a different image for every chapter, I defined a new command that holds the image filename (\newcommand\chapterillustration{}) and re-define it at each chapter (\renewcommand\chapterillustration{cherry-tomatos}).

Notice that the positioning of the chapter title and the fern leaf background image is different depending on whether the chapter starts on an odd or even page. The memoir document class provides the commands \checkoddpage and \ifoddpage...\else\...\fi, so that you can define what to do in each case.  Don't worry if you're not using the memoir document class, these commands are also available via the changepage package.

Now to actually implement these definitions. The memoir document class lets you define chapter styles (e.g. \makechapterstyle{FancyChap}{\def\printchaptertitle##1{...}} see the manual on "Chapter Headings" for more details) in the preamble, which you would activate in the document body with \chapterstyle{FancyChap}.

On the other hand, if you're not using the memoir document class, use the \titleformat and \titlespacing commands from the titlesec package instead.

Sorry I'm too tired to even post relevant snippets; here are the links to the .tex sources to produce the sample pages above. I've incorporated the code for Changing page size and sizes, too. (By the way I used the lipsum package to generate the dummy text. You know, Lorem ipsum dolor sit amet...)
The sample public domain images are from here (cherry tomatos), here (computer chips) and here (fern leaf).

5 comments:

  1. ThisULCornerWallPaper the command does not work.
    which version of the wallpaper package that you are using?

    ReplyDelete
  2. Régis, I'm using

    Package: wallpaper 2005/01/18, v1.01

    Did you get any error/warning messages, or did the wallpaper just not appear? How about the other commands (\ThisLLCornerWallPaper, \ThisLRCornerWallPaper...), do they work for you?

    ReplyDelete
  3. Indeed it doesn't recognize wallpaper commands...
    like ThisULCornerWallPaper e.t.c

    ReplyDelete
  4. Hmmm. Curious. Régis and Dimitris, could you try running this minimal example to see if the wallpaper package works for you at all?

    \documentclass{article}
    \usepackage{wallpaper}
    \begin{document}
    \ThisULCornerWallPaper{1}{SomePic}
    Blah blah blah.
    \end{document}

    Could you post the error or warning messages, as well as the version number of your wallpaper package?

    ReplyDelete
  5. After checking on MikTeX 2.9, I found that its wallpaper.sty is v2.4; while my example requires wallpaper.sty 2.5 to work. So if you're using MikTeX, grab the latest package manually from http://tug.ctan.org/tex-archive/macros/latex/contrib/wallpaper/ :-)

    ReplyDelete