Siarhei Khirevich's site

Tips on Writing a Thesis in LaTeX

Page layout

Page layout defines dimensions and location of the content elements (textual, graphical, or technical) on a page. In terms of LaTeX page layout, "body" text block, margins, headers, and footers can be attributed to such content elements. The basic LaTeX command \documentclass activates default layout, specific for each document class (e.g. article or book). The oneside and twoside options of \documentclass adjust page layout for the one- and two-sided printing, respectively. Together with options a4paper and 11pt (defining the dimensions of a paper and the value of \normalsize font, respectively) several adjacent pages of the output PDF file look like this:


As you see, changing the page layout from oneside to twoside leads to asymmetric horizontal margins and corresponding shift of the text block while its width is kept fixedwhich can be seen in the non-changed location
of the last line of each paragraph

The default margins produced by LaTeX appeared to me too wide. In my thesis the text often discusses the data shown in figures, and reading the document assumes switching reader’s attention from text to figures and back. An additional switching between pages will slow down this process, and therefore it is straightforward to increase the amount of information (text) displayed on a page by reducing the page margins and font size. (Of course there are always aesthetic and technical limits in such size reduction.) Additionally, I did not place informational content into the page margins (e.g. margin notes), and therefore their size could be safely reduced. It worth noting that reduction of the margin sizes also restricts the possibility of a reader to make margin notes on a hardcopy of the document.

Changing default page layout with typearea package

A recommended way (see section 1.2 in "An essential guide to LaTeX2ε usage") to change a page layout in LaTeX is to employ typearea package, which is part of KOMA-script bundle. One of the approaches used by typearea to construct a page layout is to divide the page into equal amount of rows and columns, and then extract part of the cells from the resulting cell set (see details in section 2.2 in KOMA-script documentation). The typearea option DIV defines the amount of rows and columns, and a larger value results in a wider text block and narrower page margins.

In my thesis I have prepared all the figures with maximal width of 160 mm, and did not perform any scaling while including them into the LaTeX document, which was done to have similar size of the font in figures and in the text, as well as consistency in the final size of figure elements (such as thickness of lines and dimensions of markers). The value of DIV=14 (see corresponding table in section 2.6 of KOMA-script manual) resulted in dimensions of the text block suitable for 160 mm-wide figures: with such choice of DIV the text block was wider than any figure. The corresponding one- and two-sided page layouts looked as follows:


The option BCOR=2mm (responsible for binding correction, section 2.2 in KOMA-script manual) can be seen as an additional way for fine adjustments, and I used it to slightly reduce the width of the text block and to place it more symmetric on a page in the case of one-sided layout. The options headinclude=true, footinclude=false make an additional adjustment of the text block vertical size (see p. 37 in section 2.6 of KOMA-script manual). Just note that chosen the option DIV=14 together with 11pt resulted in the text lines wider than the value assumed to be optimal by typearea, and the following warning appeared in the LaTeX compilation logs:

Package typearea Warning: Bad type area settings!
(typearea)                The detected line width is about 19%
(typearea)                larger than the heuristically detected line width.
(typearea)                You should e.g. decrease DIV, increase fontsize
(typearea)                or change papersize.

Hence, the font size should be increased or DIV value decreased to reduce the amount of characters per text line and to improve text readability (see section 2.1 of KOMA-script documentation). I did not decrease DIV because, as mentioned, the document figures were originally prepared in "up to 160 mm wide" format and were not scaled at all while including them into the document. Based on this experience, I would suggest to use smaller maximal width of figures (say, 140 mm or less) in case of typesetting for A4 paper in order to have more flexibility for adjusting the width of the text block.

Re-locating the text block

The next figure shows one more time the two-sided page layout produced after activating typearea with the options described before:


In this figure the bold lines indicate the page edges along which printed sheets assumed to be bound (glued) in a hardcopy. As you see, the narrowest margins are near those edges, and therefore part of the text will be located close to the binding edge/spine, or, in other words, gutter will be narrow; this may introduce difficulties while reading the printed document. (It worth to note that narrowest margins near the binding edge is a standard attribute of classical approaches of constructing a page layout, one of which is actually used by typearea activated with DIV option.) To resolve this issue I moved the text block away from the binding edge adding the following lines to the last two commands:


\if@twoside % commands below work only for twoside option of \documentclass

The command block between \makeatletter and \makeatother is executed only in the case of twoside option of \documentclass due to the conditional statement \if@twoside … \fi (to avoid text block shift for one-sided document), and it introduces horizontal offset of 12 mm (\setlength{\textblockoffset}{12mm}) for odd/even (\addtolength{\hoffset}{\textblockoffset}) and even only (\addtolength{\evensidemargin}{-2.0\textblockoffset}) pages. The 12 mm offset value is an arbitrary choice, and I just assumed it to be optimal for the selected options of \documentclass and \usepackage{typearea}.

The last command set enables easy switching between one- and two-sided versions of the document (with corresponding offset of the text block) by changing only oneside (or twoside) option of the \documentclass command. In both versions the width of the text block stays exactly the same and thefore there is no need to re-check the typesetting resultwhich is usually the case because despite good
default typesetting quality produced by LaTeX,
long documents often require additional manual
tuning such as removal of widow/orphan lines or
re-location of figures
after switching layouts. Using the described approach, there is still possible a situation when the text lines can appear in the compiled document differently for oneside and twoside options, namely in case of using page numbers in the text (e.g., "...for the detailed explanation see page 123..."). This can occur because of additional empty pages at the beginning of a chapter in two-sided layout. But it can be avoided referring to the particular section of a document (e.g., "...for the detailed explanation see Section 1.1...") the rather than to the page numbers directly.

While typesetting thesis, the last command set formed the basis for producing two document versions, for screen (oneside) and for printing (twoside); links to both document versions are available on the downloads page.

After print and binding the thesis appeared in the following form (click for enlarged version):

If you likeI hope you came to the bottom of this
page not just by fast scrolling
the information presented on this web site, and would like to support development of this project you may consider buying me a coffee.