# How to make the margins relative to the actual content rather than the baseline?

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:

\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?

• what do yo mean the content of the page or the papersize? – touhami Sep 21 '15 at 20:24
• I mean the content: in this document, the last fraction should be visible, for instance. – Colas Sep 21 '15 at 20:30
• @touhami "the last fraction should be visible": I mean there should be a second page with the last equation, so that it is visible. – Colas Sep 21 '15 at 20:40
• this seem not simple. One can try encourage pagebreak. In your example you can try \setlength{\topskip}{8pt}. – touhami Sep 21 '15 at 21:24
• so try \usepackage[paperwidth=10cm, paperheight=3.2cm, margin=0mm,bottom=.5\baselineskip]{geometry} – touhami Sep 21 '15 at 22:11

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}


• I will test it but It looks like what I was looking for. Thanks. – Colas Sep 22 '15 at 21:09

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}


• 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
• Maybe it is equal to .5\baselineskip? – Colas Sep 22 '15 at 1: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