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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With