# “Killmargins” package?

Editors such as "Gummi" show a split-screen with the LaTeX source code on the left, and a preview of the later document on the right. However, having a substantial paper margin makes editing more tedious due to the extra scrolling and the fact that the "Fit Page Width" scaling is not suitable when working with small screens.

For editing documents with a wide variety of document classes, which are often publisher-dependent, it would be nice to have a simple way of removing the page margin to 1 or 2 millimeters.

Is there some package for LaTeX that can read the current page layout settings and modify them accordingly, so that the publisher's layout stays the same? Of course, this could be done by defining the page geometry by hand, but this is relatively tedious as it would have to be done for every style file separately. In principle, shouldn't it be possible to have a package doing that for the user when being included?

Surely, the effect can be obtianed using "pdfcrop" or similar tools, but that slows down live preview considerably, not mentioning that some editors (such as "Gummi") do not support customizing the build command.

Edit: Here is an example for which tohecz's easy-to-use solution unfortunately does not work due to a "Package geometry Error: \paperheight (0.0pt) too short.":

\documentclass{sig-alternate}
\usepackage[paperwidth=\dimexpr\the\textwidth+2em\relax, hmargin=1em]{geometry}
\begin{document}
Hello World
\end{document}


Without the second line, the TeX code compiles file. The class file can be downloaded from http://acm.org/sigs/publications/sig-alternate.cls

• I use \addtolength{\hoffset}{-110pt} – Loop Space Feb 5 '14 at 9:55
• Very interesting question. Actually, I think many pdf viewers would benefit from such an option, too. (The only one I know is called... Kindle;).) – mbork Feb 11 '14 at 14:49
• @mbork Goodreader on iPad handles cropping really well as well. – Loop Space Feb 11 '14 at 17:30
• Maybe, I avoid anything with a bitten apple picture on it. But to the point: another way might be to use Emacs instead of Gummi. I am pretty sure that you could make a similar setup in Emacs in a moment (auto compiling+cropping+auto-reverting view - the last item exists already, the first one can be programmed in two minutes, the second one might need writing a shell script or a short elisp function.) However, as noted in the question, performance might be bad (especially that pdf viewing in Emacs is based on converting the pdf to bitmaps). ;) – mbork Feb 11 '14 at 18:07

In the following, I do exactly the "tedious approach". I modify the physical page size and layout offsets (by altering \pdfpagewidth, \pdfpageheight, \hoffset and \voffset) without changing the publisher's layout itself.

While it is true that the actual numbers are highly class-specific, it is generally just two or three tries until one has found them.

\documentclass{sig-alternate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tweak page size and offsets during development
% TODO: remove before submission
\pdfpagewidth=7.2in
\pdfpageheight=9.5in
\hoffset=-0.65in
\voffset=-0.65in
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}

\begin{document}

\title{The Dark Side of The Moon: Legends, Myths, and Musik}

\author{Various Artitsts}
\maketitle              % typeset the title of the contribution

\begin{abstract}
The Dark Side of the Moon is the eighth studio album by the English progressive rock band Pink Floyd, released in March 1973. It built on ideas explored in the band's earlier recordings and live shows, but lacks the extended instrumental excursions that characterised their work following the departure in 1968 of founder member, principal composer, and lyricist, Syd Barrett. The Dark Side of the Moon's themes include conflict, greed, the passage of time, and mental illness, the latter partly inspired by Barrett's deteriorating mental state.
\end{abstract}

\section{Introduction}

\lipsum

\end{document}


• Nice! Will award the bounty in 2 days unless someone finds a "fully automatic" solution. – DCTLib Feb 11 '14 at 13:01
• There's no dark side of the moon really. Matter of fact, it's all dark. -- Gotta love your answer and the reference to DSOTM! :) – Paulo Cereda Feb 14 '14 at 9:07

\usepackage[paperwidth=\dimexpr\the\textwidth+2em\relax, hmargin=1em]{geometry}


It will make a custom-sized page width, but preserve the set-up textwidth, and the page will have just very small horizontal margins. Similar tricks can be used for vertical margins, but it's more tricky because of headers and footers, so for that, one would actually need to know your exact settings.

• Hmm. That does not seem to work for 2 columned layouts (the columns get a lot shorter. Also, at least with the "sig-alternate" style, this produces the error "Package geometry Error: \paperheight (0.0pt) too short." unless I set the paper height manually. – DCTLib Feb 5 '14 at 10:12
• @Ruedi Well, compose a MWE then. Without a specific example, it's hard to know that this doesn't work for you, or why it is so. – yo' Feb 5 '14 at 10:21
• Here is a M(N)WE: \documentclass{sig-alternate} \usepackage[paperwidth=\dimexpr\the\textwidth+2em\relax, hmargin=1em]{geometry} \begin{document} Hello World \end{document} -- The class file can be downloaded from acm.org/sigs/publications/sig-alternate.cls – DCTLib Feb 5 '14 at 15:00
• @Ruedi: Please add the MWE to your question, here in a comment it is unlikely found. – Daniel Feb 10 '14 at 12:33
• @Daniel: Good idea. Done. – DCTLib Feb 11 '14 at 12:59

## fullpage package

You could be interested by the package fullpage which enlarges the text width.

Normal margins:

With fullpage package declared:

Normal layout:

Fullpage layout:

MWE:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\usepackage{fullpage}
\usepackage{lipsum}
\usepackage{layout}

\begin{document}

\lipsum[1]
\newpage
\layout
\end{document}


## savetrees package

There is also the savetrees package which is designed for using less paper when printing. This package reduces the margins like fullpage but go beyond that and packs as much text as pos­si­ble onto each page. For example, the titles are in smaller fonts with less vertical space between them.

Here is an example:

MWE (by carefull, savetrees needs lmodern package).

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\usepackage{savetrees}
\usepackage{lmodern}
\usepackage{lipsum}
\usepackage{layout}

\begin{document}

\lipsum[1]

\section{section 1}
\label{sec:section-1}

\subsection{subsection 1}
\label{sec:subsection-1}

\end{document}

• But this actually changes the layout. – jonalv Feb 5 '14 at 12:31
• I should have probably stated explicitly that a requirement for the solution is that the layout is not changed, so that during editing of the document, formulas can be split into parts so that they fit the final layout, figures can be designed that way, etc. – DCTLib Feb 5 '14 at 14:57
• Ok, sorry I missed this point. – ppr Feb 5 '14 at 15:04

A "fully automatic" solution is difficult, a document might use headers, footers, marginal stuff, ...

Therefore the example uses the layout conventions of the used class sig-alternate:

\documentclass[preprint]{sig-alternate}

\newif\ifkillmargins
\killmarginstrue % configure

\ifkillmargins
% horizontal settings
% -------------------
\setlength{\oddsidemargin}{1mm}% configure
\setlength{\paperwidth}{\textwidth}
% the class sig-alternate forbids marginal paragraphs
\setlength{\evensidemargin}{\oddsidemargin}

\setlength{\topmargin}{1mm}%
\setlength{\paperheight}{\textheight}
% class sig-alternate forbids page headings
% class sig-alternate does not seem to use a footer (\let\thepage\relax)

% propagate settings of paper size to the driver
% without changing the layout
\usepackage[pass]{geometry}
\fi

\begin{document}
\Large
\noindent
Top left\leaders\hbox{$\cdot$}\hfill top right\par
\vfill\centerline{\huge\bfseries column 1}\vfill
\noindent
left\footnote{bottom left\leaders\hbox{$\cdot$}\hfill bottom right}%
\hfill right
\newpage
\noindent
Top left\leaders\hbox{$\cdot$}\hfill top right\par
\vfill\centerline{\huge\bfseries column 2}\vfill
\noindent
bottom left\leaders\hbox{$\cdot$}\hfill bottom right%
\newpage
\end{document}