29

I am in the process of writing my master thesis and i am using Tikz to generate few graphs. Unfortunately, the input file for the graphs are not so small, so i already faced the problem that space limitation (solved). Nevertheless, it will take a long time to generate those plots.

My question is whether it is possible to save the generated Tikz figures into a file and to load the file instead? Since the problem is always that the labels do not have the right font size…

PS.

I am using scrbook and pdflatex, I would have no problem to change to something else if it will solve my problem.

24

You can do this with the TikZ library external. It saves each picture in an external file, which has a proper graphics format. From now on TikZ will read the external file unless you tell it to regenerate the external file.

There are several methods that regenerate the external graphics files. For example, by setting the TikZ key external/force remake at the start of your document, you tell TikZ to regenerate subsequent external pictures. You may set the key as follows: tikzset{external/force remake}. Other methods, including methods that use Makefiles, are explained in Section 32.4.3 of the pgf manual.

The following is shamelessly copied from the TikZ manual.

Note: You have to run LaTeX with shell-escape enabled.

\documentclass{article}
% main document, called main.tex
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % activate!
\begin{document}
\begin{tikzpicture}
\node {root}
child {node {left}}
child {node {right}
child {node {child}}
child {node {child}}
};
\end{tikzpicture}
A simple image is \tikz \fill (0,0) circle(5pt);.
\end{document}
  • 1
    This is not quite true. Even if the picture has changed, you have to ask for the figure to be remade. TikZ will happily assume that anything with the right file name is up to date unless you do, for example by using \tikzset{external/force remake}. – qubyte Feb 14 '12 at 10:26
  • 1
    @Eagle It will do it for every tikzpicture in the current group. By putting the picture in a group and enforcing external/force remake at the start of the group, you can restrict the scope of the regeneration to the pictures inside the group. – user10274 Feb 14 '12 at 11:53
  • 1
    ... but it will do it on each compilation run when that option is set. In a document with lots of pictures, I use the external/remake next key just before the one I'm currently working on and then delete it when I'm happy. Note that if you don't specify names for your pictures then they are named numerically and so if you insert a new picture not at the end, you'll have to regenerate the lot. – Loop Space Feb 14 '12 at 12:03
  • 1
    I like to keep a commented out force remake with every TikZ picture. Whenever I need to regenerate one I uncomment it. – qubyte Feb 14 '12 at 14:59
  • 1
    @MarcvanDongen: Now what would make my day is a routine that runs a checksum of the code in a TikZ picture and compares it with the previous run (may need two compilations). Then it could automatically rebuild when a change is made. – qubyte Feb 14 '12 at 15:39
7

If you are on Windows or Linux you can use QtikZ, a dedicated TikZ editor that offers live compilation of your TikZ code and export to PDF and other formats.

You can also consider the standalone package to generate PDF compiling your TikZ code alone with pdflatex.

Finally, TikZ offers the external library to generate PDFs during the first compilation of your main file (chapter 32 of the manual).

  • latexit does much the same on OS-X – The V Sep 27 '16 at 15:49
  • When I tried downloading the QtikZ 0.10 installer for Windows, my Windows Defender told me it is malware (contains a trojan). – TMM Dec 6 '16 at 22:14
1

You can try a semi graphical tikz editor Tikzedt which I feel has many features like creating pdf file and standalone files.

  • NOTE: "TikzEdt is currently (regrettably) only natively available for Windows" (tikzedt.org stand: 26.10.16) – loved.by.Jesus Oct 26 '16 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.