# Question about including tikzpicture in a research paper

I am using \documentclass[conference]{IEEEtran} for writing a paper. I will be using tikz environment for drawing figures. Some figures will occupy only a single column, but I have a couple of figures that will occupy both.

For drawing figures, I have two options:

1. I create separate .tex-files for drawing my block diagrams and then import the fig.pdf in my paper.tex by using \begin{figure} .... \end{figure}
2. Include tikz code directly in my paper.tex

Which one is a better option? I am more inclined towards option 2 but am not aware of any problems if I use this option.

• From TikZ code you can always obtain PDF figures but not vice versa. – Przemysław Scherwentke Jul 24 '16 at 22:08
• I'd say option 1. Once I used option 2 and the journal (which uses LaTeX!) scanned (!!) my beautiful tikz image and then included it. Didn't make me happy. – JPi Jul 25 '16 at 2:25
• I am always using the external library in such cases and hence my pdfs of the images are generated automatically during the writing process. Before submission I am switching to only including the PDF in the code (I am even deleting the tikzpackage from the usepackages). That way it doesn't matter whether the journals system provides tikz or not – Ronny Jul 25 '16 at 4:10
• I have used standalone package to generate figures and include them into main text using includegraphics. gnu-make to automate the build process with correct dependencies. – Dilawar Oct 23 '18 at 10:27

I would suggest doing your preparation with TikZ, as Przemysław Scherwentke comments, it's much easier if you want to edit your diagrams - and it would be foolhardy to assume this will never be necessary.

Yet at the same time it's likely - and I think the best way to confirm is to contact the relevant journal itself - that the journal will want a separate file for the graphic. Though this is not necessarily because they can't process TikZ, but so they can include the image separately on an article's webpage for example.

To this end a sensible workflow might be to use in the article

\begin{figure}
\input{tikzcode}
\end{figure}


and have a separate file tikzcode.tex which contains the TikZ code, alongside a second file to compile just the image (https://tex.stackexchange.com/a/29821/106162)

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\input{tikzcode}
\end{document}


You can then replace the \input{tikzcode} with \includegraphics{tikzstandalone} which links to a PDF copy of the image if necessary. By using \input{tikzcode} like this you always have the latest version of the image when you just compile the main article, yet it's very quick to switch to using a separate image if/when necessary.

The TikZ external library should alternatively allow for including the TikZ code in the main file and using it to generate separate files for all the images as well (https://tex.stackexchange.com/a/271475/106162).

There are I guess some things which can be done in TikZ but not (easily?) replicated when importing a graphic, like references in the tikzpicture Compiling a tikzpicture including \ref but from my own experience, I've yet to construct anything in tikz that would suffer (other than by way of customisability) from generating a pdf of the image and using \includegraphics{}.

• Thank you for your answer. Please correct me if I am wrong. My folder should contain main_paper.tex file. Assume that I have only one figure to include.For this I should have two .tex files..... tikzcode_fig1.tex and another in using \documentclass{standalone}. Is this correct? I am sorry but I couldn't follow you and will appreciate if you can provide some more detail. – NAASI Jul 25 '16 at 13:42
• That is my suggestion, the disadvantage is the need for many files. main_paper.tex is the paper, tikzcode_fig1.tex has the begin{tikzpicture}...\end{tikzpicture} and these two make the paper compilable with \input{tikzcode_fig1.tex} in main_paper.tex. To generate a separate image file for the figure add a third file compile_fig1.tex with the \documentclass{standalone} setup, compiling this will give you a PDF file of the figure compile_fig1.pdf. You can then swap \input{tikzcode_fig1.tex} for \includegraphics{compile_fig1.pdf} and remove all TikZ from main_paper.tex. – Dai Bowen Jul 25 '16 at 13:57