# tikz figure from file

Lets say i have a tikz figure in a file called tik_fig1.tex and tik_fig2.tex with \documentclass[tikz]{standalone}

Is it then possible to add these to a main.tex with \documentclass{article} by referencing the files, eg as

\documentclass{article}
\begin{document}

\begin{figure}
\end{figure}

\begin{figure}
\end{figure}

\end{document}


assuming all files are in the same directory.

• either strip off the documentclass and \input the tikz, or use \includegraphics{tik_fig1.pdf} to include the generated output from the standalone files. Aug 20, 2021 at 11:37
• ahh thanks i will try it out :) Aug 20, 2021 at 11:38
• See also the tikzscale package. It provides a graphicx driver for tikz (tex) files. Standalone is more efficient, though. Aug 20, 2021 at 15:36

You can \usepackage{standalone}.

% File-name: main.tex
\documentclass{article}
\usepackage{tikz}
\usepackage{standalone}

\begin{document}
\includestandalone{input}
\end{document}

% File-name: input.tex
\documentclass{standalone}

\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (1,1);
\end{tikzpicture}
\end{document}


Keep both of these files in the same directory of course. Note that you shall not add the .tex suffix to the argument of the \includestandalone command. Also you must load tikz in the main.tex file.