I would like to insert some code before the chapter title appears. I have defined:
\newcommand{\toptitle}[2]{\itshape #1 \hfill #2 \par}
Then, if I am writing for example:
\begin{document}
\toptitle{Quantum Mechanics}{15.10.2011}
\chapter{My Chapter}
\end{document}
the chapter title does not appear because this code precedes it. I am using the titlesec package but couldn't find a command to append code before the chapter title. Is it possible?
Best Answer
Without using
titlesec
, you can redefine the\@makechapterhead
command (defined inbook.cls
) which actually typesets the chapter title; you could do something along these lines:Using the
etoolbox
package, the above redefinition can be done in a shorter way: