15

Note to would-be closers : This question is different from this older question in my view because 1) none of the answers in that other question deal with page numbering and 2) I do not need multicolumns (used in all the answers to the other question also).

To print txt-only books downloaded from the Internet, to save paper space I use the following template (and print to the A4 format)

\documentclass{article}
\usepackage[footskip=0pt]{geometry}

\addtolength{\textwidth}{4cm}
\addtolength{\textheight}{5cm}

\addtolength{\hoffset}{-2cm}
\addtolength{\voffset}{-2.5cm} 

\begin{document}

(... ASCII-only tex here, no TeX or LaTeX)

\end{document}

Yes I know that most people would find this unbearable to read, but I don't mind and I only use that for my personal one-time readings.

In my view, all four margins are fine except for the lower margin (as shown in the image below). I'd like this margin to have the same area as the other margins, and thus lower the page number. Any ideas ?

enter image description here

6
  • I'm sure we've had a question on this before - I'll have a look
    – Chris H
    Jan 30, 2019 at 13:42
  • 2
    Possible duplicate of How can get rid of margins and minimize white space to fully use a page in LaTeX?. IMO this old question covers it, but some of what's of use here is in the comments, as well as the answers
    – Chris H
    Jan 30, 2019 at 13:46
  • 1
    @ChrisH I plead that my question is different because 1) none of the answers in that other question deal with page numbering and 2) I do not need multicolumns (used in all the answers to the other question also).
    – user40960
    Jan 30, 2019 at 13:49
  • Fair enough - mine is only one vote and several are needed to call it a duplicate. I still think a complete solution will end up being a subset of the accepted answer there
    – Chris H
    Jan 30, 2019 at 13:52
  • @user40960 BTW by using the savetrees package you not only have more desirable margins but the package also takes care of spacing, interlines etc so it is overall a better solution rather than using only the geometry package.
    – Maxiride
    Jan 30, 2019 at 15:29

3 Answers 3

20

The geometry package can do what you want, if you let it do the whole job of page layout instead of just part of it.

I'm not sure exactly what physical margins your adjustments to \textwidth etc wind up producing, but these geometry settings produce something that looks roughly like your screenshot, except for better placement of the page number:

\documentclass[12pt,oneside]{book}
\usepackage[a4paper,margin=1cm,nohead,foot=0.5cm]{geometry}
\pagestyle{plain}
\begin{document}

screenshot of the second page of _Moby-Dick_ with 1cm margins on A4 paper

Together with this font configuration...

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}

... this page layout fits the Project Gutenberg text of Moby-Dick onto 329 physical pages. With newtxtext instead of lmodern it shrinks to 310 pages. (These page counts include the ETYMOLOGY and EXTRACTS prefaces, but no table of contents nor any of the Project Gutenberg boilerplate. Also, I went to the trouble of creating TeX markup for chapters. It would be shorter still without that.)

1
  • Exaclty what I was looking for ! Thanks a lot.
    – user40960
    Jan 30, 2019 at 16:19
27

I'd suggest using the package savetrees loaded with the [extreme] option which its purpose is exactly the scenario you are describing by minimizing all the margins to the extreme, fitting as much text as possible on a page. More than that you'd print out of the paper. Its sample page, specifically the last page showcase the results that can be obtained.

4
  • 2
    Thanks ! It's Impressive : by just putting \usepackage[extreme]{savetrees} I get an output that is slightly better than the one I have so far. I'll accept this answer if no better solution comes up
    – user40960
    Jan 30, 2019 at 13:57
  • Using a structured package like savetrees you could dig into it's .cls files and study how the author does it. I'm confident some more tweaking could be done.
    – Maxiride
    Jan 30, 2019 at 14:05
  • 2
    It's a package, so it does not have a .cls file but a .sty file.
    – TeXnician
    Jan 30, 2019 at 14:11
  • 5
    I think your reply is perfectly suited as an answer :-)
    – Daniel
    Jan 30, 2019 at 14:18
3

Short answer:

Get info about the length \footskip. ;-)

Long answer:

I don't recommand modifying \hoffset and \voffset for setting the margins.

According to the TeXBook, chapter 23, the purpose of these parameters is:

If you want your output to be positioned differently when it is ultimately printed, you can offset it by giving nonzero values to \hoffset and \voffset. For example,
    \hoffset=.5in      \voffset=1.5in
will move the output half an inch to the right of its normal position, and 1.5 inches down. You should be careful not to offset the output so much that it falls off the edge of the physical medium on which it is being printed, unless you know that such out-of-bounds activity won't cause trouble.

If I got this right, the layout of pages (i.e., the width of text etc) should not depend on \hoffset and/or \voffset as these dimension-parameters are to provide a possibility for shifting the entire page when it is already typeset according to the layout for typesetting pages.

As far as I know, \hoffset and \voffset usually have the value 0pt and you change these values to shift entire pages horizontally/vertically by the values to which these parameters are set.

Changing \hoffset and \voffset should, e.g., not affect the width of text typeset by LaTeX.

Imagine someone puts a stamp on a piece of paper. The stamp is exactly the same size as the paper. The stamp is the text that LaTeX has typeset. \voffset and \hoffset determine how much the top left corner of the stamp is offset up/down and/or right/left relative to the top left corner of the paper.


The package layout might be of interest to you.

It defines the command \layout which produces a drawing where you get a visible impression of all page-layout-parameters. The output of the command \layout looks like this:

enter image description here

enter image description here


For the horizontal alignment, LaTeX provides one parameter for the left margin of right-hand-pages.
As right-hand-pages usually have page-numbers whose parity is odd, this parameter is called \oddsidemargin.

For the horizontal alignment, LaTeX provides one parameter for the left margin of left-hand-pages.
As left-hand-pages usually have page-numbers whose parity is even, this parameter is called \evensidemargin.

The distinguishing between right-hand-pages and left-hand-pages only applies with "twoside"-documents.

With "oneside"-documents every page is treated as if it was a right-hand-page. Thus with "oneside"-documents only the parameter \oddsidemargin is applied.

After playing with the package layout, I created a template where you can specify for right-hand-pages the margins at the left, the right, the bottom and at the top.

In case the document is a "twoside"-document, the template will calculate the margins for left-hand-pages automatically so that
    left margin of right-hand-page=right margin of left-hand-page
and
    right margin of right-hand-page=left margin of left-hand-page.

I assume you wish a minimalist approach without page-headers.

When playing around with the example below, while applying the article-class's option "twoside", make sure to set the view-mode of your pdf-viewing-program to "facing pages(first page centered)" or the like.

\documentclass[a4paper,twoside]{article}%
%------------------------------------------------------
% These packages are needed for detecting the engine -
% detecting the engine is needed for finding out if
% adjusting \(pdf)pagewidth and \(pdf)pageheight is 
% needed with things like the landscape-option:
%------------------------------------------------------
\usepackage{iftex, ifpdf}
%------------------------------------------------------
\ifXeTeX 
  \pdfpagewidth=\paperwidth
  \pdfpageheight=\paperheight
\else
  \ifLuaTeX 
    \pagewidth=\paperwidth
    \pageheight=\paperheight
  \else
     \ifPDFTeX
       \pdfpagewidth=\paperwidth
       \pdfpageheight=\paperheight
     \fi
  \fi
\fi
%------------------------------------------------------
\pagestyle{plain}%
\newlength\myleftoddmargin
\newlength\myrightoddmargin
\newlength\mytopmargin
\newlength\mybottommargin
\newlength\myverticalgapbetweenbottommarginandpagenumber
%-----------------------------------------------------------------
%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
% !!! Specify the margins here:                                !!!
%!!!!                                                          !!!
\setlength\myrightoddmargin{1.5cm}%
\setlength\myleftoddmargin{.75cm}%
% \csname if@twoside\endcsname
%   \setlength\myleftoddmargin{.5\myrightoddmargin}%
% \else
%   \setlength\myleftoddmargin{\myrightoddmargin}%
% \fi
\setlength\mytopmargin{1.5cm}%
\setlength\mybottommargin{1.5cm}%
\setlength\myverticalgapbetweenbottommarginandpagenumber{.5\mybottommargin}%
%!!! That should do the trick.                                 !!!
%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
%-----------------------------------------------------------------
\setlength\hoffset{0pt}% or whatever horizontal offset you need.
                       % Usually the value is 0 by default.
\setlength\voffset{0pt}% or whatever vertical offset you need.
                       % Usually the value is 0 by default.
\setlength\oddsidemargin{\myleftoddmargin}%
\addtolength\oddsidemargin{-1in}%
\setlength\evensidemargin{\myrightoddmargin}%
\addtolength\evensidemargin{-1in}%
\setlength\marginparwidth{.7\myrightoddmargin}%
\setlength\marginparsep{.15\myrightoddmargin}%
\setlength\textwidth{\paperwidth}%
\addtolength\textwidth{-\myleftoddmargin}%
\addtolength\textwidth{-\myrightoddmargin}%
%-----------------------------------------------------------------
\newlength\standardletterheight
\newlength\standardletterdepth
\settoheight\standardletterheight{%
  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890%
}%
\settodepth\standardletterdepth{%
  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890%
}%
\setlength\topmargin{\mytopmargin}%
\addtolength\topmargin{-1in}%
% This is the height of boxes of headings:
\setlength\headheight{0ex}%
% This is the distance between the bottom of a heading-box
% and the first line of text - Also \topskip-glue is added to
% ensure that baselines of first lines of text of pages all are
% in the same height:
\setlength\headsep{0ex}%
% In case of having page-headings, you probably don't need
% to play around with\topskip.
\setlength\topskip{\standardletterheight}%
\setlength\textheight{\paperheight}%
\addtolength\textheight{-\mytopmargin}%
\addtolength\textheight{-\mybottommargin}%
\addtolength\textheight{-\standardletterdepth}%
\setlength\footskip{\myverticalgapbetweenbottommarginandpagenumber}%
\addtolength\footskip{\standardletterdepth}%
\addtolength\footskip{.5\standardletterheight}%

\begin{document}
\hbox to\textwidth{Xg\xleaders\hbox{Xg}\hfill Xg}%
\nointerlineskip
\null\xleaders\hbox to\textwidth{Xg\xleaders\hbox{Xg}\hfill Xg}\vfill
\nointerlineskip
\hbox to\textwidth{Xg\xleaders\hbox{Xg}\hfill Xg}%
\nointerlineskip
\newpage
\hbox to\textwidth{Xg\xleaders\hbox{Xg}\hfill Xg}%
\nointerlineskip
\null\xleaders\hbox to\textwidth{Xg\xleaders\hbox{Xg}\hfill Xg}\vfill
\nointerlineskip
\hbox to\textwidth{Xg\xleaders\hbox{Xg}\hfill Xg}%
\nointerlineskip
\newpage
\hbox to\textwidth{Xg\xleaders\hbox{Xg}\hfill Xg}%
\nointerlineskip
\null\xleaders\hbox to\textwidth{Xg\xleaders\hbox{Xg}\hfill Xg}\vfill
\nointerlineskip
\hbox to\textwidth{Xg\xleaders\hbox{Xg}\hfill Xg}%
\nointerlineskip
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .