How to fit the paper-size to the content in LaTeX
I'd like to create a pdf/ps/eps that contains only one s开发者_运维问答ingle formula. I thought the easiest way would be to use latex. Unfortunately, I found no option to specify, that the paper-size should automatically be set to fit the contents.
I found that dvipng has a "-T tight" option, that actually does the trick, but... I want it in vector-graphics format.
Any suggestions?
Thanks.
With the standalone class, you get exactly what you want.
\documentclass{standalone}
\begin{document}
\[
x + y = z
\]
\end{document}
Try pdfcrop, it crops your pdf to the minimum. You need to have Perl installed.
for Mac, there is a little app called LaTeXit which does exactly that. http://chachatelier.fr/programmation/latexit_en.php
Fixing the bounding box of generated EPS should help:
epstopdf --gsopt=-dEPSCrop blah.eps
or eps2pdf
has a -B
option that detects the tightest possible Bounding Box.
Somewhat perversely, you can generate your Tex using Metapost: include your formula between btex and etex tags, and compile it following the instructions in either mptopdf(1) (prefered, part of pdftex) or mpost(1) (you'll need to run Tex separately as well, I think). It is perverse to invoke Metapost just to have it invoke Tex, but it you will get formula-sized output without any evil pdf hackery.
If you need any Latex (as opposed to plain Tex), then you need a bit of boilerplate to get this to work, cf. LaTeX labels in MetaPost.
精彩评论