TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on an online web-app that incorporates LaTeX document generation.

Currently, as a beginner to LaTeX (but the most experienced developer in my team), I am trying to determine the most efficient way to generate LaTeX docs into a viewable format. Memory is a concern to us, so here are our methods to begin with.

> latex sample.tex

Outputs a dvi which I can then convert to a png or a pdf

> pdflatex sample.tex

Outputs a pdf directly

Those are the main two methods I have used so far, other methods have either failed or been found to be too complex.

If anything, a .tex file directly to a jpeg would seem the most efficient, but I would prefer for some expert opinions;]

share|improve this question
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say "thank you" to users who helped you. – Kurt Feb 22 '13 at 4:32
Please have a look at tex.stackexchange.com/questions/3/compiling-documents-online. I'm not sure to what extend it is possible, but maybe it would be better to reuse existing code instead of recreating everything from scratch. – canaaerus Feb 22 '13 at 6:25
Have a look at dvisvgm. It converts dvi to svg. – Alex Feb 22 '13 at 21:32

You can obtain jpg or png files from latex source with the help of imagemagic. Consider this code:

  edge down and up again/.style={
    to path={
       |- ([shift={(\tikztotarget.south)}] +0pt,+-2.5mm) -- (\tikztotarget) }}}
\node at (10, 10) (root) {root} ;
\node at (10, 7) (lvl1middle) {lvl1middle} ;
\node at (8, 6) (lvl2left) {lvl2left} ;
\node at (13, 5) (lvl2right) {lvl2right} ;
\node at (10, 5) (lvl2middle) {lvl2middle} ;

\path[edge down and up again] (root) edge [line to] (lvl1middle)
                        (lvl1middle) edge           (lvl2left)
                                     edge [line to] (lvl2middle)
                        (lvl2middle) edge           (lvl2right);

Save the above code as myfile.tex. Compile it with pdflatex with shell escape option. You should get a myfile.png file. For details consult standalone class documentation.

The above can also be achieved by following code that doesn't use standalone. Here demo.tex is your actual file whose contents are needed as image. This makes use of shell escape capabilities. :

%compile pdf first
\immediate\write18{pdflatex demo}
% convert to jpg
\immediate\write18{convert -density 200 -alpha on demo.pdf demo-\@percentchar02d.jpg}
Checkout the folder for image files.

You will get two files in the same directory - demo-00.jpg and demo-01.jpg with each page resulting in a jpg file.

share|improve this answer

TeX and derivatives can only produce output directly in two formats, DVI and PDF. The DVI format can be converted into several others, but there is no direct way to produce for example a JPEG. (Note: there are workflows which hide the detail, but in teh end there is a conversion step somewhere to get say a JPEG or .png file)

share|improve this answer

This may have been solved by mediawiki, I'm not an expert but you may want to look at the Texvc addon -- or rather I think texvc is a a standalone programme that supports the mediawiki math extension.

share|improve this answer

Your Answer


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.