I am not sure of want you have in this files and what you want obtain, but supposing that you have a main file book.tex
in the directory "Bellankonda", and files as chap_page_015 are only chunks of body text (no fully compilable LaTeX documents) and you want obtain a unique PDF merging all these chunk, then the book file could be somethig as this:
\documentclass{book}
\begin{document}
\input{Chapter_02/chap_page_015}
\input{Chapter_02/chap_page_016}
\input{Chapter_02/chap_page_017}
% etcetera
\end{document}
If the subfiles are something as whole chapters, that must start-end newpages, may be you want use \include
instead of \input
. Please see When should I use \input vs. \include?
If the child documents are complete LaTeX files with preamble (starting with \documentclass
and ended with \end{document} you can use the same file put including in the preample the packages standalone
, or docmute
, or subfiles
(in this case use \subfiles
instead of \input
). The child documents must be all of the same class, in other case, you can try the combine
class, but usually this usually this means asking for troubles. Another option in this case could be produce PDF files of individual pages and merge all with pdfpages
package.
Edit
As the comment of Aku ask for a loop to write automatically the \input
commands, a solution could be the \foreach
command. The code below is a simple example where the main document include from page1.tex
to page5.tex
using this command:
% Main file
\documentclass{article}
\usepackage{tikz}
\begin{document}
\foreach \c in {1,...,5}{\input{page\c.tex} }
\end{document}
With the subdocuments made from the commandline in this way:
echo " page {\em number 1}\par " > page1.tex
echo " page {\em number 2}\par " > page2.tex
echo " page {\em number 3}\par " > page3.tex
echo " page {\em number 4}\par " > page4.tex
echo " page {\em number 5}\par " > page5.tex
The results must be the following:
While there are packages I'd use the standard latex \include
functionality.
Put each chapter in a separate file (starting \chapter
not \documentclass
) and use \label
and \ref
freely across chapters. have a main.tex that looks like
\documentclass{book}
% \includeonly{chapter2}
\begin{document}
\include{chapter1}
\include{chapter2}
\end{document}
When you are working on chapter 2 uncomment the \includeonly
and just chapter2 will be processed. References to chapter 1 will still work so long as the .aux
file from previous runs that included chapter 1 are still around.
Best Answer
Here is a complete example of the input/include command at work:
The example consists of 3 files in a folder structure as follows:
fig.jpg
is just an ordinary jpg image file. The contents offile1.tex
are as follows:Note the inclusion of the (relative) path as well as the filename of
file2.tex
.The contents of file2.tex are
Note that
file2.tex
does not have its own preamble, document class,\begin{document}
etc.Think of
\input
as having a similar effect to you manually copying and pasting whatever is infile2.tex
intofile1.tex
: no need to include anything you wouldn't want to copy in this fashion. Following through this copying/pasting logic: note also that the path tofig.jpg
needs to be relative tofile1.tex
, notfile2.tex
. Sincefig.jpg
is in the same folder asfile1.tex
this means that we don't have to specify any path.Saving this file/folder structure and compiling
file1.tex
results in a document withfig.jpg
included in it.