Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTeX Page Size --- how do I produce a page that is "just big enough"?

I was learning about using the command line version of latex today, and I was experimenting with outputting .tex to .dvi, and then .dvi to .png.

The problem is, I have a simple .tex document which contains some math. The goal is to eventually produce a png form of the equation. But when I run:

$ latex -output-format=dvi test.tex
$ dvipng test.dvi

I get test1.png that is shaped like a regular letter-sized page. I only want an image that is as big as the equation needs to be. I'm sure I'm missing something obvious, but I can't figure it out!

Is there a command line option for either latex or dvipng to specify that the output file should only be set on a page as large as needed to render the equation?

Here's my example test.tex:

\documentclass{article}
\begin{document}
The solution to $\sqrt{x} = 5$ is $x=25$.
\end{document}

Thanks!

like image 219
Kenny Avatar asked Feb 06 '10 22:02

Kenny


2 Answers

Try

dvipng -T tight filename

EDIT: As Mr tur1ing points out, you'll also want \pagestyle{empty} to avoid having a page number muck up the works.

like image 169
Norman Ramsey Avatar answered Oct 07 '22 00:10

Norman Ramsey


Try mathurl and Roger's Online Equation Editor. There probably several other such sites.

like image 34
lhf Avatar answered Oct 06 '22 22:10

lhf