# How to use sections from other tex files?

I have 8 files which I am serially listing in my main.tex file.

All 8 files contain one chapter.

Now I have created a diagrams.tex file which has 10-12 diagrams using tikz.

I am not including this file in my main.tex file.

But I still want diagrams to show up in my main.pdf, as well keep the chapters manageable.

Can I simply import the figures from diagrams.tex using one or two line commands in my chapter .tex files so that the relevant figures show up where I want to?

-
You may write your diagrams in separate files, and then include/input them as needed – Lionel MANSUY Feb 21 at 12:41

You can use standalone class to create your TikZ diagramas. With

\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}
...
\end{tikzpicture}
\begin{tikzpicture}
...
\end{tikzpicture}
\end{document}


each figure will be drawn cropped and placed on a different page. Then you can use \includegraphics[page=1]{diagrams} where you want to include each one of them.

-

I sometimes use the figure/table deferral mechanism of the boxhandler package. The way you would do this is to issue the \HoldFigures command. Then you could \input the file of figure definitions (in order), but it would not print out. Then, as you need a figure, you issue \nextFigure.

Of course, to use this solution, you need to set up your figures using the boxhandler mechanism for figure creation, which is

\bxfigure{caption}{image}


The package also allows you to tailor the captions in a very flexible way.

-