# include full latex document into another latex document

I like to draw picture in a full latex document then insert it into another LaTeX document. I wish to just use \input command to include the whole document rather than to insert the TikZ related preamable to main document and insert tikzpicture code into the other place.

for example, main document is:

\documentclass{article}
\begin{document}
Test document
\input{tikz.tex}
\end{document}


The tikz.tex content is:

\documentclass[border=1pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle (1cm);
\end{tikzpicture}
\end{document}

• why do you want to do this? it's possible as the answer shows but it replaces what should be a trivial \input command by a very fragile and invasive mechanism that tries to support skipping over the preamble of the included document. It would be much much simpler to input the tikz directly. Dec 22, 2016 at 1:07

\usepackage{standalone,tikz}


to the preamble of the main document.

\documentclass{article}
\usepackage{standalone,tikz}
\begin{document}
Test document
\input{tikz}
\end{document}


If you really wish to avoid adding \usepackage{tikz} to the main document, you can use

\documentclass{article}
\usepackage[subpreambles]{standalone}
\begin{document}
Test document
\input{tikz}
\end{document}


In that case, consult the documentation for options you may need in case of conflicts.