1

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}
add(tik_fig1.tex)
\end{figure}

\begin{figure}
add(tik_fig2.tex)
\end{figure}

\end{document}

assuming all files are in the same directory.

3
  • 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
  • 1
    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

1 Answer 1

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.