views:

345

answers:

2

Hi,

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!

+9  A: 

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.

Norman Ramsey
@Kenny: Do not forget the '\pagestyle{empty}' command.
tur1ng
+1  A: 

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

lhf