12

I wrote a whole latex file. Due to journal's restrictions, I am forced to submit a word file. Since I have pretty complex tables: I don't want to rebuild in Word and copying tables with snipping tool (Windows) from displayed PDF results in a pretty poor resulution, I wondered whether it is possible to print tables as PNG? Is there a more intelligent way to achieve better results?

Some toy table taken from https://en.wikibooks.org/wiki/LaTeX/Tables as MWE:

\documentclass{article} 
\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}
| improve this question | | | | |
  • Quick and dirty: make a screenshot – samcarter_is_at_topanswers.xyz Jul 28 '17 at 12:47
  • 2
    Doesn't Word allow you to embed a SVG picture? I know LibreOffice admits it. – Andrea Lazzarotto Jul 28 '17 at 14:04
  • 1
    There are plenty of ways to convert a PDF (be it LaTeX generated or not) to SVG. If Word allows you to insert a SVG file, you should consider taking this route. I did it with both LibreOffice Writer and LibreOffice Impress in the past and I was able to even retain the text content as searchable text. – Andrea Lazzarotto Jul 28 '17 at 17:49
  • 1
    PS: woah, it seems that you can either use EMF or SVG (the latter only from Word 2016 onwards): superuser.com/q/397644/278831 You can then retain all the advantages of vector-quality output! – Andrea Lazzarotto Jul 28 '17 at 17:50
  • 1
    You can also open a PDF document directly with Word 2016 onwards. Has saved me hours of work in similar situations. – Mace Jul 28 '17 at 18:54
17

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. :)

| improve this answer | | | | |
9

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

| improve this answer | | | | |
6

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.

| improve this answer | | | | |
4

Definitely possible, I found some good reads:

Your recipe goes like this:

  1. Download image magic - I used the portable version ImageMagick-7.0.6-3-portable-Q16-x64 for your example. Unpack it.
  2. Compile your pdf.
  3. Copy your pdf to the image magic folder. Lets call it tabular.pdf
  4. On Windows: you press Ctrl+Rand then type cmd- this will open a command-line window for for you.
  5. Change to the correct directory by typing cd **"**IMAGMAGICKPATH**"**. The IMAGMAGICKPATH should be the path were you unpacked your portable IMAGEMAGICK or wherever you installed IMAGEMAGICK. In my case I used cd "C:\Users\nhck\Downloads\ImageMagick-7.0.6-3-portable-Q16-x64".
  6. No, to convert, type: convert -density 300 -quality 100 tabular.pdf tabular.png

Pay attention about the paths here. In this example I was in the Imagemagick folder and had copied tabular.pdf there as well. The output was saved there as well.

edit: Maybe a comment on convert: You can find the handbook for convert here: http://www.imagemagick.org/script/convert.php In the example I set the densityoption to 300 - representing a resolution of 300dpi. This should be sufficient for print. If you plan to resize (enlarge the image) you should go for a higher resolution here. The qualityoption addresses image compression: The lower this value the lower the output file size and the image quality. In your case quality is most important and file size typically doesn't matter, so I set it to 100 - which is the upper limit.

| improve this answer | | | | |
  • Thanks for quick response! I downloaded image magic. However, my slightly stupid question is: where can I allocate command line in this program? – Jens Jul 28 '17 at 8:58
  • 1
    I've tried to extend the answer for you. Maybe this video also helps:youtu.be/MBBWVgE0ewk – nhck Jul 28 '17 at 9:12
2

Another way to convert to .png format using Texmaker , first compile the LaTeX file using Texmaker, go to view pdf , then write click on that you will have an option to convert to .png format.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.