[texhax] \include Chapter1} does not work

Uwe Lueck uwe.lueck at web.de
Mon Oct 24 10:18:43 CEST 2011


"John C Frain" <frainj at gmail.com> wrote 22 October 2011 00:41:
> There is some kind of missunderstanding here.
> [...]
> \chapter{Chapter 1 Title}
> Chapter 1 text follows here
> [...]
> If a (master) LaTeX file contains seveal \include statements the
> compile may be restricted to the master file and those files listed in
> an \includeonly statements in the preamble to the master file.

And indeed, the chapter files must *not* contain \documentclass
and \begin/\end{document}.

The misunderstanding may be what Adolf Giger writes in the
attached AJGbook1.tex.pdf:

> Herb Schulz suggested preparing chapters 1
> and 2 in separate TeX sessions, still using the
> same preambles.

But on 10/18/11 4:39 AM, "Herbert Schulz" <herbs at wideopenwest.com> wrote:
> Yes, you supply the ChapterN.tex files. They are ``generated'' the same way
> you ``generated'' the AJGbook.tex files from within TeXShop. You then use
> \include commands so that when you typeset AJGbook.tex using pdflatex (by
> default with TeXshop) and it will read in the ChapterN.tex files you include
> (and if you have an \includeonly command it will not include the ones missing
> there).

Herb says that when you work with TeXshop, edit the master file
and the chapter files with TeXshop. It is a misinterpretation to conclude
the chapter files should be treated by "separate TeX sessions", and
Herb did not say in any way that they must have their own preambles.

I don't know exactly what a "TeX session" is, I guess it is
editing and recompiling the source files for *one document*
-- by running the TeX compiler on some file.
But only the master file must be this file.

>From the same AJGbook1.tex.pdf:
> Error message: chap1.tex can be used only
> in preamble ! and there was no pdf printed.

You better copy the error message (from the .log file)
into the mail body instead of typing your own summary
-- which is quite wrong here. The message actually is

> ! LaTeX Error: Can be used only in preamble.

and a code line (or something looking so) follows
that is split into the part that has been processed and a
-- lower -- part that has not been processed so far,
and the final command of the upper part is what the
message refers to: it is the \documentclass command
in chap1.tex.

So the message says what I said before: DO NOT
make extra preambles in the chapter files.
DO NOT repeat \documentclass.
In one TeX run, LaTeX does NOT accept another
preamble after processing the first one.

The source of the misunderstanding may still be the word
"generated" that has been quoted so often in this thread.
As before, Herbert Schulz" wrote:

> Yes, you supply the ChapterN.tex files. They are ``generated'' the same way
> you ``generated'' the AJGbook.tex files from within TeXShop.

"Generated" here means that the author must type/edit them. 
When run on those files "generated" by the author,
TeX "generates" DVI/PDF from those files, in the course of this
it should "generate" the chapters (according to \includeonly
-- here "chapters" refers to the DVI/PDF pages that the TeX compiler
turns the author's chapN.tex files into). Herb by no means said
that you must run TeX on thechapter files in order to "generate" the chapters.

I have never worked with TeXShop, as to how to use it with
\include. Some years ago I worked with WinShell. There indeed
you had tabs for all the input files that were open for editing.
WinShell did not know which one the master file was,
and often it ran a chapter file instead of the master file.
It liked to run the file that was edited just before -- typically
a chapter file. To avoid this, you had to click on the tab
for the master file after editing a chapter file.

HTH -- Uwe.



More information about the texhax mailing list