Take the 2-minute tour ×
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.

Is it possible to avoid left space from equations previewed with preview package?

\documentclass{minimal}
\usepackage{amsmath}
\usepackage[active,tightpage,displaymath]{preview}
\setlength\PreviewBorder{5pt}%

\begin{document}
\[x=3+y^2\]
\end{document}

The result is:

enter image description here

I would like a clipped (cropped?) equation. Is it possible?

Do you know a better solution to extract equations as images?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

You can use the pdfcrop Perl script.

share|improve this answer
    
I didn't know about it, thanks. It crops every page, so I still need package preview to produce pages with one mathematical expression on them. After that pdftk can split the document in individual pages. –  Ignasi Mar 22 '11 at 14:23
    
the preview package will generate one equation per page, and pdftk can split them into one file per page. The command is pdftk latex_output.pdf burst. –  cheshirekow Sep 7 '13 at 20:35
add comment

The left space is caused by the display style. You could use in-text style ($ ... $ or \( ... \)) instead and use \displaystyle in it to get the same result without the space. You need to wrap the equation manually in a preview environment:

\documentclass{minimal}
\usepackage{amsmath}
\usepackage[active,tightpage]{preview}
\setlength\PreviewBorder{5pt}%

\begin{document}
\begin{preview}
$\displaystyle x=3+y^2$
\end{preview}
\end{document}

Even shorter would be the use of the standalone class which uses preview internally. Note that the border option is only available since v0.4 2011/02/28. Before that you would need to set \PreviewBorder manually.

\documentclass[border=5pt]{standalone}
\begin{document}
$\displaystyle x=3+y^2$
\end{document}
share|improve this answer
    
your solution works perfect for one line equations but not for multiline expressions (split, gather, ...). At least I don't know how to do it. May be my minimal working example was too minimal. –  Ignasi Mar 22 '11 at 14:12
add comment
\documentclass{minimal}
\usepackage{amsmath}
\usepackage[active,tightpage,textmath]{preview}
\setlength\PreviewBorder{5pt}%

\begin{document}
$x=3+y^2$
\end{document}

Use textmath option instead of displaymath and use $ ... $ math environment.

share|improve this answer
add comment

Your Answer

 
discard

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.