diff options
Diffstat (limited to 'usergrps/uktug/baskervi/8_3/third.tex')
-rw-r--r-- | usergrps/uktug/baskervi/8_3/third.tex | 775 |
1 files changed, 775 insertions, 0 deletions
diff --git a/usergrps/uktug/baskervi/8_3/third.tex b/usergrps/uktug/baskervi/8_3/third.tex new file mode 100644 index 0000000000..6dec1fe873 --- /dev/null +++ b/usergrps/uktug/baskervi/8_3/third.tex @@ -0,0 +1,775 @@ +\chapter{Environmentally aware}\label{env} +\section{Environments} +\LaTeX\ is environmentally aware! One of the key features +of \LaTeX\ is the way in which it uses `environments'\index{environment}: +that is, an `enclosed' structure (which may be part of +another structure), which has some kind of unity. We have +already met one environment, the \verb|document|. There +are a number of other \LaTeX\ environments, all intended +for slightly different purposes. + +Environments have the common feature that they are +bounded by a \verb|\begin{..}|\index{begin@\texttt{begin}} +\verb|\end{..}|\index{end@\texttt{end}} pair. You may only ever +terminate an environment by an environment of exactly the +same name. However, the \verb|\end{document}| will +generally close everything, perhaps with a few oblique +comments from \LaTeX. + +\section{Quoting} +To illustrate an environment, look first at quoting. \LaTeX\ +has two slightly different environments for quoting: +\verb|quote| and \verb|quotation|. A \texttt{quote}\index{quote@\texttt{quote}} +is intended for short, perhaps one line, quotations. +\begin{verbatim} +\begin{quote} +Joe Bob says check it out. +\end{quote} +\end{verbatim} +yields +\begin{quote} +Joe Bob says check it out. +\end{quote} +What do we note about this? The quote is indented to offset it +from the existing text, and there is a little white space +above and below. If we had a longer quotation, we would +be able to see whether the indentation we see was a `normal' paragraph +indentation or whether the whole quote was indented or whether the whole quote +is indented: +\begin{quote} +I am not now, and never have been, a member of the +American Communist Party -- \emph{attributed to Mao Xedung}. +\end{quote} +Obviously it applies to all lines. + +The other alternative is \verb|quotation|\index{quotation@\texttt{quotation}}, +which is really designed for longer quotations containing several +paragraphs: +\begin{quotation} +I know your works, that you are neither hot or cold: I would that you were +either hot or cold. + +But because you are lukewarm, neither hot or cold, I will spit +you out. +\end{quotation} +which may be obtained from +\begin{verbatim} +\begin{quotation} +I know your works, that you are neither +hot or cold: +I would that you were either hot or cold. + +But because you are lukewarm, +neither hot or cold, I will spit you out. +\end{quotation} +\end{verbatim} + +\begin{question} +Use the \texttt{quotation} environment to produce a piece of +quoted text. If your mind is a complete blank, you could +always try: +\begin{verbatim} +It's one hundred and six miles to Chicago; +we got a full tank of gas, half a pack of +cigarettes, it's dark, and we're wearing +sunglasses. + +Hit it. +\end{verbatim} +\end{question} + +\section{Verse or worse} +Lamport introduces another environment +which he describes thus: +\begin{quote} +Poetry is displayed with the \texttt{verse} environment. +\end{quote} +Few poets would want to have their work described as +verse\index{vers@\texttt{verse}}, and even fewer would use the \texttt{verse} +environment to present it. However, the environment is +not without its uses. +And in fact, to be `fair' it has some rather appealing +qualities. Unlike every other situation we have seen so +far, \LaTeX\ asks that you do the line breaking\index{line breaking} yourself +in the \texttt{verse} environment. Do this by terminating a +line with \verb|\\|\index{backslash}. As we shall discover, this works in all +sorts of other places too. +%\begin{verbatim} +\begin{verse} +Bring me my Bow of burning gold:\\ +Bring me my Arrows of desire:\\ +Bring me my Spear: O clouds unfold!\\ +Bring me my Chariot of fire! +\end{verse} +%\end{verbatim} +was produced from +\begin{verbatim} +\begin{verse} +Bring me my Bow of burning gold:\\ +Bring me my Arrows of desire:\\ +Bring me my Spear: O clouds unfold!\\ +Bring me my Chariot of fire! +\end{verse} +\end{verbatim} + +One feature may be worth emphasising. The last line of a stanza does not +have to end with \verb+\\+. Since it is immediately followed by +\verb+\end{verse}+ there is no need to introduce an additional (and +therefore redundant) instruction. +\begin{question} +Find out what happens when you end the last line with \verb+\\+. Does +\LaTeX\ handle it in an elegant and friendly way? +\end{question} + + + +Lamport clearly had Blake in mind when he created the +{\tt verse} environment, since lines which are too long +for the page width wrap over nicely, with a little bit +of extra indentation: +\begin{verse} +Excess of sorrow laughs. Excess of joy weeps.\\ +The roaring of lions, the howling of wolves, the raging +of the stormy sea, and the destructive sword, are +portions of eternity too great for the eye of man.\\ +The fox condemns the trap, not himself +\end{verse} + +There are two other features of note here. The first is that the \verb|\\| +instruction has a variant\index{variant} form, the \texttt{*}\index{asterisk@*} +form. If you write \verb|\\*|, \LaTeX\ will not allow the page to be +broken at that point. This useful feature is +an example of a variant form for the instruction. We will find that many +\LaTeX\ instructions have a \verb|*| variant, which modifies +the default way in which the instruction is handled. + +The second feature is that the instruction may take an optional\index{options} +argument. We have met optional arguments before, and we shall meet them again and +again. Optional arguments are always enclosed in square brackets -- +\mbox{\texttt{[}\thinspace\texttt{]}}. Here the optional argument allows us to +specify how much additional space to leave between lines -- a +\emph{dimension}\index{dimensions} is specified, complete with its units. In the +case of the +\verb+\\+ instruction we would have something like \verb+\\[0.5cm]+ where some +dimension, in this case 0.5\,cm, was specified in the square brackets. This is +similar to the optional arguments we have already met for +\verb|\documentclass|, except that +\verb|\documentclass| also requires an argument in braces. Once we know +what units we can use, this optional argument offers some useful +possibilities. + +\section{Units\index{units} -- a digression}\label{units} +We have come a long way, without any real reference to the sizes\index{size} of +things, except fonts. In general, we shouldn't be too concerned with sizes of most +things on the page, since the selection of the document style implicitly +specifies many of the relationships and sizes of parts of the document. +Nevertheless, there are times when we want to do something particular, +where we must somehow specify a size. + +\begin{table*} +\begin{center} +\begin{tabular}{|cll|} +\hline +abbreviation & name & conversion\\ +\hline + pt & point & \\ + pc & pica & 1\thinspace pc=12\thinspace pt \\ + in & inch & 1\thinspace in=72.27\thinspace pt \\ + bp & big point & 72\thinspace bp=1\thinspace in \\ + cm & centimeter & 1\thinspace in=2.54\thinspace cm \\ + mm & millimeter & 10\thinspace mm=1\thinspace cm \\ + dd & did\^ot point & 1157\thinspace dd=1238\thinspace pt \\ + cc & cicero & 1\thinspace cc=12\thinspace dd \\ + sp & scaled point & 65536\thinspace sp=$2^{16}$sp=1\thinspace pt \\ + em & width of `M' & (current font)\\ + ex & height of `x' & (current font)\\ +\hline +\end{tabular} +\end{center} +\caption{Units\index{units} used in \LaTeX\ to specify dimensions}\label{tunit} +\end{table*} + +Table \ref{tunit} shows the units which \LaTeX\ `knows' about, +together with their conversions. To specify a dimension, say +\verb|12pt|, \verb|0.7pc| or \verb|12in|, or even \verb|12 pt|, \verb|0.7 pc| +or \verb|12 in| if you find that easier to write or read. If you inadvertently +say \verb|12inches|, \LaTeX\ will assume that the \verb|12in| is the +dimension, and that the \verb|ches| is text to be printed. Of course +\verb|12points| wouldn't even be understood and would generate an error. + +(\La)\TeX\ uses the conversions as \emph{exact} +ratios -- in other words, even if they are not the exact and true +conversions, they are what \LaTeX\ uses (this ensures a degree of +standardisation within \LaTeX). Any value preceding one of these units +may be specified as either a whole (integer) number, or one with a decimal +point (decimal numbers would not make much sense in the case of `scaled +points'). \LaTeX\ does not support mixtures of units, so that `two picas +and four points' would not be acceptable, except as 2.3333333pc or 28pt. + +You do not have to stick to any particular dimensions throughout your +document. Mix metric, Imperial and printers' dimensions as you wish. The +printer's point\index{points} makes some sort of sense as a base unit, since all +the fonts are described in terms of their `point' size. But outside that +particular area, any other `size' can be described in any of the above +dimensions. If you do not include a dimension, \LaTeX\ will often assume +points are meant; it is safer to give the dimension. If the dimension is +zero, it still needs units. + +The \verb|em|\index{em} and \verb|ex|\index{ex} deserve a little more +explanation. They are the only two `relative measures'. In +typographic terms, an em (also known as a \emph{mutton}) is a horizontal +measure (being approximately the width of a capital `M' in the \emph{current} +font), while an ex (also known as an \emph{en-nut}) is a vertical measure (the +height of an `x' in the \emph{current} font). If you change font, the values of +em and ex will also change. Although an em is intended as a horizontal +measure, it will be possible to use it in a vertical sense: similarly, the ex +may be used for horizontal amounts. \LaTeX\ is not that picky. + +\subsection{The point} +In this sort of situation, in verse, it is more +general to specify a distance which is related in some way to the font in +use: a relative rather than an absolute figure: +\begin{verse} +Our plesance here is all vain glory,\\ +This fause warld is but transitory;\\ +The flesh is brukle, the Fiend is slee:\\*[2ex] +\emph{Timor mortis conturbat me.} +\end{verse} +The `refrain' is separated from the rest of the poem by an additional +2\,ex, obtained by terminating the line preceding the refrain by +\verb|\\[2ex]|: +\begin{verbatim} +The flesh is brukle, the Fiend is slee:\\[2ex] +\end{verbatim} +\begin{question} +Try that last example, but use different units. How would you leave a gap +which was equivalent to a blank line? +\end{question} +\section{Lists} +If \LaTeX\ is remembered for nothing else, it will be +remembered for the way in which Lamport elevated the +`list'\index{lists} into a common, powerful, all-pervading structure. +The more I think about it, the more I see myself +surrounded by documents which are most effectively +presented as lists, or lists within lists. As a technique +for structuring an argument, and giving relative weights +to various parts and sub-parts, it can be enlightening and fundamental. + +\LaTeX\ has three basic list structures, each with +slightly different attributes and visual properties. +There are also facilities to extend these. The structures +are\index{index@\texttt{itemize}}\index{enumerate@\texttt{enumerate}}\index{description@\texttt{description}} +\begin{itemize} +\item enumerate +\item itemize +\item description +\end{itemize} +Of course, this is a list! It was generated by +\begin{verbatim} +\begin{itemize} +\item enumerate +\item itemize +\item description +\end{itemize} +\end{verbatim} +Now we have (almost) the whole syntax\footnote{You should +be able to guess that there are probably some optional +arguments lurking about somewhere. There usually are.} of +these list-making environments. + +As usual, the environment must be terminated with the +correct name. + +\begin{question} +Try doing something like this: +\begin{verbatim} +\begin{itemize} +\item just a word or two +\item and another one +\end{enumerate} +\end{verbatim} +The error message which \LaTeX\ gives in this +context is very annoying: +\begin{verbatim} +! \begin{itemize} on input line 3 ended + by \end{description}. +\end{verbatim} +It is informative that \LaTeX\ stops at this point, but +also helpful that it will allow you to continue. A pity it misleads. +\end{question} + +If you are an \texttt{emacs} guru, or have another similarly +powerful editor\footnote{Correctly, \texttt{emacs} is a way +of life. Like (\La)\TeX, there is nothing \texttt{emacs} cannot do, +in the right hands.}, and skill, you could ensure that your +\verb|\begin{..}| was always terminated +correctly. + +\subsubsection{Itemizing} +Using the \verb|itemize|\index{itemize@\texttt{itemize}} environment, each item +is marked in some way. Different levels of itemization are given +different symbols. This implies that you can +nest itemization instructions. In fact, you can nest the +whole concept of environments in general, and lists in +particular\footnote{Almost true; don't go too deep.}. + +\begin{question} +Find out what the symbols are for the various levels of +itemization. +\end{question} +\begin{question} +Find out just how deeply you can nest itemization. +\end{question} + +\subsubsection{Enumerating} +As you may guess, the \texttt{enumerate} environment numbers each +item\index{enumerate@\texttt{enumerate}}. This implies that there must be a +counter marching away somewhere, incrementing each time \verb|\item| is +encountered. And so there is. There may be several, since we can, as +usual, nest enumeration too. +\begin{question} +Find out what happens when you nest levels of +enumeration. For example, you could use one of your last exercises, +changing the \verb|\begin{itemize}| to \verb|\begin{enumerate}|. +Remember to change the \verb|\end| too. +\end{question} +\begin{question} +Now nest enumeration within itemization (or even +itemization within enumeration). +\end{question} + +\subsubsection{Describing} +In the \verb|description|\index{description@\texttt{description}} environment, +you +\emph{must} provide an optional (\emph{sic}) argument on the \verb|\item|. +This argument will be the `key' to the list. In the +previous list environments, \LaTeX\ generated something +(a symbol, or a number\slash letter) to mark each \verb|item|. +This time, you have to provide the `mark': +\begin{verbatim} +\begin{description} +\item[aardvark] mainly harmless -- +as in ``aardvark never hurt anyone''. +\item[Betty Boop] a pleasure and a +delight. One of \emph{the} great artistes. +\item[crow] family of birds including the +magpie (\textsl{pica pica}) +\end{description} +\end{verbatim} +which comes out looking like +\begin{description} +\item[aardvark] mainly harmless -- as in ``aardvark never +hurt anyone''. +\item[Betty Boop] a pleasure and a delight. One of \emph{the} +great artistes. +\item[crow] family of birds including the magpie (\textsl{pica pica}) +\end{description} +\begin{question} +Perhaps I exaggerate when I say that this environment requires an optional +argument. Demonstrate what happens if you omit the optional argument on the +\verb+\item+s in \verb+description+. Or whether the other list environments +may take optional arguments. +\end{question} +\begin{question} +It has always seemed to me that these three basic list environments are not +well named -- with two verbs and a noun. Devise a better and more consistent +set of names. \textsc{Html} uses the rather terse \texttt{ol} (ordered list), +\texttt{ul} (unordered list), and \texttt{dl} (data list). +\end{question} +%%%%%%%%%%%inserted section 3-e.tex +\section{Read my lips} +Another two pairs of environments may be useful. As these +notes show, it is often useful to be able to express chunks +of text in typrewriter form -- that is `verbatim', where +every symbol is recorded as it was typed in. This may not be +a frequent requirement. \LaTeX\ has a \verb+verbatim+ environment +which will handle this. Obviously it has to turn off lots of \LaTeX's normal +processing, and as a result there are some limitations. When the environment is +ended, the \verb+\end{verabtim}+ must occur on a line by itself. A variant is +the *-form, where any blanks (spaces) within the material will be printed out +as \verb*+ +. Besides needing to be able to present chunks of text literally, +it may also be necessary to do this for odd symbols or words. The command +\verb+\verb+ is provided for this. For example, if we write +\begin{verbatim} +The backslash, \verb+\+, introduces every instruction, with a few +exceptions, including \verb=~=. +\end{verbatim} +then the result will be +\begin{quote} +The backslash, \verb+\+, introduces every instruction, with a few +exceptions, including \verb=~=. +\end{quote} +Note how \verb+\verb+ works. The material which is to be expressed verbatim is +`enclosed' within a pair of repeated arbitrary symbols. The only symbols which +may not be used are \verb+*+, since there is a variant, \verb+\verb*+, where +any enclosed blanks are again represented by \verb*+ +. For example +\begin{verbatim} +The tag \verb*+< html>+ will not be +recognized, since the space (\verb*+ +) +after the \verb+<+ should not be present +\end{verbatim} +would give us +\begin{quote} +The tag \verb*+< html>+ will not be recognized, since +the space (\verb*+ +) after the \verb+<+ should not be present +\end{quote} +Although line endings are respected in the \verb+verbatim+ environment, + you should not have a line end in the body of a \verb+\verb+. This is seldom a +problem, but if you use an editor which wraps (like \Textures), you may +inadvertantly break a \verb+\verb+ over a line. \LaTeX\ will note the error. +Another important factor is that neither of these instructions may appear in +the argument of another instruction. + + +The sister environment to \verb+verbatim+ is \verb+alltt+. This is identical, +except that \verb+\+, \verb+{+ and \verb+}+ all have their `normal' meanings. +We may therefore have +\begin{verbatim} +\begin{alltt} +Even in text we need to \textsl{slant} +\end{alltt} +\end{verbatim} +to yield +\begin{quote} +\begin{alltt} +Even in text we need to \textsl{slant} +\end{alltt} +\end{quote} +If we wish to use this feature we should first ensure that the \verb+alltt+ +package is loaded. We'll cover this aspect a little later. + +\section{One paragraph at a time} +The other major environments are connected with the setting of paragraphs. In +a later chapter we will look at how \LaTeX\ actually handles the +setting of text. In the mean time we will note that sometimes it does not +manage to align the right margin and complains of `overfull boxes'. There are +many solutions to this. One is to provide \LaTeX\ with more flexibility in +setting the paragraph. This can be translated as `being more sloppy'. The two +environments \verb+sloppypar+ and \verb+fussypar+ are provided to handle this. +The default is \verb+fussypar+, and therefore it is unclear just why you might +want to switch it on, when a `sloppy' set of paragraphs can be delimited +easily. Note this is a paragraph matter. Since \LaTeX\ does its +typesetting on a paragraph by paragraph basis, there is no point trying to set +part of a paragraph `sloppy' and part `fussy'. The concept just does not exist. + +An alternative to this \verb+sloppypar+ environment is to use the instruction +\verb+\sloppy+. There is a corresponding +\verb+\fussy+ instruction too. One of \LaTeX's quirks, a consequence +of treating text on a paragraph basis, is that the inclusion of +one of these instructions within a paragraph, whether at the end or the +beginning, turns the whole paragraph into that style; and of course every +following paragraph too, unless you issue new instructions, or are careful to +limit the action in some other way. + + + +It is also possible to exercise control over the way \LaTeX\ sets lines within +paragraphs. Normally \LaTeX\ spreads out the space between words to have both +the right and left margins aligned vertically -- set `flush left' and +`flush right' +(or \emph{justified}). If, instead of adjusting the space, +it is made constant, the left margin remains fixed and a ragged +right margin would appear. The \verb+flushleft+ environment has this effect. +Its mirror-twin, \verb+flushright+ will make the left margin ragged. And a third +variant may be more useful, \verb+center+, where the text is effectively +centred around the middle axis. Taken with \verb+\\+ to break lines, this is +sometimes a useful way of creating title information. All three of these +environments have corresponding instructions: respectively they are +\verb+\raggedright+, \verb+\raggedleft+ and \verb+\centering+. Again, recall that +these instructions and environments will apply to whole paragraphs. + +Observation will demonstrate that the \verb+verse+ environment is set +ragged right, presumably to minimise +hyphenation, while \verb+quotation+ is justified. + +\subsection{More to come} +This is was just a glimpse of the environments available in \LaTeX. +A few more will crop up. It makes little sense to present + \emph{all} the environments at once, especially +when they each have quite different functions. The key +things to note are +\begin{itemize} +\item that they must be enclosed by the same +identifier or label (e.g.~\texttt{quote} or \texttt{itemize}), +\item that they \emph{may} have +optional arguments, +\item and that they may not overlap. +\end{itemize} + +\section{Sections\index{sections} and the like} +Many (most) documents can be thought of as highly +hierarchical, with a subdivision into successively +smaller units, down the scale through `parts', +`chapters', `section', `subsections', right down through +`paragraphs'\index{paragraphs} to sentences and even words. \LaTeX\ recognizes +this and provides a set of `sectioning' instructions, shown in +Table~\ref{tsect} +\begin{figure*} +\begin{center} +\begin{tabbing} +\makebox[1.5in]{}\=\verb|\part|\\ +\>\quad\=\verb|\chapter|\\ +\>\>\quad\=\verb|\section|\\ +\>\>\>\quad\=\verb|\subsection|\\ +\>\>\>\>\quad\=\verb|\subsubsection|\\ +\>\>\>\>\>\quad\=\verb|\paragraph|\\ +\>\>\>\>\>\>\quad\=\verb|\subparagraph| +\end{tabbing} +\end{center} +\caption{The sectional hierarchy}\label{tsect} +\end{figure*} + +Now, note that we do not in fact go down right to the +sentence or word level. And also note that Lamport's +\verb|\paragraph|\index{paragraph@\texttt{paragraph}} and \verb|\subparagraph| +are not really paragraphs at all. Lamport merely says +\begin{quote} +``The names \dots\ are unfortunate, since they usually +denote units that are usually composed of several +paragraphs; they have been retained for historical +reasons.'' +\end{quote} +Make of that what you will. + +Each sectioning instruction requires an `argument' -- its own +title. Since this is mandatory, it appears in braces. +(Remember that only optional arguments appear in square +brackets.) + +What do we get out of sectioning? It is easiest to see by +trying it out. As you will have realised, this document +is produced with \LaTeX. We have already used +\verb|\chapter|\index{chapter@\texttt{chapter}} at the beginning of this +`section', using the statement +\begin{verbatim} +\chapter{Environmentally aware} +\end{verbatim} +Somehow, \LaTeX\ managed to work out that this is the +chapter~\ref{env}, and arranged for the details to be +printed out. So one of the things going on in the +background is to keep track of the level of the +sections. Similarly, this particular section started with a +\begin{verbatim} +\section{Sections and the like} +\end{verbatim} +instruction. Again, \LaTeX\ kept track of the levels. Notice +too that it presented the information in different ways. +There are no sub-sections here, but we could invent a few: +\begin{verbatim} +\section{Sections} +In article and report, section is the + highest level. +\subsection{Subsections} +After the section comes the subsection. +\subsubsection{Subsubsection} +After that comes the subsubsection. +\paragraph{Paragraph} +Then we have paragraphs which run on + immediately after the paragraph label. +\subparagraph{Subparagraph} +And at the very lowest level, the + subparagraph, which, like the paragraph + runs on. +\end{verbatim} + yields Figure~\ref{sectioning} where the slight reduction in size is +deliberately introduced to highlight these sub-divisions. +Each of these sections must contain something, if only a lower level unit. +At the lowest unit, there must be some text. + + +\begin{figure*} +\begin{center} +\begin{minipage}{0.75\textwidth} +\small +\textbf{\large 3\quad Sections}\\[0.4\baselineskip] +In article and report, section is the highest level.\\[0.75\baselineskip] +\textbf{\normalsize 3.2\quad Subsections}\\[0.4\baselineskip] +After the section comes the subsection.\\[0.75\baselineskip] +\textbf{3.2.1\quad Subsubsection}\\[0.4\baselineskip] +After that comes the subsubsection.\\[0.75\baselineskip] +\textbf{Paragraph}\quad +Then we have paragraphs which run on immediately after the paragraph +label.\\[0.75\baselineskip] +\textbf{Subparagraph}\quad +And at the very lowest level, the subparagraph, which, like the paragraph runs +on. +\end{minipage} +\end{center} +\caption{Sub-divisions from Section to Subparagraph\label{sectioning}} +\end{figure*} + + + + +\begin{question} +This book makes no real use of \verb|\paragraph| and \verb|\subparagraph| +since its author doesn't think in those terms. Find out how \LaTeX\ +actually handles the text which follows these sectioning instructions. The +results may not be entirely anticipated. +\end{question} + + Naturally, in order to begin +(say) a subsection, you will already have begun a section. And equally +naturally, you may expect to have several subdivisions within a division. +On the other hand, as may be obvious here, the +\verb|book| style does not require the presence of +\verb|\part|. It can start with a \verb|\chapter|. +Similarly, the \verb|\article| style does not use +\verb|\chapter| at all. This does mean you can string all +your articles together into a book, all too easily, just +by a few easy edits. + +\begin{question} +Demonstrate what happens when you nest the sectioning (subsectioning, +subsubsectioning\dots) instructions inconsistently. +\end{question} + +What else have we gained? The table of contents\index{table of +contents}\index{contents} at the beginning is also generated automatically as a +result of creating sections. Now, examine the table of contents +carefully to determine which levels are actually +reflected in the table of contents which is created. The section +`argument' (the bit in braces) goes into the table of contents ({\em +toc}) in its entirety. The entry may also be used to change the +running head\index{running head}\index{head} (at the top of the +page)\footnote{not here, because the \BV\ house style over-rides this.}. + +\LaTeX\ allows you to modify the behaviour of the +sectioning\index{sections} instructions in two main ways: +\begin{enumerate} +\item we may wish a different entry +to appear in the table of contents from the `body'; or +\item we may not wish the entry to appear in the table of contents, or +the running head (and by implication, not to be numbered). +\end{enumerate} + +Both these requirements may be fairly readily +accommodated. +Changing the table of contents `\texttt{toc}' entry is readily +accomplished by adding an optional argument: +\begin{verbatim} +\subsection[What I really +want to appear]{Sub-sub-section} +\end{verbatim} +This optional argument will now appear in the table of contents +in place of the entry which introduces the subsection. +Limiting the action, and producing a `simple' entry +is possible through the \verb|*| form\index{variant}. This is another of the +instructions which have a variant form, followed immediately by the~\verb|*|. +In this case, it would appear as +\begin{verbatim} +\subsubsection*{An almost anonymous entry} +\end{verbatim} +This also suppresses the increments in the +counter for this particular subsection. +%\end{itemize} + + +\section{Table of contents} +Having mentioned the presence of a table of contents (or +a \emph{potential} table of contents), we have to say a +little more about it. This is not generated unless you do +actually ask for it. How do you ask for it? +Say\index{tableofcontents@\texttt{tableofcontents}} +\begin{verbatim} +\tableofcontents +\end{verbatim} +and \LaTeX\ will insert the table of contents at that +point. Now, if the table of contents appears somewhere at the beginning +of the document, how does \LaTeX\ `anticipate' what the section +descriptions are to be? +Since it cannot know, what actually happens is +that you run your \LaTeX\ file several times. The first +time round \LaTeX\ generates a new file of the same name, +but with a \verb|.toc|\index{toc@\texttt{.toc}} extension. It is this file which +is read the second time around. Note that it might still +be out of step, if you have edited the file in between. +Essentially what has to happen is that the very final, +unchanged file has to be run \emph{at least} twice to resolve the table +of content entries (recall that it includes the page +numbers too). + +\section{Other background activity} +Although we have not touched on figures and tables (yet), +there are similar instructions which allow list of figures and tables to be +generated. A similar sort of process goes on. A special +file is generated which contains information about the +list of figures, the list of tables, or even a glossary +or an index. The instructions for lists of figures and +tables are: +\begin{verbatim} +\listoffigures +\listoftables +\end{verbatim} +and the files they write are given the extensions +\verb|.lof|\index{lof@\texttt{.lof}} and +\verb|.lot|\index{lot@\texttt{.lot}}. In +fact, you will find that +\LaTeX\ can be altogether profligate, creating all sorts +of other files, usually with the main file's name, but +different extensions. Every \LaTeX\ job creates a +\verb|.log|\index{log@\texttt{.log}} and an +\verb|.aux|\index{aux@\texttt{.aux}} file. The log file can give +a lot of information about what +is going on. Sometimes some of it is useful. Typically +a log is produced as you run the file through \LaTeX, but +more information will be inserted into the \verb+.log+ file, which may +be consulted later. The `auxiliary' file is more specific and +contains some useful information for subsequent \LaTeX\ runs. It is not +intended for reading by people, just \LaTeX. + +The truth is simply that we very +rarely get everything finished, or right, the first time +around -- it is so tempting to run a bit through \LaTeX\ +and see if it looks any good. In passing we could +demolish the myth that electronic document preparation +saves any time or money, or that office productivity tools have anything to +do with increasing productivity. When you can make the corrections yourself, +you do, using your time, which is costly. And you seek perfection, because you +know it is attainable. Before, you were just grateful to get something -- +anything. + +Most of these extra `information' files are there solely for +\LaTeX, and are of little direct use to us (except in terms of what they will +allow us to do). They are just about human readable, but why bother? Perhaps +the key thing to note though is that if you send off your \LaTeX\ file to +someone else, or receive one from someone else, you +really should expect to have it run through your document at least twice before +it looks as it should. This is a bit unexpected for the naive +or inexperienced. + + + +\begin{question} +Now have a look and see what extra files \LaTeX\ appears +to have generated for you. Look too at an old \verb|.log| +file to see the information which \LaTeX\ will have +issued about these extra files. As usual, it is often +difficult to distinguish the useful material from the +rather less useful material (`garbage'). We really need a +\verb|.junk| file too. +\end{question} + + +%\mbox{\verb|[|\thinspace\verb|]|}. Here the optional argument allows us to + +\begin{question} +One of the things that puzzle me about +\LaTeX\ is why sections are not environments, or even +lists. \LaTeX\ will permit you to write something like +\begin{verbatim} +\begin{itemize} +\section{... +\begin{quote} +\section{..... +\end{quote} +. +. +\end{itemize} +\end{verbatim} +While I can see that the section may be part of an +environment, I am surprised that it can span environments +in this way. + +Any explanations? +\end{question} |