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.

if you want to include an image in your chapter title, what follows may be an option:

{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\vspace*{-3.9cm}\hspace*{-3.1cm}% to position the figure

then, in the main document, you would call the name of a figure just before the chapter command:


What is the exact role of the first two commands \thechapterimage and \chapterimage above?

share|improve this question

3 Answers 3

up vote 11 down vote accepted

If you have prior programming experience, it may help to think of it this way (although that’s not actually what’s happening):

\thechapterimage is a variable (which stores the image path), and to assign a new value to this variable, you need to write \renewcommand\thechapterimage{some value}.

Now, this is obviously very cumbersome when done repeatedly so we define a shortcut for this “assignment.” The shortcut corresponds to a method (more precisely, a setter method): it gets one parameter and sets the value:


Clearly, this “setter” is executing the same assignment as above. Strictly speaking, you don’t need the \chapterimage macro but it makes the code simpler and clearer.

share|improve this answer
my question to Will was: in what sense \thechapterimage is different from \chapterimage. \thechapterimage is a varaible that can store a path, and then \chapterimage is what? what's inside? –  pluton Sep 8 '10 at 13:11
why cannot we store a path in \chapterimage? –  pluton Sep 8 '10 at 13:12
@pluton: Actually, I had intended to describe precisely that. Well, try again: \chapterimage is not a variable, it’s a method. The code in your comment to Will’s post cannot work for obvious reasons: you declare \chapterimage to take one argument – but in your usage later you use it without specifying arguments. \chapterimage doesn’t “store” anything, as it were. It is just a shortcut for setting the variable. –  Konrad Rudolph Sep 8 '10 at 13:28
\chapterimage is a method, ok, but could it be possible to achieve the same result by using \chapterimage only (no call to \thechapterimage or so)? Thanks –  pluton Sep 8 '10 at 15:52
@pluton: there is none – The names are completely arbitrary (though convention). If it weren’t convention, clearer names might be \thevalueoffoo and \setfoo, respectively. But again, these are just names for the user, they don’t impart any semantics. –  Konrad Rudolph Sep 8 '10 at 17:51

\chapterimage (re)defines \thechapterimage which is used inside \chapter.

share|improve this answer
and why not \newcommand{\chapterimage}[1]{#1} and then includegraphics[width=\paperwidth]{\chapterimage} ? –  pluton Sep 7 '10 at 23:57
That doesn't make sense. Try it and see. –  Will Robertson Sep 8 '10 at 1:53
yes, this is silly (see Konrad's comment) –  pluton Sep 8 '10 at 15:40

You probably mean "why not using directly \renewcommand\thechapterimage{image} in the document instead of the detour with \chapterimage". That is possible too, but it is

  1. longer and
  2. means that a user has to use \renewcommand regularly. Package writer write in such cases often a wrapper command which hides the \def/\renewcommand from the user. Other examples for such wrapper commands are \title and \author.
share|improve this answer

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.