Thursday, January 5, 2012

Right-hand page opening for article class in LateX

So I like to use article documentclass for a variety of reasons, though mostly because I'm used to it. But what if you want your article to be formatted such that each new section opens on an odd (right-hand) page?

Looking around got me to this solution, in the preamble:

\documentclass[a4paper,12pt,twoside]{article}
twoside allows you to have different even and odd headers and margins.

\usepackage[bindingoffset=1cm,margin=2cm, includeheadfoot]{geometry}
 This sets up the margins such that there is a bigger margin to allow for binding.

\newcommand*\stdsection{}
\let\stdsection\section
\renewcommand*\section{%
\clearpage\ifodd\value{page}\else\mbox{}\clearpage\fi
\stdsection}
This does a clearpage whenever a section is on an even page. It works a treat and you can also use it for subsections etc. This does mean that your list of figures and tables also start on a new, odd, page, which is no great change, really.

hat-tip to: http://www.latex-community.org/forum/viewtopic.php?f=5&t=2813&start=0&st=0&sk=t&sd=a
UPDATE: If you don't want to have a section starting on a new page, then just put:
\begingroup
\let\clearpage\relax
[whatever you don't want on a new page]
\endgroup 

No comments:

Post a Comment