I've already searched stackexchange but I couldn't find what I was looking for. The thing is that I have different .tex files (five in total, the main files), each of them includes other tex files. Every file is a volume (Volume 1, Volume 2..). For Volume 1:


And the same applies for the other volumes. What I want to do is a single .tex document or PDF that includes all of them (including an index with all the volumes). Is there anyway to do this?

Thanks in advance.

  • 2
    Easy stuff for Linux and a script, more difficult with LaTeX methods;-) – user31729 Jul 2 '16 at 14:22
  • 1
    wouldn't that very document create a pdf which includes all of them? Also, instead of input{file}\newpage, you could just use \include[file}, which would start a new page for every single one, and you would also be able to use \includeonly{file1}. – Runar Jul 2 '16 at 14:31
  • Welcome! Your question isn't terribly clear to me right now. What is the structure of the file hierarchy exactly? What is the content of each currently \input file (structurally - not actually content)? What do you mean by an index with all the volumes? Do you mean that the index should combine \index{<word>} entries from each volume? Or do you not really mean an index but, say, a table of contents? Does each volume also get its own ToC and/or index? How should be pagination work? What about the bibliography? Are you already using \part for the \input files? – cfr Jul 2 '16 at 15:41
  • hey cfr. I have 5 files (or Volumes 1,2...), each file includes a "main_volume_number.tex", inside the "main_volume_number.tex" i use the input command to add the different chapters of the volume (\input{...}). What I want to do is merge in a single PDF/tex file all the Volumes (i.e. main_volume_1.tex + main_volume_2.tex + and so on), so I can have a single Table of contents/table of figures/ (yes, I meant ToC and not index). Is it more clear now? (English is not my first language xD) – Jon Jul 2 '16 at 16:50

As an old emacs user there is a related feature in auctex, where the ToC can be listed together with the included files. Similar can be put in ToC of the document by also including the input files. Given the following files in ./Sections/:


\section{A section}
\subsection{Sub section 1}
Text in subsection


\section{A new section}
\subsection{Sub section in new section}
Text in subsection


\subsection{Yet another subsection}
Sub text

The main file adds a ToC line for each input file:


%\def\input#1{\addcontentsline{toc}{section}{*** #1 ***}\DEFinput{#1}} %% TeX style
\renewcommand\input[1]{\addcontentsline{toc}{section}{*** #1 ***}\DEFinput{#1}} %% LaTeX style


enter image description here

| improve this answer | |
  • This seems ill-advised. Rather than redefine \input, just define (and via \newcommand) the command \definput: \newcommand{\definput}[1]{\addcontentsline{toc}{section}{*** #1 ***}\input{#1}} – jon Jul 2 '16 at 21:16
  • @jon I agree, and that was my initial intention. However, there seem to be many nested inputs and my impression was that the need was to get some overview of them. In that case you would not like to replace the command everywhere, but rather to redefine \input. But I am not even sure I have understood the question completely. (About \def versus \renewcommand I would say they both have their plus and minus). – StefanH Jul 2 '16 at 22:24
  • Replacing the command everywhere takes a matter of seconds using regexp. But using \def is dangerous for many people new to LaTeX. (But I also don't understand the question.) – jon Jul 3 '16 at 5:28
  • I have updated with \renewcommand – StefanH Jul 3 '16 at 8:27

There is an alternative way available, instead of handling TeX or PDF file, you can go with merging PS files by using "Runflex", this is not an exact solution, but giving other alternatives...

| improve this answer | |
  • 1
    Could you provide a link to this Runflex? A simple Google search doesn't yield anything of value. – Werner Apr 10 '17 at 13:21

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.