Skip to content

Instantly share code, notes, and snippets.

@juliennonin
Last active February 15, 2022 13:58
Show Gist options
  • Save juliennonin/51375e2340ebb82c7dfccb323b6bd099 to your computer and use it in GitHub Desktop.
Save juliennonin/51375e2340ebb82c7dfccb323b6bd099 to your computer and use it in GitHub Desktop.

Converting TikZ / SVG into PNG

\documentclass[varwidth]{standalone}
\usepackage{graphicx, import ,xcolor, tikz}

\begin{document}
\begin{tikzpicture}
  \draw [step=0.5] (-1.4,-1.4) grid (1.4,1.4);
\end{tikzpicture}

\begin{figure}
    \centering
    \import{}{diagram.pdf_tex}  % SVG exported from Inkscape
\end{figure}
\end{document}

Convert into PDF :

pdflatex -output-dir=out content.tex && mv out/content.pdf content.pdf

Convert into PNG (using ImageMagik) :

convert -density 300 convert.pdf -quality 90 file.png

Issue : Non authorized

Solution : changing the policy.xml of ImageMagick (/etc/ImageMagick-6/policy.xml).

You can find more information here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment