5

I need to have small margins in my document. It seems that the margins are relative to the baselines rather than the content.

See this example, where the content is cut out of the page:

enter image description here

\documentclass{article}

\usepackage[paperwidth=10cm, 
            paperheight=3.2cm,
            margin=0mm]{geometry}

\begin{document}

We have
\[ A= 2^{N-2}  \]
\[ B= 2^{N-1}  \]
\[ C= 2^{N-2}-\frac{(1+i)^N+(1-i)^N}{4}  \]
\[ D= 2^{N-2}+\frac{(1+i)^N+(1-i)^N}{4}  \]

\end{document}

How to make the margins relative to the actual content rather than the baseline? Is it possible?

Colas
  • 6,772
  • 4
  • 46
  • 96

2 Answers2

5

It's not clear what you want to get, but the explanation about the cropped part is easy: the last baseline sits at the bottom of the paper, because of margin=0pt; however, LaTeX allows the depth of the last line to be at most 5pt before taking countermeasures. The relevant parameter is \maxdepth.

\documentclass{article}

\usepackage[paperwidth=10cm,
            paperheight=3.2cm,
            margin=0mm]{geometry}

\setlength{\maxdepth}{0pt}

\begin{document}

We have
\[ A= 2^{N-2}  \]
\[ B= 2^{N-1}  \]
\[ C= 2^{N-2}-\frac{(1+i)^N+(1-i)^N}{4}  \]
\[ D= 2^{N-2}+\frac{(1+i)^N+(1-i)^N}{4}  \]

\end{document}

enter image description here

egreg
  • 1,121,712
1

As typography goes this is bad practice, but I suspect it is precisely what you want.

\documentclass{article}
\usepackage[paperwidth=10cm,showframe,
            paperheight=3.2cm,
            margin=0mm,bottom=5pt]{geometry}
\lineskip 1pt plus 1pt minus 1pt
\begin{document}

We have
\[ A= 2^{N-2}  \]
\[ B= 2^{N-1}  \]
\[ C= 2^{N-2}-\frac{(1+i)^N+(1-i)^N}{4}  \]
\[ D= 2^{N-2}+\frac{(1+i)^N+(1-i)^N}{4}  \]

\end{document}

The 5pt bottom margin appears to be a magic number for any descenders (any font size), even using a default \lineskip.


Even more dramatic results can be obtained using:

\lineskip=0pt plus 1fil
\begin{document}
\baselineskip=0pt

The downside is that only descenders (anything below the baseline) will go below the bottom margin.

An alternative is to put the baseline at the very bottom of each equation using \raisebox, only you can't put display mode math inside a \raisebox (at least not without using a \parbox, which leads to too much vertical space). Anyway, the following fakes display mode math (without equation numbers).

\documentclass{article}
\usepackage[paperwidth=10cm,
            paperheight=3.2cm,
            margin=0pt]{geometry}

\newcommand{\mybox}[1]% #1 = contents
{\ifvmode\vskip\lineskip\else\newline\fi
 \centerline{\raisebox{\depth}{$\displaystyle #1$}}%
 \vskip\lineskip}

\lineskip=1pt plus 1fil

\begin{document}
We have
\mybox{ A= 2^{N-2}  }
\mybox{ B= 2^{N-1}  }
\mybox{ C= 2^{N-2}-\frac{(1+i)^N+(1-i)^N}{4}  }
\mybox{ D= 2^{N-2}+\frac{(1+i)^N+(1-i)^N}{4}  }
\end{document}

raisebox solution

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • This works for this precise document but I am looking for a generic solution. – Colas Sep 21 '15 at 22:50
  • Further experiments have shown that a 5pt bottom margin is enough to force the last line to the next page before it runs off the bottom of the page. I've replaced the bottom line with \rule[-13pt]{10pt}{26pt) and replaced the bottom 2 lines with \rule[-25pt]{10pt}{50pt) and can still see white below the bottom. – John Kormylo Sep 21 '15 at 23:43
  • 1
    Maybe it is equal to .5\baselineskip? – Colas Sep 22 '15 at 01:29
  • @Colas - Changing \baselineskip seems to have little effect, other than to change the minimum line spacing. This is better seen by adding another line so that the page is not terminated by \end{document}. Nor does it seem related to \lineskiplimit, whose default value is 0pt. – John Kormylo Sep 22 '15 at 14:29