TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

when I try to display a math equation with LaTeX, there is always whitespace to the right and left of the math equation. I am trying it with code like this:

%Math equation here

This method works for regular text, it just doesn't seem to work for math. Is there a solution?

share|improve this question
Doesn't happen to me. May you give a real example? – egreg Oct 9 '11 at 20:17
It would be great if you could give a complete document that acts like this. For example, what kind of "math equation" are you using? $...$? \[...\]? \begin{align}...\end{align}? – Ryan Reich Oct 9 '11 at 20:18
@egreg: can easily been seen with \[ y \] – Herbert Oct 9 '11 at 20:39
I only didn't post it because I didn't see it as relevant, but, here it is: \documentclass{standalone \begin{document} \[ \int_1^a{\frac{dx}{x}} = \ln a \] \[ \int{x^n} = \frac{x^{n+1}}{n+1}\] \end{document} – chbaker0 Oct 9 '11 at 20:42
The one work-around is to use pdfcrop, as suggested in my comment where this original problem arose. However, this may be related to some options of preview. – Werner Oct 9 '11 at 20:43
up vote 13 down vote accepted

The construction \[...\] builds a whole paragraph, so that standalone is forced to leave space for it.

A formula written as

$\displaystyle <formula>$

will give the same result as \[<formula>\], but will not produce excess white space.

If you want two "centered" formulas one after the other, then

\int_1^a{\frac{dx}{x}} = \ln a \\
\int{x^n} = \frac{x^{n+1}}{n+1}

is the way to go. For aligned equations you can use aligned.

share|improve this answer

Based on the code in the comments this seems to have been an issue with how the standalone package is begin used. With the latest version of standalone, the [varwidth] option is needed. The MWE below does not produce any space around the formulas:

enter image description here



  \[ \int_1^a \frac{dx}{x} = \ln a \]
  \[ \int {x^n} = \frac{x^{n+1}}{n+1}\] 
share|improve this answer
Re varwidth: The v1.0 version uses crop by default, not preview as before, and this uses a horizontal box for the content. The \[ \] doesn't like restricted horizontal mode. The varwidth options wraps the content into a varwidth environment (from the varwidth package) which is a minipage with a variable width. Unfortunately I had to sacrifice 100% backwards compatibility in order to provide a good default setting. crop avoids a few drawbacks of preview. The default setting can be easily changed using the config file. See the manual, especially the "Version update" section – Martin Scharrer Jan 25 '12 at 17:00



it creates a file <file>-pics.pdf which holds the equation as a cropped pdf

Run it with pdflatex -shell-escape <file> or alternetively with xelatex or lualatex

share|improve this answer
I tried to typeset your code using TeXShop first, with XeLaTeX selected and second, with LuaLaTeX selected. However, in both cases, I get "!undefined control sequence. \PreviewEnvironment". – Sony Oct 9 '11 at 22:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.