tags:

views:

373

answers:

4

When typesetting a document with \documentclass{book}, the margins on odd and even pages are different, just like in a book. This means the contents on a page is not centered, which is all fine, except sometimes on the titlepage.

My question is: how can I get the titlepage centered when typesetting a document using the book class?

Here is an example:

\documentclass{book}
\title{Lorem ipsum dolor yada yada}
\begin{document}
\maketitle
\end{document}

I would like to have the title centered on the page. Is there a clean way to do this?

+1  A: 

Use the geometry package.

lhf
Can I use the geometry package to change page geometry on just the first page?
Hans W
I think you can issue multiple \geometry commands.
lhf
+1  A: 

Use the adjustwidth environment from the changepage (or outdated chngpage) package. The documentation for the changepage package is located in the changepage.sty file itself.

The adjustwidth environment can be used to temporarily adjust the width of a block of text. Note that due to the way LaTeX splits your text into pages, you should avoid using the adjustwidth environment for blogs of text that will split across a single page if the left and right margins vary on odd and even pages.

Let's say your document has a 1-inch inner margin and a 2-inch outer margin. If you want the title centered on the page physically (i.e., have an effective 1-inch margin for both inner and outer), you can use the following code:

\usepackage{changepage}% or chngpage -- note that the syntax differs slightly between the two packages

\begin{adjustwidth*}{}{-1in}% leave left margin alone, decrease right margin by 1in
%\begin{adjustwidth}[]{}{-1in}% same as above, but this syntax is for the chngpage package
  \begin{center}
    My Title\par
    Author Name\par
    Whatever you want on your title page
  \end{center}
\end{adjustwidth*}

The adjustwidth environment takes two parameters: adjustments for the left and right margins, respectively. If you leave one of the parameters blank, that margin won't be changed.

If you're using the changepage package, the adjustwidth* environment will do the right thing based on whether you're on an odd or even page. The chngpage package doesn't have the starred environment, so you have to supply an empty optional argument [] to get the same effect.

More information on the changepage package can be found on its CTAN page.

godbyk
Thanks, this is what I was looking for.
Hans W
+1  A: 

Are you trying to center the title vertically or horizontally? If vertically, then you can put the following in your preamble to redefine the maketitle command such that the title is the only thing that shows up, and it's placed vertically in the center:

\makeatletter
\renewcommand{\maketitle}{
  \begin{titlepage}%
  \let\footnotesize\small
  \let\footnoterule\relax
  \let \footnote \thanks
  \null\vfill
  \begin{center}%
    {\LARGE \@title \par}%
  \end{center}\par
  \vfill\null
  \end{titlepage}%
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}
\makeatother

If you're trying to center horizontally and you don't mind losing the alternating odd/even margins, you can add the oneside option to the book class: \documentclass[oneside]{book}. I'm sure there's a way to change the margins for just the title page, but that's beyond my knowledge.

RTBarnard
A: 

Is there a problem with

\documentclass[oneside]{book}

?

Or is your problem that your want two sided printing but the margins need adjusting?

dmckee
I want the two sided printing, but wish to adjust the margins on the front page only.
Hans W
Ah...then disregard this suggestion.
dmckee