place image above chapter heading

229 views
Skip to first unread message

triniboy

unread,
Dec 9, 2011, 10:15:12 AM12/9/11
to LaTeX Users Group
How do I go about placing an image above the chapter heading:

\documentclass[10pt]{report}
\usepackage{amsmath,amssymb,amsfonts} % Typical maths resource
packages
\usepackage{graphics}
\usepackage{graphicx} % Packages to allow inclusion of
graphics
\usepackage{color} % For creating coloured text and
background
\usepackage{hyperref} % For creating hyperlinks in
cross references
\usepackage{fancyhdr}
\usepackage{textcomp}
\usepackage{subfigure}
%\usepackage{pstricks}
\usepackage{shapepar}
\usepackage{chapterbib}
\usepackage[normalem]{ulem}
\usepackage{array}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{picins}
\usepackage{makeidx}

\parindent 1cm
\topmargin -1.20cm \oddsidemargin 0.5cm \evensidemargin 0.5cm
\textwidth 15cm \textheight 23.5cm \headsep .4cm

\makeatletter
\def\thebibliography#1{\chapter*{{References}\@mkboth
{REFERENCES}{REFERENCES}}\list
{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin
\labelwidth
\advance\leftmargin\labelsep
\usecounter{enumi}}
\def\newblock{\hskip .11em plus .33em minus .07em}
\sloppy\clubpenalty4000\widowpenalty4000
\sfcode`\.=1000\relax}
\makeatother

\title{{\LARGE{\bf{PHASE-LOCKED LOOP}}\\
{\LARGE{\bf{FUNDAMENTALS}}}}}

\author{\it{by}\vspace{1cm}\\
{\bfseries\itshape{Superstar}}\\
{\small \copyright \ Date $15^{th}$ April 2009}}

\setcounter{tocdepth}{2}

\date{}

\makeindex

\begin{document}

%[would like to place image here]

\chapter*{This is where it all beings}
Text text text text text text text text text
text text text text text text text text
text text text text text text text text

\end{document}

Peter Flynn

unread,
Dec 9, 2011, 6:45:30 PM12/9/11
to latexus...@googlegroups.com
On Fri, Dec 9, 2011 at 3:15 PM, triniboy <rbsi...@gmail.com> wrote:
How do I go about placing an image above the chapter heading:

Rewrite the definition of \chapter and its associated macros to let you specify
\chapter{This is where it all begins}[start] (example below).

You seem to have misunderstood rather a lot about LaTeX, though:

\documentclass[10pt]{report}
\usepackage{amsmath,amssymb,amsfonts}
%\usepackage{graphics} % This package is obsolete: remove it
\usepackage{graphicx}
\usepackage{color} % This package is obsolete: replace it with xcolor
\usepackage{hyperref} % This package must always come last

\usepackage{fancyhdr}
\usepackage{textcomp}
\usepackage{subfigure}
%\usepackage{pstricks}
\usepackage{shapepar}
\usepackage{chapterbib}
\usepackage[normalem]{ulem}
\usepackage{array}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{picins}
\usepackage{makeidx}

\parindent 1cm
% Don't do this, use the geometry package

\topmargin -1.20cm \oddsidemargin 0.5cm \evensidemargin 0.5cm
\textwidth 15cm \textheight 23.5cm \headsep .4cm

\makeatletter
% Don't need this, use \renewcommand{\bibname}{References} instead

   \def\thebibliography#1{\chapter*{{References}\@mkboth
     {REFERENCES}{REFERENCES}}\list
     {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin
\labelwidth
   \advance\leftmargin\labelsep
   \usecounter{enumi}}
   \def\newblock{\hskip .11em plus .33em minus .07em}
   \sloppy\clubpenalty4000\widowpenalty4000
   \sfcode`\.=1000\relax}
   \makeatother
% Yuck. All-caps titles are not nice. \bf is obsolete, use \textbf instead

\title{{\LARGE{\bf{PHASE-LOCKED LOOP}}\\
{\LARGE{\bf{FUNDAMENTALS}}}}}
% \it is obsolete, use \textit instead

\author{\it{by}\vspace{1cm}\\
{\bfseries\itshape{Superstar}}\\
% Don't put the copyright and date in the author
{\small \copyright \  Date $15^{th}$ April 2009}}
% move this line away from \author and \title, it's confusing
\setcounter{tocdepth}{2}
% put the copyright and author here. AVOID superscript ordinals (looks like Word)
\date{\copyright\ 15th April 2009}
% Move this line away from the author and date, it's confusing

\makeindex

\begin{document}

%[would like to place image here]
% Why is the chapter unnumbered?

\chapter*{This is where it all beings}
Text text text text text text text text text
text text text text text text text text
text text text text text text text text

\end{document}

Anyway, here's an example of a redefined \chapter that lets you add an image. The important bit is that it must not push the chapter title down, so it must fit into the 50pt specified. If you want more space, then you need to change the 50pt and 50\p@ to something else so that it stays consistent.

This assumes you have an image called start.jpg or start.png (or start.eps if you are using DVI).

\documentclass{report}
\usepackage{xargs,graphicx}
\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#2\relax\vspace*{50\p@}\else
    {\centering\includegraphics[height=50\p@]{#2}\par\vskip1em}%
  \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#2\relax\vspace*{50\p@}\else
    {\centering\includegraphics[height=50\p@]{#2}\par}%
  \fi
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}
\makeatother
\begin{document}
\title{Phase-locked loop fundamentals}
\author{Superstar}
\date{\copyright\ 15th April 2009}
\maketitle
\tableofcontents
\chapter[Beginnings]{This is where it all begins}[start]
Chapter with a picture
\chapter{More new stuff}
Chapter without a picture
\end{document}

///Peter

Reply all
Reply to author
Forward
0 new messages