Latex package to include external tikz figures and similarly to \includegraphics command.
Add includetikz
in your current directory, or texmf install.
Then add
\usepackage[<options>]{includetikz}
in your text source.
Option | Description |
---|---|
[external] | Compute all include tikz as external pdf files with checksum (see tikz external library). |
[origin] | Compute all pdf picture in a subdirectory "autogen" under the original figure directory (Default will use the source directory ). |
[force] | Force all tikz figures to be recompiled (Slower build). |
[disable] | Disable all pictures and replace by a black picture (Faster build). |
[optimize] | Optimize generated pdf. |
Create you tikz figures in a separate file then include them in your tex source using
\includetikz[<options>]{path/to/image.tikz}
Tikz PDFs are generated by default under a new directory called "autogen" in the source directory. You can change the default path using the option "origin" to create this directory relative to each figure directory.
NB: .tikz or .tex extension work.
Option | valuetype | Description |
---|---|---|
[scale] | float | Scale the tikz image |
[font keepratio] | X | Scale the image and inverse scale font size |
[font scale] | float | Scale tikz image font |
[font style] | string | Tikz image font style (beta) |
[fill opacity] | float | Modify image opacity (beta) |
Command | Description |
---|---|
\includetikzdisable |
Disable all pictures (to make compilation faster) |
\includetikzorigin |
Change autogen path to figure origin directory |
\includetikzforcerebuild |
Force tikz picture to be recompiled |
Minimal example:
% Preamble.
\usepackage{includetizk}
% Document.
\includetikz[scale=0.9]{figs/monimage.tikz}
Generate monimage.tikz during first compilation, then use auto-generated pdf:
% Preamble.
\usepackage[external]{includetizk}
% Document.
\includetikz[font scale=1.3]{figs/monimage.tikz}
This often happens when you output files in another directory using the
latex option -output-directory=<workdir>
.
The easier solution is to create a simlink inside the working directory.
See the providen example.
This is one of the goal of this package.
Compile your latex file the first time to generate all tikz pictures.
Then comment the includetikz lines and replace them by the \includegraphics
function:
%\usepackage{includetikz}
\usepackage{graphicx}
%\includetikz[scale=0.5]{path/to/fig/figname-1}
\includegraphics{autogen/figname-1-n0}
%\includetikz[scale=0.5]{path/to/fig/figname-1}
\includegraphics{autogen/figname-1-n1}
%\includetikz[scale=0.5]{path/to/fig/figname-2}
\includegraphics{autogen/figname-2-n0}
Note that all generated picture are suffixed by -nX
where X represent the nth call of the same figure.
(This is necessary for the case where the same picture is generated with different options)
If the origin option is passed then the path would be path/to/fig/autogen/
instead of autogen/
.