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?

  • 1
    Doesn't happen to me. May you give a real example?
    – egreg
    Oct 9, 2011 at 20:17
  • 2
    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, 2011 at 20:18
  • @egreg: can easily been seen with \[ y \]
    – user2478
    Oct 9, 2011 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, 2011 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, 2011 at 20:43

3 Answers 3


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.


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}\] 
  • 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 Jan 25, 2012 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

  • 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, 2011 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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