Page LayoutChapter in the head of the page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Chapter in the head of the page

Post by QwareeqMathematics »

Hi guys;

How to decrease the distance between the word for ex "Chapter 1" and the top of the page in report document class.

Also, for the Chapters that not numbered .

I read file about titletoc and titlesec packages .To be honest, I couldn't do it with it :| .

Sorry, if this post has posted before.
:)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Chapter in the head of the page

Post by gmedina »

Hi,

you can avoid using the titlesec package, by simply redefining the \@makechapterhead and \@makeschapterhead commands. Add this in the preamble of your document:

Code: Select all

Code, edit and compile here:
\makeatletter
\def\@makechapterhead#1{%
\vspace*{10\p@}% default: 50pt
{\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@
}}
\def\@makeschapterhead#1{%
\vspace*{10\p@}% default: 50pt
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Only two lines were changed (those that have the comment "default: 50pt"). Change the value of the argument of the \vspace* command in those two lines according to your needs.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Re: Chapter in the head of the page

Post by QwareeqMathematics »

Hi :)

I copied the code and I put it in preamble , but nothing happened , I try to change the value from 10 to 1, or 2, or 20. But Nothing happened.

Where is the problem ??? Do I need to change the code \chapter to something else.

Thank you :)
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Chapter in the head of the page

Post by gmedina »

QwareeqMathematics wrote: I copied the code and I put it in preamble , but nothing happened...
Are you sure? Try using -50pt instead of 10pt and you should see the result.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Re: Chapter in the head of the page

Post by QwareeqMathematics »

I eliminated the * from \vspace , and it worked so nice.

Another thing, when I add several non numbered chapters successively and add contents lines as chapter for all of them , the distance between them is up normal.

I tried to change the distance between chapters in table of contents using \parskip, but I add some sections , the name of sections become up each other, how to decrease the distance between the names of chapters which they haven't any section in contents.

Also, Could I center the chapter, and decrease the distance between the first line in the chapter with the name of chapter.

Sorry for my a lot questions.

Thank you so much :)
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Chapter in the head of the page

Post by gmedina »

QwareeqMathematics wrote: ...Another thing, when I add several non numbered chapters successively and add contents lines as chapter for all of them , the distance between them is up normal.

I tried to change the distance between chapters in table of contents using \parskip, but I add some sections , the name of sections become up each other, how to decrease the distance between the names of chapters which they haven't any section in contents.
I do not fully understand what is it that you want to achieve. In the first paragraph of the quoted text you mention starred chapters and in the second paragraph you seem to be talking about chapters in general. Can you please describe in a more precise way your problem?
QwareeqMathematics wrote: ... Also, Could I center the chapter, and decrease the distance between the first line in the chapter with the name of chapter...
You can do that by adding some more changes to the code that I posted before; use something like the following (the modified lines include comments at the end):

Code: Select all

Code, edit and compile here:
\makeatletter
\def\@makechapterhead#1{%
\vspace*{-50\p@}% default: 50pt
{\parindent \z@ \centering \normalfont% default: \raggedright
\ifnum \c@secnumdepth >\m@ne
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 0\p@% default: 20\p@
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\def\@makeschapterhead#1{%
\vspace*{-50\p@}% default: 50pt
{\parindent \z@ \centering% default: \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1,1,2,3,5,8,13,21,34,55,89,144,233,...
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Re: Chapter in the head of the page

Post by QwareeqMathematics »

Oh, sorry for confusion .

I meant , if add for example the following nonnumbered chapters successively [ Dedication, Acknowledgment,Introduction ]. When I add these chapters names in content using \addcontentsline{toc}{chapter}{name}, how to decrease the distance between them in the content??

Thank u gentle man.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Chapter in the head of the page

Post by gmedina »

Edit: I initially forgot to include some \protect commands that I will now add.

Hi,

in this case you can use the \addtocontents command to decrease the vertical spacing between entries in the ToC, by using something like the following:

Code: Select all

\addtocontents{toc}{\protect\addvspace{<unit>}}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The following simple example illustrates this approach:

Code: Select all

Code, edit and compile here:
\documentclass{report}
\begin{document}
\tableofcontents
\chapter*{Dedicatory}
\addcontentsline{toc}{chapter}{Dedicatory}
\addtocontents{toc}{\protect\addvspace{-10pt}}
\chapter*{Acknowledgements}
\addcontentsline{toc}{chapter}{Acknowledgements}
\addtocontents{toc}{\protect\addvspace{-10pt}}
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}
\chapter{A test numbered chapter}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Of course, feel free to change -10pt to the unit that best suits your needs.
Last edited by gmedina on Wed Jul 15, 2009 8:11 pm, edited 1 time in total.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Re: Chapter in the head of the page

Post by QwareeqMathematics »

WoW, Nice Result .

I appreciate your help .

Thank you in advanced .

;) :D
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Chapter in the head of the page

Post by QwareeqMathematics »

Error Message !!

When I generate the file for the first there wasn't any error,but when I do that again it give me the following error :

Code: Select all

Code, edit and compile here:
\contentsline {chapter}{Title Page}{i}
\vskip -10pt\relax
\contentsline {chapter}{Committee Members}{ii}
\vskip -10pt\relax
\contentsline {chapter}{Dedication}{iii}
\vskip -10pt\relax
\@tempskipb -10pt\relax \vskip -\lastskip \vskip \@tempskipb
\contentsline {chapter}{Acknowledgments}{iv}
\contentsline {chapter}{Contents}{v}
\vskip -10pt\relax
\contentsline {chapter}{Abstract}{vi}
\GenericError { }{LaTeX Error: Something's wrong--perhaps a missing \item }{See the LaTeX manual or LaTeX Companion for explanation.}{Try typing <return> to proceed.\MessageBreak If that doesn't work, type X <return> to quit.}
\contentsline {chapter}{Introduction}{vii}
\contentsline {chapter}{\numberline {I}Preliminaries}{1}
\contentsline {section}{\numberline {I.1}Modules,R-Module Homomorphisms and Exact Sequences}{1}
\contentsline {chapter}{\numberline {II}Regular and Unit Regular Rings}{3}
\contentsline {section}{\numberline {II.1}Regular Rings}{3}
\contentsline {chapter}{Bibliography}{5}
\contentsfinish
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The codes for my TEST file is :

Code: Select all

Code, edit and compile here:
\documentclass[11pt,a4paper]{report}
\usepackage[pdftex]{graphicx}
\usepackage{amssymb,latexsym,amsmath,mathrsfs,fullpage,array,ifsym,color}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{-50\p@}% default: 50pt
{\parindent \z@ \centering \normalfont% default: \raggedright
\ifnum \c@secnumdepth >\m@ne
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 0\p@% default: 20\p@
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\def\@makeschapterhead#1{%
\vspace*{-50\p@}% default: 50pt
{\parindent \z@ \centering% default: \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
\renewcommand{\bibname}{References}
\setlength{\parskip}{3ex}
\begin{document}
\pagenumbering{roman}
\thispagestyle{empty}
\addcontentsline{toc}{chapter}{Title Page}
\addtocontents{toc}{\addvspace{-10pt}}
**********************************
---Here is the text for title page
**********************************
\newpage
\addcontentsline{toc}{chapter}{Committee Members}
\addtocontents{toc}{\addvspace{-10pt}}
**********************************
---Here is the text Committee Members
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I deleted all line of addcontentsline and addtocontent, but the problem still in the file, when I delete \tableofcontents, every becomes O.k.

BTW, I tried to close the file and open again, but nothing more ERROR :|

Where is the problem ??

Thank you
Post Reply