TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please consider the following code:


   paperwidth=216mm, paperheight=303mm,
   left=23mm,  %% or inner=23mm
   right=18mm, %% or outer=18mm
   top=23mm, bottom=23mm,

%% Command to hold chapter illustration image

%% Define how the chapter title is printed
%% Background image at top of page
%% Draw a semi-transparent rectangle across the top
\tikz[overlay,remember picture]
  (current page.north west) rectangle 
  ([yshift=-3cm] current page.north east);
  %% Check if on an odd or even page
  %% On odd pages, "logo" image at lower right
  %% corner; Chapter number printed near spine
  %% edge (near the left); chapter title printed
  %% near outer edge (near the right).
    \begin{tikzpicture}[overlay,remember picture]
    \node[anchor=south west,
      at (current page.north west) 
      {\chaptername\ \thechapter};
      inner ysep=12pt, inner xsep=20pt,
      rounded rectangle,anchor=east, 
      at (current page.north east) {#1};
  %% On even pages, "logo" image at lower left
  %% corner; Chapter number printed near outer
  %% edge (near the right); chapter title printed
  %% near spine edge (near the left).
  \else {
    \begin{tikzpicture}[overlay,remember picture]
    \node[anchor=south east,
      at (current page.north east)
      {\chaptername\ \thechapter};
      inner sep=12pt, inner xsep=20pt,
      rounded rectangle,anchor=west,
      at ( current page.north west) {#1};

\chapter{First Chapter}

\chapter{Second Chapter}


Problem: On compiling with pdflatex, the output PDF contains "image2" only - for both chapter headings.

i.e. The code section:

\chapter{First Chapter}

\chapter{Second Chapter}

is producing "image2" for both the Chapters.

Please help me with this issue.

share|improve this question
up vote 7 down vote accepted

This is caused by the asynchronous behaviour of TeX: Your images are placed when pages are built, which happens well after typesetting. If you insert a \newpage in front of \renewcommand\chapterillustration{image2}, the problem goes away.

share|improve this answer
Thanks, it works. But I can't insert blank new pages in the book, after every Chapter. Can't we have some another solution for this? – Sandeep Singh Aug 25 '12 at 8:27
I haven't studied your layout in detail, but I had assumed that, when you make chapter illustrations part of the page layout, that you do want each chapter to start on a new page? If this is not so, then I am confused as to what you are trying to accomplish. – Harald Hanche-Olsen Aug 25 '12 at 8:30
Sorry, I misunderstood your point. Your fix is fine. – Sandeep Singh Aug 25 '12 at 8:37

Maybe a uglier solution but you get rid of the \newpage:

Change the following lines in your preamble

%% Command to hold chapter illustration image
\expandafter\newcommand\csname chillu\roman{chapter}\endcsname{#1}}

%% Define how the chapter title is printed
%% Background image at top of page
\ThisULCornerWallPaper{1}{\csname chillu\roman{chapter}\endcsname}

and use it like this in your document:

\chapter{First Chapter}

\chapter{Second Chapter}
share|improve this answer
If you use \roman instead of \alph you won't run out of numbers ;-) – Stephan Lehmke Aug 25 '12 at 9:42
@StephanLehmke Good point. I wasn't aware that the romans foresightedly designed their numeral system compatible with the name conventions of TeX macros. – periswon Aug 25 '12 at 10:28
leads to compilation error:File `\chillui .mps' not found – Sandeep Singh Aug 25 '12 at 13:43
Did you take into account that you have to switch the order of \chapter and \chapterillustration in your original code? When I use \chapterillustration before \chapter I get the same error. – periswon Aug 25 '12 at 14:43
@periswon:Thanks for your kind help. I want to share this will all of you:stackoverflow.com/questions/491904/…. Setting: \documentclass[oneside]{book} removes ALL the Blank Pages from the Book :) – Sandeep Singh Aug 25 '12 at 14:58

Your Answer


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.