Creating smaller files that are read and compiled by main tex file

I have some long tables which take large space in my main tex file. Can i get rid of it and transfer it to another file and indicate the main tex file to fill up the code from the external file. It is just like functions work in codes. You can write your entire code in one file but it is easy if you have your entire latex code divided among multiple files. Is that possible?

• \input{another_file}. See here Mar 5 '18 at 22:55

\input can be used for this purpose:

The external file mytable.tex:

\begin{tabular}{...}
...
\end{tabular}


The main file includes it:

\input{mytable}


Longer parts that begin and end at page breaks (e.g. chapters) can use \include:

\include{Introduction}


with Introduction.tex:

\chapter{Introduction}
\label{chap:Introduction}
...


If the main file is organized this way:

\include{Introduction}
\include{ChapterA}
...


Then just a chapter can be compiled by calling \includeonly in the preamble:

\includeonly{ChapterA}
...
\begin{document}


Then chapter "Introduction" is excluded from the compile run. However, the numbers (chapters, equations, ...) are still taken from the .aux file.