\include
commands?
The original LaTeX provided the \include
command to address the
problem of long documents: with the relatively slow computers of the
time, the companion \includeonly
facility was a boon. With the
vast increase in computer speed, \includeonly
is less valuable
(though it still has its place in some very large projects).
Nevertheless, the facility is retained in current LaTeX, and causes
some confusion to those who misunderstand it.
In order for \includeonly
to work, \include
makes a separate
.aux
file for each included file, and makes a `checkpoint' of
important parameters (such as page, figure, table and footnote
numbers); as a direct result, it must clear the current page
both before and after the \include
command. What's more, this
mechanism doesn't work if a \include
command appears in a file
that was \include
d itself: LaTeX diagnoses this as an error.
So, we can now answer the two commonest questions about \include
:
\include
commands?
Answer: because it has to. If you don't like it, replace the
\include
command with \input
- you won't be able to use
\includeonly
any more, but you probably don't need it anyway, so
don't worry.
\include
d files? - I always used to be
able to under LaTeX 2.09.
Answer: in fact, you couldn't, even under LaTeX 2.09, but the failure
wasn't diagnosed. However, since you were happy with the behaviour
under LaTeX 2.09, replace the \include
commands with \input
commands (with \clearpage
as appropriate).
When TeX is laying out text, it doesn't work from word to word, or from line to line; the smallest complete unit it formats is the paragraph. The paragraph is laid down in a buffer, as it appears, and isn't touched further until the end-paragraph marker is processed. It's at this point that the paragraph parameters have effect; and it's because of this sequence that one often makes mistakes that lead to the paragraph parameters not doing what one would have hoped (or expected).
Consider the following sequence of LaTeX:
{\raggedright % declaration for ragged text Here's text to be ranged left in our output, but it's the only such paragraph, so we now end the group.} Here's more that needn't be ragged...
TeX will open a group, and set the ragged-setting parameters within
that group; it will then save a couple of sentences of text and
close the group (thus restoring the previous value of the
ragged-setting parameters). Then it encounters a blank line, which it
knows to treat as a \par
token, so it typesets the two sentences;
but because the enclosing group has now been closed, the parameter
settings have been lost, and the paragraph will be typeset normally.
The solution is simple: close the paragraph inside the group, so that the setting parameters remain in place. An appropriate way of doing that is to replace the last three lines above with:
end the group.\par} Here's more that needn't be ragged...
In this way, the paragraph is completed while the setting parameters are still in force within the enclosing group.
Another alternative is to define an environment that does the appropriate job for you. For the above example, LaTeX already defines an appropriate one:
\begin{flushleft} Here's text to be ranged left... \end{flushleft}
Sometimes LaTeX saves data it will reread later. These data are often the argument of some command; they are the so-called moving arguments. (`Moving' because data are moved around.) Places to look for are all arguments that may go into table of contents, list of figures, etc.; namely, data that are written to an auxiliary file and read in later. Other places are those data that might appear in head- or footlines. Section headers and figure captions are the most prominent examples; there's a complete list in Lamport's book (see TeX-related books).
What's going on really, behind the scenes? The commands in the moving
arguments are already expanded to their internal structure during the
process of saving. Sometimes this expansion results in invalid TeX
code when processed again. ``\protect
\cmd
'' tells LaTeX to save
\cmd
as \cmd
, without expansion.
What is a `fragile command'? It's a command that expands into illegal TeX code during the save process.
What is a `robust command'? It's a command that expands into legal TeX code during the save process.
No-one (of course) likes this situation; the LaTeX3 team have removed the need for protection of some things in the production of LaTeX2e, but the techniques available to them within current LaTeX mean that this is an expensive exercise. It remains a long-term aim of the team to remove all need for these things.
\verb
work within...?
The LaTeX verbatim commands work by changing category codes. Knuth
says of this sort of thing ``Some care is needed to get the timing
right...'', since once the category code has been assigned to a
character, it doesn't change. So \verb
has to assume that it is
getting the first look at its parameter text; if it isn't, TeX has
already assigned category codes so that \verb
doesn't have a
chance. For example:
\verb+\error+
will work (typesetting `\error
'), but
\newcommand{\unbrace}[1]{#1} \unbrace{\verb+\error+}
will not (it will attempt to execute \error
). Other errors one
may encounter are `\verb
ended by end of line', or even `\verb
illegal in command argument'.
This is why the LaTeX book insists that verbatim
commands must not appear in the argument of any other command; they
aren't just fragile, they're quite unusable in any command parameter,
regardless of
\protect
ion.
TeX provides two primitive commands \uppercase
and
\lowercase
to change the case of text; they're not much used, but
are capable creating confusion.
The two commands do not expand the text that is their parameter -
the result of \uppercase{abc}
is `ABC
', but \uppercase{\abc}
is always `\abc
', whatever the meaning of \abc
. The commands
are simply interpreting a table of equivalences between upper- and
lowercase characters.
They have (for example) no mathematical sense, and
\uppercase{About $y=f(x)$}
will produce
ABOUT $Y=F(X)$
which is probably not what is wanted.
In addition, \uppercase
and \lowercase
do not deal very well
with non-American characters, for example \uppercase{\ae}
is the
same as \ae
.
LaTeX provides commands \MakeUppercase
and \MakeLowercase
which fixes the latter problem. These commands are used in the
standard classes to produce upper case running heads for chapters
and sections.
Unfortunately \MakeUppercase
and \MakeLowercase
do not solve
the other problems with \uppercase
, so for example a section
title containing \begin{tabular}
... \end{tabular}
will
produce a running head containing \begin{TABULAR}
. The simplest
solution to this problem is using a user-defined command, for
example:
\newcommand{\mytable}{\begin{tabular}... \end{tabular}} \section{A section title \protect\mytable{} with a table}
Note that \mytable
has to be protected, otherwise it will be
expanded and made upper case.
#
signs doubled in macros?
The way to think of this is that ##
gets replaced by #
in just the
same way that #1
gets replaced by `whatever is the first argument'.
So if you define a macro and use it as:
\def\a#1{+++#1+++#1+++#1+++} \a{b}
the macro expansion produces `+++b+++b+++b+++', which people find normal. However, if we now replace part of the macro:
\def\a#1{+++#1+++\def\x #1{xxx#1}}
\a{b}
will expand to `+++b+++\def\x b{xxxb}
'. This
defines \x
to be a macro delimited by b
, and taking no
arguments, which people may find strange, even though it is just a
specialisation of the example above. If you want \a
to
define \x
to be a macro with one argument, you need to write:
\def\a#1{+++#1+++\def\x ##1{xxx##1}}
and \a{b}
will expand to
`+++b+++\def\x #1{xxx#1}
', because #1
gets replaced by `b'
and ##
gets replaced by #
.
To nest a definition inside a definition inside a definition then
you need ####1
, as at each stage ##
is replaced by
#
. At the next level you need 8 #
s each time, and so on.
LaTeX splits footnotes when it can think of nothing better to do. Typically, when this happens, the footnote mark is at the bottom of the page, and the complete footnote would overfill the page. LaTeX could try to salvage this problem by making the page short of both the footnote and the line with the footnote mark, but its priorities told it that splitting the footnote would be preferable.
As always, the best solution is to change your text so that the problem doesn't occur in the first place. Consider whether the text that bears the footnote could move earlier in the current page, or on to the next page.
If this isn't possible, you might want to change LaTeX's perception
of its priorities: they're controlled by
\interfootnotelinepenalty
- the larger it is, the less willing
LaTeX is to split footnotes.
Setting
\interfootnotelinepenalty=10000
inhibits split footnotes altogether, which will cause `Underfull
\vbox
' messages unless you also specify \raggedbottom
. The
default value of the penalty is 100, which is rather mild.
An alternative technique is to juggle with the actual size of the
pages. \enlargethispage
changes the size of the current page by
its argument (for example, you might say
\enlargethispage{\baselineskip}
to add a single line to the page,
but you can use any ordinary TeX length such as 15mm
or -20pt
as argument). Reducing the size of the current page could force the
offending text to the next page; increasing the size of the page may
allow the footnote to be included in its entirety. It may be
necessary to change the size of more than one page.