# best practice to include (standalone precompiled) graphics

## General understanding

I know that several people have asked about how to include plots and graphics (created by tikz and pstricks) into a latex document.

Now it seems evident to ask how to handle a big number of graphics. At first it seems crucial to pre-compile graphics that should enter the document to reduce compilation time. But there are many different ways to perform that issue and actually the package standalone seems the most auspicious.

By trying it, I recognized that all files have to be in the same folder otherwise it would result in errors (Including pictures in subdirectories with standalone package).

## MWE

\documentclass{article}
\input{Style/macros.tex}
\usepackage{standalone}
\standaloneconfig{mode=buildnew}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{filecontents}

\begin{filecontents*}{Style/macros.tex}
\fontsize{10}{12}
\end{filecontents*}
\begin{filecontents*}{Documents/test_standalone_slave.tex}
\documentclass{standalone}
\input{../Style/macros.tex}
\usepackage{tikz,pgfplots}

\begin{document}

\begin{tikzpicture}
\draw (0,0) circle (2);
\end{tikzpicture}

\end{document}
\endinput
\end{filecontents*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz,pgfplots}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
That's it!
\includestandalone{Documents/test_standalone_slave}
\end{document}


## Question

How do I now include graphics like the previous MWE (adapted from matlab2tikz for including my macros) in order to have the same common font size and shape (width and height)?

-
I found this: tex.stackexchange.com/a/142479/412 workflow very useful. –  Dror Jan 5 at 5:37
If the files are precompiled, they will contain whatever font(s) specified during the initial compilation. Therefore you will have to make sure that the precompiled graphics and the master document are configured equally. If not, you will have to recompile the precompiled graphics in order to make the font(s) match. –  eiterorm May 17 at 19:16
@eiterorm: Could you therefore say what commands and packages have to be in the common style to ensure this? I could include the common style via \input or write a document-specific package? –  strpeter May 17 at 19:21
@strpeter, unfortunately I don't know any automated way to do this. The font size is specified in the documentclass command, and you would need different document classes for the graphics (standalone) and for the master (article, report, book, etc.). If not, you could make a preamble file with the document class and the appropriate packages to be loaded by both the master document and the graphics documents. You would still have to recompile everything if you made any changes to the preamble definitions, though. Alas, I don't know how to externally specify the font size. –  eiterorm May 17 at 19:29
Yes, that's exactly what I intended! So I just have to know how to write the font size (and what else should be loaded as certain packages like fontenc) into such a preamble file preamble_file.tex. –  strpeter May 19 at 7:32