tags:

views:

1526

answers:

2

I am writing my PhD thesis (120+ pages) in latex, the deadline is approaching and I am struggling with layout problems.

I am using the documentstyle book.

I am posting both problems in this one thread because I am not sure if the solution might be related to both problems or not.

Problems are:

1.) The page numbers are mostly located on the top-right of each page (this is correct and where I want them to be).

However, only on the first page of chapters and on the first page of what I call "special chapters", the page number is located bottom-centered. With "special chapters" I mean: List of Contents, List of Figures, List of Tables, References, Index.

My university will not accept the thesis like this. The page number must ALWAYS be top-right one each page, even if the page is the first page of a chapter or the first page of something like the List of Contents.

How can I fix this?

2.) On the first page of chapters and "special chapters" (List of Contents...), the chapter title is located far too low on the page. This is the standard layout of LaTeX with documentstyle book I think.

However, the chapter title must start at the very top of the page! I.e. the same height as the normal text on the pages that follow.

I mean the chapter title, not the header.

I.e., if there is a chapter called

"Chapter 1

Dynamics of foobar under mechanical stress"

then that text has to start from the top the page, but right now it starts several centimeters below the top.

How can I fix this?

Have tried all kinds of things to no effect, I'd be very thankful for a solution!

Thanks.

+2  A: 

To change the page appearance, you can use the fancyhdr package. It's probably a change in the \pagestyle used for the special chapters.

To change the appearance of the chapter title (to have the chapter title printed from the top on the page, you have to use a modified style that change \chapter command rendering.

Here is an example of command I used for my own thesis. It is probably not the appearance you want but gives you an hint about the command you have to redefine.

% modified from book.ltx latex sources
\def\@makechapterhead#1{%  
\thispagestyle{empty}%  
\vspace*{50\p@}%
\vspace*{10\p@}%  
{\parindent \z@ \centering \reset@font
    \thickhrulefill\quad
    \scshape \@chapapp{} \thechapter
    \quad \thickhrulefill
    \par\nobreak
    \vspace*{10\p@}%
    \interlinepenalty\@M
    \hrule
    \vspace*{10\p@}%
    \Huge \bfseries #1\par\nobreak
    \par
    \vspace*{10\p@}%
    \hrule
    \vskip 40\p@}}
Lohrun
+2  A: 

A try to answer

problem #1.

Even if you're using the headings pagestyle, or your custom pagestyle, the special pages (chapter beginnings and so on) are formatted with the plain pagestyle.

To avoid this, load the fancyhdr package (as mentioned in the previous answer) with

\usepackage{fancyhdr}

in your preamble. Then, (always in the preamble) define your custom pagestyle. For normal pages (assuming you're not using twoside as an option of \documentclass[]{}):

\fancypagestyle{phdthesis}{%
\fancyhf %clear all headers and footers fields
\fancyhead[R]{\thepage} %prints the page number on the right side of the header
}

For special pages:

\fancypagestyle{plain}{%redefining plain pagestyle
\fancyhf %clear all headers and footers fields
\fancyhead[R]{\thepage} %prints the page number on the right side of the header
}

After doing this, you can set you page style declaring \pagestyle{phdthesis} right before \begin{document}. For further details, refer to the fancyhdr package documentation.


Now trying to answer

problem #2

As a first attempt, you can use the titlesec package, using the option compact. In the preamble, type:

\usepackage[compact]{titlesec}

If you're not completely satisfied with this solution, you can specify the spacing above and below the titles with \titlespacing

\usepackage{titlesec}
\titleformat{ command }[ shape ]{ format }{ label }{ sep }{ before }[ after ]
\titlespacing{ command }{ left }{ beforesep }{ aftersep }[ right ]

With \titleformat you can define your own style for chapter titles, and then you can define the spacing with \titlespacing. I don't know which style of titles you have to use, so it's better for you to have a look to the package documentation (you can recall package documentation typing texdoc NameOfThePackage in a terminal).

Please note that you need to define the chapter title format in order to specify its vertical spacing (page 5 of the documentation). As an example:

\usepackage{titlesec}
\titleformat{\chapter}[hang]{\huge}{\thechapter}{1em}{}
\titlespacing{\chapter}{0pt}{0pt}{1cm}

With these commands you have the chapter title with the number and the chapter name on the same line, a 0 pt space before the title, and a 1 cm space between the title and the follwing text.

Alessandro C.
Hi Alessandro, I tried using \titlespacing like this: [CODE]\usepackage[compact]{titlesec}\titlespacing*{\chapter}{30mm}{-20pt}{40pt}[\CODE] and variations thereof, but it simply changes nothing. The document compiles fine to PDF, but there is absolutely no change in the title positioning etc.
There's a mistake: the compact option may override the \titleformat or \titlespacing commands. Now editing.
Alessandro C.
At the bottom of answer #2 I added an example. I tested on my own on one of my documents and it works. In order to see the changes you need to somehow display the page layout, that is the box on the page where the text is put into. You can do that with the layout package.
Alessandro C.
Did you try the example? Did it work?
Alessandro C.
Hi Alessandro,yes I tried it, it *does* change the position of the headings as I wanted it to change, but as a side-effect it changed the way the headings are typed as well. What I mean is, the position is now correct, that's great. But previously, when I invoke a chapter like this [CODE]\chapter{Introduction}[/CODE], then it would type "Chapter 1[NEWLINE]Introduction". Now it just types "1 Introduction", without the string "Chapter" and without the newline.
I understand. It's all about reading the documentation. In order to modify the title spacing for chapters, you need to modify their formats. This is done with the \titleformat command; if you specify the option *display* instead of *hang*, you'll have the default behaviour, like the old \chapter command.So, you just need to replace the \titleformat line with this one:[CODE]\titleformat{\chapter}[display]{\huge}{\bfseries \chaptertitlename~\thechapter}{1em}{\bfseries} % [/CODE]Hope this satisfies your requirements ;)
Alessandro C.
Yes! Thanks a bunch, this solved it!Reading the documentation is one thing, understanding the documentation fully is another :)I have one follow-up question about problem #1, will post a separate comment. Thanks anyway right now for helping me with problem #2!
About problem #1. I don't know if I understood your explanations entirely, but I managed to set the page numbers to be always top-right in any situation - with one exception! Namely, the first page of the Index. I create an index using [CODE]\printindex[/CODE]. This works fine and the position of "Index" is also on the top of the page, according to the solution of problem #2. However, the first page of the index is the only page in my entire thesis where the page number is still bottom-centered. Maybe it has s/th to do with the pagestyle of the index?
How I set the page numbers to always be top-right (except index):[CODE]\pagestyle{fancy}\lhead{}\chead{}\rhead{\thepage}\lfoot{}\cfoot{}\rfoot{}\renewcommand{\headrulewidth}{0pt}% %page number ALWAYS top-right \makeatletter \renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi \thispagestyle{fancy}% \global\@topnum\z@ \@afterindentfalse \secdef\@chapter\@schapter} \makeatother[/CODE]
why you need to re-define the \chapter command?
Alessandro C.