3

I am wondering if there is any kind of difference mentiones in the approaches above?

Situation1: I have my main.tex with just normal text. When drawing a picture, I create another .tex file with just using there:

\begin{tikzpicture}
...
\end{tikzpicture} 

So the picture has his own file what makes modifying of it easier.

Situation2: I recently learend about the standalone-package. What if I now also use an extra .tex file just for my picture but now using the standalone package by saying:

\documentclass[10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
[...]
\end{tikzpicture}
\end{document}

And then also use the \input command in my main.tex

Have Situation 2 any advantages for example in compilation time or are both approaches complete identical? For now on they seem quite identical for me, however this could may change later on with the grwoth of the document. Many thanks.

EDIT: The tikz-picture itself I create and change via QTikz

1 Answer 1

4

Including the compiled pdf files

Using the standalone document class saves compilation time when you are using \includegraphics to include the compiled pdf file.

Including the tex files using the standalone package

When you use the standalone package in you main document (\usepackage{standalone}) and include a tex file (standalone document class), the tikz code is run again, therefore not saving compilation time.

Alternative method

Therfore I would suggest an additional method: Include your images with the \input command with the tikz externalize library:

\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\tikzsetexternalprefix{ext-tikz/} % all tikz files will be stored as a pdf in here

For this method, you need to run the compiler with the -shell-escape option. (For example, change the call of pdfLaTeX to pdflatex -synctex=1 -interaction=nonstopmode %.tex -shell-escape.) This can be done in the settings of your editor or, if you are using the command line, by adding the command to your usual call.

This method saves time by compiling the images only when necessary but also uses the same fonts as used in the document (and perhaps some other advantages).

The compiled tikz images are stored separately as pdf's (in this case in a specified folder, namely "ext-tikz". You can also manually set the filename (filename) with the \tikzsetnextfilename{filename} command.

3
  • Maybe you should add that for using the external library, you must compile with the --shell-escape option.
    – Max
    Aug 17, 2018 at 12:12
  • @Max, I have added the -shell-escape option. Can someone confirm that only one - is enough at the beginning of the option?
    – Tom
    Aug 17, 2018 at 12:52
  • On my setup (Windows 10, Miktex, using pdflatex) it doesn't seem to matter if you use one or two dashes.
    – Max
    Aug 17, 2018 at 12:58

You must log in to answer this question.

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