insert text above chapter heading

1,343 views
Skip to first unread message

triniboy

unread,
Nov 18, 2011, 5:59:05 PM11/18/11
to LaTeX Users Group
Hello,

How do I go about inserting text just above the chapter heading? This
is the effect that I would like to achieve:

"This is the start of the best document ever written"

CHAPTER 1
Phase of Life Forms

Blah blah blah...
______________________________________________________________________________

This is the tex file that I have begun writing:


\begin{document}

\begin{minipage}[!h]{1\textwidth}
"This is the start of the best document ever written"
\end{minipage}

\chapter{Phase of Life Forms}
Blah blah blah...

\end{document}


I get the text but then the chapter begins on another page. How can
the chapter heading be on the same page as the text "This is the start
of the best document ever written" before it.

Thanks for your help.

Peter Flynn

unread,
Nov 19, 2011, 8:21:10 AM11/19/11
to latexus...@googlegroups.com

You need to rewrite the definition of \chapterhead to do this, because the \clearpage is embedded in it. I have an example of this on another machine which I will go find.


--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To post to this group, send email to latexus...@googlegroups.com.
To unsubscribe from this group, send email to latexusersgro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/latexusersgroup?hl=en.

Peter Flynn

unread,
Nov 21, 2011, 4:52:25 AM11/21/11
to latexus...@googlegroups.com
On Sat, Nov 19, 2011 at 1:21 PM, Peter Flynn <angleb...@gmail.com> wrote:

You need to rewrite the definition of \chapterhead to do this, because the \clearpage is embedded in it. I have an example of this on another machine which I will go find.

My mistake, it's \@makechapterhead and \@makeschapterhead that need redefining, along with \@chapter and \@schapter, using the additional optional argument provisions of the xargs package. This let you provide a third (optional) argument to put the epigraph in:

\documentclass[12pt]{report}
\usepackage{xargs}
\makeatletter
\renewcommandx{\@chapter}[3][1,3=\relax]{%
  \ifnum \c@secnumdepth >\m@ne
    \refstepcounter{chapter}%
    \typeout{\@chapapp\space\thechapter.}%
    \addcontentsline{toc}{chapter}%
                    {\protect\numberline{\thechapter}#1}%
  \else
    \addcontentsline{toc}{chapter}{#1}%
  \fi
  \chaptermark{#1}%
  \addtocontents{lof}{\protect\addvspace{10\p@}}%
  \addtocontents{lot}{\protect\addvspace{10\p@}}%
  \if@twocolumn
    \@topnewpage[\@makechapterhead{#2}{#3}]%
  \else
    \@makechapterhead{#2}{#3}%
    \@afterheading
  \fi}
\def\@makechapterhead#1#2{%
  \if\relax#2
    \vspace*{50\p@}%
  \else
    \vbox to50\p@{\centering#2\par\vss}\bigskip
  \fi
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
\renewcommandx{\@schapter}[2][2=\relax]{%
  \if@twocolumn
    \@topnewpage[\@makeschapterhead{#1}{#2}]%
  \else
    \@makeschapterhead{#1}{#2}%
    \@afterheading
  \fi}
\def\@makeschapterhead#1#2{%
  \if\relax#2
    \vspace*{50\p@}%
  \else
    \vbox to50\p@{\centering#2\par\vss}\bigskip
  \fi
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}
\makeatother
\begin{document}
\title{Optional epigraph above chapter titles}
\author{}
\maketitle
\tableofcontents
\chapter{A normal chapter title}
Stuff
\chapter{A chapter title with an epigraph above}[Entia non sunt
  multiplicanda pr\ae ter necessitatem~--- William of Occam]

Stuff
\chapter*{An unnumbered chapter}
Stuff
\chapter*{An unnumbered chapter with an epigraph above}[The
  hardest
thing in the world to understand is the Income
  Tax\\\leavevmode\hfill--- Albert Einstein]

\end{document}

///Peter

triniboy

unread,
Nov 21, 2011, 10:24:08 AM11/21/11
to LaTeX Users Group
THANK YOU FOR YOUR HELP AND TIME!!! PERFECT!!!

Lynndle Maasdorp

unread,
Aug 4, 2015, 1:23:35 PM8/4/15
to LaTeX Users Group
Hi all

Could you please give me clue as to which line I would have to amend so that the text I would like to have above my chapter title could be centered?

Peter Flynn

unread,
Aug 4, 2015, 7:59:18 PM8/4/15
to latexusersgroup
On Tue, Aug 4, 2015 at 5:06 PM, Lynndle Maasdorp <lynn...@gmail.com> wrote:
Hi all

Could you please give me clue as to which line I would have to amend so that the text I would like to have above my chapter title could be centered?

I don't understand the question. The example I gave in my first message of 21 Nov 2011 does already center the text. 

P
Reply all
Reply to author
Forward
0 new messages