Printing a table as PNG?

For the sake of completeness, I'd like to add that the standalone class can export the document to PNG format (using ImageMagick's convert under the hood), provided that the engine is executed with the --shell-escape option:

\documentclass[convert]{standalone} 
\begin{document}    
\begin{tabular}{l*{6}{c}r}
Team              & P & W & D & L & F  & A & Pts \\
\hline
Manchester United & 6 & 4 & 0 & 2 & 10 & 5 & 12  \\
Celtic            & 6 & 3 & 0 & 3 &  8 & 9 &  9  \\
Benfica           & 6 & 2 & 1 & 3 &  7 & 8 &  7  \\
FC Copenhagen     & 6 & 2 & 1 & 3 &  5 & 8 &  7  \\
\end{tabular}
\end{document}

When invoked without any options, the used preset will be: PNG format, a density of 300 dpi, no explicit size and the output file name is given by \jobname + .png extension. The standalone class has other options, so I recommend taking a look at the documentation. :)


Others have provided good answers but I have one that is simpler, at least for me.

  1. Compile the Tex file to a PDF
  2. Open the PDF with Inkscape (or another vector graphics program like Adobe Illustrator)
  3. Size the page to your needs and export a PNG.

Here is my exported PDF at 300 dpi. I like this method because it's easy to re-export your figures as any file format that you need. I think this solution is fairly elegant as it can allow you to save the vectorized graphics if you chose to save it as a PDF file.

enter image description here


Another way is to use the dvipng program which comes with miktex and texlive. Assuming your file is called mytable.tex you can use the following:

latex mytable.tex
dvipng -D 300 -bg Transparent -T tight -o mytable.tex.png mytable.tex.dvi

The first line will generate a .dvi file which is used to generate a .png file with a resolution of 300 dpi in the second line.

You can read more about dvipng here: https://linux.die.net/man/1/dvipng

I prefer to use the standalone document class when creating images with latex, since it crops any white space around the content.

Tags:

Png

Tables

Msword