How I can produce a png from a tizk tex file (with class standalone)?

114 Views Asked by At

I have the following LaTex file:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[fill=yellow]{Hello World!};
\end{tikzpicture}
\end{document}

and I would like to get a single png file from that file. How can I do that?

Many thanks!

PD: I use Ubuntu 22.04

I tried the command convert, online converting but I need something snappy.

2

There are 2 best solutions below

0
samcarter_is_at_topanswers.xyz On BEST ANSWER

If you have imagemagick installed and compile your document with shell-escape enabled, you can simply use the convert option of the standalone class:

\documentclass[tikz,convert]{standalone}
\begin{document}
\begin{tikzpicture}
\node[fill=yellow]{Hello World!};
\end{tikzpicture}
\end{document}
0
ramiboutas On

Use the following command in your shell prompt:

$ pdflatex example.tex && pdftocairo -png example.pdf -r 300 -singlefile

This will, of course, produce as well a pdf file.

enter image description here