[OS X TeX] include cannot be nested?

Ross Moore ross at ics.mq.edu.au
Sat Nov 4 19:27:31 EST 2006


Hello Alain,

On 05/11/2006, at 10:32 AM, Alain Schremmer wrote:

> Charilaos Skiadas wrote:
>
>>> On Nov 4, 2006, at 4:43 PM, Alain Schremmer wrote:
>>>
>>>> I have now spent a whole day trying to understand file paths up and
>>>> down folders and I think that I finally got to understand how LaTeX
>>>> works but now I am getting a message saying "include cannot be
>>>> nested". Since I would of course swear on anything that it used to,
>>>> I am now terminally stuck as I don't know what it really means and
>>>> what to do.
>>>
>>>
>>> \include's can't be nested. You would probably want to use \input  
>>> for
>>> your exercises.

No! ...  (see below)

>>>
>>> http://www.eng.cam.ac.uk/help/tpl/textprocessing/teTeX/latex/ 
>>> latex2e-
>>> html/ltx-245.html
>>
> That's quite definite. Now I wonder about the extent to which I can  
> trust my memory. (But see below.)
>
>>>
>>> The following is from a blog post that I haven't managed to finish
>>> yet, about managing large projects in LaTeX. It's, as far as I
>>> understand, the differences between \include{afile} and \input 
>>> {afile}:
>>>
>>> 1. You cannot have nested \include's, while you could have as many
>>> nested \input's as you like.
>>
> Yes, but I need to be able to renew the command and \input cannot  
> be renewed since it is a TeX command.

No, you don't want to renew commands like \input  or  \include .
(\input especially)

What you want is to *use* these commands within a particular context,
along with doing other things. Thus you want to *define* a new command
and then *use this* within your document source.

e.g.  something like this:

\newcommand{\exinput}[3][]{%  includes an exercise
  % #1 = optional indicator for hard exercises
  % #2 = title
  % #3 = file name where the exercise is stored
  \begin{exercise}[#1]{#2}%
   \input{#3}%
  \end{exercise}%
}

where the {exercise} environment is something that has been
setup elsewhere for this document.


Then the document source should contain instances, such as:

  \exinput{easy one}{exercises/ex1_1}
  \exinput{another easy one}{exercises/ex1_2}
  \exinput[*]{now a hard one}{exercises/ex1_3}
  \exinput[!]{now a really hard one}{exercises/ex1_4}


>>> This makes \input a great command to use
>>> for including libraries of custom commands and other preamble stuff.

>>> 2. \include'd files generate their own .aux files, while \input'ed
>>> files don't. I am guessing pdfsync might also not work with  
>>> \input'ed
>>> files, but I haven't tested this.

... and these .aux files are read, even when the file that needs
to be \input is not read.

This is why \include cannot be nested.
The .aux files for any 2nd-level \include'd files would *not* be read,
so the metadata that they contain would not be available.
Thus counter values, symbolic references, bib-items, etc.
would all get out-of-whack.


>>> 3. \include'd files start on a new page no matter what. Depending on
>>> the document class used, they might even start on the first  
>>> available
>>> odd-numbered page. This makes \include's perfect for starting a new
>>> chapter.
>>> 4. \include calls \clearpage right before starting its work. This
>>> means that any floats, like tables and figures, that haven't been
>>> rendered yet for one reason or another, will now be inserted.


Add to this list a new point:   (for large projects)

   5.  If you want anything that is only slightly different from what
       LaTeX provides, then *define your own markup names* for the  
effect.
       Make a \newcommand  definition to implement this, in terms of
       what LaTeX does provide.
       Never redefine anything that LaTeX provides, or is an underlying
       TeX primitive.

It is advantageous to even have simple command definitions such as:

  \newcommand{\exinclude[1]}{\include{#1}}

since you may want to re-use the same collection of data-files
for another project --- or another aspect of the same project
--- in which the markup will be interpreted differently.
It's always much harder to do this when everything has been
written explicitly in primitives, rather than with higher-level,
user-defined commands.

> I now think I know why things worked before as I have now found the  
> exchange that led to my "solution". The thread was called "Unwanted  
> blank page" and the central message is Sneep's 1/3/06 4:08 PM. I  
> have now forgotten all the stuff I tried and did or didn't do ever  
> since but this gives me the occasion for a clean start.



>
> Grateful regards (but any new help would still be … helpful.)
> --schremmer


Hope this helps.

	Ross Moore


>
> Also, I should say that I have no floats and that I don't  
> understand nor really care about underfull/overfull boxes, etc.

Pity; because usually these refer to a glitch that really is visible
on the typeset page.

> I hope I won't be offending anyone if I say that I don't really  
> care for typographical beauty—actually, I do to an extent but  
> certainly not in my own prodduction and I will leave to whoever  
> downloads the stuff to clean it.



------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114
------------------------------------------------------------------------


------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the MacOSX-TeX mailing list