# Producing stand-alone figures with TikZ in LaTeX

With TikZ (the abbreviation for This is not a drawing program in German) you can produce beautiful figures for your papers (look here for some examples). One problem that often arises is that having the TikZ-code in your LaTeX file is not very efficient when working on the figure: You don’t want to regenerate your paper every time you change something in your figure. Another problem arises when your TikZ code is very long. LaTeX might complain and will not generate the figure.

The easiest way to circumvent these problems is by using a stand-alone file that generates a pdf-file that can be included in your paper.

Here is the code for doing this. The main point is to set the documentclass to “standalone”. Note that you should have the LaTeX package “standalone” installed.

This generates a stand-alone pdf-file which can be included in your paper:

## 2 Replies to “Producing stand-alone figures with TikZ in LaTeX”

1. Rodrigue

Hi all
I really appreciate the post. As I’m new in latex I don’t understand yet why some messages appear when executing the code. I copied and pasted the above code on my setup but when running it, a window appeared asking me to install the programme standalone.cls. When I pressed on Install, two errors appeared stating that the File ‘standalone.cls’ is not found. Consequently, the PDF file cannot be generated. How can I overcome this?
I used Texmaker 5.0.3 with MiKtex version 2.9

The log file is given below:

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7140 64-bit) (preloaded format=pdflatex 2019.8.15) 23 AUG 2019 06:54
entering extended mode
**./best_figures.tex
(best_figures.tex
LaTeX2e

Type X to quit or to proceed,
or enter new name. (Default extension: cls)

Enter file name:
! Emergency stop.

l.5 \usepackage
{verbatim}

*** (cannot \read from terminal in nonstop modes)

Here is how much of TeX’s memory you used:
12 strings out of 492895
267 string characters out of 3133470
57270 words of memory out of 3000000
4026 multiletter control sequences out of 15000+200000
3640 words of font info for 14 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
10i,0n,8p,66b,8s stack positions out of 5000i,500n,10000p,200000b,50000s
! ==> Fatal error occurred, no output PDF file produced!

Best regards
Rodrigue