# tikz to an image file

This should be easy an easy task, but somehow I am confused, therefore I would like to state an example

\documentclass[11pt]{report}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{bayesnet}
\begin{document}

\begin{figure}
\centering
\tikz{ %
\node[latent] (phi) {$\phi$};
\node[latent, right=of phi] (f) {$f$};
\node[obs, right=of f] (y) {$\bf{y}$};
\node[latent, above =of f] (sigma) {$\sigma_y$};
\edge {phi} {f};
\edge {f, sigma} {y};
}
\end{figure}
\end{document}


I am using TeXstudio on windows and I would like to produce an image file (say .eps) rather than a pdf.

• In Linux, qtikz would do the job. Not sure whether this is available for Apple (which I believe TeXstudio is?). If so, this may help as well. – vaettchen Jan 8 '18 at 10:20
• latex --> dvi --> eps ? – Zarko Jan 8 '18 at 10:52
• To get the image as standalone, you can use the standalone-class. – knut Jan 8 '18 at 11:17
• .tex --pdflatex--> .pdf --pdftops--> .eps ? – Paul Gaborit Jan 8 '18 at 14:48

In my experience with eps exports from tikz, I haven't exactly been pleased with the results. Mostly if I need vector graphics from tikz, I compile to pdf and use that (or convert to svg, e.g. with Inkscape). If you simply need an image, you can convert to png with ImageMagick.

For my own purposes I have created an ImageExport.tex file:

%% Usage for eps-pictures
% Warning: Quality of text seems to be awful with eps...
% Use this documentclass instead of the one below
% \documentclass{standalone}

% Step 1: Include the tikzpicture below, adjust the used packages if needed
% Step 2: Compile to standard pdf, you should receive the image as pdf cropped to the drawing
% Step 3: Run pdftops -eps ImageExport.pdf
% Step 4: Rename the resulting eps file accordingly, use it!

% If some app doesn't want to include the graphic correctly, try running pdftops -level1 -eps ImageExport.pdf or pdftops -level2 -eps ImageExport.pdf

%% Usage for png-pictures

% Step 1: Include the tikzpicture below, adjust the used packages if needed
% Step 2: Compile like always but be sure to use the --shell-escape option. Ignore errors like "Undefined control sequence \HyperFirstAtBeginDocument"
% Step 3: Rename the resulting png file accordingly, use it!

\documentclass[convert={convertexe={magick}}]{standalone}

\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,calc,...}

\begin{document}
\input{my/tikz/graphic.tex}
\end{document}