# How to output a multiline equation with no margins

I'm trying to output a .pdf that just contains an equation, without any borders at all, or borders the same width all the way round.

So far, I've tried two things. Using the standalone document class, and using the preview package. The first one doesn't quite suit my needs because you can't use the equation or align environments so you can't put in multi-line, aligned equations.

The second technique is better, but the resulting pdf has whitespace to the left of the equation instead of having no border at all.

Here's what I have so far:

\documentclass{article}
\usepackage{amsmath}
\usepackage[active,tightpage,displaymath]{preview}

%\PreviewBorder=1pt &setting this to 0 doesn't remove the margin on the left

\begin{document}
\begin{align*}
E_i = &E_{Z} + E_{an} + E_{ex}\\
= &- \mu_0 M_{s, i} H cos (\phi_i)\\
&+ K_{u,i} sin^2(\phi_i - \theta)\\
&- J_{i+1} \mu_0 M_{s, i} M_{s, i+1} cos(\phi_i - \phi_{i+1})\\
&- J_{i-1} \mu_0 M_{s, i} M_{s, i-1} cos(\phi_i - \phi_{i-1})
\end{align*}
\end{document}


I hope the question is clear enough. Let me know if not.

• not sure what the purpose of this question is, but if the idea is to get a small .pdf file that can be included somewhere else, what i'd do is, first, add \thispagestyle{empty} just after \begin{document}, and then use (from the command line) pdfcrop -margin 3 filename.pdf. this will produce a file filename-crop.pdf that is tightly cropped on all edges; the small margin is added to avoid skiving off the edges of those glyphs that touch the margins. Apr 6, 2015 at 18:12
• @barbara That was exactly what I was looking for. Thanks. Apr 6, 2015 at 18:19

i'm sure there's another question already that answers this, but i can't find it.

if the idea is to get a small .pdf file to include somewhere else, there are two steps to follow:

• make sure the output doesn't have anything extraneous, like a page number. to do this, add \thispagestyle{empty} just after \begin{document}.

• when you have the minimal .pdf file, run this from the command line:

pdfcrop -margin 3 filename.pdf

the small margin is added to avoid skiving off the edges of those glyphs that touch the margins.

this will produce a file filename-crop.pdf` that is tightly cropped on all edges.