[Tuglist] Expanding \input{files}

E. Krishnan tuglist@tug.org.in
Sat, 13 Apr 2002 11:06:20 +0530 (IST)

On Thu, 11 Apr 2002, H.S.Rai wrote:

> Is there any tool or way (other than "insert file") to
> expand files included by \input.  For example if master.tex
> has following statements:
> \input{file1}	\input{file2}	\input{file3}
> and further, there are two \input statements in each of
> file1, file2 and file3.
> Is it possible to view content of all these 6 files in
> master.tex

I have some partial solutions to your question, in GNU Emacs:

1. Using RefTeX: For this to work, each of your "input files" should start 
   with some LaTeX "section" command such as \chapter, \section etc. (or 
   their starred versions). Load RefTeX in your emacs sessions by 
   including the lines below in your .emacs file:

	(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
	(setq reftex-enable-partial-scans t)
        (setq reftex-save-parse-info t)
        (setq reftex-use-multiple-selection-buffers t)

   Open the master file and type 
		M-x reftex-parse-all
   (Here M- stands for the "meta" key, usually "Alt"). Then type 
			C-c =

   (C- denotes the Ctrl key). You'll then get a "table of contents" from 
   which you can select and edit your various input files. If you're 
   running Emacs in X, then all these can be done via menus and mouse 

2. Using elisp: In your "master" file, after each \input, write a piece of 
   elisp as follows:


	\input{file1}%(find-file "file1.tex")
	\input{file2}%(find-file "file2.tex")


   Also, include the code    

		%(find-file "master.tex")

  at the end of each input file. Open the master file, place the cursor 
  just after the closing parenthesis of the second line and type

			C-c C-e

   The file file1.tex will be opened. To get back to the master file, do 
   the same procedure at the end of the lisp code in the input file.

3. Using outline mode: This is not really a solution to your question, but 
   an alternative way of looking at it. Instead of keeping the document in 
   multiple files and then inputting In a master file, you can put the 
   entire  document in a single file and then collapse it into just the 
   sectioning heads using the outline mode. Type

			M-x outline-minor-mode

   in such a file and then use the various "show" or hide" commands.

   I've a feeling that the second method can be used for a "complete" 
   solution to your question, but I don't know enough lisp for that.