I'm currently a presentation based on a paper originally written in Latex. Currently, I use Kile and Ubuntu for my work.

What I'm finding is that I need a large number of the equations from the original paper scattered around the presentations (and are using them to annotate diagrams etc). My current method of screenshots + gimp is rather slow :)

So, what I would like to do is compile the tex document and instead of creating a pdf/dvi, I would like it to spit out a number of files, which each file being one of the equations from the document, preferably in a vector format, but I will live with a PNG if I have to, so long as it's of high enough resolution.

I've had a look at a number of utilities.

The following web utility: http://www.codecogs.com/latex/eqneditor.php does more or less what I want for an individually typed equation. However, I've used a lot of mactros in equations that make it a little messy to use (for example)

\newcommand{\SkewSymmetric}[1]{\ensuremath{ \left[ #1 \right]_{\times}}}

I've had a look at pdf2svg, but it doesn't quite do what I want - I still need to crop out the equation of interest.

Is there anything else I should look at?

  • 1
    Are you not writing your presentation in LaTeX? Apr 5, 2011 at 8:30
  • 3
    I'm embarrassed to admit it, but no :)
    – Damien
    Apr 6, 2011 at 0:55

5 Answers 5


Check out the preview package. E.g., including


prints all equation environments and nothing else, each cropped, one to a page. It's equally effective with DVI and pdf output. Embedded macros in equation (or whatever) environments are handled transparently and properly.

The pdf can then be converted to SVG images with the following command:

pdf2svg filename.pdf output-page%03d.svg all
  • 5
    the option displaymath should do it anyway.
    – user2478
    Apr 5, 2011 at 5:57
  • Almost... The equation number is still embedded in each equation. Is there a way to automatically get rid of it?
    – Damien
    Apr 6, 2011 at 0:49
  • 2
    @Damien: sure, assuming your document is based on one of the standard LaTeX classes, define the equation number out of existence thus: \makeatletter\renewcommand\@eqnnum{}\makeatother.
    – Kilgore
    Apr 6, 2011 at 11:59
  • Not sure what I've done wrong. I've placed the suggested \makeatletter command before \begin{document} and after. It seems not to make a difference, even with a standard template. Any ideas?
    – Damien
    Apr 7, 2011 at 12:36
  • I have included some additional notes in a new answer below to get rid of the whitespace and embedded equation numbering.
    – Damien
    Aug 19, 2011 at 7:45

To extend the answer from @Kilgore:

To get rid of the equation numbers (AND you have an excellent backup of the original file(s)!), yon can do the following:


files=`find . | grep -e '\.tex$'`

for file in $files ; do 

    echo "Stripping: $file"

    # Create a copy of the existing file
    cp $file $file.strip_backup

    sed -i 's/begin{equation\*}/begin{align*}/g'   $file
    sed -i 's/end{equation\*}/end{align*}/g'   $file

    sed -i 's/begin{equation}/begin{align*}/g'   $file
    sed -i 's/end{equation}/end{align*}/g'   $file

    sed -i 's/begin{align}/begin{align*}/g'   $file
    sed -i 's/end{align}/end{align*}/g'   $file


The individual equations can be extracted using:


(Note the addition of the *)

To remove the excessive whitespace, use the following utility:

pdfcrop output.pdf

And, finally, you can split this into individual svg files

mkdir output-equations
pdf2svg filename.pdf output-equations/output-page%03d.svg all

If the svg images are still not properly cropped, Inkscape can fix that:

inkscape -z --verb=FitCanvasToDrawing --verb=FileSave --verb=FileClose output-equations/*.svg
  • if you get ! LaTeX Error: Command \align* already defined., be sure to \usepackage{mathtools} before preview Feb 27 at 20:49

Make a Metapost file with one figure per equation, with each equation in an "unboxed box":

  boxit.a(btex $$e^{i\pi}+1=0$$ etex);
  a.c = (0,0);

  boxit.a(btex $$F={G m_1 m_2 \over d^2}$$ etex);
  a.c = (0,0);

Run mptosvg, which will generate one SVG file per figure, with the right bounding boxes.



        1-\strut\displaystyle\frac{2\,M}{r}, \quad \text{for}\, r>R,

    foo $ xy=f(x) $ bar

    foo \[ dy=g(x) \] bar

Latex to SVG cmd

$latex test.tex
$dvisvgm.exe -n -p 1-5 -c 1.2,1.2 test.dvi
  • Have you tested this with a document with multiple equation environments to see that it does what the OP calls for? (And please format code blocks properly so others can easily cut and paste.) Jun 27, 2016 at 13:47
  • Welcome to TeX.SX! Thank you anyway for sharing your knowledge! To format code, you can indent lines by 4 spaces or enclose words in backticks `, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).
    – ebosi
    Jun 27, 2016 at 14:29

You can also use ltximg package, which uses the preview package internally but also crops the generated fragments and converts them to many different formats. You could use @Damien's answer above to convert all math environments into align*'s and call:

ltximg --latex --extrenv 'align*' --imgdir eqs --svg --png -o test-out test_eq.tex

to get pdf, svg and png fragments extracted from test_eq.tex into eqs directory. ltximg by default extracts only picture environments (tikz, pstricks, etc.), so we need to use --extrenv to specify math environments.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .