[Tex/LaTex] Equal left and right margins in documentclass book

booksmargins

How do I ensure that, using the documentclass book, my left and right page margins are equal?

I can't use oneside as a class option, because it mangles my headers, and I can't use the geometry package.

I tried

\setlength{\oddsidemargin}{15.5pt} 
\setlength{\evensidemargin}{15.5pt}

(found here: https://en.wikibooks.org/wiki/LaTeX/Page_Layout#Odd_and_even_margins), but that did not at all lead to equally sized margins.

There must be a simple way to do this!

Best Answer

You don't say why you can't use geometry which allows you to specify the margins directly, so makes this easier, but latex does not directly specify the right margin, you can specify the left margin, and the text width and the right margin is just whatever space is left over.

So assuming you don't want to change \textwidth or \paperwidth you want the left and right margins to be half the difference between those, and then you want to set \@oddsidemargin to be 1in less than that (as by default the origin is 1in in from the top left corner).

so

\setlength\oddsidemargin{\dimexpr(\paperwidth-\textwidth)/2 - 1in\relax}
\setlength\evensidemargin{\oddsidemargin}

Note that this assumes that \paperwidth is set correctly for your paper (a4paper or usletter options typically) and that the pdf media size has been set to the paper size (loading graphicx, or geometry or hyperref would do that) or set

\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth

or in newer luatex the same but without pdf in the command names.

Related Question