19. Defining page size, margins and layout

You use several packages and settings in the project stylesheet to define the page size, margins and layout of the document. This topic goes through each of the settings to give you an idea of how this is done.

This should be done before customizing headers and footers,

Setting the page size

Page size is defined when the LaTex document class, in this case book. In this example, the page size is defined as A4 which in the stylesheet is set as mm values: 210mm x 295mm. Alternately, you can use letterpaper for US letter size. Using the book class, this command sets the page size to A4, the base font size to 11pt and pagination to double-sided.

1
\documentclass[a4paper,11pt,twoside]{book}

Using the geometry package

The geometry package defines page dimensions. It provides many arguments but I only used the following two arguments:

The \geometry command sets the papersize precisely, where

You then add this to the preamble in your stylesheet.

1
2
\usepackage[vcentering,dvips]{geometry}
\geometry{papersize={210mm,295mm},total={160mm,185mm}}

Defining offsets for headers and footers

You need to allow space for the headers and footer on the page. This can be done using the package geometry to define the offsets for headers and footers between the body text and the footers.

For example, use the following commands for an A4 page size.

1
2
3
4
5
\setlength\voffset{-1in}
\setlength\hoffset{-1in}
\setlength\topmargin{1cm}
\setlength\oddsidemargin{3cm}
\setlength{\evensidemargin}{3cm}

Defining text flow size

The height of the text flow on each page is defined using textheight. The original setting for text height was 24.5. The following command changes it to 23.5cm.

1
\setlength\textheight{23.5cm}

The width of the text flow is defined using textwidth. The original setting for text height was 16cm. The following changes it to 15cm.

1
\setlength\textwidth{15cm}

Defining the distance between text flow and headers and footers

The command footskip defines the distance between the footer and the text flow.

1
\setlength\footskip{1.0cm}

The commands headheight and headsep define the distance between the header and the text flow.

1
2
\setlength\headheight{1cm}
\setlength\headsep{1cm}

Paragraph settings

You can indent the first line of paragraphs using the paarindent command. If you set the indentation to 0cm then the paragraphs do not have an indentation.

1
\setlength{\parindent}{0cm}

You can set the spacing between paragraphs in points using \parskip. In the following example, the distance is set to 3 pts.

1
\setlength{\parskip}{3pt}

Line spacing is determined by these commands. In the following example, line spacing is set to 1.5 using the \setspace package. Options are commented out.

1
2
3
4
5
\usepackage{setspace}
\singlespacing
%\onehalfspacing
%\doublespacing
\setstretch{1.1}

Alternately, you can use the command \baselinestretch but you can adjust the command using \renewcommand.

1
\renewcommand{\baselinestretch}{1.5}

Click to continue.