3

Writting my bachelor thesis (unfortunatelly we are told to use MS Word) I am using Tikz for creating my figures. As I have several tikz-files I am using the standalone package to create a .pdf for each file.

But, when I now change for exmaple the font-size or the font-style I have to recompile every picture manually.

I kow you can compile more than one tikz-file inside the standalone, doing so results in 10 pages with one figure on each. The problem is that they are stored in one pdf-file.

Is there the possibility that the standalone can create a seperate file for each fiure? More, it would be great If I can set the name for those files to recognize them later on.

MWE:

\documentclass[tikz,multi=true]{standalone}
\begin{document}
  \begin{tikzpicture}
    \node{Picture 1};
  \end{tikzpicture}
  ## here I want to break the file to create seperate file with name=picture 2
  \begin{tikzpicture}
    \node{Picture 2};
  \end{tikzpicture}
\end{document}

Picture:

enter image description here

EDIT

After implementing the solution from Ross which seems to do what I intended to do occur in erros:

\documentclass[tikz, multi=true]{standalone}
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/]
\begin{document}
\tikzsetnextfilename{importantFigure}
  \begin{tikzpicture}
   \node{Picture 1};
  \end{tikzpicture}
\tikzsetnextfilename{anotherimportantFigure}
  \begin{tikzpicture}
   \node{Picture 2};
  \end{tikzpicture}
\end{document}

My errors are:

enter image description here

However the pictures are printed and stored in one file each. But rerun the code results still in the error and the pictures are not updated.

5
  • You can externalise each of the pictures, like here: tex.stackexchange.com/a/1475
    – Ross
    Mar 19, 2020 at 14:48
  • @Ross doing so result in an error I cannot resolve, however the pictures are printed, I will cahnge my original post
    – SRel
    Mar 19, 2020 at 15:34
  • Also, \includegraphics has an undocumented option [page=..], so you really don't need to use multiple files. Mar 19, 2020 at 16:16
  • You need to use article class, not standalone. Compile with --shell-escape enabled. Your MWE works for me with this change.
    – Ross
    Mar 20, 2020 at 2:52
  • hm... changing to article results in one pdf with the nodes are on one huge page, not two seperate and tight crop files
    – SRel
    Mar 20, 2020 at 19:36

1 Answer 1

3

For my thesis I used the following procedure :

  1. Create a header_fig.tex file containing all packages e.g. \usepackage{...} or libraries \usetikzlibrary{...} required for my pictures or settings e.g. \tikzset{...} or \pgfplotsset{}
  2. Create one or more tikz pictures in separate .tikz files with the following format
\documentclasse[tikz]{standalone}
\usepackage{import}
\import{absolute/path/to/the/header_fig/file} 

\begin{document}
    \begin{tikzpicture}
         <All of your favorite tikz code>
    \end{tikzpicture}
\end{document}

The import package avoids relative paths if you have a complex directory tree for all of your thesis pictures

  1. If you want to modify global settings, just change them in the header_fig file
  2. If you want to recompile all your pictures use a system for-loop or an arara call see Arara rule for automatic compilation of all files in a directory tree for instance.

This procedure allows to have separate .tikz and therefore .pdf files yet with global settings for all of your pictures. And I you want to speed up compilation, you can still add very specific libraries in the preamble of the relevant pictures.

1
  • thank you I will test it
    – SRel
    Mar 19, 2020 at 15:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .