I am trying to extract/convert a tikzpicture
to a format that is suitable for powerpoint without losing quality. The code that I have found and adjusted is the following:
\documentclass[a4paper]{scrartcl}
\usepackage{pgfplots, tikz}
\pgfrealjobname{mytikzpicture}
\begin{document}
\beginpgfgraphicnamed{outputpicture}%
\begin{tikzpicture}
\begin{axis} [height=7cm, width=10cm, title=\textbf{Title}, xlabel= XYZ, ylabel = ABC]
\addplot coordinates {(0,-30) (30,-30) (60, 0) (90, 30) (120, 60) (150, 90) (200, 140)} node[pos=0.115,pin=-360:{A}] {};
\addplot coordinates {(0, -40) (30, -40) (30, 60) (60, 60) (90, 60)(120, 60) (150, 60) (200, 60)} node[pos=0.734,pin=-90:{B}] {};
\legend {{XYZ}, {ABC}}
\end{axis}
\end{tikzpicture}
\endpgfgraphicnamed
\end{document}
mytikzpicutre
is the name of the file with the initial graph. I named the output as outputpicture
; the entire code is saved under the name output. However I get an error:
pgf: Sorry, image externalization failed: the resulting image wdpgfgraphicnamed'.
Could anybody help me with this problem?
Best Answer
You can use the Python script "tikz2pdf" (http://kogs-www.informatik.uni-hamburg.de/~meine/software/scripts/tikz2pdf): Save the tikz image in a separate file (e.g. foo.tex):
Run "tikz2pdf foo.tex".
Note that if you haven't run the script before it will generate a template file called .tikz2pdf.tex and this does not include the "pgfplots" package default.
If you don't want to use the tikz2pdf script you can copy the template file it provides:
Compile this using pdflatex and you get a pdf file that is tightly cropped around your image.
I hope this helps!