diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /info/beginlatex/src/old |
Initial commit
Diffstat (limited to 'info/beginlatex/src/old')
59 files changed, 19073 insertions, 0 deletions
diff --git a/info/beginlatex/src/old/beginlatex-tugbook.tex b/info/beginlatex/src/old/beginlatex-tugbook.tex new file mode 100644 index 0000000000..bf2d7c4796 --- /dev/null +++ b/info/beginlatex/src/old/beginlatex-tugbook.tex @@ -0,0 +1,8648 @@ +\documentclass[letterpaper,twoside]{report} +\usepackage{tugbook} +\begin{document} +\title{Formatting information} +\subtitle{A beginner's introduction to typesetting with + \LaTeX{}} +\author{Peter Flynn\\[1em]{\fontseries{m}\selectfont Silmaril Consultants\\ +\textit{Textual Therapy Division}}} +\date{v.3.4 November 2003} +\maketitle +\clearpage +\subsubsection*{Acknowledgments} +Thanks to all the people who sent me corrections and + suggestions for improvement or additions to earlier versions. + As usual, the problem has been what to leave out, not what to + include.\par +Some of the suggestions were well-intentioned but would + have turned the book into a higher-level mathematics treatise. + One of my objectives was to omit all maths except for a short + example, as all the other books on \TeX{} and \LaTeX{} already + cover mathematical typesetting in finer and better detail than + I am capable of.\par +Some of the suggestions would have taken me down + pathways I prefer not to tread. Large software corporations + are full of well-meaning, hard-working individuals who + genuinely believe that their products make life easier for + users. Unfortunately, experience shows that this is often only + true in the first hot flush of using a new program: in the + long run the winners are those whose data is secure, + accessible, and reusable; whose documents can be reformatted + at any time, on any platform, without penalty, financial or + otherwise.\par +I make no apology for recommending Unix-like systems + running \LaTeX{} as the platform of choice for + document-processing applications\mdash{}if you have a + choice\mdash{}and I'm happy to be able to include the + Apple Macintosh in that family. Unfortunately, there are those + whose circumstances at home or work require them to use + something else, and I am pleased that \LaTeX{} can help them by + being available on their platform as well.\par +I have incorporated all the remaining suggestions + except where it would materially distort the objective of + being a \emph{beginner's} booklet. A + special thank-you goes to Barbara Beeton, Karl Berry, and + William Adams for their editorial corrections and + contributions, finding all kinds of mistakes from simple slips + of the finger to cultural differences to over-complicated ways + of explaining things.\par +It is very difficult for people who write technical + documentation to remember how they struggled to learn what has + now become a familiar system. So much of what we do is second + nature, and a lot of it actually has nothing to do with the + software, but more with the way in which we view and approach + information, and the general level of knowledge of computing. + If I have obscured something by making unreasonable + assumptions about \emph{your} knowledge, please + let me know so that I can correct it.\par +\par\vspace*{2pc}\noindent\ignorespaces +Peter Flynn is author of \titleof{htmlbook} and \titleof{sgmltools}, and editor of + \titleof{xmlfaq}. +\par\vfill +\subsubsection*{Technical~note} +The text for the March 2003 online edition was edited + into a customized version of DocBook from the original private + format (Read The Fine Markup + Language (RTFML)\index{RTFML@RTFML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!RTFML@RTFML|textbf}). All subsequent work has been done in + DocBook with a customization layer for typographics. XSLT\index{XSLT@XSLT} was used to generate HTML\index{HTML@HTML} (for the Web and plain-text versions) and + \LaTeX{} (for PDF\index{PDF@PDF} and + PostScript\index{PostScript}). The November 2003 edition + was published in \titlecite{tugboat}.\par\vfill +{\footnotesize\noindent\ignorespaces +This document is Copyright © 1999, 2000, 2001, + 2002, 2003 by Silmaril Consultants under the terms of what is + now the GNU Free Documentation License (copyleft). + +Permission is granted to copy, distribute and/or modify + this document under the terms of the GNU Free Documentation + License, Version 1.2 or any later version published by the + Free Software Foundation; with no Invariant Sections, no + Front-Cover Texts, and no Back-Cover Texts. A copy of the + license is included in the section entitled \titlecite{gnufdl}. + +You are allowed to distribute, reproduce, and modify it + without fee or further requirement for consent subject to the + conditions in \S\thinspace\ref{gfdl-4}. The author has + asserted his right to be identified as the author of this + document. If you make useful modifications you are asked to + inform the author so that the master copy can be updated. See + the full text of the License in Appendix~\ref{gfdl}. + +\par} +\thispagestyle{empty} +\renewcommand{\contentsname}{Contents} +\tableofcontents +\listofexercises +\prelim{Introduction}\label{intro} + +This booklet originally accompanied a 2-day course on + using the \LaTeX{} typesetting system. It has been extensively + revised and updated and can now be used for self-study or in the + classroom. It is aimed at users of Linux or Microsoft Windows + but it can be used with \LaTeX{} systems on any platform, + including other Unix workstations, Apple Macs, and + mainframes. +\subsection*{Who needs this booklet?}\addcontentsline{toc}{subsection}{Who needs this booklet?} + +The audience for the original training course was assumed + to be computer-literate and composed of professional, + business, academic, technical, or administrative computer + users. The readers of the booklet (you) are mostly assumed to + be in a similar position, but may also come from many other + backgrounds. You are expected to have one or more of the + following or similar objectives: +\begin{itemize} +\item +production of typesetter-quality formatting; + +\item +formatting of long, complex, highly-structured, + repetitive, or generated documents;\footnote{\LaTeX{} can easily be used for once-off or short + and simple documents as well, but its real strength + lies in consistency and automation.} + +\item +save time and effort by automating common + tasks; + +\item +independence from specific makes or models of + proprietary hardware, software, or file formats + (portability); + +\item +use of Open Source software (free of restrictions, + sometimes also free of charge). + +\end{itemize} +\subsection*{Skills needed}\addcontentsline{toc}{subsection}{Skills needed} + +\LaTeX{} is a very easy system to learn, and requires no + specialist knowledge, although some familiarity with the + publishing process is useful. It is, however, assumed that you + are completely fluent and familiar with using your computer + before you start. Specifically, effective use of this document + requires that you already know and understand the following + thoroughly: +\begin{itemize} +\item +how to run and use a good plain-text editor + (\emph{not} a wordprocessor and not a toy + like \product{Notepad}); + +\item +where all 94 of the printable ASCII\index{ASCII@ASCII} characters are on your keyboard + and what they mean (and how to type accents and symbols, + if you use them); + +\item +how to create, open, save, close, rename, and delete + files and folders (directories); + +\item +how to use a Web browser or File + Transfer Protocol (FTP)\index{FTP@FTP|textbf}\index{Acronyms@\textbf{Acronyms}, defined!FTP@FTP|textbf} program to download and save + files from the Internet; + +\item +how to uncompress and unwrap (unzip) downloaded + files. + +\end{itemize} + +If you don't know how to do these things yet, + it's probably best to go and learn them first. Trying to + become familiar with the fundamentals of using a computer + \emph{at the same time} as learning \LaTeX{} is + not likely to be as effective as doing them in order. +\subsection*{Objectives of this booklet}\addcontentsline{toc}{subsection}{Objectives of this booklet} + +By the end of this booklet, you should be able to + undertake the following tasks: +\begin{itemize} +\item +use a plain-text editor to create and maintain your + \LaTeX{} documents; + +\item +add \LaTeX{} markup to achieve your formatting + requirements; + +\item +typeset \LaTeX{} documents, correct simple formatting + errors, and display or print the results; + +\item +identify, install, and use additional formatting + packages (using CTAN\index{CTAN@CTAN} for + downloading where necessary); + +\item +recognise the limitations of procedural markup systems + and choose appropriate generic markup where + appropriate. + +\end{itemize} +\subsection*{Synopsis}\addcontentsline{toc}{subsection}{Synopsis} + +The original course covered the following topics as + separate sessions, now represented in the booklet as + chapters: +\begin{enumerate}\item +Where to get and how to install \LaTeX{} (te\TeX{} and + fp\TeX{} from \TeX{} Live);\index{fptex@fp\TeX{}}\index{tetex@te\TeX{}}\index{texlive@\TeX{} Live} + +\item +How to type \LaTeX{} documents: using an editor to + create files (\product{WinShell}, + \product{WinEdt} or + \product{Emacs}); + +\item +Basic structures (the Document Class Declaration and + its layout options; the document environment with sections + and paragraphs); + +\item +Typesetting, viewing, and printing; + +\item +The use of packages and CTAN\index{CTAN@CTAN} to adapt formatting using standard + tools; + +\item +Other document structures (lists, tables, figures, + images, and verbatim text); + +\item +Textual tools (footnotes, marginal notes, + cross-references, indexes and glossaries, and + bibliographic citations); + +\item +Typographic considerations (white-space and typefaces; + inline markup and font changes; extra font installation + and automation); + +\item +Programmability and automation (macros and modifying + \LaTeX{}'s behaviour); + +\item +Conversion and compatibility with other systems (XML\index{XML@XML}, + \product{Word}, etc.).\index{xml@\textsc{xml}} + +\end{enumerate} + +A few changes have been made in the transition to printed + and online form, but the basic structure is the same, and the + document functions as a workbook for the course as well as a + standalone self-teaching guide. It is important to note that + the document \emph{does not cover} mathematical + typesetting, complex tabular material, the design of + large-scale macros and document classes, or the finer points + of typography or typographic design, although it does refer to + these topics in passing on a few occasions. +\index{mathematics} +There are several other guides, introductions, and + `get-started' documents on the Web and + on CTAN\index{CTAN@CTAN}. Among the more popular + are: +\begin{itemize} +\item +\titlecite{begin}, where all + beginners should start; + +\item +\titlecite{lshort} is a good + beginner's tutorial; + +\item +\titlecite{gentle} is a classic + tutorial on Plain \TeX{}; + +\item +\titlecite{imported} shows you how + to do (almost) anything with graphics: side-by-side, + rotated, etc.; + +\item +\titlecite{mathguide} gets you + started with the American Math Society's powerful + packages; + +\item +\titlecite{symbol-list} shows over + 2,500 symbols available in \LaTeX{}. + +\end{itemize} + +(Taken from the CTAN\index{CTAN@CTAN} search + page.) +\subsection*{Production note}\addcontentsline{toc}{subsection}{Production note}\label{prodnote} + +This document is written and maintained in XML\index{XML@XML}, using a customized version of the + \product{DocBook}DTD\index{DTD@DTD}. Conversions were made to HTML\index{HTML@HTML} and \LaTeX{} using XSLT\index{XSLT@XSLT} scripts and \person{Michael Kay}'s \product{Saxon} + processor. The complete source, with all ancillary files, is + available online at \url+http://www.ctan.org/tex-archive/info/beginlatex/+ + but if you want to try processing it yourself you must install + \product{Java} (from Sun, IBM\index{IBM@IBM}, or a number of others) and + \product{Saxon} (from \url+http://saxon.sourceforge.net/+), in addition to + \LaTeX{}. + +This document is published under the terms and conditions + of the GNU\index{GNU@GNU} Free Documentation + License. Details are in Appendix~\ref{gfdl}. +\subsubsection*{Symbols and conventions}\addcontentsline{toc}{subsubsection}{Symbols and conventions}\label{symbols} + +The following typographic notations are used: +\begin{center} +\label{symboltable} +\begin{tabular}{lp{3.75in}}\textbf{\normalfont\bfseries\upshape Notation}&\textbf{\normalfont\bfseries\upshape Meaning}\\[2pt]\hline\\[-.95\baselineskip] +\command{command}&Control sequences which perform an action, e.g. + \command{newpage}\\ +\length{length}&Control sequences which can be set to a + dimension (measurement in units), e.g. \length{parskip}\\ +\counter{counter}&Values used for counting (as opposed to + measuring in units), e.g. \counter{secnumdepth}\\ +\textbf{\textit{term}}\index{term@\textbf{\textit{term}}}&Defining instance of a specialist term\\ +\product{product}&program or product name\\ +\env{environment}&Formatting environment\\ +\package{package}&\LaTeX{} package (available from CTAN\index{CTAN@CTAN})\\ +{\ttfamily{}\selectfont{}\uline{mybook}} or {\ttfamily{}\fontshape{sl}\selectfont{}value}&Examples of things you have to supply real-life + values for\\ +\key{x}&A key on your keyboard\\ +\key{Ctrl}--\key{x}~&Two keys pressed together\\ +\key{Esc}\thinspace{}\key{q}&Two keys pressed one after another\\ +\guiicon{Submit}&On-screen button to click\\ +\menuitem{Menu}{Item}&Drop-down menu with items\\ +\end{tabular} +\end{center} + +Examples of longer fragments of input are shown with a + border round them. Where necessary, the formatted output is + shown immediately beneath. Warnings are shown with a shaded + background. Exercises are shown with a double border. +\subsubsection*{Availability of \sfLaTeX{} systems}\addcontentsline{toc}{subsubsection}{Availability of \sfLaTeX{} systems}\label{availability} + +The traditional \TeX{} implementation is a Command-Line Interface (CLI)\index{CLI@CLI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CLI@CLI|textbf}, that is, a + `console' program which you run from + a Unix or Mac shell window or an MS-DOS command window by + typing the command \verb+tex+ or + \verb+latex+ followed by the name of your + document file. In automated (unattended) systems, + this command is issued from within a Unix shell script or + MS-DOS/Windows batch file. All the popular distributions for + Unix and MS-DOS/Windows, both free and commercial, deliver + this interface as standard (te\TeX{}, fp\TeX{}, MiK\TeX{}, + PC-\TeX{}, True\TeX{}, etc.). + +While it is quite possible to run \TeX{} and \LaTeX{} this + way, it is more normal to use an editor as your interface to + the program as well as to your document. This allows you to + control \LaTeX{}, the typeset display, and other related + programs with a mouse-click or menu item. This is the method + assumed in this booklet. In the editors used for examples + (\product{Emacs}, + \product{WinShell}, and + \product{WinEdt}) the typesetting process + is logged visibly in an adjoining text window so that you + can see the progress of pages being typeset, and any error + messages that may occur.\footnote{Some recent versions of + \product{Emacs} hide this window by + default unless errors occur in the typesetting.} This method is called an + \textbf{\textit{asynchronous}}\index{asynchronous@\textbf{\textit{asynchronous}}} + typographic display because the typeset window only updates + \emph{after} you have typed the text and + [re-]processed it, not \emph{while} you are + still typing. + +\label{synchro}% +Some commercial implementations of \TeX{} + offer a \textbf{\textit{synchronous}}\index{synchronous@\textbf{\textit{synchronous}}} + typographic interface: \product{Textures} + for the Apple Macintosh from Blue Sky Research, + \product{Scientific Word} from MacKichan + Software, and \product{V\TeX{}} from + MicroPress, Inc (both for Microsoft Windows) are three + examples. At least one free version + (\LyX{}, see Figure~\ref{lyxwin} in \S\thinspace\ref{editors}) offers + the same kind of interface. In these, you type directly into + the typographic display, as with a graphical wordprocessor, + using the font controls of whatever Graphical User Interface (GUI)\index{GUI@GUI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!GUI@GUI|textbf} are + appropriate. + +With a synchronous display you get your instant textual + gratification, but your level of control is restricted to + that of the graphical user interface, which almost certainly + does not provide access to everything that \LaTeX{} can do. + For complete control of the formatting you still need access + to the \LaTeX{} language. There are several methods available + free for Unix and some other systems for + close-to-synchronous updates of the typeset display + (including \person{Jonathan Fine}'s \product{Instant + Preview} and the \TeX{} daemon), and for + embedding typographic fragments from the typeset display + back into the editor window (\person{David Kastrup}'s \package{preview-latex} + package). + +Whatever method you choose, \TeX{} Live and CTAN\index{CTAN@CTAN} are not the only source of + software. The following vendors offer robust commercial + implementations of \TeX{} and \LaTeX{}, and if you are in a + position where their enhanced support and additional + features are of benefit, I urge you to support them. In + most cases their companies, founders, and staff have been + good friends of the \TeX{} and \LaTeX{} communities for many + years. +\begin{center} +\begin{tabular}{p{.666in}p{1in}ll}\textbf{\normalfont\bfseries\upshape Product}&\textbf{\normalfont\bfseries\upshape Platform}&\textbf{\normalfont\bfseries\upshape Company}&\textbf{\normalfont\bfseries\upshape URI}\\[2pt]\hline\\[-.95\baselineskip] +PC\TeX{}&MS-Windows&Personal \TeX{}, Inc&\url+www.pctex.com/+\\ +True\TeX{}&MS-Windows&True \TeX{}&\url+truetex.com/+\\ +Textures&Apple Mac&Blue Sky Research&\url+www.bluesky.com/+\\ +Scientific Word&MS-Windows&Mackichan Software&\url+www.mackichan.com/+\\ +V\TeX{}&MS-Windows, Linux, OS/2&MicroPress, Inc&\url+www.micropress-inc.com/+\\ +Y\amp Y\TeX{}&MS-Windows&Y\amp Y Software&\url+www.yandy.com/+\\ +\end{tabular} +\end{center} +\prelim{Foreword}\label{foreword} + +As noted in the Introduction, this document + accompanied a 2-day introductory training course (still + does) which I run in UCC and elsewhere. It became obvious from + repeated questions in class and afterwards, as well as from + general queries on \url+comp.text.tex+ that many people do not read the + FAQ\index{FAQ@FAQ}s, do not buy the books and + manuals, do not download the free documentation, and instead try + to get by using the training technique known as + `sitting by Nelly', which involves + looking over a colleague's shoulder in the office, lab, + library, or classroom, and absorbing all his or her bad + habits. + +In the summer of 2001 I presented a short proposal on the + marketing of \LaTeX{} to the annual conference of the \TeX{} Users + Group held at the University of Delaware, and showed an example + of a draft + brochure\footnote{\url+http://www.silmaril.ie/documents/latex-brochure/leaflet.pdf+} designed to persuade newcomers to try \LaTeX{} + for their typesetting requirements. As a result of questions and + suggestions, it was obvious that it needed to include a pointer + to some documentation, and I agreed to make available a revised + form of this document, expanded to be used outside the + classroom, and to include those topics on which I have had most + questions from users over the years. + +It turned out to mean a significant reworking of a lot of + the material, some of which appears in almost every manual on + \LaTeX{} but which is essential to the beginner and therefore + bears repetition. I took the opportunity to revise the structure + of the training course in parallel with the booklet (expanding + it from its original one day to two days), and to include a more + comprehensive index. It is by no means perfect (in both senses), + and I would be grateful for comments and bugs to be sent to me + at the address given under the credits. + +I had originally hoped that the \LaTeX{} version of the + document would be processable by any freshly-installed default + \LaTeX{} system, but the need to include font samples which go + well beyond the default installation, and to use some packages + which the new user is unlikely to have installed, means that + this document itself is not really a simple piece of \LaTeX{}, + however simply it may describe the process itself. + +However, as the careful reader will have already noticed, + the master source of the document is not maintained in \LaTeX{} + but in XML\index{XML@XML}. A future task is therefore + to compare the packages required with those installed by + default, and flag portions of the document requiring additional + features so that an abbreviated version can be generated which + can be guaranteed to process even with a basic \LaTeX{} + installation. + +\label{docs}% +If you are just starting with \LaTeX{}, at an early + opportunity you should try to get hold of a copy of \titlecite{latexbook} which is the original + author's manual. More advanced users should get the + \titlecite{companion} or one of its + successors. In the same series there are also the \titlecite{graphicscomp} and the \titlecite{webcomp}. Mathematical users might want to + read \titlecite{mathguide}. +\prelim{Preface}\label{preface} + +Many people discover \LaTeX{} after years of struggling with + wordprocessors and desktop publishing systems, and are amazed to + find that \TeX{} has been around for nearly 25 years and they + hadn't heard of it. It's not a conspiracy, just + `a well-kept secret known only to a few million + people', as one anonymous user put it. + +Perhaps a key to why it has remained so popular is that it + removes the need to fiddle with the formatting while you write. + Although playing around with fonts and formatting is attractive + to the computer newcomer, it is counter-productive for the + serious author or editor who wants to concentrate on + writing\mdash{}ask any journalist or professional author. In + response to a beginner's concern about `learning to + write in \LaTeX{}', here's some advice posted (in + the + \verb+comp.text.tex+ + newsgroup\footnote{\url+news:comp.text.tex/MPG.18d82140d65ddc5898968c@news.earthlink.net+}): +\begin{quotation}\small\noindent +No, the harder part might be \emph{writing}, + period. \TeX{}/\LaTeX{} is actually easy, once you relax and + stop worrying about appearance as a be-all-and-end-all. Many + people have become `Word Processing + Junkies' and no longer + `write' documents, they + `draw' them, almost at the same level + as a pre-literate 3-year old child might pretend to + `write' a story, but is just creating a + sequence of pictures with a pad of paper and box of + \product{Crayola}s\mdash{}this is perfectly + normal and healthy in a 3-year old child who is being + creative, but is of questionable usefulness for, say, a grad + student writing a Master's or PhD thesis or a business person + writing a white paper, etc. For this reason, + \emph{I} strongly recommend + \emph{not} using any sort of fancy GUI\index{GUI@GUI} `crutch'. + Use a plain vanilla text editor and treat it like an + old-fashioned typewriter. Don't waste time playing with your + mouse. + +Note: I am \emph{not} saying that you should + have no concerns about the appearance of your document, just + that you should \emph{write} the document + (completely) first and tweak the appearance + later\dots \emph{not} [spend time on] lots of + random editing in the bulk of the document itself. +\setlength{\parfillskip}{0pt}\hfill[\citeauthortitleyear{heller}]\end{quotation} + +\label{mathtex}% +Knuth originally wrote \TeX{} to typeset + mathematics for the second edition of his master-work \titlecite{aocs}, and it remains pretty much the only + typesetting program to include fully-automated mathematical + formatting done the way mathematicians want it. Knuth generously + placed the entire system in the public domain, so for many years + there was no publicity of the commercial kind which would have + got \TeX{} noticed outside the technical field. Nowadays, + however, there are many companies selling \TeX{} software or + services, dozens of publishers accepting \LaTeX{} documents for + publication, and hundreds of thousands of users using \LaTeX{} + for millions of documents.\footnote{A guesstimate. With free software it's impossible + to tell how many people are using it, but it's a + \emph{lot}.} + +There is occasionally some confusion among newcomers between + the two main products, \TeX{} and \LaTeX{}: +\begin{itemize} +\item +\TeX{} is a typesetting program, originally written by + Prof \person{Don Knuth} (Stanford) around 1978. It implements a + macro-driven typesetters' programming language of some + 300 basic operations and it has formed the core of many + other desktop publishing (DTP)\index{DTP@DTP|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DTP@DTP|textbf} + systems. Although it is still possible to write in the raw + \TeX{} language, you need to study it in depth, and you need + to be able to write macros (subprograms) to perform even the + simplest of repetitive tasks. + +\item +\LaTeX{} is a user interface for \TeX{}, designed by + \person{Leslie Lamport} (Digital Equipment + Corporation (DEC)\index{DEC@DEC|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DEC@DEC|textbf}) in 1985 to automate all the common + tasks of document preparation. It provides a simple way for + authors and typesetters to use the power of \TeX{} without + having to learn the entire language. \LaTeX{} is the + recommended system for all users except professional + typographic programmers and computer scientists who want to + study the internals of \TeX{}. + +\end{itemize} +\begin{sidebar}\label{myths} +\subsection*{Debunking the mythology} +Naturally, over all the years, a few myths have grown up + around \LaTeX{}, often propagated by people who should know + better. So, just to clear up any potential + misunderstandings\dots +\begin{description} +\item[\sffamily MYTH: `\sfLaTeX{} has only got one + font'] +Most \LaTeX{} systems can use any OpenType, TrueType, + Adobe (PostScript\index{PostScript}) Type1 or + Type3, or \mf{} font, among others. This is more + than most other known typesetting systems. + \LaTeX{}'s default font is Computer Modern (based on + Monotype Series 8: see + Table~\ref{fontable}), not Times Roman, and some + people get upset because it `looks + different'. Typefaces differ: that's what + they're for. +\item[\sffamily MYTH: `\sfLaTeX{} is a Unix + system'] +People are also heard saying: `\LaTeX{} is a + Windows system', `\LaTeX{} is a + Mac system', etc., etc. \emph{ad + nauseam}. \TeX{} systems run on almost + every computer in use, from some of the biggest + supercomputers down to handhelds (Personal Digital Assistant (PDA)\index{PDA@PDA|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PDA@PDA|textbf}s like the Sharp + \product{Zaurus}). That includes + Windows and Linux PCs, Macs, and all Unix systems. If + you're using something \TeX{} doesn't run on, + it must be either incredibly new, incredibly old, or + unbelievably obscure. +\item[\sffamily MYTH: `\sfLaTeX{} is obsolete'] +Quite the opposite: it's under constant + development, with new features being added almost + weekly. Check the \url+comp.text.tex+ for messages about recent + uploads to CTAN\index{CTAN@CTAN}. It's + arguably more up-to-date than most other systems: + \LaTeX{} had the Euro (\EUR{}) before anyone else, it had + Inuktitut typesetting before the Inuit got their own + province in Canada, and it still produces better + mathematics than anything else. +\item[\sffamily MYTH: `\sfLaTeX{} isn't WYSIWYG\index{WYSIWYG@WYSIWYG}'] +Simply not true. The DVI\index{DVI@DVI} + and PDF\index{PDF@PDF} preview is better + WYSIWYG\index{WYSIWYG@WYSIWYG} than any wordprocessor + and most DTP\index{DTP@DTP} systems. + +What critics mean is that \LaTeX{}'s + typographic display is asynchronous with the edit + window. This is only true for the default CLI\index{CLI@CLI} implementations. See the Introduction for + details of synchronous versions. +\item[\sffamily MYTH: `\sfLaTeX{} is ``too + difficult''\thinspace'] +This has been heard from physicists who can split atoms; + from mathematicians who can explain why \(\pi\) exists; from business people who can + read a balance sheet; from historians who can grasp + Byzantine politics; from librarians who can understand + LoC and MARC; and from linguists who can decode Linear + `B'. Most people grasp \LaTeX{} in 20 + minutes or so. It's not rocket science (or if it is, I + know any number of unemployed rocket scientists who will + teach it to you). +\item[\sffamily MYTH: `\sfLaTeX{} is ``only for + scientists and + mathematicians''\thinspace'] +Not at all. Although it grew up in the + mathematical and computer science fields, two of its biggest + growth areas are in the humanities and business, + especially since the rise of XML\index{XML@XML} brought new demands for + automated typesetting. +\end{description} +\end{sidebar}\chapter{Installing \TeX{}} +\label{get} +\index{tetex@te\TeX{}}\index{fptex@fp\TeX{}}\index{miktex@MiK\TeX{}}\index{Linux}\index{Unix}\index{Microsoft Windows}\index{Mac OS X}\index{Apple Mac}\index{OS X} +This course is based on using \person{Thomas Esser}'s te\TeX{} (for Linux and other Unix-like + systems, including Mac OS\thinspace{}X) and + \person{François Popineau}'s fp\TeX{} (for Microsoft Windows), both from + \TeX{} Live + (fp\TeX{} is an implementation of te\TeX{}). Many other + implementations of \TeX{}, including \person{Christian Schenk}'s Mik\TeX{} for + Microsoft Windows, and \person{Tom Kiffe}'s CMac\TeX{} for the Apple Macintosh, can be + downloaded from CTAN\index{CTAN@CTAN}. \LaTeX{} is + included with all distributions of \TeX{}. + +\TeX{} Live is issued annually as a joint effort by virtually + all the local \TeX{} user groups around the world (see \url+http://www.tug.org/lugs.html+ for addresses). + There are many other distributions of \LaTeX{} both free and + commercial, as described in the Introduction: they all process + \LaTeX{} identically, but there are some differences in size, + speed, packaging, and (in the case of commercial distributions) + support. +\section{Editing and display} + +Before you start using \LaTeX{} you will need to decide on + which plain-text editor you want to use to create and maintain + your documents. There is a wide range available, and probably + no other piece of software causes more flame-wars in Internet + and other discussions than your choice of editor. It's a + highly personal choice, so feel free to pick the one you like. + My personal biases are revealed below. + +If you are intending to produce + PostScript\index{PostScript} or PDF\index{PDF@PDF} (Adobe Acrobat) files, you will need a + viewer to display them. \product{GSview} + displays both PostScript\index{PostScript} and PDF\index{PDF@PDF} files; \product{xpdf} + and Adobe's own \product{Acrobat Reader} + just display PDF\index{PDF@PDF} files. +\begin{warning} +\label{pdfurl} +\subsubsection*{Additional downloads} +For licensing reasons, the + \product{GSview}, and \product{Acrobat + Reader} viewers and the + \product{WinEdt} editor cannot be + distributed on the \TeX{} Live media. You have to download + and install them separately. This is a restriction imposed + by their authors or vendors, not by the \TeX{} Live + team. +\begin{itemize} +\item +\product{GSview} is available for + all platforms from \url+http://www.ghostscript.com/gsview/index.htm+ + (on Unix and VMS systems it's also available as + \product{GhostView} and + \product{gv}: see \url+http://www.cs.wisc.edu/~ghost/+) + +\item +\product{Acrobat Reader} (all + platforms) can be downloaded from \url+http://www.adobe.com/products/acrobat/readstep2.html+ + +\item +\product{Xpdf} (X Window systems + only) can be downloaded from \url+http://www.foolabs.com/xpdf/+ + +\item +\product{WinEdt} (Microsoft Windows + only) comes from \url+http://www.winedt.com+ + +\end{itemize} +\end{warning} +\begin{center} +\label{editchoice} +\begin{tabular}{lp{4in}}\textbf{\normalfont\bfseries\upshape Editor}&\textbf{\normalfont\bfseries\upshape Comments}\\[2pt]\hline\\[-.95\baselineskip] +\product{Emacs}&Large and powerful. Needs learning (a life-skill + like \LaTeX{}) but well worth it. Multi-platform, it + opens and edits anything and everything, with special + features for \LaTeX{} etc., and good productivity + tools for writers. Open Source.\\ +\product{WinShell}&Simple but effective beginner's tool for + MS-Windows. Runs \LaTeX{} etc. with toolbar buttons. + Very easy to use, small footprint. Strongly + recommended. Free.\\ +\product{WinEdt}&Comprehensive editor aimed at heavy \LaTeX{} + usage, with toolbar, productivity features, and good + support. Configurable for almost any distribution of + \TeX{} (with some effort). Free trial, licensable after + 1 month, MS-Windows only.\\ +\product{PFE}&Popular general-purpose editor for MS-Windows: no + special \LaTeX{} features but a very configurable + launcher and command-line controller. Free but no + longer developed.\\ +\product{BBedit}&Plain-text editor for Apple Macs, + heavily used for text applications. Some \TeX{} + distributions for the Mac come with their own editor, + but this is a popular and useful tool. 30-day demo.\\ +\product{vi}&Standard editor on Unix systems. Dual-mode editor + (separate text-entry and command modes), now showing + its age. Adored by devotees, detested by others, just + like \product{Emacs} \smiley{}. + Free.\\ +\end{tabular} +\end{center} +\section{Installation for Linux and Unix} +\label{lininst} + +Make sure your system libraries and utilities are up to + date. If you are using Red Hat Linux, use the + \product{up2date} program to download and + install updates. For Debian and other distributions, use + \product{apt-get} or similar utilities. On + Red Hat systems, remove (or don't install) the RPM version of + te\TeX{} and associated utilities to avoid version + conflicts. + +If you are installing \TeX{} Live to a new partition, or if + you have the opportunity to reformat the partition before use, + use \product{mkfs} with a granularity as + small as it will go (usually 1024 bytes). This avoids the + partition running out of inodes because \TeX{} uses very large + numbers of very small files. + +Plan the installation carefully if you are installing for + multiple users (a shared machine): read \S\thinspace\ref{pkginst} for some comments on where to put additional + files downloaded later, and see the FAQ on the same topic at + \url+http://www.tex.ac.uk/cgi-bin/texfaq2html?label=wherefiles+ + +Above all, Read The Fine + Manual (RTFM)\index{RTFM@RTFM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!RTFM@RTFM|textbf}. The documentation is in + \url+readme.html+, and there's a PDF\index{PDF@PDF} copy for printing. + +The installer runs in a shell window, so it can be done + even from systems with no X Window installation, but it does + need to be installed as root if you want to stick with the + default directory locations. + +Type the command \verb+sh install-tl.sh+ + to run it: the options are mostly self-explanatory, and + beginners should pick the Recommended scheme and leave all + other settings at their defaults. +\section{Installation for Apple Mac} +\label{macinst} + +This is exactly the same interface as for the Linux/Unix + installation. The documentation does point out that + `most front ends (\product{\TeX{}Shop}, + \product{I\TeX{}Mac},\dots ) use the te\TeX{} + default location which is + \url+/usr/local/teTeX+, so, Mac users could + find interest in installing \TeX{} Live in + \url+/usr/local/teTeX+ rather than in + \url+/usr/TeX+.' +\section{Installation for Microsoft Windows} +\label{wininst} + +Before you install \TeX{} Live, make sure you have enough + disk space: the default installation takes about 350Mb on a + modern filesystem. The installation assumes you have a fully + updated version of Windows, so visit the Microsoft Web site + first (\url+http://www.microsoft.com/+) and + click on \product{Windows Update}. Select and + install all the relevant updates for your operating system + (Windows 95, 98, ME, 2000, NT, or XP). You should be doing + this regularly anyway, to keep your system healthy. You may + want to run \product{ScanDisk} and give your + hard disks a full surface check. \TeX{} consists of a very + large number of quite small files, so it's important that + your disk is in good shape. When you insert the \TeX{} Live + disk, it should start the setup program automatically. If you + have auto-run turned off, open \product{My + Computer}, double-click on the relevant drive, + and then double-click \product{Autorun} to + start the setup program. Some versions of Microsoft Windows + are broken and won't start the program correctly this + way. If this happens, use \product{My + Computer} to go to the + \url+bin\win32+ subfolder of the \TeX{} Live + disk and double-click + \url+TeXLive.exe+\thinspace{}. +\par\smallskip\noindent\textbf{Once the \TeX{} Live program is running:} +\begin{enumerate} +\item \textbf{\LaTeX{}}\\ +Install \LaTeX{} itself from the + \menuitem{TeXLive Software}{Install on + Hard Disk} menu. If you're new to + \LaTeX{}, pick Quick Install on the following screen. This + gives you everything you need to get started, and + doesn't ask any questions, it just installs it all + straight away. + +If you're installing under Windows NT, 2000, or + XP, you may want to click on the option to install for all + users if you have other users on your system. + +If you want to use \product{Emacs} as + your editor, click the option for XemTeX + Support.\footnote{Note this is nothing to do with \person{Eberhard Matthes}' DOS implementation of \TeX{} called + em\TeX{}\mdash{}the `Xem' is short for + \product{Xemacs}.} +\item \textbf{Emacs}\\ +After installation, right-click and drag + \url+Xemacs.exe+ from the + \url+C:\Program Files\TeXLive\bin\win32+ + folder out onto your desktop and let go, then pick + `Create Shortcut'. This places + \product{Emacs} on your desktop for easy + access. +\item \textbf{WinShell and WinEdt}\\ +If you want to install + \product{WinShell}, run the installer + program in the \url+support/winshell+ + directory. For \product{WinEdt} you must + go to their Web site (\url+http://www.winedt.com/+) for a + downloadable version. + +You don't have to install just one editor: if + you've got the space, install them all so you can try + them out. You can always uninstall the ones you don't + want afterwards. +\item \textbf{GSView}\\ +Ghostscript is installed automatically, but for + \product{GSView} you need to go to \url+http://www.cs.wisc.edu/~ghost/gsview/+, + and download the most recent version. + +If you use \product{GSView}, please + register your copy with Ghostgum, Pty. (\url+http://www.ghostgum.com.au/+). +\end{enumerate} + +Newcomers should note that the downloadable + \product{WinEdt} comes preconfigured for a + different distribution of \TeX{} (MIK\TeX{}) and needs some + careful reconfiguration to work with \TeX{} Live. I recommend + that beginners use \product{WinShell} to + start with and graduate to \product{Emacs} + when they become more expert. Many other people will doubtless + tell you different\dots +\begin{warning} + +Please read the \TeX{} Live update pages at \url+http://www.tug.org/texlive/bugs.html+ for + details of any changes since the disks were released, and + download and install any additional software + required. +\end{warning} +\chapter[Using your editor to create documents]{Using your editor \\to create documents} +\label{plaintext} + +\LaTeX{} documents are all \textbf{\textit{plain-text}}\index{plain-text@\textbf{\textit{plain-text}}} files.\footnote{`Plain-Text' originally meant just + the 94 printable characters of the American Standard Code for Information + Interchange (ASCII)\index{ASCII@ASCII|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!ASCII@ASCII|textbf} but now more commonly includes both + these \emph{and} the relevant 8-bit + characters from \emph{one} (only) character + set such as ISO-8859-1 (Western Latin\ndash{}1) or + ISO-8859-15 (Western Latin plus the Euro sign). These are + international standards which work everywhere: try to avoid + using manufacturers' proprietary character sets like + Microsoft Windows\ndash{}1252 or Apple Macintosh + Roman\ndash{}8, because they are unusable on some other + systems.} You can edit them with any editor, and transfer + them to any other computer system running \LaTeX{} and they will + format exactly the same. Because they are plain text they cannot + corrupt your system, and they cannot be used for virus + infections as wordprocessor files can. Everything you can see + is in the file and everything in the file is displayed to you: + there is nothing hidden or secret and no proprietary + manufacturers' `gotchas' like + suddenly going out of date with a new version. + +In a \LaTeX{} document, you type your text along with + \textbf{\textit{markup}}\index{markup@\textbf{\textit{markup}}} which identifies the + important parts of your document by name, for example + `title', `section', + `figure', etc. \LaTeX{} does all the formatting for + you automatically, using the markup to guide its internal rules + and external stylesheets for typesetting. +\begin{warning} + +You will usually hear this markup referred to as + `commands' or sometimes `control + sequences' (which is the proper \TeX{}nical term for + them). For all practical purposes these terms all mean the + same thing. +\end{warning} + +You do not need to format any of your text by hand + \emph{in your editor}, because \LaTeX{} does it all + by itself when it typesets. You can of course regularise or + neaten its appearance \emph{in your editor} for + ease of editing (for example, keeping each item in a list on a + separate line), but this is not required. + +This course assumes that users have either + \product{WinEdt} (Windows only) or + \product{Emacs} (any platform) installed. Both + are discussed briefly in \S\thinspace\ref{editors} and the menus and toolbars for running + \LaTeX{} are explained in \chaptername~\ref{process}. +\section{Quick start for the impatient} +\label{quickstart} + +If you already know all this stuff about editors and + plain-text files and running programs, or you know your system + is already correctly installed (including your editor), + you'd probably like to type something in and see \LaTeX{} + do its job. If you don't, then skip forward to \S\thinspace\ref{commands} and read a bit more about \LaTeX{} + first. +\begin{enumerate} +\item \textbf{Install the software}\\ +Make sure you have a properly-installed \LaTeX{} system + and a copy of a suitable editor + (\product{Emacs} or + \product{WinEdt} are recommended). +\item \textbf{Create a demonstration document}\\\label{demodoc}% +Open your editor and type in the following text + \emph{exactly} as given. Do + \emph{not} make any changes or miss anything + out or add anything different: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +\documentclass[12pt]{article} +\usepackage{palatino,url} +\begin{document} +\section*{My first document} + +This is a short example of a \LaTeX\ document I wrote on +\today. It shows a few simple features of automated +typesetting, including + +\begin{itemize} +\item setting the default font size to 12pt; +\item specifying `article' type formatting; +\item using the Palatino typeface; +\item adding special formatting for URIs; +\item formatting a heading in `section' style; +\item using the \LaTeX\ logo; +\item generating today's date; +\item formatting a list of items; +\item centering and italicizing; +\item autonumbering the pages. +\end{itemize} + +\subsection*{More information} + +This example was taken from `Formatting Information', +which you can download from +\url{http://www.ctan.org/tex-archive/info/beginlatex/} +and use as a teach-yourself guide. + +\begin{center} +\textit{Have a nice day!} +\end{center} + +\end{document} + \end{Verbatim} +\end{sourcecode} +\item \textbf{Save the document}\\ +Save the document as + \url+demo.tex+\thinspace{}. +\item \textbf{Run \LaTeX{}}\\ +Click on the \guiicon{\LaTeX{}} toolbar icon + or the + \menuitem{\TeX{}}{\TeX{} + File} menu item; or type \verb+latex demo+ in a + command window. +\item \textbf{Preview the typesetting}\\ +Click on the \guiicon{DVI} toolbar icon or + the + \menuitem{\TeX{}}{\TeX{} + View} menu item; or type \verb+dviview demo+ + (Microsoft Windows) or \verb+xdvi demo &+ + (Unix and Linux). + +(Note that there may be a pause the first time some + fonts are used, while bitmaps are created.) +\item \textbf{Print it}\\ +Click on the \guiicon{Print} toolbar icon + within the previewer (Microsoft Windows) or type + \verb+dvips demo+ (Unix and Linux). +\end{enumerate} + +If you encounter any errors, it means you + \emph{do} need to study this chapter after + all! +\section{Editors} +\label{editors} +\index{editors} +All the text of your documents can be typed into your + \LaTeX{} document from a standard keyboard using any decent + plain-text editor. However, it is more convenient to use an + editor with special features to make using \LaTeX{} easier. Two + of the most popular are \product{WinEdt} + (Windows only) and \product{Emacs} (all + platforms). The \LyX{} document editor is a special case, as it + uses the What You See Is What You + Mean (WYSIWYM)\index{WYSIWYM@WYSIWYM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!WYSIWYM@WYSIWYM|textbf} model of synchronous typographic editing as + opposed to WYSIWYG\index{WYSIWYG@WYSIWYG}, and many users + prefer this interface (but see the reservations in the Introduction). +\begin{figure} +\caption{The \LyX{} document editor} +\label{lyxwin} +\begin{center} +\includegraphics[width=1\textwidth]{lyx} +\end{center} +\end{figure} +\subsection{WinEdt} + +\product{WinEdt} is a plain-text editor + for Microsoft Windows (all versions). It lets you create and + maintain files of plain text (\emph{not} + wordprocessing files) for any application, but it has a host + of special functions and shortcuts for \TeX{} and \LaTeX{}. + Download it from \url+http://www.winedt.com+\mdash{}there's a + 1-month free trial, then it nags you to buy it. + +\product{WinEdt} has a built-in toolbar + of configurable buttons, preset for use with \LaTeX{}, and it + provides automatic syntactic colourising of \LaTeX{} commands + in files you edit. +\begin{figure} +\caption{The \product{WinEdt} editor} +\label{winedt} +\begin{center} +\includegraphics[width=0.75\textwidth]{winedt} +\end{center} +\end{figure} + +Apart from standard features like the + \menu{File} and \menu{Edit} menus, + searching, etc., \product{WinEdt} has + default buttons on its toolbar for one-click typesetting, + previewing, and PostScript\index{PostScript} or + PDF\index{PDF@PDF} generation from \LaTeX{} + documents. + +\product{WinEdt} comes configured for + the Mik\TeX{} distribution of \LaTeX{}, rather than fp\TeX{}, + so some editing of the menus is required (explained in the + local installation document) after finishing the fp\TeX{} + installation. Alternatively, you could install Mik\TeX{} + instead. +\subsection{GNU Emacs} + +\product{Emacs} is a product of + the GNU\index{GNU} + Project.\footnote{`GNU's Not + Unix (GNU)\index{GNU@GNU|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!GNU@GNU|textbf}' is a project to make a + computer operating environment completely free of + restrictions.} Versions are available for all makes and models + of computer, and it has a \LaTeX{}-mode which provides + syntactic colouring + (`fontification' in + \product{Emacs}-speak) and mouseclick + processing from a menu or toolbar. +\begin{figure} +\caption{Emacs editing \LaTeX{}} +\begin{center} +\includegraphics[width=0.75\textwidth]{emacs} +\end{center} +\end{figure} + +\product{Emacs} is a very large and + powerful editor, with modes to handle almost everything you + do on a computer. Many users run + \product{Emacs} once on logging in, and + never leave it for the rest of the day\mdash{}or month. As well as edit, you + can use it to read your mail, browse the Web, read Usenet + news, do wordprocessing and spreadsheets, compile programs, + help you write in any computer language\mdash{}including + XML\index{XML@XML} and \LaTeX{}\mdash{}and it + provides a few games as well. + +\product{Emacs}, like + \product{WinEdt}, knows about \LaTeX{} and + how to process it, so there is a menu full of \LaTeX{} + operations to click on. If you are editing more complex + documents, especially with mathematics, there is an add-on + package (`mode' in + \product{Emacs}-speak) called + \product{AUC\TeX{}} which has even more + functionality. + +Because \product{Emacs} runs on + Microsoft Windows, + Macs,\index{Macintosh} + Linux, VMS,\index{VMS} and + most other platforms, many \LaTeX{} users who have multiple + machines prefer it to other editors because it provides the + same environment regardless of which platform they are + using. +\section{\sfLaTeX{} commands} +\label{commands} + +\LaTeX{} commands all begin with a + \textbf{\textit{backslash}}\index{backslash@\textbf{\textit{backslash}}} + (\verb+\+) and are usually made up of lowercase + letters only, for example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\clearpage + \end{Verbatim} +\end{sourcecode} + +Do not confuse the backslash (\verb+\+) with + the forward slash (\verb+/+). They are two + separate characters. + +The \command{clearpage} command is an instruction + to the typesetter to start a new page. It's actually + quite rare\mdash{}page-breaking is automatic in + \LaTeX{}\mdash{}but it makes a good example of a simple + command. +\subsection{Simple commands} +\label{simplecmd} + +\label{swallow}% +Simple one-word commands like + \command{clearpage} which end with a letter must be + separated from any following text with white-space (a + newline [linebreak], tab character, or an ordinary space). + For example either of these two forms will be fine: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\clearpage The importance of poetic form must not be ignored + \end{Verbatim} +\end{sourcecode} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\clearpage +The importance of poetic form must not be ignored + \end{Verbatim} +\end{sourcecode} + +However, if you omit the white-space, as in the + following example, \LaTeX{} will try to read it as a command + called \verb+\clearpageThe+, which doesn't + exist, and it will complain at you. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\clearpageThe importance of poetic form must not be ignored + \end{Verbatim} +\end{sourcecode} + +\LaTeX{} swallows any white-space which follows a command + ending in a letter. It does this automatically, so you + won't get unwanted extra space in your typeset output, + but it does mean that any simple command which ends in a + letter and has no arguments (see below) must be followed by + white-space before normal text starts again, simply to keep + the command separate from the text. +\subsection{Commands with arguments} +\label{cmdargs} + +Many \LaTeX{} commands are followed by one or more + \textbf{\textit{arguments}}\index{arguments@\textbf{\textit{arguments}}} (a term from + the field of Computer Science, meaning information to act + upon), for example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\chapter{Poetic Form} +\label{pform} + \end{Verbatim} +\end{sourcecode} + +Such arguments always go in + \verb+{+\textbf{\textit{curly + braces}}\index{curly + braces@\textbf{\textit{curly + braces}}}\verb+}+ like + those\index{braces|see{curly braces}} shown above. Be careful not to confuse the + curly braces on your keyboard with round parentheses + \verb+( )+, square brackets + \verb+[ ]+, or angle brackets + \verb+< >+. They are all + different. + +With commands like this (with arguments) you do + \emph{not} need to use extra white-space after + the command name, because there is an argument following it + which will keep it separate from any normal text with + follows after that. +\subsection{White-space in \sfLaTeX{}} +\label{white-space} +\index{white-space} +In \LaTeX{} documents, all \emph{multiple} + spaces, newlines (linebreaks), and TAB characters are + treated as if they were a \emph{single} space + or newline during typesetting. \LaTeX{} does its own spacing + and alignment using the instructions you give it, so you + have extremely precise control. You are therefore free to + use extra white-space in your editor for optical ease and + convenience when editing. + + + The following is therefore exactly equivalent to the example + in the preceding section: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\chapter {Poetic Form}\label + {pform} + \end{Verbatim} +\end{sourcecode} + +That is, it will get typeset exactly the same. In + general, just leave a blank line between paragraphs and a + single space between words and sentences. \LaTeX{} will take + care of the formatting. +\section{Special characters} +\label{specials} +\index{special characters} +There are ten keyboard characters which have special + meaning to \LaTeX{}, and cannot be used on their own except for + these purposes: +\begin{center} +\begin{tabular}{clcc}\textbf{\normalfont\bfseries\upshape Key}&\textbf{\normalfont\bfseries\upshape Meaning}&\multicolumn{1}{>{\bfseries\pbs{\centering}}b{1.5in}}{\normalfont\bfseries\upshape \emph{If you need + the actual character itself, type + this:}}&\textbf{\normalfont\bfseries\upshape Character}\\[2pt]\hline\\[-.95\baselineskip] +\key{$\backslash$}&The command character&\texttt{\$}\command{backslash}\texttt{\$}&$\backslash$\\ +\key{\$}&Math typesetting delimiter&\command{\$}&\$\\ +\key{\%}&The comment character&\command{\%}&\%\\ +\key{{\char'136}}&Math superscript character&\command{{\char'136}}&{\char'136}\\ +\key{\amp }&Tabular column separator&\command{\amp }&\amp \\ +\key{{\char'137}}&Math subscript character&\command{{\char'137}}&{\fontencoding{OT1}\fontfamily{cmtt}\selectfont{}{\char'137}}\\ +\key{{\char'176}}&Non-breaking space&\command{{\char'176}}&{\char'176}\\ +\key{\#}&Macro parameter symbol&\command{\#}&\#\\ +\key{{\char'173}}&Argument start delimiter&\texttt{\$}\command{{\char'173}}\texttt{\$}&{\fontencoding{OT1}\fontfamily{cmtt}\selectfont{}{\char'173}}\\ +\key{{\char'175}}&Argument end delimiter&\texttt{\$}\command{{\char'175}}\texttt{\$}&{\fontencoding{OT1}\fontfamily{cmtt}\selectfont{}{\char'175}}\\ +\end{tabular} +\end{center} + +These were deliberately chosen because they are rare in + normal text, with the exception of \$, \#, \amp , + and \%, some of whose meanings were already established + as \textbf{\textit{metacharacters}}\index{metacharacters@\textbf{\textit{metacharacters}}} + (characters standing as symbols for something else) by the + time \TeX{} was written. +\subsection{Using the special characters} +\index{Euro symbol} +Because of the special meaning \LaTeX{} uses for the + dollar-sign on its own, if you want to print \$35.99 + you type \verb+\$35.99+. + +(An unusual but interesting serif-font Euro\index{euro@\euro{}} sign {\rmfamily{}\selectfont{}\euro{}} + is got with the \command{texteuro} command from the + \package{textcomp} package. {\sffamily{}\selectfont{}The standard sans-serif \EUR{} needs the + \package{marvosym} package and is done with + the \command{EUR} command.}\footnote{The European Commission has specified that everyone + use the sans-serif design, even in serif text, but this + is amazingly ugly and most designers rightly ignore + it.}) + +If you want to print AT\amp T you need to type + \verb+AT\&T+; if you want to print 45\% + you need to type \verb+45\%+; and if + you want a \textbf{\textit{hash mark}}\index{hash mark@\textbf{\textit{hash mark}}} (the + \textbf{\textit{octothorpe}}\index{octothorpe@\textbf{\textit{octothorpe}}} or + American number or `pound' [weight] sign + `\#') you type + \verb+\#+. For a pound + (sterling)\index{pound@£} + sign £, now nearly obsolete except in the UK and some + of its former dependencies, use your \key{£} key + or type \command{textsterling}. + +\label{comment}% +The \textbf{\textit{comment + character}}\index{comment + character@\textbf{\textit{comment + character}}} (\verb+%+) makes \LaTeX{} + ignore the remainder of the line in your document, so you + can see it in your editor, but it will never get typeset, + for example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +Today's price per Kg is £22.70 % get Mike to update this + \end{Verbatim} +\end{sourcecode} +\section{Quotation marks} +\label{quotes} +\index{quotation marks} +Do \emph{not} use the unidirectional + typewriter keyboard \key{"} key for quotation + marks. Correct typographic quotes are got with the \ttkey{`} key and the \ttkey{'} key, doubled if you want double + quotes: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +He said, ``I'm just going out.'' + \end{Verbatim} +\end{sourcecode}\leavevmode\enspace +\begin{quote}\noindent +{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}He said, + ``I'm just going out.''}\end{quote}\end{example} + +This ensures you get real left-hand and right-hand + (opening and closing) quotes (usually shaped like tiny + \textsuperscript{66} and \textsuperscript{99} + or as similarly symmetrically-balanced strokes). If you are + using \product{Emacs} as your editor, the + \key{"} key (usually Shift 2) is + specially programmed in \LaTeX{}-mode to think for itself and + produce correct \verb+``+ and + \verb+''+ characters (so this is one occasion when + you \emph{can} use the \key{"} + key). +\begin{warning} + +If you are reading this in a browser, or if you have + reprocessed the file using different fonts, it may not show + you real quotes (some of the browser fonts are defective) + and the \command{thinspace} below may be too wide. + Download the typeset (PDF\index{PDF@PDF}) version + of this document to see the real effect. +\end{warning} + +\label{thinspace}% +When typing one quotation inside another, + there is a special command \command{thinspace} which + provides just enough separation between double and single + quotes (a normal space is too much and could allow an + unwanted linebreak): +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +He said, `Her answer was ``never''\thinspace', and... + \end{Verbatim} +\end{sourcecode}\leavevmode\enspace +\begin{quote}\noindent +He said, `Her answer was + ``never''\thinspace{}', and\dots \end{quote}\end{example} +\section{Accents} +\label{accents} +\index{accents} +For accented letters in ISO 8859-1 (Latin\ndash{}1, Western + European), 8859-15 (same but with the Euro) or other + Latin-alphabet character sets just use the accented keys on + your keyboard (if you have them). If you don't, you need + to use your operating system's standard keyboard + \key{Ctrl} or \key{Alt} key combinations + to generate the characters (see the panel `Keystrokes for accented letters' on p.\pageref{keystrokes}). + +You must also tell \LaTeX{} what input encoding you are + using. Specify this by using the + \package{inputenc} package\footnote{We + haven't covered the use of packages yet. Don't + worry, see \chaptername~\ref{ctan} if you're + curious.} in your preamble with the + relevant option. For example, to make \LaTeX{} understand the + codes for ISO Latin\ndash{}1, use: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage[latin1]{inputenc} + \end{Verbatim} +\end{sourcecode} +\begin{sidebar}\label{keystrokes} +\subsection*{Keystrokes for accented letters} +This is for users whose keyboards do not have native + accent characters on them. See your Operating System manual + for full details. Here are two common examples: +\begin{itemize} +\item +Under Linux the letter é is usually got with + \key{AltGr}--\key{;}~\thinspace{}\key{e}. Refer to the + \product{xkeycaps} utility for a table + of key codes and combinations (get it from \url+http://www.jwz.org/xkeycaps/+). + +\item +Under Microsoft Windows the letter é is got with + \key{Ctrl}--\ttkey{'}~\thinspace{}\key{e} or holding down the + \thinspace{}\key{Alt} key and typing \thinspace{}\key{0}\thinspace{}\key{1}\thinspace{}\key{3}\thinspace{}\key{0} + on the numeric keypad (\emph{not} the top + row of shifted numerals). Refer to the + \product{charmap} utility for a table + of key codes and combinations (find it in the + \url+C:\Windows+ folder). + +\end{itemize} +\end{sidebar} +If you cannot generate ISO 8859-1 characters from your + keyboard at all, or you need additional accents or symbols + which are not in any of the keyboard tables, use the symbolic + notation below. In fact, this can be used to put any accent + over any letter: if you particularly want a \~g you can + have one with the command + \command{{\char'176}}\verb+g+ (and Welsh + users can get \^w with + \command{{\char'136}}\verb+w+). +\begin{center} +\begin{tabular}{lcc}\textbf{\normalfont\bfseries\upshape Accent}&\textbf{\normalfont\bfseries\upshape Example}&\textbf{\normalfont\bfseries\upshape Characters to type}\\[2pt]\hline\\[-.95\baselineskip] +Acute (fada)&é&\verb+\'e+\\ +Grave&è&\verb+\`e+\\ +Circumflex&ê&\verb+\^e+\\ +Umlaut or diæresis&ë&\verb+\"e+\\ +Tilde&ñ&\verb+\~n+\\ +Macron&\=o&\verb+\=o+\\ +Bar-under&\b o&\verb+\b o+\\ +Dot-over (sé{\fontfamily{cmr}\selectfont\i}\.m{\fontfamily{cmr}\selectfont\i}ú)&\.m&\verb+\.m+\\ +Dot-under&\d s&\verb+\d s+\\ +Breve&\u u&\verb+\u u+\\ +Há\v cek (caron)&\v u&\verb+\v u+\\ +Long umlaut&\H o&\verb+\H o+\\ +Tie-after&{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}\t oo}&\verb+\t oo+\\ +Cedilla&\c c&\verb+\c c+\\ +O-E ligature&\oe , \OE &\verb+\oe+, + \verb+\OE+\\ +A-E ligature&\ae , \AE &\verb+\ae+, + \verb+\AE+\\ +A-ring&\aa , \AA &\verb+\aa+, + \verb+\AA+\\ +O-slash& \o , \O &\verb+\o+, + \verb+\O+\\ +Soft-l&\l{}, \L{}&\verb+\l+, + \verb+\L+\\ +Ess-zet (scharfes-S)&\ss &\verb+\ss+\\ +\end{tabular} +\end{center} + +If you use this symbolic method only, you do not need to + use the \package{inputenc} package. Before the + days of keyboards and screens with their own real accented + characters, the symbolic notation was the + \emph{only} way to get accents, so you may come + across a lot of older documents (and users!) using this method + all the time. + +Irish and Turkish dotless-{\fontfamily{cmr}\selectfont\i} is done with the + special command \command{i}, so an {\fontfamily{cmr}\selectfont\'\i}-fada + (which is normally typed with \key{{\fontfamily{cmr}\selectfont\'\i}}) + requires + \verb+\'\i+ if you need to type it in long format, + followed by a backslash-space or dummy pair of curly braces if + it comes at the end of a word and there is no punctuation, + because of the rule that \LaTeX{} control sequences which end + in a letter (see \S\thinspace\ref{swallow}) always absorb any + following space. So what you normally type as + {\textit\uline{R{\fontfamily{cmr}\selectfont\'\i} Tea\.mra\.c}} has to be + \verb+R\'\i\ Tea\.mra\.c+ when typed in full + (there are not usually any keyboard keys for the + dotless-{\fontfamily{cmr}\selectfont\i} or the lenited characters). A similar rule + applies to dotless-{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}{\fontfamily{cmr}\selectfont\j}}. +\section{Sizes, hyphenation, justification, and breaking} +\label{handj} +\index{hyphenation}\index{justification}\index{hj@H\amp J|see{hyphenation, justification}} +\LaTeX{}'s internal measurement system is + extraordinarily accurate. The underlying \TeX{} engine conducts + all its business in units smaller than the wavelength of + visible light, so if you ask for 15mm space, that's what + you'll get.\footnote{Within the limitations of your screen or printer, of + course. Most screens cannot show dimensions of less than + \(\frac{1}{96}\)$''$ without resorting to magnification + or scaling, and even at 600dpi, fine oblique lines or + curves on a printer can still sometimes be seen to stagger + the dots.} At the same time, many dimensions in + \LaTeX{}'s preprogrammed formatting are specially set up + to be flexible: so much space, plus or minus certain limits to + allow the system to make its own adjustments to accommodate + variations like overlong lines, unevenly-sized images, and + non-uniform spacing around headings. + +\TeX{} uses the most sophisticated justification algorithm + known to achieve a smooth, even texture to normal paragraph + text. The programming for this has been borrowed by a large + number of other DTP systems, and users of these are often + quite unaware that they are in fact using a significant part + of \TeX{} in their work. Occasionally, however, you will need + to hand-correct an unusual word-break or line-break, and there + are facilities for doing this on individual occasions as well + as throughout a document. +\subsection{Specifying size units} +\label{dimensions} +\index{dimension}\index{units} +Most people in printing and publishing habitually use + points and picas and ems. Some designers use cm and mm. Many + English-language speakers still use inches. You can + specify lengths in \LaTeX{} in any of these + units, and others: +\index{pt (points)}\index{points}\index{pc (picas)}\index{picas}\index{bp (big points)}\index{sp (scaled points)}\index{dd (Didot points)}\index{cc (Ciceros)}\index{em (relative measure)}\index{ex (relative measure)}\index{mm (millimeters)}\index{cm (centimeters)}\index{in (inches)}\begin{center} +\begin{tabular}{@{}l>{\pbs{\raggedright}}p{4in}}\textbf{\normalfont\bfseries\upshape Unit}&\textbf{\normalfont\bfseries\upshape Size}\\[2pt]\hline\\[-.95\baselineskip] +\vrule height1.5em width0pt\bfseries\itshape &\vrule height1.5em width0pt\bfseries\itshape Printers' fixed measures\\[2pt] +pt&Anglo-American standard points (72.27 to the + inch)\\ +pc&pica ems (12pt)\\ +bp&Adobe `big' points (72 + to the inch)\\ +sp&\TeX{} `scaled' points + (65536 to the pt)\\ +dd&Didot (European standard) points (67.54 to the + inch)\\ +cc&Ciceros (European pica ems, 12dd)\\ +\vrule height1.5em width0pt\bfseries\itshape &\vrule height1.5em width0pt\bfseries\itshape Printers' relative measures\\[2pt] +em&ems of the current point size (historically the + width of a letter `M' but see + below)\\ +ex&x-height of the current font (height of letter + `x')\\ +\vrule height1.5em width0pt\bfseries\itshape &\vrule height1.5em width0pt\bfseries\itshape Other measures\\[2pt] +cm¢imeters (2.54 to the inch)\\ +mm&millimeters (25.4 to the inch)\\ +in&inches\\ +\end{tabular} +\end{center} + +The em can cause beginners some puzzlement because + it's based on the `point size' + of the type, which is itself misleading. The point size + refers to the depth of the metal body on which foundry type + was cast in the days of metal typesetting, + \emph{not} the height of the letters + themselves. Thus the letter-size of 10pt type in one face + can be radically different from 10pt type in another (look + at Table~\ref{fontable}, where all the examples are + 10pt). An em is the height of the type in a specific size, + so 1em of 10pt type is 10pt and 1em of 24pt type is 24pt. + Another name for a 1em space is a + `quad', and \LaTeX{} has a command + \command{quad} for leaving exactly that much + horizontal space. To make the point, Figure~\ref{emsize} shows two capital Ms of 72pt and 36pt + type in different faces, surrounded by a box exactly 1em of + those sizes wide. A special name is given to the 12pt em, a + `pica' em, as it has become a fixed + measure in its own right. +\begin{figure} +\caption{Different sizes of type boxed at 1em} +\label{emsize} +\begin{center} +\begin{tabular}{rl}\textbf{\normalfont\bfseries\upshape Times New Roman 72pt}&\textbf{\normalfont\bfseries\upshape Adobe Helvetica 36pt}\\[2pt]\hline\\[-.95\baselineskip] +{\vrule height80pt + width0pt}{\setlength{\fboxsep}{0pt}\fbox{{\fontencoding{OT1}\fontfamily{ptm}\fontsize{72}{72}\selectfont{}\hbox to1em{\hss M\emstrut\hss}}}}&{\setlength{\fboxsep}{0pt}\fbox{{\fontencoding{T1}\fontfamily{phv}\fontsize{36}{36}\selectfont{}\hbox to1em{\hss M\emstrut\hss}}}}\\ +\end{tabular} +\end{center} +\end{figure} + +If you are working with other DTP users, watch out for + those who think that Adobe points (bp) are the only ones. + The difference is only .27pt per inch, but in 10$''$ of + text (a full page of A4) that's 2.7pt, which is nearly + 1mm, enough to be clearly visible if you're trying to + align one sample with another. +\subsection{Hyphenation} +\label{hyph} + +\LaTeX{} hyphenates automatically according to the + language you use (see \S\thinspace\ref{langs}). To specify + different breakpoints for an individual word, you can insert + soft-hyphens\index{hyphens!soft} (discretionary hyphens, done with + \command{-}) wherever you need them, for + example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +When in Mexico, we visited Popoca\-tépetl by helicopter. + \end{Verbatim} +\end{sourcecode} + +To specify hyphenation points for all occurrences of a + word, use the \command{hyphenation} command in your + preamble (see the panel `The Preamble' on p.\pageref{preamble}) with one or more + words in its argument, separated by spaces. This will even + let you break `helico-\linebreak pter' correctly. In this command + you use normal hyphens, not soft-hyphens.\index{hyphens!discretionary} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\hyphenation{helico-pter Popoca-tépetl im-mer-sion} + \end{Verbatim} +\end{sourcecode} + +If you have frequent hyphenation problems with long, + unusual, or technical words, ask an expert about changing + the value of \length{spaceskip}, + which controls the flexibility of the space between words. + This is not something you would normally want to do, as it + can change the appearance of your document quite + significantly. + +If you are using a lot of unbreakable text (see next + section and also \S\thinspace\ref{inlineverb}) it may + also cause justification problems. One possible solution to + this is shown in \S\thinspace\ref{macargs}. +\subsection{Unbreakable text} + +To force \LaTeX{} to treat a word as unbreakable (the + opposite of hyphenation), use the \command{mbox} + command: + \verb+\mbox{pneumonoultramicroscopicsilicovolcanoconiosis}+. + This may have undesirable results, however, if + you change margins: + \mbox{pneumonoultramicroscopicsilicovolcanoconiosis}\dots + +To tie two words together with an unbreakable + space\index{hard space}\index{white-space!hard} (hard space), use a tilde (\verb+~+) + instead of the space. This will print as a normal space but + \LaTeX{} will never break the line at that point. You should + make this standard typing practice for things like + people's initials followed by their surname, as in + Prof. D. E. Knuth: + \verb+Prof.\ D.~E.~Knuth+. +\begin{warning} + +Note that a full point after a lowercase letter is + treated as the end of a sentence, and creates more space + before the next word. Here, after + `Prof.', it's + \emph{not} the end of a sentence, and the + backslash-space forces \LaTeX{} to insert just an ordinary + word-space because it's OK to break the line after + `Prof.', whereas it would look + wrong to have initials separated with Prof. D.E. Knuth broken over a line-end. +\end{warning} +\subsection{Dashes} + +For a long dash\mdash{}what printers call an + `em rule' like this\mdash{}use three + hyphens typed together, \verb+like~--- this+, + and bind them to the preceding word with a tilde to avoid + the line being broken before the dash. It's also common + to see the dash printed without spaces---like that: the + difference is purely æsthetic. \emph{Never} + use a single hyphen for this purpose. + +Between digits like page ranges (35\ndash{}47), it is + normal to use the short dash (what printers call an en-rule) + which you get by typing two hyphens together, as in + \verb+35--47+. If you want a minus sign, use math + mode (\S\thinspace\ref{math}). +\subsection{Justification} + +The default mode for typesetting is justified (two + parallel margins, with word-spacing adjusted automatically + for the best optical fit). In justifying, \LaTeX{} will never + add space between letters, only between words. There is a + special package called \package{so} + (`space-out') if you need special + effects like letter-spacing, but these are best left to the + expert. + +There are two commands + \command{raggedright} and + \command{raggedleft} which set ragged-right (ranged + left) and ragged-left (ranged right). Use them inside a + group (see the panel `Grouping' on p.\pageref{grouping}) to confine their + action to a part of your text. + +{\raggedleft +These modes also exist as + `environments' (see \S\thinspace\ref{environments}) called + \env{raggedright} and + \env{raggedleft} which are more convenient + when applying this formatting to a whole paragraph or more, + like this one. +\par}\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{raggedleft} +These modes also exist as environments called raggedright and +raggedleft which is more convenient when applying this formatting +to a whole paragraph or more, like this one. +\end{raggedleft} + \end{Verbatim} +\end{sourcecode} +\subsection{Languages} +\label{langs} + +\LaTeX{} can typeset in the native manner for several + dozen languages. This affects hyphenation, word-spacing, + indentation, and the names of the parts of documents used as + headings (e.g. Table of Contents). + +Most distributions of \LaTeX{} come with US English and + one or more other languages installed by default, but it is + easy to add the \package{babel} package and + specify any of the supported languages or variants, for + example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage[frenchb]{babel} +... +\selectlanguage{frenchb} + \end{Verbatim} +\end{sourcecode} + +Changing the language with + \package{babel} automatically changes the + names of the structural units and identifiers like + `Abstract', + `Index', etc. to their translated + version. For example, using French as above, chapters will + start with + `\emph{Chapitre}'. +\section{Mathematics} +\label{math} +\index{mathematics} +As explained in the Preface, \TeX{} was + originally written to automate the typesetting of books + containing mathematics. The careful reader will already have + noticed that mathematics is handled differently from normal + text, which is why it has to be typeset specially. This + document does not cover mathematical typesetting, which is + explained in detail in many other books and Web pages, so all + we will cover here is the existence of the math mode commands, + and some characters which have special meaning, so they + don't trip you up elsewhere. + +In addition to the 10 special characters listed in \S\thinspace\ref{specials}, there are three more characters which + only have any meaning inside mathematics mode:\index{math characters} +\begin{center} +\begin{tabular}{cl}\textbf{\normalfont\bfseries\upshape Key}&\textbf{\normalfont\bfseries\upshape Meaning}\\[2pt]\hline\\[-.95\baselineskip] +\key{$|$}&Vertical bar\\ +\ttkey{<}&Less-than\\ +\ttkey{>}&Greater-than\\ +\end{tabular} +\end{center} + +If you type any of these in normal text (ie outside math + mode), you will get very weird things happening and lots of + error messages. If you need to print these characters, you + \emph{must} type them using math mode. + +The hyphen also has an extra meaning in math mode: it + typesets as a minus sign, so if you want to write about + negative numbers you need to type the number in math mode so + the minus sign and the spacing come out right. + +To use math mode within a paragraph, enclose your math + expression in \command{(} and \command{)} + commands. You can get the much-quoted equation + \(E=mc^{2}\) by typing + \verb+\(E=mc^2\)+, and to get a temperature like + \ifmmode-\else$-$\fi{}30° you need to type + \verb+\(-30\)°+.\footnote{Bear in mind that the degree symbol is a non-ASCII\index{ASCII@ASCII} character, so you must specify + what input encoding you are using if you want to type it: + see the example of the \package{inputenc} + package in \S\thinspace\ref{accents}. If you don't + want to use non-ASCII\index{ASCII@ASCII} characters + (or if you are using a system which cannot generate them), + you can use the command \command{textdegree} to + get the degree sign.} + +To typeset a math expression as `displayed + math' (centered between paragraphs), enclose it + in the commands \command{[} and + \command{]}.\footnote{You will also see dollar signs used for math mode. + This is quite common but deprecated: it's what plain + \TeX{} used in the days before \LaTeX{}, and the habit got + ingrained in many mathematicians. It still works as a + convenient shorthand like \url+$x=y$+, as do + double-dollars for display-mode math like + \url+$$E=mc^2$$+, but they are only mentioned + here to warn readers seeing them in other authors' + work that \command{(}\dots \command{)} + and \command{[}\dots \command{]} are + the proper \LaTeX{} commands.} +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\[\bar n^*_j(s)=\frac{\left\{s\sum_{i=1}^kn_i(0)p^* +_{i,k+1}(s)+M^*(s)\right\}\sum_{i=1}^kp_{0i}p^*{ij} +(s)}{1-s\sum_{i=1}^kp_{0i}p^*_{i,k+1}(s)}+\sum_{i=1} +^kn_i(0)p^*_{ij}(s)[j=1,2,\dots,k].\] + \end{Verbatim} +\end{sourcecode}\leavevmode\enspace +\begin{quote}\noindent + \(\bar n^*_j(s)= + \frac{\left\{s\sum^k_{i=1}n_i(0)p^*_{i,k+1}(s)+M^*(s)\right\} + \sum^k_{i=1}p_{0i}p^*{ij}(s)}{1-s\sum^k_{i=1}p_{0i}p^*_{i,k+1}(s)} + +\sum^k_{i=1}n_i(0)p^*_{ij}(s)\,\rlap{[j=1,2,\dots,k]}\) + \end{quote}\end{example} + +Displayed equations can be auto-numbered by using the + \env{equation} environment instead of the + \command{[} and \command{]} commands. +\chapter{Basic document structures} +\label{basic} +\index{sections} +\LaTeX{}'s approach to formatting is to aim for + consistency. This means that as long as you identify each + \textbf{\textit{element}}\index{element@\textbf{\textit{element}}} of your document correctly, it + will be typeset in the same way as all the other elements like + it, so that you achieve a professional finish with minimum + effort. + +Elements are the component parts of a document. The popular + structure of parts, chapters, sections, subsections, + subsubsections, paragraphs, lists, tables, figures, and so on is + familiar to everyone from reading books, newspapers, magazines, + reports, articles, and other classes of documents. + +To achieve this consistency, every \LaTeX{} document must + start by declaring what \textbf{\textit{document class}}\index{document class@\textbf{\textit{document class}}} it + belongs to. +\section{The Document Class Declaration} +\label{docdecl} +\index{document class} +To tell \LaTeX{} what class of document you are going to + create, you type a special first line into your file which + identifies it.\footnote{Readers familiar with SGML\index{SGML@SGML}, HTML\index{HTML@HTML}, or XML\index{XML@XML} will recognize the concept + as similar to the Document Type + Declaration.} To start a report, for + example, you would type the \command{documentclass} + command like this: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass{report} + \end{Verbatim} +\end{sourcecode} + +There are four default classes provided, and many others + are available online: +\begin{description} +\item[\sffamily \package{report}] +for business, technical, legal, academic, or + scientific reports; +\item[\sffamily \package{article}] +for magazine or journal articles, reviews, + conference papers, or research notes; +\item[\sffamily \package{book}] +for books and theses; +\item[\sffamily \package{letter}] +for letters.\footnote{The default \package{letter} + class is rather idiosyncratic: there are much better + ones you can download and install yourself, such as + the \package{memoir} and + \package{komascript} packages.} +\end{description} + +The \package{article} class in particular + can be used (some would say `abused') for almost + any short piece of typesetting by simply omitting the titling + and layout (see below). + +The default classes are normally only used for + compatibility when exchanging documents with other \LaTeX{} + users, as they come with every copy of \LaTeX{} and are + therefore guaranteed to format identically everywhere. For + most purposes, especially for publication, you can download + replacements or extensions of these classes: +\begin{itemize} +\item +The \package{memoir} and + \package{komascript} packages contain + sophisticated replacements for all the default + classes; + +\item +Many academic and scientific publishers provide their + own special class files for articles and books (often on + their Web sites for download); + +\item +Conference organisers may also provide class files for + authors to write papers for presentation; + +\item +Many universities provide their own thesis document + class files in order to ensure exact fulfillment of their + formatting requirements; + +\item +Businesses and other organizations can provide their + users with corporate stylesheets on a central server and + configure \LaTeX{} installations to look there first for + class files and packages. + +\end{itemize} + +It is worth noting that some of the default document + classes are intended for final printing on different sizes of + paper than A4 or Letter. Books and journals are not usually + printed on office-size paper, so printing them on standard + office stationery makes them look odd: the margins are too + wide, or the positioning is unusual, or the font size is too + small. These default classes are adequate for drafts or for + sending to another \LaTeX{} user (because you know their system + will understand them) but they are not really sufficient for + professional publishing purposes. For this you need a style + file designed by the publisher to fit their series of + publications (quite often based on the default classes, but + looking very different). As noted earlier, the + \package{memoir} and + \package{komascript} packages provide good + facilities for helping design these. +\subsection{Document class options} +\label{doclayout} +\index{paper sizes} +The default layouts are designed for US + `Letter' size paper.\footnote{Letter size is 8½$''$$\times$11$''$, which is the + trimmed size of the old Demi Quarto, still in use in + North America. The other common US office size is + `Legal', which is + 8½$''$$\times$14$''$, a bastard cutting, but close to + the old Foolscap (8¼$''$$\times$13¼$''$). ISO + standard paper sizes are still virtually unknown in + North America.} To create documents with the correct proportions + for standard A4 paper, you need to specify the paper size in + an optional argument in square brackets before the document + class name, e.g. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[a4paper]{report} + \end{Verbatim} +\end{sourcecode} + +The other default settings are for: \begin{inparaenum}[\itshape a\upshape)] \item 10pt type (all document classes); \item two-sided printing (books and reports) or + one-sided (articles and letters); and \item separate title page (books and reports + only)\end{inparaenum}. These can be modified with the following + document class options which you can add in the same set of + square brackets, separated by commas: +\index{fonts!sizes}\begin{description} +\label{docfontsize} +\item[\sffamily \opt{11pt}] +to specify 11pt type (headings, footnotes, etc. get + scaled up or down in proportion); +\item[\sffamily \opt{12pt}] +to specify 12pt type (again, headings scale); +\item[\sffamily \opt{oneside}] +to format one-sided printing for books and + reports; +\item[\sffamily \opt{twoside}] +to format articles for two-sided printing; +\item[\sffamily \opt{titlepage}] +to force articles to have a separate title + page; +\item[\sffamily \opt{draft}] +makes \LaTeX{} indicate hyphenation and + justification problems with a small square in the + right-hand margin of the problem line so they can be + located quickly by a human. +\end{description} + +There are extra preset options for other type sizes + which can be downloaded separately (10pt, 11pt, and 12pt + between them cover probably 95\% of all document + typesetting). In addition there are hundreds of add-in + packages which can automate other layout and formatting + variants without you having to program anything by hand or + even change your text. +\begin{exercise} +\label{firstline} +\addcontentsline{loe}{section}{\numberline{1}Create a new document} +\subsubsection*{Create a new document}\begin{enumerate}\item +Use your editor to create a new document. + +\item +Type in the Document Class Declaration as shown + above. + +\item +Add a font size option if you wish. + +\item +In North America, omit the + \opt{a4paper} option or change it to + \opt{letterpaper}. + +\item +Save the file (make up a name) ensuring the name + ends with \url+.tex+. + +\end{enumerate} +\end{exercise} +\section{The document environment} +\label{docenv} + +After the Document Class Declaration, the text of your + document is enclosed between two commands which identify the + beginning and end of the actual document: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} + +\begin{document} +... +\end{document} + \end{Verbatim} +\end{sourcecode} + +(You would put your text where the dots are.) The reason + for marking off the beginning of your text is that \LaTeX{} + allows you to insert extra setup specifications before it + (where the blank line is in the example above: we'll be + using this soon). The reason for marking off the end of your + text is to provide a place for \LaTeX{} to be programmed to do + extra stuff automatically at the end of the document. + We're not going to do either of those yet, + though. + +A useful side-effect of marking the end of the document + text is that you can store comments or temporary text + underneath the \verb+\end{document}+ in the + knowledge that + \LaTeX{} will never try to typeset them. + +\label{environments}% +This + \command{begin}\thinspace{}\dots \command{end} + pair is an example of a common \LaTeX{} structure called an + \textbf{\textit{environment}}\index{environment@\textbf{\textit{environment}}}. + Environments enclose text which is to be handled in a specific + way. All environments start with + \verb+\begin{...}+ and end with + \verb+\end{...}+ (putting the name of the + environment in the curly braces). +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{2}Add a document environment} +\subsubsection*{Add a document environment}\begin{enumerate}\item +Add the \env{document} environment to + your file. + +\item +Leave a blank line between the Document Class + Declaration and the \verb+\begin{document}+ + (you'll see why later). + +\item +Save the file. + +\end{enumerate} +\end{exercise} +\section{Titling} +\label{titling} +\index{titles} +The first thing you put in the + \env{document} environment is almost + always your document title, the author's name, and the + date (except in letters, which have a special set of commands + for addressing which we'll look at later). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} + +\begin{document} + +\title{Practical Typesetting} +\author{Peter Flynn\\Silmaril Consultants} +\date{December 2004} +\maketitle + +\end{document} + \end{Verbatim} +\end{sourcecode} + +The \command{title}, \command{author}, + and \command{date} commands should be + self-explanatory. The double backslash (\verb+\\+) + means a forced linebreak. You always finish the title block with the + \command{maketitle} command, otherwise the titling + will never be typeset. The \command{maketitle} + command is reprogrammable so you can alter the appearance of + titles on a consistent basis. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{3}Adding the title block} +\subsubsection*{Adding the title block}\begin{enumerate}\item +Add a \command{title}, + \command{author}, \command{date}, and + \command{maketitle} command to your file. + +\item +Use your own name, make up a title, and give a + date. + +\item +Add two backslashes after your name and add your + organisation or department name. + +\item +The order of the first three commands is not + important, but the \command{maketitle} command + must come last. + +\end{enumerate} +\end{exercise} + +When this file is typeset, you get something like this + (I've cheated and done it in + colour (\S\thinspace\ref{colorpkg}) for fun\mdash{}yours will be in black and white + for the moment): +\begin{center} +\fbox{\includegraphics[width=0.5\textwidth]{title}} +\end{center} + +However, before we see how to get this displayed or + printed, there are a few more elements to cover: abstracts, + sectioning, the Table of Contents, and paragraphs. If + you're really impatient, though, refer to \chaptername~\ref{process} to see how to typeset and display + it. +\section{Abstracts and summaries} +\label{abstracts} +\index{abstracts}\index{summaries} +In reports and articles it is normal for the author (you) + to provide an Abstract or Summary, in which you describe + briefly what you have written about and explain its + importance. Abstracts in articles are usually only a + few paragraphs long; Summaries in reports can run to several + pages, depending on the length and complexity of the report + itself. + +In both cases the Abstract or Summary is theoretically + optional (that is, \LaTeX{} doesn't force you to have one), + but almost always included. In practice, of course, you go + back and type the Abstract or Summary + \emph{after} having written the rest of the + document, but for the sake of the example we'll jump the + gun and type it now. + +Immediately after the \command{maketitle} you can + use the \env{abstract} environment, in which + you simply type your Abstract or Summary, leaving a blank line + between paragraphs (see \S\thinspace\ref{paragraphs} for this + convention). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} +\usepackage[latin1]{inputenc} +\renewcommand{\abstractname}{Summary} +\begin{document} + +\title{Practical Typesetting} +\author{Peter Flynn\\Silmaril Consultants} +\date{December 2004} +\maketitle + +\begin{abstract} +This document presents the basic concepts of typesetting in a +form usable by non-specialists. It is aimed at those who find +themselves (willingly or unwillingly) asked to undertake work +previously sent out to a professional printer, and who are +concerned that the quality of work (and thus their corporate +image) does not suffer unduly. + +The topics cover layout, the need for accuracy, the choice of +typeface, arrangement of the document, adherence to +specifications, and the production process. No foreknowledge +of printing or publishing is needed, but an eye for detail, +a feeling for æsthetics, and some fluency with a computer is +expected. +\end{abstract} + +\end{document} + \end{Verbatim} +\end{sourcecode} + +In business and technical documents, the Abstract is often + called a Management Summary, or Executive Summary, or Business + Preview, or some similar phrase. \LaTeX{} lets you change the + name associated with the \env{abstract} + environment to any kind of title you want, using the + \command{renewcommand} command to give the + \command{abstractname} a new value: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand{\abstractname}{Executive Summary} + \end{Verbatim} +\end{sourcecode} + +Notice how the name of the command you are renewing + (\command{abstractname}) goes in the first set of + curly braces, and the new value you want it to have goes in + the second set of curly braces. The environment you use is + still called \env{abstract} (that is, you still + type + \verb+\begin{abstract}+\dots \verb+\end{abstract}+): + what the \command{abstractname} does is change the + name that gets displayed and printed, not the name of the + environment you store the text in. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{4}Using an Abstract or Summary} +\subsubsection*{Using an Abstract or Summary}\begin{enumerate}\item +Add the \command{renewcommand} line given + above to your Preamble. + +The Preamble is at the start of the document, in + that gap \emph{after} the + \command{documentclass} line but + \emph{before} the + \verb+\begin{document}+ (remember I said we'd + see what we left it blank for: see the panel `The Preamble' on p.\pageref{preamble}). + +\item +Add an \env{abstract} environment + after the \command{maketitle} and type in a + couple of short paragraphs of text. + +\item +Save the file (no, I'm not paranoid, just careful). + +\end{enumerate} +\end{exercise} + +If you look carefully at the example Abstract above, + you'll see I added an extra command to the Preamble + (\verb+\usepackage[latin1]{inputenc}+). We'll + see later what this means (Brownie points for guessing it, + though, if you read \S\thinspace\ref{accents}). +\begin{sidebar}\label{preamble} +\subsection*{The Preamble} +Modifications which you want to affect a whole document + go at the very start of your \LaTeX{} file, immediately after + the \command{documentclass} line and before the + \verb+\begin{document}+ line: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} +\renewcommand{\abstractname}{Sneak Preview} +\begin{document} +... +\end{document} + \end{Verbatim} +\end{sourcecode} + +This position, between the Document Class Declaration + and the beginning of the \env{document} + environment, is called the \textbf{\textit{preamble}}\index{preamble@\textbf{\textit{preamble}}}, + and it is used for small or temporary modifications to the style + and behaviour of the document. Major or permanent + modifications should go in a \url+.sty+ file + and be invoked with a \command{usepackage} command. +\end{sidebar}\section{Sections} +\label{sections} +\index{sections} +In the body of your document, \LaTeX{} provides seven + levels of division or sectioning for you to use in structuring + your text. They are all optional: it is perfectly possible to + write a document consisting solely of paragraphs of + unstructured text. Even novels are normally + divided into chapters, although short stories are often made + up solely of paragraphs. + +Two of these divisions, Parts and Chapters, are only + available in the \package{book} and + \package{report} document classes, because they + don't have any meaning in articles and + letters.\footnote{It is arguable that chapters also have no place in + reports, either, as these are conventionally divided into + sections as the top-level division. \LaTeX{}, however, + assumes your reports have chapters, but this is only the + default, and can be changed very simply (see + \chaptername~\ref{macros}).\label{repchap}} +\begin{center} +\begin{tabular}{clll}\textbf{\normalfont\bfseries\upshape Depth}&\textbf{\normalfont\bfseries\upshape Division}&\textbf{\normalfont\bfseries\upshape Command}&\textbf{\normalfont\bfseries\upshape Notes}\\[2pt]\hline\\[-.95\baselineskip] +\(\ifmmode-\else$-$\fi{}1\)&Part&\command{part}&Only in books and reports\\ +0&Chapter&\command{chapter}&Only in books and reports\\ +1&Section&\command{section}&Not in letters\\ +2&Subsection&\command{subsection}&Not in letters\\ +3&Subsubsection&\command{subsubsection}&Not in letters\\ +4&Titled paragraph&\command{paragraph}&Not in letters\\ +5&Titled subparagraph&\command{subparagraph}&Not in letters\\ +\end{tabular} +\end{center} + +In each case the title of the part, chapter, section, etc. + goes in curly braces after the command. \LaTeX{} automatically + calculates the correct numbering and prints the title in bold. + You can turn section numbering off at a specific depth: + details in \S\thinspace\ref{secnum}. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\section{New recruitment policies} +... +\subsection{Effect on staff turnover} +... +\chapter{Business plan 2004--2006} + \end{Verbatim} +\end{sourcecode} + +There are packages\footnote{Details of how to use \LaTeX{} packages are in \S\thinspace\ref{packages}.} to let you control the typeface, style, spacing, + and appearance of section headings: it's much easier to + use them than to try and reprogram the headings manually. Two + of the most popular are the \package{ssection} + and \package{sectsty} packages. + +Headings also get put automatically into the Table of + Contents, if you specify one (it's optional, and we + haven't done that yet: see \S\thinspace\ref{toc}). But if you make manual styling changes to + your heading, for example a very long title, or some special + line-breaks or unusual font-play, this would appear in the + Table of Contents as well, which you almost certainly + don't want. \LaTeX{} allows you to give an optional extra + version of the heading text which only gets used in the Table + of Contents and any running heads, if they are in effect + (\S\thinspace\ref{runningheads}). This goes in [square + brackets] before the curly braces: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\section[Effect on staff turnover]{The effect of the revised + recruitment policies on staff turnover at divisional + headquarters} + \end{Verbatim} +\end{sourcecode} +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{5}Start your document text} +\subsubsection*{Start your document text}\begin{enumerate}\item +Add a \command{chapter} command after + your Abstract or Summary, giving the title of your + first chapter. + +\item +If you're planning ahead, add a few more for + chapters 2, 3, etc. Leave a few blank lines between + them to make it easier to add paragraphs of text + later. + +\item +I shouldn't need to tell you what to do after + making significant changes to your document + file. + +\end{enumerate} +\end{exercise} +\subsection{Section numbering} +\label{secnum} +\index{section numbering} +All document divisions get numbered by default. Parts + get Roman numerals (Part I, Part II, etc.); + chapters and sections get decimal numbering, and Appendixes + (which are just a special case of chapters, and share the + same structure) are lettered (A, B, C, etc.). + +You can change the depth to which section numbering + occurs, so you can turn it off selectively. In this document + it is set + to {\arabic{secnumdepth}}. + If you only want parts, chapters, and sections numbered, not + subsections or subsubsections etc., you can change the + value of the \counter{secnumdepth} + counter using the the \command{setcounter} command, + giving the depth value from the table in \S\thinspace\ref{sections}: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setcounter{secnumdepth}{1} + \end{Verbatim} +\end{sourcecode} + +A related counter is \counter{tocdepth}, which specifies what + depth to take the Table of Contents to. It can be reset in + exactly the same way as \counter{secnumdepth}. The current setting + for this document is {\arabic{tocdepth}}. + +To get an \emph{unnumbered} section + heading which does \emph{not} go into the + Table of Contents, follow the command name with an asterisk + before the opening curly brace: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\subsection*{Shopping List} + \end{Verbatim} +\end{sourcecode} + +All the divisional commands from \command{part*} + to \command{subparagraph*} have this + `starred' version which can be used + on special occasions for an unnumbered heading when the + setting of \counter{secnumdepth} would normally + mean it would be numbered. +\section{Ordinary paragraphs} +\label{paragraphs} + +After section headings comes your text. Just type it and + leave a blank line between paragraphs. That's all \LaTeX{} + needs. + +The blank line means `start a new paragraph + here': it does \emph{not} (repeat: + \emph{\textbf{not}}) mean you get a blank + line in the typeset output. Now read this paragraph again. + +The spacing between paragraphs is a separately definable quantity, a + \textbf{\textit{dimension}}\index{dimension@\textbf{\textit{dimension}}} or \textbf{\textit{length}}\index{length@\textbf{\textit{length}}} called \length{parskip}. This is normally zero + (no space between paragraphs, because that's how books + are normally typeset), but you can easily set it to any size + you want with the \command{setlength} command in the + Preamble: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\parskip}{1cm} + \end{Verbatim} +\end{sourcecode} + +\label{paraspace}% +This will set the space between paragraphs + to 1cm. See \S\thinspace\ref{dimensions} for details of the + various size units \LaTeX{} can use. \emph{Leaving multiple + blank lines between paragraphs in your source document + achieves nothing}: all extra blank lines get + ignored by \LaTeX{} because the space between paragraphs is + controlled only by the value of \length{parskip}. To change the space + between paragraphs, specify it with the command as shown + above. + +White-space in \LaTeX{} can also be made flexible (what + \titlecite{latexbook} calls + `rubber' lengths). This means that + values such as \length{parskip} can + have a default dimension plus an amount of expansion minus an + amount of contraction. This is useful on pages in complex + documents where not every page will be an exact number of + fixed-height lines long, so some give-and-take in vertical + space is useful. You specify this in a + \command{setlength} command like this: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\parskip}{1cm plus4mm minus3mm} + \end{Verbatim} +\end{sourcecode} + +Paragraph indentation can also be set with the + \command{setlength} command, although you would + always make it a fixed size, never a flexible one, otherwise + you would have very ragged-looking paragraphs. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\parindent}{6mm} + \end{Verbatim} +\end{sourcecode} + +By default, the first paragraph after a heading follows + the standard Anglo-American publishers' practice of + \emph{no} indentation. Subsequent paragraphs are + indented by the value of \length{parindent} (default + 18pt).\footnote{Paragraph spacing and indentation are cultural + settings. If you are typesetting in a language other than + English, you should use the \package{babel} + package, which alters many things, including the spacing + and the naming of sections, to conform with the standards + of different countries and languages.} You can change this in the same way as any other + length. + +In the printed copy of this document, the paragraph + indentation is set to {\the\parindent} and the space + between paragraphs is set to {\the\parskip}. These values do not + apply in the Web (HTML) version because not all browsers are + capable of that fine a level of control, and because users can + apply their own stylesheets regardless of what this document + proposes. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{6}Start typing!} +\subsubsection*{Start typing!}\begin{enumerate}\item +Type some paragraphs of text. Leave a blank line + between each. Don't bother about line-wrapping or + formatting\mdash{}\LaTeX{} will take care of all that. + +\item +If you're feeling adventurous, add a + \command{section} command with the title of a + section within your first chapter, and continue typing + paragraphs of text below that. + +\item +Add one or more \command{setlength} + commands to your Preamble if you want to experiment with + changing paragraph spacing and indentation. + +\end{enumerate} +\end{exercise} + +To turn off indentation completely, set it to zero (but + you still have to provide units: it's still a + measure!). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\parindent}{0in} + \end{Verbatim} +\end{sourcecode} + +If you do this, though, and leave + \length{parskip} set to zero, your readers + won't be able to tell easily where each paragraph begins! + If you want to use the style of having no indentation with a + space between paragraphs, use the + \package{parskip} package, which does it for + you (and makes adjustments to the spacing of lists and other + structures which use paragraph spacing, so they don't get too + far apart). +\section{Table of contents} +\label{toc} +\index{table of contents!automated entries} +All auto-numbered headings get entered in the Table of + Contents (ToC) automatically. You don't have to print a + ToC, but if you want to, just add the command + \command{tableofcontents} at the point where you want + it printed (usually after the \command{maketitle} + command and before the Abstract or Summary. + +Entries for the ToC are recorded each time you process + your document, and reproduced the \emph{next} + time you process it, so you need to re-run \LaTeX{} one extra + time to ensure that all ToC page-number references are + correctly calculated. + +We've already seen in \S\thinspace\ref{sections} how + to use the optional argument to the sectioning commands to add + text to the ToC which is slightly different from the one + printed in the body of the document. It is also possible to + add extra lines to the ToC, to force extra or unnumbered + section headings to be included. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{7}Inserting the table of contents} +\subsubsection*{Inserting the table of contents}\begin{enumerate}\item +Go back and add a \command{tableofcontents} + command after the \command{maketitle} command + in your document. + +\item +You guessed. + +\end{enumerate} +\end{exercise} + +The commands \command{listoffigures} and + \command{listoftables} work in exactly the same way + as \command{tableofcontents} to automatically list + all your tables and figures. If you use them, they normally go + after the \command{tableofcontents} command. + +The \command{tableofcontents} command normally + shows only numbered section headings, and only down to the + level defined by the \counter{tocdepth} counter (see \S\thinspace\ref{secnum}), but you can add extra entries with the + \command{addcontentsline} command. For + example if you use an unnumbered section heading command to + start a preliminary piece of text like a Foreword or + Preface, you can write:\index{table of contents!adding manual entry} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\subsection*{Preface} +\addcontentsline{toc}{subsection}{Preface} + \end{Verbatim} +\end{sourcecode} + +This will format an unnumbered ToC entry for + `Preface' in the + `subsection' font style. You can use + the same mechanism to add lines to the List of Figures or List + of Tables by substituting \url+lof+ or + \url+lot+ for \url+toc+. +\chapter{Typesetting, viewing and printing} +\label{process} +\index{typesetting}\index{viewing}\index{printing} +We've now got far enough to typeset what you've entered. I'm + assuming at this stage that you have typed some sample text in + the format specified in the previous chapter, and you've saved + it in a plain-text file with a filetype of + \verb+.tex+ and a name of your own + choosing. +\index{filenames}\begin{exercise} +\addcontentsline{loe}{section}{\numberline{8}Saving your file} +\subsubsection*{Saving your file} +If you haven't already saved your file, do so now (some editors + and interfaces let you typeset the document without saving it!). + +Pick a sensible filename in a sensible directory. Names + should be short enough to display and search for, but + descriptive enough to make sense. See the panel `Picking suitable filenames' on p.\pageref{filenames} for more details. +\end{exercise} +\section{Typesetting} +\label{setting} + +Typesetting your document is usually done with by clicking + on a button in a toolbar or an entry in a menu. Which one you + click on depends on what output you want. +\begin{itemize} +\item +The standard (default) \LaTeX{} program produces a + device-independent (DVI)\index{DVI@DVI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DVI@DVI|textbf} file which + can be used with any \TeX{} viewer or printer driver on any + make or model of computer (there are dozens of these + available: at least one of each (viewer and printer + driver) should have been installed with your distribution + of \TeX{}). + +\item +The \product{pdflatex} program + produces an Adobe Acrobat Portable + Document Format (PDF)\index{PDF@PDF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PDF@PDF|textbf} file which can be used with + any suitable viewer, such as + \product{GSview}, + \product{PDFview}, the + \product{Opera} browser, or Adobe's + own \product{Acrobat Reader}. + +\end{itemize} + +Depending on which one you choose, you may have to + [re]configure your editor so that it runs the right program. + They can all do all of them, but they don't always come + pre-set with buttons or menus for every possible option, + because they can't guess which one you want. +\subsection{Standard \sfLaTeX{}} + +There are two ways of running \LaTeX{}: from the toolbar + or menu, or from the command line. Toolbars and menus are + most common in graphical systems, and are the normal way to + run \LaTeX{}. Command lines are used in non-graphical systems + and in automated processes where \LaTeX{} is run unattended + (so-called `batch' or + `scripted' processing). +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{9}Running \LaTeX{} from the toolbar or menu} +\subsubsection*{Running \LaTeX{} from the toolbar or menu} +Run \LaTeX{} on your file according to which system + you're using: +\begin{itemize} +\item +In \product{WinEdt}, click the + \guiicon{\LaTeX{}} toolbar icon; + +\item +In \product{Emacs}, click the + \menuitem{\TeX{}}{\TeX{} + File} menu item. + +\end{itemize} + +Your editor may suggest you save your file if you + haven't already done so. Do it. +\end{exercise} + +Whichever way you run \LaTeX{}, it will process your file + and display a log or record of what it's doing (see the + example in Exercise~\ref{terminal}: it looks the same no + matter what system you use). This is to let you see where + (if!) there are any errors or problems. + +\emph{Don't panic if you see errors}: + it's very common for learners to mistype or mis-spell + commands, forget curly braces, type a forward slash instead + of a backslash, or use a special character by mistake. + Errors are easily spotted (lines in the log window beginning + with an exclamation mark) and easily corrected in your + editor, and you can run \LaTeX{} again to check you have + fixed everything. \S\thinspace\ref{errmsg} describes some of + the most common mistakes and suggests how to fix + them. + +When \LaTeX{} finds an error (a real one, not just a + warning), it displays an error message and pauses. You must + type one of the following letters to continue: +\begin{center} +\begin{tabular}{cp{4in}}\textbf{\normalfont\bfseries\upshape Key}&\textbf{\normalfont\bfseries\upshape Meaning}\\[2pt]\hline\\[-.95\baselineskip] +\key{x}&Stop immediately and + e{\textit\uline{x}}it the program.\\ +\key{q}&Carry on {\textit\uline{q}}uietly as best + you can and don't bother me with any more error + messages.\\ +\key{e}&Stop the program but re-position the text in my + {\textit\uline{e}}ditor at the point where you + found the error.\\ +\key{h}&Try to give me more {\textit\uline{h}}elp.\\ +\key{i}&(followed by a correction) + {\textit\uline{i}}nput the correction in place + of the error and carry on.\\ +\end{tabular} +\end{center} + +The log will also tell you if there were problems with + overlong or underrun lines (unusual hyphenations, for + example), pages running short or long, and other + typographical niceties (most of which you can ignore until + later). + +Unlike other systems, which try to hide unevennesses in + the text\mdash{}usually unsuccessfully\mdash{}by interfering + with the letter-spacing, \LaTeX{} takes the view that the + author or editor should be able to contribute. While it is + certainly possible to set \LaTeX{}'s parameters so that + the spacing is sufficiently sloppy that you will almost + never get a warning about badly-fitting lines or pages, you + will almost certainly just be delaying matters until you + start to get complaints from your readers or + publishers. + +In \product{WinEdt} the log appears in + a separate window and you have to press the + \key{Enter} key to dismiss it after checking it. + In \product{Emacs}, the log appears in the + bottom half of the edit window and can be dismissed with the + \menuitem{Files}{One + Window} menu or by pressing + \key{Ctrl}--\key{X}~\thinspace{}\key{1}. + +If there were no errors, your + file is ready for displaying or printing. +\begin{sidebar}\label{filenames} +\subsection*{Picking suitable filenames} +Never, ever use directories (folders) or file names which + contain spaces. Although your operating system probably + supports them, some don't, and they will only cause grief + and tears with \TeX{}. + +Make filenames as short or as long as you wish, but + strictly avoid spaces. Stick to upper- and lower-case letters + without accents (A\ndash{}Z and a\ndash{}z), the digits + 0\ndash{}9, the hyphen (\verb+-+), and the full + point or period (\verb+.+), (similar to the + conventions for a Web URI\index{URI@URI}): it will let you refer to \TeX{} + files over the Web more easily and make your files more + portable. +\end{sidebar}\subsection{pdf\sfLaTeX{}} + +If you have configured your editor to generate PDF\index{PDF@PDF} files direct instead of DVI\index{DVI@DVI} files, by using the + \product{pdflatex} program instead of + standard \LaTeX{}, then you click the + \guiicon{pdf\LaTeX{}} icon in + \product{WinEdt} or type the + \verb+pdflatex+ command in a terminal (console) window + (exactly the same method as shown above for standard + \LaTeX{}). \product{Emacs} does not have a + default menu configured for + \product{pdflatex}. +\subsection{Running \sfLaTeX{} from a command window} +\label{cmdwin} + +This is worth practising even if you normally use a + graphical access system, so that you understand what it does. +\begin{exercise} +\label{terminal} +\addcontentsline{loe}{section}{\numberline{10}Running \sfLaTeX{} in a terminal or console window} +\subsubsection*{Running \sfLaTeX{} in a terminal or console window}\begin{itemize} +\item +If you are using a non-graphical system, then by + definition you are already using a command-line terminal + or console. + +\item +Under Linux or Unix (X Window systems such as KDE, + Gnome, OpenWindows, CDE, etc.) you open a command (shell) + window by clicking on the shell or screen icon in the + control panel at the bottom of your screen. + +\item +Under Microsoft Windows you open a command window + by clicking on the + \menuitem{Start}{Programs}[MS-DOS] + or + \menuitem{Start}{Command Prompt} + menu item. + +\end{itemize} + +When the command window appears, type +\begin{sourcecode}\begin{Verbatim}[fontsize=\small,commandchars=\\\{\}] +cd {\textit\uline{documents}} +latex {\textit\uline{mybook}}\end{Verbatim} +\end{sourcecode} + +Substitute the name of your document directory + (folder) for \url+documents+ in the + \verb+cd+ command, and your document filename + for \url+mybook+ in the + \verb+latex+ command. Remember to press the + \key{Enter} key at the end of each line. + +You can run \product{pdflatex} in the + same way by typing \verb+pdflatex+ instead of + \verb+latex+. +\end{exercise} +\begin{center} +\includegraphics[width=0.75\textwidth]{terminal} +\end{center} +\section{Error messages} +\label{errmsg} + +Most error messages are self-explanatory, but because some + errors can only be righted by humans who can read and + understand what it's supposed to mean, they don't + get spotted by \LaTeX{} until much later, leading to several + messages in a row. + +Only a few common error messages are given here: those + most likely to be encountered by beginners. If you find + another error message, and it's not clear what you should + do, ask for help. + +Fortunately it's usually easy to find \LaTeX{} errors, + as the layout of an error message is always the same. + Error messages begin with an exclamation mark at the start of + the line in the log, and give a description of the error, + followed by a line starting with the line number in your + document file where the error was spotted. + +Newcomers should remember to check the list of special + characters in (\S\thinspace\ref{specials}): a very large + number of errors when you are learning \LaTeX{} are due to + accidentally typing a special character when you didn't mean + to. This disappears after a few days as you get used to + them. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +! Too many }'s. +l.6 \date December 2004} + \end{Verbatim} +\end{sourcecode} + +In the example above, the reason \LaTeX{} thinks there + are too many + \verb+}+'s is that the opening curly brace + after \command{date} and before the word + \verb+December+ is missing, so the closing curly + brace is seen as one too many (which it is!).\footnote{In fact, there are other things which can follow the + \command{date} command apart from a date in curly + braces, so \LaTeX{} cannot possibly guess that you've + missed out the opening curly brace\mdash{}until it finds a + closing one!} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +! Undefined control sequence. +l.6 \dtae + {December 2004} + \end{Verbatim} +\end{sourcecode} + +In this second example, \LaTeX{} is complaining that it + has no such command (`control sequence') as + \verb+\dtae+ (it's been mistyped, but only a + human can detect that fact: all \LaTeX{} knows is that + it's undefined). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +Runaway argument? +{December 2004 \maketitle +! Paragraph ended before \date was complete. +<to be read again> + \par +l.8 + \end{Verbatim} +\end{sourcecode} + +In this final example of an error, the closing curly + brace has been omitted from the date, resulting in + \command{maketitle} trying to format the title page + while \LaTeX{} is still expecting more text for the date! As + \command{maketitle} creates new paragraphs on the + title page, this is detected and \LaTeX{} complains that the + previous paragraph has ended but \command{date} is + not yet finished. + +I'll repeat the advice from earlier: if you find an + error message you can't understand, ask for help. See + the section on online help (\S\thinspace\ref{help}) for details. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +Underfull \hbox (badness 1394) in paragraph at lines 28--30 +[][]\LY1/brm/b/n/10 Bull, RJ: \LY1/brm/m/n/10 Ac-count-ing in Busi- +[94] + \end{Verbatim} +\end{sourcecode} + +In this example of a warning, \LaTeX{} cannot stretch the + line wide enough without making the spacing bigger than its + currently permitted maximum. The badness (0\ndash{}10,000) + indicates how severe this is (here you can probably ignore it). + It says what lines of your file it was typesetting when it found + this, and the number in square brackets is the number of the + page onto which the offending line was printed. + +The codes separated by slashes are the typeface and font + style and size used in the line. Ignore them for the moment: + details are in step~\ref{fdfiles} in the procedure on p.\thinspace\pageref{fdfiles}. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +[101] +Overfull \hbox (9.11617pt too wide) in paragraph at lines 860--861 +[]\LY1/brm/m/n/10 Windows, \LY1/brm/m/it/10 see \LY1/brm/m/n/10 X Win- + \end{Verbatim} +\end{sourcecode} + +Last of all, the opposite warning: this line is too long + by a shade over 9pt. The chosen hyphenation point which + minimises the error is shown at the end of the line + (\emph{Win-}). Line numbers and page numbers are + given as before. In this case, 9pt is too much to ignore, and + a manual correction needs making, or the flexibility settings + need changing (outside the scope of this booklet). +\section{Screen preview} +\label{dvi} +\index{preview} +Once the file has been processed without errors (or even + if there are still errors, but you want to see what it's + doing with them), standard \LaTeX{} will have created a + DVI\index{DVI@DVI} file with the same name as your + document but the filetype + \verb+.dvi+. If you're using + \product{pdflatex}, a PDF\index{PDF@PDF} file will have been created, and you + can skip to + \S\thinspace\ref{pdfview}. +\subsection{Previewing DVI output} +\label{dviview} + +To see the typeset output, click on the + \menuitem{TeX}{TeX View} + menu item in \product{Emacs} or the + \guiicon{dvi} Preview toolbar icon in + \product{WinEdt}. A What You See Is What You Get (WYSIWYG)\index{WYSIWYG@WYSIWYG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!WYSIWYG@WYSIWYG|textbf} + preview window will appear with your typeset display. +\begin{center} +\includegraphics[width=0.75\textwidth]{xdvi} +\end{center} + +Most previewers have a wide range of scaling, zooming, + and measuring functions, but remember this is a + \emph{picture} of your output: you cannot edit + the image. To change it, you always edit your source text and + reprocess. + +With \product{xdvi} and its derivatives + like \product{dviview}, you can leave the + display window open, and after you've reprocessed your + document through \LaTeX{}, moving your mouse back into the + window will make the display update automatically (click + your mouse if you have your windowing system set to need a + click to focus). +\begin{sidebar} +The very first time you display your DVI\index{DVI@DVI} output with a new installation of + \TeX{}, there may be a short pause if the previewer needs + to create the special bitmaps used for screen previews of + some fonts. These give greater accuracy on low-resolution + devices like screens. As you continue to work with \LaTeX{} + and your system accumulates these font files, the pause + for generating them will disappear. +\end{sidebar}\subsection{Previewing with PDF} +\label{pdfview} + +If you have configured your system to generate PDF\index{PDF@PDF} files direct instead of + DVI\index{DVI@DVI} + files, just open the \url+.pdf+ file using + any PDF\index{PDF@PDF} viewer or + browser. + +It is possible to configure + \product{WinEdt} to display a toolbar icon + which will pop up \product{Acrobat Reader} + or some other browser with the current PDF\index{PDF@PDF} output file. + +Adobe's \product{Acrobat Reader} + cannot automatically update the view if you reprocess your + document through \product{pdflatex}. You + have to close the display with \key{Ctrl}--\key{W}~ and reload the file with \key{Alt}--\key{1}~. +\begin{warning} +\subsubsection*{Bitmap fonts} +Acrobat Reader is extremely poor at rendering Type3 + bitmap fonts. If you are using these (mostly old \LaTeX{} + installations who have not upgraded to Type1), you will + see very fuzzy display at low magnifications. It will + print perfectly, but Acrobat Reader's display is + disappointing. The solution is to use a better viewer or + to install and upgrade to the Type1 versions of the CM + fonts (see \S\thinspace\ref{type1cm}), or both, but there + remain a few useful fonts which are still only available + in Type3 format. If you need to use them, you probably + need to warn your readers to expect a fuzzy display from + Acrobat Reader (but good printout), and to change to a + better reader if they can. +\end{warning} +\subsection{Previewing with PostScript} +\label{makeps} + +PostScript\index{PostScript} is a page description + language invented by Adobe and used in laser printers and + high-end typesetters. It's been the universal standard + for electronically-formatted print files for over a decade, + and all printers and publishers are accustomed to using + them. PDF\index{PDF@PDF}, a descendant of + PostScript, is rapidly taking over, but + PostScript\index{PostScript} itself is still extremely + common, largely because it is very robust, and is usually an + ASCII\index{ASCII@ASCII} file, which makes it very + portable and easy to generate. The drawback is the large + size of PostScript\index{PostScript} files, especially + if they contain bitmapped graphics. + +The \product{dvips} program which comes + with all \TeX{} systems is used to generate + PostScript\index{PostScript} files directly from your + DVI\index{DVI@DVI} output. These + \url+.ps+ files can be viewed, printed, or + sent to a platemaker or filmsetter. + +An alternative to viewing the DVI file direct is + therefore to generate a PostScript\index{PostScript} file, especially if + you're going to have to do this for your publisher + anyway, and many editors can be configured to do this by + default. Look for a \guiicon{dvips} toolbar icon or + menu entry and click on it. + +It's very simple to do manually anyway: let's + assume your \LaTeX{} file was called + \url+mydoc.tex+, so processing it has created + \url+mydoc.dvi+. Just type: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +dvips -o mydoc.ps mydoc + \end{Verbatim} +\end{sourcecode} + +\noindent in a command window (see Exercise~\ref{terminal} on + p.\thinspace\pageref{terminal} for how to get one) + and \product{dvips} will create + \url+mydoc.ps+ which can be used both for + previewing and printing. + +To view a PostScript\index{PostScript} file, you + need a PostScript\index{PostScript} previewer like + \product{GSview}, which works with the + PostScript\index{PostScript} interpreter + \product{Ghostscript}, which should have + been installed along with your whole \TeX{} system (if not, + install both now: \product{GSview} is + separately licensed and cannot be included in the \TeX{} Live + distribution, so you have to download it yourself). + +\product{GSview} can be set to watch + the PostScript\index{PostScript} file and automatically + update the display any time the file is changed, without you + even having to click on the window. +\section{Printer output} +\label{print} +\index{printing} +\TeX{} systems print on almost anything from the simplest + dot-matrix printers to the biggest phototypesetters, including + all the laser printers and a host of other devices in between. + \emph{How} you do it varies slightly according + to how you do your typesetting and previewing: +\begin{description} +\item[\sffamily If you are using PDF] +you can print directly from your PDF\index{PDF@PDF} viewer + (e.g. \product{PDFview}, + \product{Acrobat Reader}, etc.). Be + careful never to click on the `Fit to page' + option in your viewer, as it will change the size of + your document so all your measurements become + wrong. +\item[\sffamily If you are using DVI] +and you have a previewer which has a + \textbf{print} function configured for your + printer, you can use that. If not, create a PostScript\index{PostScript} + file and use that (see below). +\item[\sffamily If you are using PostScript\index{PostScript}] +use the \textbf{print} function in + \product{GSview}. +\item[\sffamily If you have a real PostScript\index{PostScript} + printer] +or you are using a system with built-in + PostScript\index{PostScript} printing support (such + as Linux), you can create and send + PostScript\index{PostScript} output directly from + \product{dvips} to the printer without + the need to open it in a previewer first. In + \product{Emacs}, for example, this is + what happens when you use the + \menuitem{\TeX{}}{\TeX{} + Print} menu item. +\item[\sffamily Non-PostScript\index{PostScript} printers] +You can create a PostScript\index{PostScript} + file with \product{dvips} (see \S\thinspace\ref{makeps}) and use + \product{GSview} to print it + (\product{GSview} can print + PostScript\index{PostScript} files to almost any + make or model of non-PostScript\index{PostScript} + printer); + + +\item[\sffamily Or, if you want a + non-PostScript\index{PostScript}/Ghostscript + solution] +install or configure a \TeX{} print driver for your + printer (as supplied with your \TeX{} installation, and + there are dozens on CTAN\index{CTAN@CTAN}: their names all start + with \url+dvi+ and are followed by an + abbreviation for the printer make or model like + \product{dvieps} for Epson, + \product{dvihp} for Hewlett-Packard, + \product{dvialw} for Apple + LaserWriters, etc.). Configure the + driver to print directly to the print queue, or pipe it + to the print queue manually. On Linux with an HP printer, + for example, this would be +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +dvihp mydoc | lpr + \end{Verbatim} +\end{sourcecode} + +Microsoft Windows has no easy way to bypass the + print spool, but you can do it from an MS-DOS command window + with +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +dvihp mydoc -o mydoc.hp +print /b mydoc.hp + \end{Verbatim} +\end{sourcecode} + +Read the documentation for the driver, as the + options and defaults vary. +\end{description} + +Both the \product{dvips} program and all + the previewers that print tend to have facilities for printing + selected pages, printing in reverse, scaling the page size, + \index{page size!scaling}\index{printing!reverse order}\index{printing!selected pages} and printing only odd or even pages for two-sided + work. If you are using PostScript\index{PostScript} there + are programs for manipulating the output, for example to + perform page imposition to get 4, 8, or 16 pages to a sheet + for making booklets. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{11}Print it!} +\subsubsection*{Print it!} +Show that you have understood the process of + typesetting, previewing, and printing, by displaying your + document and printing it. +\end{exercise} +\chapter[CTAN, packages, and online help]{CTAN, packages, and \\online help} +\label{ctan} + +The Comprehensive \TeX{} Archive + Network (CTAN)\index{CTAN@CTAN|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CTAN@CTAN|textbf} is a repository or collection of Web and + FTP\index{FTP@FTP} + servers worldwide which contain copies of almost every free + piece of software related to \TeX{} and \LaTeX{}. CTAN\index{CTAN@CTAN} is rooted at \url+http://www.ctan.org/+ and there are several + online indexes. There are complete \TeX{} and \LaTeX{} systems for + all platforms, utilities for text and graphics processing, + conversion programs into and out of \LaTeX{}, extra typefaces, + and (possibly the most important) the \LaTeX{} + \textbf{\textit{packages}}\index{packages@\textbf{\textit{packages}}}. +\begin{sidebar} +CTAN\index{CTAN@CTAN} should + \emph{always} be your first port of call when + looking for a software update or a feature you want to use. + Please don't ask the network help + resources (\S\thinspace\ref{help}) until you have checked CTAN\index{CTAN@CTAN} and FAQ\index{FAQ@FAQ} first. +\end{sidebar}\section{Packages} +\label{packages} +\index{packages!using} +Add-on features for \LaTeX{} are known as + `packages'. Dozens of these are + pre-installed with \LaTeX{} and can be used in your documents + immediately. To find out what packages are available, you + should use the CTAN\index{CTAN@CTAN} search page\footnote{\url+http://www.ctan.org/search+} which includes a + link to Graham Williams' comprehensive package + catalogue. + +When you try to typeset a document which requires a + package which is not installed on your system, \LaTeX{} will + warn you with an error message and you can then download the + package and install it using the instructions in \S\thinspace\ref{pkginst}. You can also download updates to + packages you already have (ones that were installed along with + your version of \LaTeX{} as well as ones you added). + +There is no theoretical limit to the number of packages + you can have installed (apart from the size of your disk), but + there is probably a physical limit to the number that can be + used inside any one \LaTeX{} document at the same time, + although it depends on how big each package is. In practice + there is no problem in having even a couple of dozen packages + active. +\subsection{Using an existing package} +\label{colorpkg} + +To use a package already installed on your system, + insert a \command{usepackage} command in your + document preamble with the package name in curly braces. + For example, to use the \package{color} + package, which lets you typeset in colours (I warned you + this was coming!): +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} +\usepackage{color} +\begin{document} + +\title{Practical Typesetting} +\author{Peter Flynn\\Silmaril Consultants} +\date{December 2004} +\maketitle + +\end{document} + \end{Verbatim} +\end{sourcecode} + +You can include several package names in one + \command{usepackage} command by separating the + names with commas, and you can have more than one + \command{usepackage} command. However, if a + package needs optional settings in square brackets, you + \emph{have} to give it its own + \command{usepackage} command, like + \package{geometry} shown here. +\begin{sourcecode}\label{oldtitle}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} +\usepackage{pslatex,palatino,avant,graphicx,color} +\usepackage[margin=2cm]{geometry} +\begin{document} + +\title{\color{red}Practical Typesetting} +\author{\color{blue}Peter Flynn\\Silmaril Consultants} +\date{\color{green}December 2004} +\maketitle + +\end{document} + \end{Verbatim} +\end{sourcecode} + +This is a simple way to do colours in titling on a + once-off basis: if it's for a repeatable style + we'll see in \chaptername~\ref{macros} how it can be + automated and kept out of the author's way. + +Many packages can have additional formatting + specifications in optional arguments in square brackets, in + the same way as the \command{documentclass} command + does. Read the documentation for the package concerned to + find out what can be done. +\begin{exercise} +\label{geoex} +\addcontentsline{loe}{section}{\numberline{12}Add colour} +\subsubsection*{Add colour} +Use the \package{color} package to add + some colour to your document. Use the + \package{geometry} package to change the + margins. + +Print your document if you have a colour printer + (monochrome printers should print it in shades of + grey). +\end{exercise} +\subsection{Package documentation} +\label{packagedoc} +\index{packages!documentation} +To find out what commands a package provides (and thus + how to use it), you need to read the documentation. In the + \url+texmf/doc+ subdirectory of your + installation there should be directories full of + \url+.dvi+ files, one for every package + installed. These can be previewed or printed like any other + DVI\index{DVI@DVI} file (see + \S\thinspace\ref{dviview}). If your installation procedure + has not installed the documentation, it can all be + downloaded from CTAN\index{CTAN@CTAN} + anyway. + +Before using a package, you should read the + documentation carefully, especially the subsection usually + called `User Interface', which + describes the commands the package makes available. You + cannot just guess and hope it will work: you have to read it + and find out. + +See the next section for details of how to create the + documentation \url+.dvi+ file for additional + packages you install yourself. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{13}Read all about it} +\subsubsection*{Read all about it} +Find and view (or print) the documentation on the + \package{geometry} package you used in + Exercise~\ref{geoex}. + +Investigate one of the other package documentation + files in the directory. +\end{exercise} +\section{Downloading and installing packages} +\label{pkginst} +\index{packages!downloading}\index{packages!installing} +Once you have identified a package you need and + haven't already got (or you have got it and need to + update it), use the indexes on any CTAN\index{CTAN@CTAN} server to find the directory + where the package lives. + +What you need to look for is always \emph{two + files}, one ending in \url+.dtx+ + and the other in \url+.ins+. The first is a + DOC\TeX{} file, which combines the package code and its + documentation in a single file. The second is the installation + routine (much smaller). You \emph{must always} + download \emph{both} files. + +If the two files are not there, it means the package is + part of a much larger bundle which you don't normally + update unless you change version of \LaTeX{}. For example, + there is no \url+color.dtx+ and + \url+color.ins+ for the + \package{color} package because it forms part + of the \package{graphics} bundle. Such packages + change very rarely, as they form part of the core of \LaTeX{} + and are very stable. In general you should not try to update + these packages in isolation. + +Some rare or unusual packages are still supplied as a + single \url+.sty+ file intended for the now + obsolete \LaTeX{}\thinspace{}2.09. You can try to use these if you + wish but they are not guaranteed to work, and have now almost + all been replaced by \LaTeXe{} versions. Always look for the + \url+.dtx+ and \url+.ins+ pair + of files first. + +\label{packinst}% +Download both files to a + \textbf{\textit{temporary directory}}\index{temporary directory@\textbf{\textit{temporary directory}}}. Keep + something like \url+C:\tmp+ for this in + Windows; Linux systems already have a + \url+/tmp+ directory. There are four steps to + installing a \LaTeX{} package: +\index{packages!installing}\begin{enumerate} +\item \textbf{Extract the files}\\\label{extract}% +Run \LaTeX{} on the \url+.ins+ file. + That is, open the file in your editor and process it as if + it were a \LaTeX{} document, or if you prefer, type + \verb+latex+ followed by the + \url+.ins+ filename in a command window in + the temporary directory. + +This will extract all the files needed from the + \url+.dtx+ file (which is why you must have + both of them present in the temporary directory). Note + down or print the names of the files created if there are + a lot of them (read the log file if you want to see their + names again). +\item \textbf{Create the documentation}\\\label{dtxdoc}% +Run \LaTeX{} on the \url+.dtx+ file + twice. This will create a \url+.dvi+ file + of documentation explaining what the package is for and + how to use it. Two passes through \LaTeX{} are needed in + order to resolve any internal crossreferences in the text + (a feature we'll come onto later). If you prefer to + create PDF\index{PDF@PDF} then run + \product{pdflatex} instead. View or print + this file in the usual manner (see \S\thinspace\ref{dvi} \emph{et + seq}.). +\item \textbf{Install the files}\\ +While the documentation is printing, move or copy the + files created in step~\ref{extract} + from your temporary directory to the correct place[s] in + your \TeX{} installation directory tree. In an installation + that conforms to the \TeX{} Directory + Structure (TDS)\index{TDS@TDS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TDS@TDS|textbf}, this would be suitably-named + subdirectories of + \url+texmf-local/tex/latex/+. See the panel `Replicating the TDS' on p.\pageref{rightplace} for how to create a parallel + structure in your local directory, and the table on p.\thinspace\pageref{where} for where `the right place' + is. + +Often there is just a \url+.sty+ + file to move but in the case of complex packages there may + be more, and they may belong in different locations. For + example, new BIB\TeX{} packages or font packages will + typically have several files to install. +\begin{center} +\label{where} +\begin{tabular}{l>{\ttfamily}l>{\pbs{\raggedright}\footnotesize}p{1.5in}}\textbf{\normalfont\bfseries\upshape Type}&\textbf{\normalfont\bfseries\upshape Directory (under + \url+texmf-local/+)}&\textbf{\normalfont\bfseries\upshape Comments}\\[2pt]\hline\\[-.95\baselineskip] +\url+.cls+&tex/latex/base&Document class file\\ +\url+.sty+&tex/latex/{\textit\uline{packagename}}&Style file: the normal package + content\\ +\url+.bst+&bibtex/bst&BIB\TeX{} style\\ +\url+.mf+&fonts/source/public/{\textit\uline{fontname}}&\mf{} font outline\\ +\url+.fd+&tex/latex/mfnfss&Font Definition files for \mf{} fonts + only\\ +\url+.fd+&tex/latex/psnfss&Font Definition files for PostScript + Type 1 fonts only\\ +\url+.pfb+&/fonts/type1/{\textit\uline{foundry}}/{\textit\uline{fontname}}&PostScript Type 1 font outline\\ +\url+.afm+&/fonts/afm/{\textit\uline{foundry}}/{\textit\uline{fontname}}&Adobe font metrics for PostScript Type 1 + fonts\\ +\url+.tfm+&/fonts/tfm/{\textit\uline{foundry}}/{\textit\uline{fontname}}&\TeX{} font metrics for \mf{} and + PostScript Type 1 fonts\\ +\url+.vf+&/fonts/vf/{\textit\uline{foundry}}/{\textit\uline{fontname}}&\TeX{} virtual fonts\\ +\url+.pdf+, + \url+.dvi+&/doc&package documentation\\ +others&tex/latex/{\textit\uline{packagename}}&other types of file unless instructed + otherwise\\ +\end{tabular} +\end{center} + +For BIB\TeX{} styles, the \LaTeX{} + \url+.sty+ files belong in + \url+texmf-local/tex/latex/...+ (called + after the package) but the \url+.bst+ file + belongs in + \url+texmf-local/bibtex/bst+. + +Don't forget to move the \url+.dvi+ + or \url+.pdf+ file of documentation into + \url+texmf-local/doc+. + +If there are configuration or other files, read the + documentation to find out if there is a special or + preferred location to move them to. +\item \textbf{Update your index}\\\label{texindex}%\index{packages!indexing} +Finally, run your \TeX{} indexer program to update the + package database. This program comes with every modern + version of \TeX{} and is variously called + \product{texhash}, + \product{mktexlsr}, or even + \product{configure}, or it might just be a + mouse click on a button or menu in your editor. Read the + documentation that came with your installation to find out + which it is. +\end{enumerate} +\begin{warning} + +This last step is \emph{utterly essential}, + otherwise nothing will work. +\end{warning} + +The reason this process has not been automated widely is + that there are still thousands of installations which do not + conform to the TDS\index{TDS@TDS}, such as old + shared Unix systems or very old, small-scale PC systems, so there + is no way for an installation program to guess where to put + the files: \emph{you} have to know this. There + are many more systems where the owner, user, or installer has + chosen \emph{not} to follow the recommended + TDS\index{TDS@TDS} directory structure, or is + unable to do so for security reasons (such as a shared system + where she cannot write to a protected directory). + +The reason for having the \url+texmf-local+ + directory (called \url+texmf.local+ on some + systems) is to provide a place for local modifications or + personal updates if you are a user on a shared system (Unix, + Linux, VMS, Windows NT/2000/XP, etc.) where you do not have + write-access to the main \TeX{} installation directory tree. + You can also have a personal \url+texmf+ + subdirectory in your own login directory. Your installation + must be configured to look in these directories first, + however, so that any updates to standard packages will be + found there \emph{before} the superseded copies + in the main \url+texmf+ tree. All modern \TeX{} + installations should do this anyway, but if not, you can edit + \url+texmf/web2c/texmf.cnf+ yourself. There is + an example in Appendix~\ref{cnf}. +\begin{exercise} +\label{insttest} +\addcontentsline{loe}{section}{\numberline{14}Install a package} +\subsubsection*{Install a package} +Download and install the + \package{paralist} package (which implements + inline lists). +\end{exercise} +\begin{sidebar}\label{rightplace} +\subsection*{Replicating the TDS} +I find it useful to make the directory structure of + \url+texmf-local+ the same as that of + \url+texmf+. Examine the subdirectories of + \url+texmf/tex/latex/+ for examples. For + updates of packages which came with your \LaTeX{} + distribution (as distinct from new ones you are adding + yourself), you can then use the same subdirectory name and + position in \url+texmf-local/...+ as the + original used in \url+texmf/...+. + +If you want to create the entire subdirectory structure + ready for use, you can do it under Unix with the following + command: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +cd /usr/TeX/texmf; find . -type d -exec mkdir -p \ +/usr/TeX/texmf-local/{} \; + \end{Verbatim} +\end{sourcecode} + +If you are using Microsoft Windows, you can download + \product{Cygwin}, which provides + you with the standard Unix tools in a shell window. The + above command should also work on a Mac running OS\thinspace{}X. In all + cases, if your installation directory is not + \url+/usr/TeX+, you need to substitute the + actual paths to your \url+texmf+ and + \url+texmf-local+ directories. +\end{sidebar}\section{Online help} +\label{help} +\index{help} +The indexes and documentation files on CTAN\index{CTAN@CTAN} are the primary online resource + for self-help and you should read these carefully before + asking questions. You should most especially read the + Frequently-Asked + Questions (FAQ)\index{FAQ@FAQ|textbf}\index{Acronyms@\textbf{Acronyms}, defined!FAQ@FAQ|textbf} document so that you avoid wasting online time + asking about things for which there is already an + easily-accessible answer. The FAQ\index{FAQ@FAQ} is at \url+http://www.tex.ac.uk/faq/+\thinspace{}. + +The Usenet newsgroup \url+comp.text.tex+ is the principal forum for questions + and answers about \LaTeX{}. Feel free to ask questions, but + please do not ask FAQ\index{FAQ@FAQ}s: read the + documentation instead. People who answer the questions do so + voluntarily, unpaid, and in their own time, so don't treat + this as a commercial support service. To access Usenet news, + type the following URI\index{URI@URI} into your browser's + `Location' or + `Address' window: + \verb+news:comp.text.tex+ (if your browser + doesn't support Usenet news properly, change it for one that + does, like \product{Mozilla}\footnote{\url+http://www.mozilla.org/+}). + +Another support resource is the mailing list \url+texhax@tug.org+. Again, feel free to ask + questions, but again, try to answer the question yourself + first (and say what you've tried in your message). + +The \TeX{} Users Group, as well as most local user groups, + maintains a web site (\url+http://tug.org+) + with lots of information about various aspects of the \TeX{} + system. See Appendix~\ref{tugform} + for information on joining TUG. + +If you need commercial levels of support, such as + 24-hour phone contact, or macro-writing services, you + can buy one of the several excellent commercial versions of + \TeX{}, or contact a consultancy which deals with \TeX{} + (details on the TUG Web site). + +Remember: check the FAQ\index{FAQ@FAQ} first! +\chapter{Other document structures} +\label{otherdoc} + +It is actually quite possible to write whole documents using + nothing but section headings and paragraphs. As mentioned in + \S\thinspace\ref{sections}, novels, for + example, usually consist just of chapters divided into + paragraphs. More commonly, however, you need other features as + well, especially if the document is technical in nature or + complex in structure. + +It's worth pointing out that + `technical' doesn't necessarily mean + `computer technical' or + `engineering technical': it just means it + contains a lot of $\tau\eta\chi\nu\epsilon$~(\emph{tekne}), the + specialist material or artistry of its field. A literary + analysis such as \titlecite{macnamara} (on the + marginal notes in the manuscripts of \authorof{bovary}'s \titlecite{bovary} manuscripts) is every bit as + technical in the literary or linguistic field as the maintenance + manual for an Airbus 300D is in the aircraft engineering + field. + +This chapter covers the most common features needed in + writing structured documents: lists, tables, figures (including + images), sidebars like boxes and panels, and verbatim text + (computer program listings). In \chaptername~\ref{texttools} we + will cover footnotes, cross-references, citations, and other + textual tools. +\section{A brief note on structure} +\label{briefstruct} + +It's very easy to sit down at a keyboard with a + traditional wordprocessor and just start typing. If it's + a very short document, or something transient or relatively + unimportant, then you just want to type it in and make it look + `right' by highlighting with the mouse + and clicking on font styles and sizes. + +In doing so, you may achieve the effect you wanted, but + your actions have left no trace behind of + \emph{why} you made these changes. As I said, + this is unimportant for trivial or short-term documents, but + if you write longer or more complex documents, or if you often + write documents to a regular pattern, then making them + consistent by manual methods becomes a nightmare. + \LaTeX{}'s facilities for automation are based on you + providing this `why' information. + +If you can tick any of the features below about your + documents, then you have already started thinking about + structure. +\begin{itemize} +\renewcommand{\labelitemi}{\raisebox{-.25ex}{\Square}} +\item +The document naturally divides into sections (parts, + chapters, etc.). + +\item +The document is long. + +\item +There is lots of repetitive formatting in the + document. + +\item +The document is complex (intellectually or + visually). + +\item +There are lots of figures or tables (or examples, + exercises, panels, sidebars, etc.). + +\item +Accuracy is important in formatting the + document. + +\item +A master copy is needed for future reference or reprinting. + +\item +This is a formal or official document needing special + care and attention. + +\item +It's \emph{my} thesis, book, + leaflet, pamphlet, paper, article, + etc. \emph{That}'s why I care. + +\item +The document (or part of it) may need ongoing or + occasional re-editing and republishing. + +\end{itemize} + +If you've got that far, you're over + half-way done. Using a structural editor\mdash{}even a simple + outliner\mdash{}can make a huge difference to the quality of your + thinking because you are consciously organising your thoughts + before setting them down. And it can make just as big a + difference to your formatting as well: more consistent, better + presented, easier for the reader to navigate through, and more + likely to be read and understood\mdash{}which is presumably why + you are writing the document in the first place. +\section{Lists} +\label{lists} +\index{lists} +Lists are useful tools for arranging thoughts in a + digestible format, usually a small piece of information at a + time. There are four basic types of list: +\begin{center} +\begin{tabular}{>{\pbs{\raggedright}}p{0.4\columnwidth}>{\pbs{\raggedright}}p{0.4\columnwidth}}\begin{description}\item[\sffamily Random or arbitrary lists](sometimes called + `itemized' or + `bulleted' lists) where the + order of items is irrelevant or unimportant. The + items are often prefixed with a bullet or other + symbol for clarity or decoration, but are + sometimes simply left blank, looking like + miniature paragraphs (when they are known as + `simple' or + `trivial' lists).\end{description}&\begin{description}\item[\sffamily Enumerated or sequential lists]where the order of items is critical, such as + sequences of instructions or rankings of + importance. The enumeration can be numeric (Arabic + or Roman), or lettered (uppercase or lowercase), + and can even be programmed to be + hierarchical (1.a.viii, 2.3.6, etc.).\end{description}\\ +\begin{description}\item[\sffamily Descriptive or labelled lists](sometimes called + `discussion' lists), which + are composed of subheadings or topic labels + (usually unnumbered but typographically distinct), + each followed by one or more indented paragraphs + of discussion or explanation.\end{description}&\begin{description}\item[\sffamily Inline lists]which are sequential in nature, just like + enumerated lists, but are + \begin{inparaenum}[\itshape a\upshape)] \item formatted \emph{within} + their paragraph; and \item usually labelled with letters,\end{inparaenum} like this example. The items are + often Boolean, with the final item prefixed by + `and' or + `or'.\end{description}\\ +\end{tabular} +\end{center} + +There are actually two other types, segmented lists and + reference lists, but these are much rarer. +\index{environment} +The structure of lists in \LaTeX{} is identical for each + type, but with a different environment name. Lists are another + example of this \LaTeX{} technique + (environments), + where a pair of matched commands surrounds some text which + needs special treatment. + +Within a list environment, list items are always + identified by the command \command{item} (followed by + an item label in [square brackets] in the case of labelled + lists). You don't type the bullet or the number or the + formatting, it's all automated. +\subsection{Itemized lists} +\index{lists!itemized}\index{lists!bulleted} +To create an itemized list, use the the + \env{itemize} environment: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{itemize} + +\item Itemized lists usually have a bullet; + +\item Long items use `hanging indentation', whereby the +text is wrapped with a margin which brings it clear of +the bullet used in the first line of each item; + +\item The bullet can be changed for any other symbol, for +example from the \textsf{bbding} or \textsf{pifont} package. + +\end{itemize} + \end{Verbatim} +\end{sourcecode} +\begin{itemize} +\label{labelitem} +\renewcommand{\labelitemi}{\raisebox{-.25ex}{\raisebox{-.25ex}{\PencilRight}}} +\item +Itemized lists usually have a bullet; + +\item +Long items use `hanging + indentation', whereby the text is + wrapped with a margin which brings it clear of the + bullet used in the first line of each item; + +\item +The bullet can be changed for any other symbol, + for example from the \package{bbding} + or \package{pifont} package. + +\end{itemize} +\end{example} + +See \S\thinspace\ref{bullets} for details of how to + change the settings for list item bullets. +\subsection{Enumerated lists} +\index{lists!numbered}\index{lists!enumerated} +To create an enumerated list, use the + \env{enumerate} environment: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{enumerate} + +\item Enumerated lists use numbering on each item; + +\item Long items use `hanging indentation' just the same +as for itemized lists; + +\item The numbering system can be changed for any level. + +\end{enumerate} + \end{Verbatim} +\end{sourcecode} +\begin{enumerate}\item +Enumerated lists use numbering on each + item; + +\item +Long items use `hanging + indentation', just the same as for + itemized lists; + +\item +The numbering system can be changed for any + level. + +\end{enumerate} +\end{example} + +See \S\thinspace\ref{numberschemes} for details of how + to change the numbering schemes for each level. +\subsection{Description lists} +\label{desc} +\index{lists!description}\index{lists!discussion} +To create a description list, use the + \env{description} environment: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{description} + +\item[Identification:] description lists require a topic +for each item given in square brackets; + +\item[Hanging indentation:] Long items use this in the +same way as all other lists; + +\item[Reformatting:] Long topics can be reprogrammed to +fold onto multiple lines. + +\end{description} + \end{Verbatim} +\end{sourcecode} +\begin{description} +\item[\sffamily Identification:] +description lists require a topic for each item + given in square brackets; +\item[\sffamily Hanging indentation:] +Long items use this in the same way as all + other lists; +\item[\sffamily Reformatting:] +Long topics can be reprogrammed to fold onto + multiple lines. +\end{description} +\end{example} +\subsection{Inline lists} +\label{inlinelists} +\index{lists!inline} +Inline lists are a special case as they require the use + of the \package{paralist} package and the + \env{inparaenum} environment (with an + optional formatting specification in square + brackets): +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage{paralist} +... +\textbf{\itshape Inline lists}, which are sequential in +nature, just like enumerated lists, but are +\begin{inparaenum}[{\itshape a})] +\item formatted within their paragraph +\item usually labelled with letters\end{inparaenum}, +like this example. The items are often Boolean, with +the final item prefixed by `and' or `or'. + \end{Verbatim} +\end{sourcecode}\leavevmode\enspace +\begin{quote}\noindent +\textbf{\textit{Inline lists}}\index{Inline lists@\textbf{\textit{Inline lists}}}, + which are sequential in nature, just like enumerated + lists, but are \begin{inparaenum}[\itshape a\upshape)] \item formatted within their paragraph; and \item usually labelled with letters\end{inparaenum}, like this example. The items are often + Boolean, with the final item prefixed by + `and' or + `or'.\end{quote}\end{example} + +See \chaptername~\ref{typo} for details of font-changing commands. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{15}List practice} +\subsubsection*{List practice} +Add some lists to your document. Pick any two of the + ones described here to practise with. + +If you successfully installed + \package{paralist} in Exercise~\ref{insttest} then you can use inline lists as + described in \S\thinspace\ref{inlinelists}. +\end{exercise} +\subsection{Reference lists and segmented lists} + +Reference lists are visually indistinguishable from + numbered or lettered lists, but the numbering or lettering + does \emph{not} imply a sequence. The numbers + or letters are just used as labels so that the items can be + referred to from elsewhere in the text (as in `see + item 501(c)3'). In this sense they are really a + kind of sub-sectional division, and \LaTeX{}'s + \command{paragraph} or + \command{subparagraph} commands (with appropriate + renumbering) would probably be a far better solution than + using a list. Label them and refer to them with + \command{label} and \command{ref} as for + any other cross-reference (see \S\thinspace\ref{xrefs}). + +Segmented lists are a highly specialised structure and + outside the scope of this document. For details of their + usage, see the the chapter `Segmentation and + Alignment' in \titlecite{teiguide}. +\subsection{Lists within lists} +\label{numberschemes} + +You can start a new list environment within the item of + an existing list, so you can embed one list inside another + up to four deep. The lists can be of any type, so you can + have a description list containing an item in which there is + a numbered sub-list, within which there is an item + containing a bulleted sub-sub-list. + +Multiple embedded lists automatically change the bullet + or numbering scheme so that the levels don't get + confused, and the spacing between levels is adjusted to + become fractionally tighter for more deeply nested levels: +\begin{enumerate}\item +by default an outer enumerated list is numbered in + Arabic numerals; +\begin{enumerate}\item +an embedded enumerated list is lettered in + lowercase; +\begin{enumerate}\item +a third level is numbered in lowercase Roman + numerals; +\begin{enumerate}\item +the fourth level uses uppercase + alphabetic letters. + +\end{enumerate} + +\end{enumerate} + +\end{enumerate} + +\end{enumerate} + +But these are only defaults and can easily be changed by + redefining the relevant set of values. You could also add a + fifth and further levels, although I suspect that would mean + your document structure needed some careful analysis, as + lists embedded five deep will probably confuse your + readers. + +The values for lists come in pairs:\footnote{In fact, any time you define a counter in \LaTeX{}, + you automatically get a command to reproduce its value. + So if you defined a new counter + \counter{example} to use in a teaching book, by + saying \url+\newcounter{example}+, that + automatically makes available the command + \url+\theexample+ for use when you want to + display the current value of + \counter{example}.} for each level there is a counter to count the + items and a command to produce the label: +\begin{center} +\begin{tabular}{rcll}\textbf{\normalfont\bfseries\upshape Level}&\textbf{\normalfont\bfseries\upshape Default}&\textbf{\normalfont\bfseries\upshape Counter}&\textbf{\normalfont\bfseries\upshape Label command}\\[2pt]\hline\\[-.95\baselineskip] +1&digit.&\counter{enumi}&\command{theenumi}\\ +2&(letter)&\counter{enumii}&\command{theenumii}\\ +3&roman.&\counter{enumiii}&\command{theenumiii}\\ +4&LETTER.&\counter{enumiv}&\command{theenumiv}\\ +\end{tabular} +\end{center} + +Note that each counter and command ends with the Roman + numeral value of its level (this is to overcome the rule + that \LaTeX{} commands can only be made of letters). To + change the format of a numbered list item counter, just renew + the meaning of its label: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand{\theenumi}{\alph{enumi}} +\renewcommand{\theenumii}{\roman{enumii}} +\renewcommand{\theenumiii}{\arabic{enumiii}} + \end{Verbatim} +\end{sourcecode} + +\noindent \label{thecounter}% +This would make the + outermost list use uppercase letters, the second level use + lowercase roman, and the third level use ordinary Arabic + numerals. The fourth level would remain unaffected. +\begin{warning} +\subsubsection*{Lists: a caution to the unwary} +Treat lists with care: people sometimes use tables for + labelled information which is really a list and would be + better handled as such. They often do this because their + wordprocessor has no way to do what they want (usually to + place the item label level with the description or + explanation) \emph{except} by using a table, + hence they are misled into believing that their text is + really a table when it's actually not. +\end{warning} +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{16}Nesting} +\subsubsection*{Nesting} +Extend your use of lists by nesting one type inside a + different one. +\end{exercise} +\section{Tables} +\label{tables} +\index{tables} +Tabular typesetting is the most complex and time-consuming + of all textual features to get right. This holds true whether + you are typing in plain-text form, using a wordprocessor, using + \LaTeX{}, using HTML or XML, using a DTP system, or some other + text-handling package. Fortunately, \LaTeX{} provides a table + model with a mixture of defaults and configurability to let it + produce very high quality tables with a minimum of + effort. +\begin{warning} +\subsubsection*{Terminology} +\LaTeX{}, in common with standard typesetters' practice, + uses the word `Table' to mean a + formal textual feature, numbered and with a caption, + referred to from the text (as in `See + Table 5'). Sometimes you can get + `informal' tables, which simply occur + between two paragraphs, without caption or number. + +The arrangement of information in rows and columns + \emph{within} either of these structures is + called a `tabulation' or + `tabular matter'. + +It is important to keep this distinction firmly in mind + for this section. +\end{warning} +\subsection{Floats} +\label{floats} +\index{floats} +Tables and Figures are what printers refer to as + `floats'. This means they are not + part of the normal stream of text, but separate entities, + positioned in a part of the page to themselves (top, middle, + bottom, left, right, or wherever the designer specifies). + They always have a caption describing them and they are + always numbered so they can be referred to from elsewhere in + the text. + +\LaTeX{} automatically floats Tables and Figures, + depending on how much space is left on the page at the point + that they are processed. If there is not enough room on the + current page, the float is moved to the top of the next + page. This can be changed by moving the Table or Figure + definition to an earlier or later point in the text, or by + adjusting some of the parameters which control automatic + floating. + +Authors sometimes have too many floats occurring too + soon after one another, without any thought for how they are + supposed to fit on the page and still leave room for text. + In this case, \LaTeX{} stacks them all up and prints them + together if possible, or leaves them to the end of the + chapter in protest. The skill is to space them out within + your text so that they intrude neither on the thread of your + argument or discussion, nor on the visual balance of the + typeset pages. But this is a skill few authors have, and + it's one point at which professional typographic advice + may be needed. + +There is a \env{float} package which lets + you create new classes of floating object (perhaps Examples + or Exercises). +\subsection{Formal tables} + +To create a Table, use the \env{table} + environment containing a \command{caption} command + where you type the caption, and the \command{label} + command to give the Table a label by which you can refer to + it. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{table} +\caption{Project expenditure to year-end 2003} +\label{ye2003exp} +... +\end{table} + \end{Verbatim} +\end{sourcecode} + +Numbering is automatic, but the \command{label} + command \emph{must follow} the + \command{caption} command, not precede it. The + numbering automatically includes the chapter number in + document classes where this is appropriate (but this can of + course be overridden). The \command{caption} + command has an optional argument to provide a short caption + if the full caption would be too long for the List of + Figures: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\caption[Something short]{Some very long caption that will +only look reasonable in the full figure.} + \end{Verbatim} +\end{sourcecode} +\subsection{Tabular matter} + +Within a Table, you can either typeset the tabular + matter using \LaTeX{}, or include a table captured as an + image from elsewhere. We will see how to include images in + the next section on Figures, where they are more + common. + +To typeset tabular matter, use the + \env{tabular} environment. The + \verb+\begin{tabular}+ command must be followed + by a compulsory second argument in curly braces giving the + alignment of the columns. These are specified for each + column using one of single letters \verb+l+, + \verb+c+, and \verb+r+ for + left-aligned, centered, or right-aligned text, or the letter + \verb+p+ followed by a width argument if you + want a long entry to wrap to several lines (a miniature + paragraph as a single cell). + +\TeX{}'s original tabular settings were designed for + classical numerical tabulations, where each cell contains a + single value. The \verb+p+ specification allows + a cell to be a miniature paragraph set to a specific width. + These are \emph{not} multi-row entries, they + are single cells which contain multiple lines of + typesetting: the distinction is very important. + Auto-adjusting cell sizes like you see in a Web browser (the + `Netscape' table model) are possible + with the \package{tabularx} package, but + these are often inelegant in print, however convenient they + may be in a Web browser. + +The \package{array} package provides for + many other typographic variations such as left-aligned, + right-aligned, and centred multi-line columns, and other + packages provide decimal-aligned columns, the aforementioned + row-spanning, multi-page, and rotated (landscape format) + tables. + +As an example, a tabular setting with three columns, the + first one centered, the second left-aligned, and the third + one right-aligned, would therefore be specified as + \verb+{clr}+, as in the example below. Note the + use of indentation to make the elements of the table clear + for editing, and note also how the typeset formatting is + unaffected by this (see Table~\ref{ye2003exp}). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{table} + \caption{Project expenditure to year-end 2003} + \label{ye2003exp} + \begin{center} + \begin{tabular}{clr} + &Item&Amount\\ + \hline + a)&Salaries (2 research assistants)&28,000\\ + &Conference fees and travel expenses&14,228\\ + &Computer equipment (5 workstations)&17,493\\ + &Software&3,562\\ + b)&Rent, light, heat, power, &etc;&1,500\\\cline{3-3} + &Total&64,783 + \end{tabular} + \par\medskip\footnotesize +The Institute also contributes to (a) and (b). + \end{center} +\end{table} + \end{Verbatim} +\end{sourcecode} +\begin{table}\caption{Project expenditure to year-end 2003} +\label{ye2003exp} +\begin{center} +\begin{tabular}{clr}\textbf{\normalfont\bfseries\upshape }&\textbf{\normalfont\bfseries\upshape Item}&\textbf{\normalfont\bfseries\upshape Amount}\\[2pt]\hline\\[-.95\baselineskip] +a)&Salaries (2 research assistants)&28,000\\ +&Conference fees and travel expenses&14,228\\ +&Computer equipment (5 workstations)&17,493\\ +&Software&3,562\\ +b)&Rent, light, heat, power, etc.&1,500\\ +\cline{3-3}\vrule height1.1em width0pt \textbf{}&\textbf{Total}&\textbf{64,783}\\ +\end{tabular} +\par\smallskip\footnotesize +The Institute also contributes to (a) and + (b).\end{center} +\end{table} + +You do not need to format the tabular data in your + editor: \LaTeX{} does this for you when it typesets the + table, using the column specifications you provided. Extra + space is automatically added between columns, and can be + adjusted by changing the \length{tabcolsep} dimension. + \person{Takaaki Ota} provides an excellent Tables mode for + \product{Emacs} which provides a + spreadsheet-like interface and can generate \LaTeX{} table + source code (see Figure~\ref{tabmode}). +\begin{figure} +\caption{Tables mode for \product{Emacs}} +\label{tabmode} +\begin{center} +\includegraphics[width=0.75\textwidth]{table} +\end{center} +\end{figure} + +It is conventional to centre the tabular setting within + the Table, using the \env{center} + environment (note US spelling) or the + \command{centering} command. The entries for each cell + are separated by an ampersand character + (\verb+&+) and the end of a row is shown by the + double-backslash (\verb+\\+). + +The \command{hline} command draws a rule across + all columns and the \command{cline} command draws a + rule across a range of columns (here, under column three + only). If used, these commands + \emph{follow} the + \verb+\\+ of the row they apply to. There are + some extra formatting commands after the tabular material in + the example. These are explained in + \chaptername~\ref{typo}. + +If there is no data for a cell, just don't type + anything\mdash{}but you still need the + \verb+&+ separating it from the next + column's data. The astute reader will already have + deduced that for a table of + \(n\) columns, there must always be + \(n\ifmmode-\else$-$\fi{}1\) ampersands in each row. The exception to + this is when the \command{multicolumn} command is + used to create cells which span multiple columns. There is + also a package (\env{multirow}) to enable + cells to span multiple rows, but both of these techniques + are outside the scope of this document. +\subsection{Tabular techniques for alignment} + +As mentioned earlier, it's also perfectly possible + to typeset tabular matter outside a formal Table, where you + want to lay out an informal tabulation between paragraphs + where a fully floating formal Table would be unnecessary + (these are usually quite short: there are several of them in + this document). + +Tabular mode can also be used wherever you need to align + material side by side, such as in designing letterheads, + where you may want your company logo and address on one side + and some other information on the other. + +By default, \LaTeX{} typesets + \env{tabular} environments inline to the + surrounding text, so if you want your alignment displayed by + itself, put it inside a positioning environment like + \env{center}, + \env{flushright}, or + \env{flushleft}, or leave a blank line or + \command{par} before and after so it gets typeset + separately. + +There is much more to tabular setting for which there is + no space here. Full details are in the manuals mentioned in + the Foreword. One final note to remind you of the + automated crossreferencing features: because the example + table is labelled, it can be referenced from anywhere in the + document as Table~\ref{ye2003exp} just by using + \verb+\ref{ye2003exp}+, regardless of how much + the surrounding document or structure is moved or edited. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{17}Create a tabulation} +\subsubsection*{Create a tabulation} +Create one of the following in your document: +\begin{itemize} +\item +a formal Table with a caption showing the number + of people in your class broken down by age and + sex; + +\item +an informal tabulation showing the price for three + products; + +\item +the logo {\setlength{\fboxsep}{-3pt}\setlength{\fboxrule}{.4pt} + \fbox{\begin{tabular}{cc}\tiny YEAR\\[-.8em]\tiny 2 + 0 0 0\vrule depth1em width0pt\end{tabular}}} + (hint: \S\thinspace\ref{fbox}) + +\end{itemize} +\end{exercise} +\section{Figures} +\label{figures} +\index{figures}\index{floats} +As explained in \S\thinspace\ref{floats}, Figures and + Tables float to a vacant part of the page, as they are not + part of the sequence of sentences making up your text, but + illustrative objects that you refer to. + +Figures can contain text, diagrams, pictures, or any other + kind of illustration. To create a figure, use the + \env{figure} environment: like Tables, they + automatically get numbered, and must include a caption (with a + label after the caption, if needed, exactly the same as for + Tables) +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{figure} +\caption{Total variable overhead variance (after + \citeauthor[p.191]{bull}} +\label{workeff} +\begin{center} +\fbox{\includegraphics[width=.5\columnwidth]{diagram}} +\end{center} +\end{figure} + \end{Verbatim} +\end{sourcecode} +\begin{figure} +\caption{Total variable overhead variance (after + \citeauthoryear{bull} \textsl{p.191})} +\label{workeff} +\begin{center} +\includegraphics[width=0.5\textwidth]{diagram} +\end{center} +\end{figure} + +You can see that the structure is very similar to the + \env{table} environment, but in this case + we have a graphic included. Details of this command + (\command{includegraphics}) are in the next + section. Details of the bibliographic citation mechanism are + in \S\thinspace\ref{bib} + +The content of the Figure could of course also be + textual, in the form of a list or a text diagram. \LaTeX{} has + a simple drawing environment called + \env{picture}, which lets you create a limited + set of lines and curves, but for a diagram of any complexity, + you should use a standard vector drawing program like + \product{tkpaint}, \product{Adobe + Illustrator}, or \product{Corel + Draw}, for reasons we shall see in the next + section. +\section{Images} +\label{images} +\index{images}\index{graphics} +Images (graphics) can be included anywhere in a \LaTeX{} + document, although in most cases of formal documents they will + occur in Figures (see preceding section). To use graphics, you + need to use the \package{graphicx} package in + your preamble: + \verb+\usepackage{graphicx}+\footnote{You may find a lot of old files which use a package + called \package{epsf}. Don't. + It's obsolete.} + +This enables the command + \command{includegraphics} which is used to insert an + image in the document. The command is followed by the name of + your graphics file \emph{without the filetype}, + for example: + \verb+\includegraphics{myhouse}+ (we'll see + soon why you don't include the filetype). + +In most cases you should just make sure the image file is + in the same folder (directory) as the document you use it in. + This avoids a lot of messing around remembering where you put + the files. If you have images you want to use in several + different documents in different places on your disk, there is + a way to tell \LaTeX{} where to look (see \S\thinspace\ref{graphicsdir}). + +For standard \LaTeX{}, graphics files + \emph{must} be in Encapsulated + PostScript (EPS)\index{EPS@EPS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!EPS@EPS|textbf} format: this has been the publishing + industry standard for portable graphics for many years, and no + other format will work portably in standard \LaTeX{}.\footnote{Some distributions of \TeX{} systems do allow other + formats, such as Microsoft + Bitmap (BMP)\index{BMP@BMP|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!BMP@BMP|textbf} files, Hewlett-Packard's Printer Control Language (PCL)\index{PCL@PCL|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!PCL@PCL|textbf} files, and + others; but you cannot send such documents to other + \LaTeX{} users and expect them to work if they don't + have the same distribution installed as you have.} + +All good graphics packages can save images as EPS\index{EPS@EPS}, but be very careful because some + packages, especially on Microsoft Windows platforms, use very + poor quality drivers which create very poor quality EPS\index{EPS@EPS} files. If in doubt, check with an + expert. If you find an EPS\index{EPS@EPS} graphic + doesn't print, the chances are it's been badly made + by the graphics software. + +For \product{pdflatex}, graphics files + can be in Joint Photographic + Experts (JPG)\index{JPG@JPG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!JPG@JPG|textbf}, Portable Network + Graphic (PNG)\index{PNG@PNG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PNG@PNG|textbf}, or PDF\index{PDF@PDF} format, + \emph{not} EPS\index{EPS@EPS}. + This means if you want to use both standard \LaTeX{} as well as + \product{pdflatex}, you need to keep your + graphics in two formats, EPS\index{EPS@EPS} and one + of the others. This is why you don't include the filetype + in the filename you give with + \command{includegraphics}: \LaTeX{} will assume + EPS\index{EPS@EPS} and + \product{pdflatex} will look for JPG\index{JPG@JPG}, PNG\index{PNG@PNG} or + PDF\index{PDF@PDF} files matching the name. + +It is in fact possible to tell \LaTeX{} to generate the + right format by itself, but this requires an external + command-line graphics converter, and as it gets done afresh + each time, it slows things down rather a lot. + +The \command{includegraphics} command can take + optional arguments within square brackets before the filename, + e.g. + \verb+\includegraphics[width=3in]{myhouse}+ to let + you re-size the image to fit. You can change height or width + and the other dimension will change to scale. If you specify + both, the image will be distorted to fit. + +For details of all the arguments, see the documentation on + the \package{graphicx} package or a copy of the + \titlecite{companion}. This package also + includes commands to {\raisebox{1ex}{\rotatebox{180}{rotate}}}, + {\scalebox{-1}[1]{mirror}}, and + {\scalebox{2}[1]{scale}} + text. +\index{rotate}\index{mirror}\index{scale} +As mentioned before, always use a vector graphics package + for creating drawings and diagrams, as these packages can save + directly in EPS\index{EPS@EPS} or PDF\index{PDF@PDF} format, which means the drawing can be + scaled to any size without loss of accuracy. Never, ever + (except in the direst necessity) save any + \emph{diagram} as a bitmap (JPG\index{JPG@JPG}, PNG\index{PNG@PNG}, etc.) as + these become blurred and jagged when scaled. Use PNG\index{PNG@PNG} to save screenshots, to preserve the + individual coloured dots (pixels), and use JPG\index{JPG@JPG} for photographs. The Tagged Image File Format (TIFF)\index{TIFF@TIFF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TIFF@TIFF|textbf}, popular with + graphic designers, should be avoided because far too many + companies have designed and implemented non-standard, + conflicting, proprietary extensions to the format, making it + virtually useless for transfer between computers (except in + faxes, where it's still used in a much stricter + version). +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{18}Adding pictures} +\subsubsection*{Adding pictures} +Add \verb+\usepackage{graphicx}+ to the + preamble of your document, and copy or download an image you + want to include. Make sure it is a JPG\index{JPG@JPG}, PNG\index{PNG@PNG}, or + PDF\index{PDF@PDF} image if you use + \product{pdflatex}, or an EPS\index{EPS@EPS} image if you use standard + \LaTeX{}. + +Add \command{includegraphics} and the filename + in curly braces (without the filetype), and process the + document and preview or print it. + +Make it into a figure following the example in \S\thinspace\ref{figures}. + +Be aware that some DVI\index{DVI@DVI} viewers + are not able to display all types of graphics, and some + cannot display colour. For best results, use PDF\index{PDF@PDF} or PostScript\index{PostScript} + preview. +\end{exercise} + +\label{graphicsdir}% +I said earlier that there was a way to + tell \LaTeX{} where to look if you had stored images centrally + for use in many different documents. The answer is in a + command \command{graphicspath} which you supply with + an argument giving the name of an additional directory path + you want searched when a file uses the + \command{includegraphics} command, for example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\graphicspath{c:\mypict~1\camera} +\graphicspath{/var/lib/images} +\graphicspath{HardDisk:Documents:Reports:Pictures} + \end{Verbatim} +\end{sourcecode} + +I've used the `safe' (MS-DOS) + form of the Windows \url+My Pictures+ folder + because it's A Bad Idea to use directory names containing + spaces (see the panel `Picking suitable filenames' on p.\pageref{filenames}). Using + \command{graphicspath} does make your file less + portable, though, because file paths tend to be specific both + to an operating system and to your computer, like the examples + above. +\section{Verbatim text} +\label{verbatim} +\index{verbatim text} +If you are documenting computer procedures, you probably + need fixed-width type for examples of programming or data + input or output. Even if you are writing about completely + non-computer topics, you may often want to quote a URI\index{URI@URI} or + email address which needs to be typeset specially. It is + particularly important in these two examples to avoid + hyphenating them if they have to break over a line-end, + because the hyphen might be taken by the user as a part of the + address. + +Standard \LaTeX{} includes two features for handling + fixed-format text, and there are many more available in + packages. +\subsection{Inline verbatim} +\label{inlineverb} + +To specify a word or phrase as verbatim text in + typewriter type within a sentence, use the special command + \command{verb}, followed by your piece of text + surrounded by any suitable character which does + \emph{not} occur in the text itself. This is a + very rare exception to the rule that arguments go in curly + braces. I often use the plus sign for this, for example to + show a \LaTeX{} command, I type + \verb`\verb+\includegraphics[width=3in]{myhouse}+` + in order to display + \verb+\includegraphics[width=3in]{myhouse}+, but + sometimes I use the + \textbf{\textit{grave accent}}\index{grave accent@\textbf{\textit{grave accent}}} (\textbf{\textit{backtick}}\index{backtick@\textbf{\textit{backtick}}} or open-quote) or the + vertical bar when the phrase already has a plus sign in it, + like \verb`\verb|\(y=a+2x^2\)|` when + illustrating the \LaTeX{} equation + \verb|\(y=a+x^2\)|. + +This command has the advantage that it turns off all + special characters (see \S\thinspace\ref{specials}) except + the one you use as the delimiter, so you can easily quote + sequences of characters in any computer syntax without + problems. However, \LaTeX{} will never break the argument of + \command{verb} at a line-end when formatting a + paragraph, even if it contains spaces, so if it happens to + be long, and falls towards the end of a line, it will stick + out into the margin. See \S\thinspace\ref{hyph} for + more information on line-ends and hyphenation. + +The \package{url} package avoids this + by providing the command \command{url} which + works in the same way as \command{verb}, with the + argument enclosed in a pair of characters, but performs a + hyphenless break at punctuation characters, as in + \url+http://www.ucc.ie/doc/ucc/siteowner.xml+. + It was designed for Web URI\index{URI@URI}s,\footnote{The original term Uniform Resource + Locator (URL)\index{URL@URL|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!URL@URL|textbf} is strongly deprecated in the Web + community in favour of the more accurate Uniform Resource Indicator (URI)\index{URI@URI|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!URI@URI|textbf}. For + details see \url+http://www.w3.org/Addressing/+. + Unfortunately the older term still persists, especially + in \LaTeX{} and XML\index{XML@XML} + markup.} so it understands their syntax + and will never break mid-way through an unpunctuated word, + only at slashes and full points. Bear in mind, however, that + spaces are forbidden in URI\index{URI@URI}s, so using spaces in + \command{url} arguments will fail, as will using + other non-URI\index{URI@URI}-valid characters. +\subsection{Display verbatim} + +For longer (multiline) chunks of fixed-format text, use + the \env{verbatim} environment: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{verbatim} +\documentclass[11pt,a4paper,oneside]{report} +\begin{document} + +\title{Practical Typesetting} +\author{Peter Flynn\\Silmaril Consultants} +\date{December 2004} +\maketitle + +\end{document} +\end{verbatim} + \end{Verbatim} +\end{sourcecode} + +Like \command{verb}, this turns off all special + characters, so you can include anything at all in the + verbatim text except the exact line + \verb+\end{verbatim}+. + +For more control over formatting, however, I recommend + the use of the \package{fancyvrb} package, + which provides a \env{Verbatim} environment + (note the capital letter) which lets you draw a rule round + the verbatim text, change the font size, and even have + typographic effects inside the \env{Verbatim} + environment. It can also be used in conjunction with the + \package{fancybox} package (see below), and + it can add reference line numbers (useful for chunks of data + or programming), and it can include entire external + files. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{19}Try some fixed-format text} +\subsubsection*{Try some fixed-format text} +Add your email address and home page URI\index{URI@URI} using the + \command{verb} and \command{url} + commands. You'll need to + \verb+\usepackage{url}+ for the latter. + +If you know some programming, try a few lines enclosed + in \env{verbatim} and + \env{Verbatim} environments. +\end{exercise} +\clearpage +\section{Boxes, sidebars, and panels} +\label{boxes} +\index{boxes}\index{sidebars}\index{panels} +\LaTeX{}, like most typesetting systems, works by setting + text into boxes. The default box is the width of the current + page, and works like an old compositor's galley (tray) + from the days of metal type: it accumulates typeset text until + it's a bit longer than the specified page height. At this + stage \LaTeX{} works out how much of it really will fit on a + page, snips it off and ships it out to the DVI\index{DVI@DVI} or PDF\index{PDF@PDF} file, + and puts the rest back into the galley to accumulate towards + the following page. +\subsection{Boxes of text} +\label{boxtext} + +Because of this `box' model, + \LaTeX{} can typeset any text into a box of any width + wherever on the page you need it. + +The simplest command for small amounts of text is + \command{parbox}. This command needs two arguments + in curly braces: the first is the width you want the text + set to, and the second is the text itself, for + example: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\parbox{1in}{Please make sure you send in your completed + forms by January 1st next year, or the penalty + clause 2(a) will apply} + \end{Verbatim} +\end{sourcecode} +\begin{center} +\begin{tabular}{p{1in}}Please make sure you send in your completed + forms by January 1st next year, or the penalty + clause 2(a) will apply\\ +\end{tabular} +\end{center} +\end{example} + +The text is typeset to the required width, and the box + is extended downwards for as long as is required to fit the + text. Note that the baseline of a \command{parbox} + is set to the midpoint of the box; that is, if you include a + \command{parbox} in mid-sentence, the centre of the + box will be lined up with the line of type currently being + set.\parbox{1cm}{ +{\scriptsize{}\selectfont{}Like + this small paragraph.\par} +} You can specify that it should be the top or + bottom by adding an optional + \opt{t} or + \opt{b} in square + brackets before the width. For example, + \verb+\parbox[t]{1in}{...}+ will produce + \parbox[t]{1in}{ +a box with the baseline aligned with the top line + of the text in the box. +} + +Notice that when setting very narrow measures with type + that is too large, the spacing may become uneven and there + may be too much hyphenation. Either use + \command{raggedright} or reduce the type size, or + (in extreme cases) reword the text or break each line by + hand. It is rare for \LaTeX{} to need this: the example above + was deliberately chosen to be obtuse as an + illustration. + +Where the contents is more extensive or more + complicated, you can use the \env{minipage} + environment. Within this you can use virtually everything + that occurs in normal text (e.g. lists, paragraphs, + tabulations, etc.) with the exception of floats like tables + and figures. The \env{minipage} environment + has an argument just like \command{parbox} does, + and it means the same: the width you want the text set + to. +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{minipage}{3in} +Please make sure you send in your completed forms by January +1st next year, or the penalty clause 2(a) will apply. +\begin{itemize} +\item Incomplete forms will be returned to you unprocessed. +\item Forms must be accompanied by the correct fee. +\item There is no appeal. The adjudicators' decision is final. +\end{itemize} +\end{minipage} + \end{Verbatim} +\end{sourcecode} +\begin{center} +\begin{tabular}{p{3in}}Please make sure you send in your + completed forms by January 1st next year, or the + penalty clause 2(a) will + apply.\begin{itemize} +\item +Incomplete forms will be returned to you + unprocessed. + +\item +Forms must be accompanied by the correct + fee. + +\item +There is no appeal. The adjudicators' + decision is final. + +\end{itemize} +\\ +\end{tabular} +\end{center} +\end{example} + +Note that in \env{minipage}s and + \command{parbox}es, the paragraph indentation is + reset to zero. If you need to change it, set it inside the + \env{minipage} or \command{parbox} + using the \command{setlength} command (see \S\thinspace\ref{paragraphs}). + +There are two other ways of typesetting text to widths + other than the normal text width: you can use a one-row, + one-cell tabulation with the \verb+p+ + column type specification, and you can use the + \command{vbox} command, which is outside the scope + of this document. +\subsection{Framed boxes} +\label{fbox} + +To put a frame round {\fbox{some text}}, use the + \command{fbox} command: + \verb+\fbox{some text}+. This works for a few + words in mid-line, but the framed box and its contents + won't break over the end of a line. To typeset + multiline text in a box, put it in a + \command{parbox}, or use a + \env{minipage} or + \env{tabular} environment as described above, + and enclose the whole thing in a + \command{fbox}. +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\fbox{\begin{tabular}{p{1in}} +Multiline text in a box typeset using \textsf{tabular} +\end{tabular}} + \end{Verbatim} +\end{sourcecode} +\begin{center} +\setlength{\tabcolsep}{6pt} +\begin{tabular}{|p{1in}|}\hline\vrule height6pt width0pt +Multiline text in a box typeset using + \package{tabular}\\ +\hline +\end{tabular} +\end{center} +\end{example} + +Note the \verb+\begin{tabular}+ and + \verb+\begin{minipage}+ still need the width + specified in the normal way: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\fbox{\begin{minipage}{3in} +This multiline text is more flexible than a tabular setting: +\begin{itemize} +\item it can contain any type of normal \LaTeX{} +typesetting; +\item it can be any specified width; +\item it can even have its own footnotes\footnote{Like this}. +\end{itemize} +\end{minipage}} + \end{Verbatim} +\end{sourcecode} +\begin{center}\setlength{\fboxrule}{1pt} +\begin{minipage}{3in} + +This multiline text is more flexible than a + tabular setting: +\begin{itemize} +\item +it can contain any type of normal \LaTeX{} + typesetting; + +\item +it can be any specified width; + +\item +it can even have its own footnotes.\footnote{Like this.} + +\end{itemize} +\end{minipage} +\end{center} +\end{example} + +The spacing between text and box is controlled by the + value of \length{fboxsep}, and + the thickness of the line by \length{fboxrule}. The following values + were used above: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\fboxsep}{1em} +\setlength{\fboxrule}{2pt} + \end{Verbatim} +\end{sourcecode} +\subsection{Sidebars and panels} +\label{fancybox} + +The \package{fancybox} package lets you + extend the principle of \command{fbox} with + commands to surround text in square, oval (round-cornered), + and drop-shadow boxes (e.g. \command{ovalbox}, + \command{shadowbox}, etc.: see the documentation for + details). + +You can create panels of any size with these borders by + using the \env{minipage} environment to + typeset the text inside a special \env{Sbox} + environment which \package{fancybox} defines. + The \env{minipage} formats the text but the + \env{Sbox} `captures' + it, allowing you to put the frame round it as it + prints. + +The printed version of this document has examples and + there is a useful one shown in \S\thinspace\ref{macenv}. +\chapter{Textual tools} +\label{texttools} +\index{tools} +Every text-handling system needs to support a repertoire of + tools for doing things with text. \LaTeX{} implements many + dozens, of which a small selection of the most frequently used + is given here: +\begin{itemize} +\item +quotations (sometimes called `block + quotes'); + +\item +footnotes and end-notes; + +\item +marginal notes; + +\item +cross-references, both normal ones and bibliographic + citations; + +\item +indexes and glossaries; + +\item +typesetting multiple columns. + +\end{itemize} +\section{Quotations} +\label{quotations} + +Direct speech and short quotes within a sentence + `like this' are done with simple + quotation marks as described in \S\thinspace\ref{quotes}. Sometimes, however, you may want longer + quotations set as a separate paragraph. Typically these are indented + from the surrounding text, and often in a different font or size. + \LaTeX{} has two environments for doing this: +\begin{description} +\item[\sffamily The {\fontseries{m}\selectfont{}\package{quote}} environment] +is for up to a line of text each per (short) + quotation, with the whole thing indented from the + previous paragraph but with no additional indentation on + each quote; +\begin{example} +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +\begin{quote} +Do, Ronny, Do. \textit{Nancy Reagan} + +Da Do Ron Ron. \textit{The Crystals} +\end{quote} + \end{Verbatim} +\end{sourcecode}\leavevmode\enspace +\begin{quote}\noindent +Do, Ronny, Do. {\fontshape{it}\selectfont{}Nancy + Reagan}\end{quote}\begin{quote}\noindent +Da Do Ron Ron. {\fontshape{it}\selectfont{}The + Crystals}\end{quote}\end{example} +\item[\sffamily The {\fontseries{m}\selectfont{}\package{quotation}} environment] +is for longer passages (a paragraph or more) of a + single quotation, where not only is the block of text + indented, but each paragraph of it also has its own + extra indentation on the first line. +\begin{example} +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +\begin{quotation}\small +At the turn of the century William Davy, a Devonshire +parson, finding errors in the first edition of his +\citetitle{davy}, asked for a new edition to be +printed. His publisher refused and Davy purchased a +press, type, and paper. He harnessed his gardener to +the press and apprenticed his housemaid to the +typesetting. After twelve years' work, a new +edition of fourteen sets of twenty-six volumes was +issued---which surely indicates that, when typomania +is coupled with religious fervour, anything up to a +miracle may be achieved.\citequote[p.76]{ryder} +\end{quotation} + \end{Verbatim} +\end{sourcecode} +\begin{quotation}\small\noindent +At the turn of the century William Davy, a + Devonshire parson, finding errors in the first edition + of his \titlecite{davy}, asked + for a new edition to be printed. His publisher refused + and Davy purchased a press, type, and paper. He + harnessed his gardener to the press and apprenticed + his housemaid to the typesetting. After twelve years' + work, a new edition of fourteen sets of twenty-six + volumes was issued---which surely indicates that, when + typomania is coupled with religious fervour, anything + up to a miracle may be achieved. +\setlength{\parfillskip}{0pt}\hfill[\citeauthortitleyear{ryder}], p.76\end{quotation} +\end{example} +\end{description} + +Such quotations are often set in a smaller size of type + (although this is not the default, hence the use of the + \command{small} command in the example). The + inclusion of the bibliographic citation at the end is + optional: here it is done with a non-standard command + \command{citequote} invented for this example (there + is more about how to do things like this in \chaptername~\ref{macros}). +\section{Footnotes and end-notes} +\label{footnotes} +\index{footnotes} +The command \command{footnote}, followed by the + text of the footnote in curly braces, will produce an + auto-numbered footnote with a superior number where you put + the command, and the note automatically printed at the foot of + the page.\footnote{Like this.} The number is reset to 1 at the start of each + chapter (but you can override that and make them run + continuously throughout the document, or restart at 1 on each + page or section). + +\LaTeX{} automatically creates room for the footnote, and + automatically reformats it if you change your document in such + a way that the point of attachment and the footnote would move + to the next (or preceding) page. + +Because of the way \LaTeX{} reads the whole footnote before + doing anything with it, you can't use + \command{verb} (\S\thinspace\ref{inlineverb}) alone + in footnotes: either precede it with + \command{protect} or use [abuse?] the + \command{url} command instead, which you should be + using for Web and email addresses in any case). + +Footnotes inside minipages (see \S\thinspace\ref{boxes}) produce lettered notes instead of + numbered ones, and they get printed at the bottom of the + minipage, \emph{not} the bottom of the physical + page (but this too can be changed). + +There is a package to hold over your footnotes and make + them print at the end of the chapter instead + (\package{endnote}) or at the end of the whole + document, and there is a package + (\package{fnpara}) to print many short + footnotes in several columns so they take up less space. It is + also possible to have several separate series of footnotes + active simultaneously, which is useful in critical editions or + commentaries: a numbered series may be used to refer to an + original author's notes; a lettered series can be used + for notes by a commentator or authority; and a third series is + available for your own notes. It is also possible to format + footnotes within footnotes. + +There are also ways to refer more than once to the same + footnote, and to defer the positioning of the footnote if it + occurs in a float like a Table or Figure, where it might + otherwise need to move to a different page. +\section{Marginal notes} +\label{marginals} +\index{marginal notes} +You can add marginal notes to your text\marginal{Like this.} instead of + (or as well as) footnotes. You need to make sure that you have + a wide-enough margin, of course: use the + \package{geometry} package (see \S\thinspace\ref{colorpkg}) to allocate enough space, otherwise + the notes will be too cramped. There are several packages to + help with formatting marginal notes, but the simplest way is + to define it yourself. Add this new command to your + preamble: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\marginal}[1]{% + \leavevmode\marginpar{\tiny\raggedright#1\par}} + \end{Verbatim} +\end{sourcecode} + +Then you can use + \verb+\marginal{Some text}+\marginal{Some text} where you need + it. Be careful, however, because marginal notes are aligned + with the line where the command starts, so a very long one + followed too closely by another will cause \LaTeX{} to try and + adjust the position so they don't overlap. + +We're jumping ahead a bit here, as we haven't + covered how to define your own commands yet. I won't even + try to explain it here, although the careful reader can + probably deduce some of it by inspection. See \chaptername~\ref{macros} for more information about making up your + own commands. +\section{Cross-references} +\label{xrefs} +\index{cross-references} +This is one of the most powerful features of \LaTeX{}. You + can label any point in a document with a name you make up, and + then refer to it by that name from anywhere else in the + document, and \LaTeX{} will always work out the cross-reference + number for you, no matter how much you edit the text or move + it around. + +A similar method is used to cite documents in a + bibliography or list of references, and there are packages to + sort and format these in the correct manner for different + journals. +\subsection{Normal cross-references} +\label{normalxref} + +You label a place in your document by using the command + \command{label} followed by a short name you make + up, in curly braces:\footnote{This section is labelled + `\url+normalxref+', + for example.} we've already seen this done for labelling + Figures and Tables. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\section{New Research} +\label{newstuff} + \end{Verbatim} +\end{sourcecode} + +You can then refer to this point from anywhere in the + same document with the command \command{ref} + followed by the name you used, e.g. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +In section~\ref{newstuff} there is a list of recent projects. + \end{Verbatim} +\end{sourcecode} + +If the label is in normal text, the reference will + provide the current chapter or section number or both (depending + on the current document class).\footnote{Thus I can + refer here to + \url+\ref{normalxref}+ and get the + value \S\thinspace\ref{normalxref}.} If + the label was inside a Table or Figure, the reference + provides the Table number or Figure number prefixed by the + chapter number. A label in an enumerated list will provide a + reference to the item number. If there is no apparent + structure to this part of the document, the reference will + be null. Labels must be unique (that is, each value must + occur only \emph{once} as a label within a + single document), but you can have as many references to + them as you like. + +Note the use of the unbreakable space + (\verb+~+) between the \command{ref} + and + the word before it. This prints a space but prevents the + line ever breaking at that point, should it fall close to + the end of a line. + +The command \command{pageref} followed by any + of your label values will provide the page number where the + label occurred, regardless of the document structure. This + makes it possible to refer to something by + page number as well as its + \command{ref} number, which is useful to + readers in very long documents. + +Unresolved references are printed as three question + marks, and also cause a warning message at the end of the + log file. There's never any harm in having + \command{label}s you don't refer to, but using + \command{ref} when you don't have a matching + \command{label} is an error. +\subsection{Bibliographic references} +\label{bib} +\index{bibliographies}\index{references} +The mechanism used for references to reading lists and + bibliographies is almost identical to that used for normal + cross-references. Although it is possible to type the + details of each citation manually, there is a companion + program to \LaTeX{} called BIB\TeX{}, which manages + bibliographic references automatically, reduces the time + needed to maintain and format them, and dramatically + improves accuracy. Using BIB\TeX{} means you only ever have + to type the bibliographic details of a work once. You can + then cite it in any document you write, and it will get + reformatted automatically to the style you specify. +\subsubsection{Citing references} +\label{citation} + +BIB\TeX{} works exactly the same way as many other + bibliographic databases: you keep details of every + document you want to refer to in a separate file, using + BIB\TeX{}'s own format (see example below). Many + writers make a habit of adding the details of every book + and article they read, so that when they write a document, + these entries are always available for reference. You give + each entry a short label, just like you do with normal + cross-references (see \S\thinspace\ref{normalxref}), and it is + this label you use to refer to in your own documents when + you cite the work using the \command{cite} + command: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +...as has clearly been shown by Fothergill~\cite{fg}. + \end{Verbatim} +\end{sourcecode} + +By default, this creates a cross-reference number in + square brackets [1] which is a common style in the + Natural Sciences (see \S\thinspace\ref{othercite} for + details of how to change this). There are dozens of + alternative citation formats in extra packages, including + the popular author/year format: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +...as has clearly been shown by~\citeauthoryear{fg}. + \end{Verbatim} +\end{sourcecode}\leavevmode\enspace +\begin{quote}\noindent +\dots as has clearly been shown by \citeauthoryear{fg}.\end{quote}\end{example} + +Note that in this case the author name is not typed, + but automatically extracted by BIB\TeX{}. There are lots of + variants on this technique in many packages, allowing you to + phrase your sentences with references in as natural a way as + possible, and rely on BIB\TeX{} to insert the right data (if + you examine the source of this document you'll find I + use some homebrew commands \command{authorof} and + \command{titleof} for a similar purpose). + +To print the bibliographic listing (usually called + `References' in articles and + `Bibliography' in books and + reports), add these two lines towards the end of your + document, or wherever you want it printed, substituting + the name of your own BIB\TeX{} file and the name of your + chosen bibliography style: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\bibliographystyle{ieeetr} +\bibliography{mybib} + \end{Verbatim} +\end{sourcecode} +\begin{itemize} +\item +The \command{bibliography} command is + followed by the filename of your BIB\TeX{} file + \emph{without} the + \url+.bib+ extension. + +\item +The \command{bibliographystyle} command + is followed by the name of any of \LaTeX{}'s + supported bibliography styles, of which there are many + dozens available from CTAN\index{CTAN@CTAN}.\footnote{The style shown + in the example here provides formatting according + to the specifications for Transactions of the IEEE + (revised).} + +\end{itemize} + +The styles \opt{plain} and + \opt{alpha} + are two common generic styles used for drafts: see below + for others. +\subsubsection{Running \product{bibtex}} +\label{bibtex} + +When you run the \product{bibtex} + program, the details of every document you have cited will + be extracted from your database, formatted according to + the style you specify, and stored in a temporary + bibliographic (\url+.bbl+) file with a + label corresponding to the one you used in your citation, + ready for \LaTeX{} to use. This is entirely automatic: all + you do is cite your references in your \LaTeX{} document + using the labels you gave the entries in your BIB\TeX{} + file, and run the \product{bibtex} + program. + +After processing your file with \LaTeX{}, run BIB\TeX{} + on it by clicking on the \guiicon{BIB\TeX{}} + toolbar icon (\product{WinEdt}) or the + \menuitem{TeX}{BIBTeX + File} menu entry + (\product{Emacs}) or by typing the + command \verb+bibtex+ followed by the name of + your document (without the \url+.tex+ + extension). When you run \LaTeX{} again it uses the + \url+.bbl+ file to add the references + where you tell it to, and a subsequent run of \LaTeX{} will + format the correct citation numbers (or author/year, or + whatever format you are using). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +$ latex mybook +$ bibtex mybook +$ latex mybook +$ latex mybook + \end{Verbatim} +\end{sourcecode} + +Because of this three-stage process, you always get a + warning message about an `unresolved + reference' the first time you add a new + reference to a previously uncited work. This will + disappear after subsequent runs of + \product{bibtex} and \LaTeX{}. + +In practice, authors tend to run \LaTeX{} from time to + time during writing anyway, so they can preview the + document. Just run BIB\TeX{} after adding a new + \command{cite} command, and subsequent runs of + \LaTeX{} will incrementally incorporate all references + without you having to worry about it. You only need to + follow the full formal sequence (\LaTeX{}, BIB\TeX{}, + \LaTeX{}, \LaTeX{}) when you have finished writing and want + to ensure that all references have been resolved. +\subsubsection{BIB\TeX{} format} +\label{bibspec} + +The format for the BIB\TeX{} file is specified in the + BIB\TeX{} documentation (see \S\thinspace\ref{packagedoc} + for how to find and print it). You create a file with a + name ending in \url+.bib+, and add your + entries, for example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +@book{fg, + title = {{An Innkeeper's Diary}}, + author = {John Fothergill}, + edition = {3rd}, + publisher = {Penguin}, + year = 1929, + address = {London} +} + \end{Verbatim} +\end{sourcecode} + +There is a prescribed set of fields for each of a + dozen or so types of document: book, article (in a + journal), article (in a collection), chapter (in a book), + thesis, report, paper (in a Proceedings), etc. Each entry + identifies the document type after the + `\verb+@+' sign, + followed by the entry label that you make up, and then + each field (in any order), using the format: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +keyword = {value}, + \end{Verbatim} +\end{sourcecode} + +Most \TeX{}-sensitive editors have a BIB\TeX{} mode + which understands these + entries. \product{Emacs} automatically + uses its \url+bibtex-mode+ whenever you open + a filename ending in \url+.bib+. When + editing BIB\TeX{} databases, the rules are simple: +\begin{itemize} +\item +Omit the comma after the last field in the entry + (only). + +\item +Titles may have their case changed in some styles: + to prevent this, enclose the title in double curly + braces as in the example. + +\item +Values which are purely numeric (e.g. years) may + omit the curly braces. + +\item +Fields can occur in any order but the format must + otherwise be \emph{very strictly} + observed. + +\item +Fields which are not used do not have to be + included (so if your editor automatically inserts them + blank, you can safely delete the unused lines). + +\end{itemize} + +To help with this, there are several interfaces to + creating and maintaining BIB\TeX{} files, such as the + \product{tkbibtex} program, which runs on + most platforms (see Figure~\ref{tkbibtex}). +\begin{figure} +\caption{tkBIB\TeX{}, one of several graphical interfaces to + BIB\TeX{} databases} +\label{tkbibtex} +\begin{center} +\includegraphics[width=0.5\textwidth]{tkbibtex} +\end{center} +\end{figure} +\subsubsection{Changing the layout} +\label{bibstyle} + +To change the title printed over the reference listing, just + change the value of \command{refname} (articles) + or \command{bibname} (books and reports) by + adding a line like this in your preamble: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand{\bibname}{Reading List} + \end{Verbatim} +\end{sourcecode} + +The formatting specifications (BIB\TeX{} styles) are + based on standard settings for journals and books from + dozens of publishers: you just pick the one you want by + name. The \url+texmf/bib/bst+ subdirectory + of your installation contains the ones installed by + default, and you search on CTAN\index{CTAN@CTAN} + for others (look for \url+.bst+ files). + Most of the others are named after university press styles + (e.g. \product{harvard}, + \product{oxford}) or the publisher or + journal which specified them (e.g. + \product{elsevier}, + \product{kluwer}, etc.). + +Some of them have an accompanying package file which + you need to include with the normal + \command{usepackage} command in your preamble. In + this case the format may be distributed as + \url+.dtx+ and \url+.ins+ + files and will need installing in the same way as any + other package (see \S\thinspace\ref{pkginst}). Always read + the documentation, because most of the formats are very + specific to the journal they were designed for, and have + fairly absolute requirements. +\begin{warning} + +If you are writing for a specific publisher, you + should remember that the rules or formats are laid down + by the typographic designer of that journal or + publisher: you cannot arbitrarily change the format just + because you don't happen to like it: it's not + your choice! +\end{warning} + +It is also possible to write your own BIB\TeX{} + (\url+.bst+) style files, although it uses + a language of its own which really needs a computer + science background to understand. However, this is + rendered unnecessary in most cases: there is an extensive + program (actually written in \LaTeX{}) called + \product{makebst}, which makes + \url+.bst+ files by asking you a (long) + series of questions about exactly how you want your + citations formatted. Just type + \verb+latex makebst+ in a command window, but + give it a dummy run first, because some of the questions + are very detailed, so you need to have thought through how + you want your citations to appear before you start. +\subsubsection{Other modes of citation} +\label{othercite} + +The method of citing a work by numeric reference is + common in the Natural Sciences but is not used in the + Humanities and Law. In these fields, citations are usually + done with short references (author/short-title/year) in a + numbered footnote. Sometimes they are actually called + `footnotes' to the exclusion of + ordinary footnotes, although they are really citations + which happen by convention to be + \emph{displayed} as footnotes: an important + distinction rarely appreciated by authors until they come + to need a normal footnote. + +The bibliography at the back of the document is then + printed \emph{unnumbered} in alphabetic + order of author, or perhaps chronologically if the + time-frame is very large. This unnumbered format is why it + is conventionally called + `References' rather than + `Bibliography': sufficient working + citation has already been provided in the footnote, and + the list at the back is for reference purposes only; + whereas in the Natural Sciences, the citation is just a + number, or possibly an author and year only, so the full + listing is called a Bibliography. + +The \package{jurabib} package + (originally intended for German law articles but now + extended to other fields in the Humanities, and to other + languages) has extensive features for doing this style of + citation and is very strongly recommended. +\section{Indexes and glossaries} +\label{indexes} +\index{indexes}\index{glossaries} +\LaTeX{} has a powerful, automated indexing facility which + uses the standard \product{makeindex} + program. To use indexing, use the package + \package{makeidx} and include the + \command{makeindex} command in your preamble: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage{makeidx} +\makeindex + \end{Verbatim} +\end{sourcecode} + +When you want to index something, using the command + \command{index} followed by the entry in curly + braces, as you want it to appear in the index, using one of + the following formats: +\begin{description} +\item[\sffamily Plain entry] +Typing \verb+\index{beer}+ will create + an entry for `beer' with the + current page + number.\index{beer} +\item[\sffamily Subindex entry] +For an entry with a subentry use an exclamation mark + to separate them: + \verb+\index{beer!lite}+.\index{beer!lite} Subsubentries like + \verb+\index{beer!lite!American}+ work to + another level deep.\index{beer!lite!American} +\item[\sffamily Cross-references] +`See' entries are done with + the vertical bar (one of the rare times it does + \emph{not} get interpreted as a math + character): + \verb+\index{Microbrew|see{beer}}+\index{Microbrew|see{beer}} +\item[\sffamily Font changes]\label{indextypo} +To change the style of an entry, use the + @-sign followed by a font change command: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +\index{beer!Rogue!Chocolate Stout@\textit{Chocolate Stout}} + \end{Verbatim} +\end{sourcecode} + +\noindent This example\index{Chocolate Stout@\textit{Chocolate Stout}} indexes + `\product{Chocolate + Stout}' and italicises it + at the same time. Any of the standard + \verb+\text...+ font-change commands work + here: see the table on p.\thinspace\pageref{fontcmds} for details. You + can also change the font of the index number on its own, + as for first-usage references, by using the vertical bar + in a similar way to the `see' + entries above, but substituting a font-change command + (\emph{without} a backslash) such as + \verb+textbf+ for bold-face text: + \verb+\index{beer!Rogue!Chocolate Stout|textbf}+\index{Chocolate Stout|textbf} (see the index). +\item[\sffamily Out of sequence] +The same method can be used as for font changes, + just without the font command: + \verb+\index{Oregon Brewing Company@Rogue}+\index{Oregon Brewing Company@Rogue} will add an entry for + `Rogue' in the + `O' section of the index, as if + it was spelled `Oregon Brewing + Company'. +\end{description} + +When the document has been processed through \LaTeX{} it + will have created a \url+.idx+ file, which you + run through the \product{makeindex} program + by typing (for example): +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +makeindex mythesis + \end{Verbatim} +\end{sourcecode} + +Some editors may have a button or menu entry for this. + The program will look for the \url+.idx+ file + and output a \url+.ind+ file. This gets used by + the command \command{printindex} which you put at the + end of your document, where you want the index printed. The + default index format is two columns. + +Glossaries are done in a similar manner using the command + \command{makeglossary} in the preamble and the + command \command{glossary} in the same way as + \command{index}. There are some subtle differences in + the way glossaries are handled: both the books by \citeauthoryear{latexbook} and by \citeauthoryear{companion} duck the issue, but + there is some documentation on \url+glotex+ on + CTAN\index{CTAN@CTAN}. +\section{Multiple columns} +\label{multicols} +\index{columns} +Use the \package{multicol} package: the + environment is called \env{multicols} (note the + plural form) and it takes the number of columns as a separate + argument in curly braces: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage{multicol} +... +\begin{multicols}{3} +... +\end{multicols} + \end{Verbatim} +\end{sourcecode} +\begin{multicols}{3} +{\setlength{\parskip}{0pt}} +\LaTeX{} has built-in support for two-column typesetting + via the \verb+twocolumn+ option in the standard + Document Class Declarations, but it is relatively inflexible + in that you cannot change from full-width to double-column + and back again on the same page, and the final page does not + balance the column heights. However, it does feature special + \env{figure*} and \env{table*} + environments which typeset full-width figures and tables + across a double-column setting. + +The more extensive solution + is the \package{multicol} package, which will + set up to 10 columns, and allows the number of columns to be + changed or reset to one in mid-page, so that full-width + graphics can still be used. It also balances the height of + the final page so that all columns are the same height, and + you can control the width of the gutter by redefining the + \command{columnsep} command to a new dimension. + +The package provides the + \env{multicols} environment (note the extra + `s') and you follow the + begin-environment command with the number of columns needed + as a second argument: \verb+\begin{multicols}{5}+. +\end{multicols} +\chapter{Fonts and layouts} +\label{typo} +\index{typographics} +This is the chapter that most users want first, because they + come to structured documents from a wordprocessing environment + where almost the \emph{only} way to convey a + change of information is to fiddle with the font and size + drop-down menus. + +As I hope you have seen, this is normally completely + unnecessary in \LaTeX{}, which does most of the hard work for you + automatically. However, there are occasions when you need to + make manual typographic changes, and this chapter is about how + to do them. +\section{Changing layout} +\label{layouts} + +The design of the page can be a very subjective matter, + and also rather a subtle one. Many organisations large and + small pay considerable sums to designers to come up with page + layouts to suit their purposes. Styles in page layouts change + with the years, as do fashions in everything else, so what may + have looked attractive in 1989 may look rather dated in + 2003. + +As with most aspects of typography, making the document + readable involves making it consistent, so the reader is not + interrupted or distracted too much by apparently random + changes in margins, widths, or placement of objects. However, + there are a number of different occasions where the layout + usually \emph{does} change, related to the + frequency with which the format appears. +\begin{itemize} +\item +The title page (and the half-title, copyright page, + dedication, and other one-page preliminaries if you use + them) is usually designed individually, as the information + on it only occurs once in that format anywhere in the + document. + +\item +The table of contents and other related lists like + figures and tables probably all need to share one + design. + +\item +The prelims like Foreword, Introduction, and Preface + should likewise follow the same format between + them. + +\item +Chapter and Appendix start pages usually share a + layout. + +\item +Other (normal) pages have a single layout, but it may + specify individual variations to handle tables, lists, + figures, sidebars, exercises, footnotes, etc. + +\end{itemize} + +If you are going to design a whole document, it's + probably a good idea to read a couple of books on layout + design first, to get a feel for the conventions which + contribute to making the reader comfortable reading. + +While unusual or radical layouts have an important role in + attention-grabbing or making a socio-political statement + (\titlecite{wired} magazine is an obvious + recent example), they are usually out of place in business + reports, white papers, books, theses, and journals. In + ephemera, on the other hand, as in advertising, they are + probably critical. +\subsection{Spacing} +\label{spacing} +\index{page size!margins}\index{margins} +We mentioned in \S\thinspace\ref{marginals} and + elsewhere the existence of the + \package{geometry} package which lets you + change margins. It also lets you set the text-area height + and width and a lot of other layout settings: read the + documentation for details (see \S\thinspace\ref{packagedoc} for how to read package + documentation). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage[left=2cm,top=1cm,bottom=2cm,right=3cm, + nohead,nofoot]{geometry} + \end{Verbatim} +\end{sourcecode} + +The spacing around the individual textual components + (headings, paragraphs, lists, footnotes, etc.) can also be + changed on a document-wide basis, as we saw with paragraph + spacing and indentation in \S\thinspace\ref{paraspace}. + +Changing the spacing of section headings for the whole + document can be done with the + \package{sectsty} package, designed to let + you adjust section-head spacing without having to know about + the internal \LaTeX{} coding. The spacing for lists can be + adjusted with the \package{mdwlist} package. + In both cases the user with highly specific requirements + such as a publisher's Compositor's Specification + should read the relevant sections in the \titlecite{companion} or ask for expert help, as + there are many internal settings which can also be changed to + fine-tune your design, but which need some knowledge of + \LaTeX{}'s internals. + +All the above are for automating changes so that they + occur every time in a consistent manner. You can also make + manual changes whenever you need: +\index{space|see{white-space}}\begin{description} +\item[\sffamily Flexible vertical space]\index{white-space!vertical!flexible} +There are three preset commands + \command{smallskip}, + \command{medskip}, and + \command{bigskip}. These output flexible + (dynamic, or `rubber') space, + approximately 3pt, 6pt, and 12pt high respectively, + but they will automatically compress or expand a + little, depending on the demands of the rest of the + page (for example to allow one extra line to fit, or a + heading to be moved to the next page without anyone + except a typographer noticing the change). These + commands can only be used after a paragraph break (a + blank line or the command + \command{par}). +\item[\sffamily Fixed vertical space]\index{white-space!vertical!fixed}\index{white-space!vertical!disappearing} +For a fixed-height space which will + \emph{not} stretch or shrink, use the + command \command{vspace} followed by a length + in curly braces, e.g. + \verb+\vspace{18pt}+ (again, this has to be + after a paragraph break). Bear in mind that extra + space which ends up at a page-break when the document + is formatted will get discarded entirely to make the + bottom and top lines fall in the correct places. To + force a space to remain and be taken into account even + after a page break (rare), use the starred variant: + \command{vspace*}. +\item[\sffamily Double spacing]\index{white-space!double-spacing}\index{double-spacing} +Double-spacing normal lines of text is usually a + bad idea, as it looks very ugly. It is still, + unfortunately, a requirement in some universities for + thesis submission, a historical relic from the days of + typewriters. Nowadays, 1\Frac13 or 1½ line + spacing is considered acceptable, according to your + font size. If your institution still thinks they + should have double line spacing, they are quite simply + wrong. Show them this paragraph and explain that they + need to enter the 21st century and adapt to the + features of automated typesetting. If they still + insist, use the \package{setspace} + package,which has commands for double line-spacing and + one-and-a-half line spacing, but be prepared for some + very ugly output. + +The space between lines is defined by the length + of \command{baselineskip} multiplied by the + value of \command{baselinestretch}. In + general, \emph{don't meddle with + \command{baselineskip} at all}, + and with \command{baselinestretch} only if + you know what you are doing. (Both can, however, + safely be used as reference values in commands like + \verb+\vspace*{\baselineskip}+ to leave a + whole line space.) +\index{spacing|see{white-space}} +The value of \command{baselineskip} + changes with the font size (see \S\thinspace\ref{fontsize}) but is + conventionally set to 1.2 times the current nominal + font size. This is a value derived from long + experience: only change it if you understand what it + means and what effect it will have. +\index{spacing|see{double-spacing}} +Quite separately, there are some perfectly genuine + and acceptable reasons for wanting wide line spacing, + for example when typesetting a proof of a critical or + variorum edition, where editors and contributors are + going to want to add notes manually by writing between + the lines, or where the text is going to be + overprinted by something else like Braille, or in + advertising or display text for special + effects. +\item[\sffamily Horizontal space]\index{white-space!horizontal} +There is a horizontal equivalent to the + \command{vspace} command: + \command{hspace}, which works in the same + way, so I can force a 1$''$ space like + this{\hspace*{1in}}in + mid-paragraph. There are also some predefined + (shorter) spaces available: +\begin{itemize} +\item +\command{thinspace} (\Frac1{12}em), + which we saw between single and double quotes in + \S\thinspace\ref{thinspace}. It's also + sometimes used between the full point after + abbreviations and a following number, as in page + references like p.\thinspace{}199, where a word space + would look too big, and setting it solid would + look too tight. + +\item +\command{enspace} (½em). + There is no direct equivalent predefined in + \LaTeX{} for mid and thick spaces as used by metal + typesetters, although it would be possible to + define them. The en as a unit is often used as the + width of a single digit in some fonts, as a + convenience so that tables of figures are easy to + line up; + +\item +\command{quad} (1em); + +\item +\command{qquad} (2em). + +\end{itemize} +\index{tracking|see{letterspacing}}\index{letterspacing} +Beyond this, all horizontal space within + paragraphs is automatically flexible, as this is what + \LaTeX{} uses to achieve justification. Never be + tempted to try and change the spacing between letters + unless you have some professional training in + typography. Some systems use letterspacing + (incorrectly called `tracking') as an aid + to justification and it is almost always wrong to do + so (and looks it). While it \emph{is} + possible to change letterspacing, it should only be + done by a typographer, and then only very rarely, as + the settings are very subtle and beyond the scope of + this booklet. +\end{description} +\subsection{Headers and footers} +\label{runningheads} + +\LaTeX{} has built-in settings to control the page style + of its default page layouts. These are implemented with the + \command{pagestyle} command, which can take an + argument of \verb+plain+ (page number centered + at the bottom), \verb+empty+ (nothing at all), + or \verb+headings+ (running heads). The + value \verb+myheadings+ can be used + if you want to reprogram the definitions of how + \command{markright} and \command{markboth} + are used, which control how chapter and section titles get + into page headers. The command + \command{thispagestyle} (taking the same arguments) + can be used to force a specific style for the current page + only. + +The \package{fancyhdr} package lets you + redefine the left-hand, centre, and right-hand page headers + and footers for both odd and even pages (twelve objects in + all). These areas can contain a page number, fixed text, + variable text (like the current chapter or section title, or + the catch-words of a dictionary), or even a small image. + They can also be used to do page backgrounds and frames, by + making one of them the top corner of an invisible box which + `hangs' text or images down over the whole + page. + +The settings for the downloadable version of this + document can be used as an example: for the whole story you + have to read the documentation. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\pagestyle{fancy}\fancyhead{} +\renewcommand\headrulewidth{.1pt} +\fancyhead[LO,RE]{\footnotesize\sffamily\lite\leftmark} +\fancyhead[LE,RO]{\footnotesize\sffamily\lite\itshape\rightmark} +\fancyfoot[C]{} +\fancyfoot[LE,RO]{\setlength{\fboxsep}{2pt}\ovalbox{\footnotesize + \sffamily\thepage}} +\fancyfoot[LO,RE]{\footnotesize\sffamily\lite\@title} +\fancypagestyle{plain}{\fancyhf{} + \fancyfoot[R]{\setlength{\fboxsep}{2pt}\ovalbox{% + \footnotesize\sffamily\thepage}} + \fancyfoot[L]{\footnotesize\sffamily\lite\@title} + \renewcommand{\headrulewidth}{0pt}} + \end{Verbatim} +\end{sourcecode} + +This is probably more complex than most documents, but + it illustrates some of the most common techniques: +\begin{enumerate}\item +Settings are prefixed by making the + \command{pagestyle} `fancy' and + setting the \command{fancyhead} to null. + +\item +The thickness of the rule at the top of the page can + be changed (or set to 0pt to make it disappear). + +\item +The header and footer settings are specified with L, + C, and R for left, centre, and right; and with O and E for + Odd and Even numbered pages. In each setting, the typeface + style, size, and font can be specified along with macros + which implement various dynamic texts (here, the current + chapter and section titles, which \LaTeX{} stores in + \command{rightmark} and + \command{leftmark}). + +\item +The `plain' variant is used for chapter + starts, and resets some of the parameters accordingly. + +\end{enumerate} +\section{Using fonts} +\label{fontuse} +\index{fonts!in general} +The default typeface in \LaTeX{} is Computer Modern (CM)\index{CM@CM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CM@CM|textbf}. This typeface was + designed by Knuth for use with \TeX{} because it is a book + face, and he designed \TeX{} originally for typesetting books. + Because it is one of the very few book typefaces with a + comprehensive set of fonts, including a full suite of + mathematics, it has remained the default, rather than Times, + because until recently the mathematical symbols for Times were + a commercial product often unavailable to users of free + software. + +\index{fonts!\mf{}}\index{fonts!Computer Modern}{\fontencoding{OT1}\fontfamily{cmr}\fontsize{11pt}{11pt}\selectfont{}Computer Modern is based on a 19th-century + book typeface from Monotype, which is why it looks a little + like an old-fashioned school book. This paragraph is set in + Computer Modern so you can see what it looks like. The + typeface is written in \mf{}, a font-drawing program + made by Knuth to accompany \TeX{} systems.} +\begin{warning} + +If you are reading this in the HTML version, the above + paragraph is only a low-resolution copy because browsers + don't usually have the Computer Modern font available. + All the rest of this document is set in \rmfontfamilyname{}, with + \sffontfamilyname{} for some of the headings and \ttfontfamilyname{} for the + fixed-width type. +\end{warning} +\begin{table}\index{fonts!examples}\caption{Fonts available with a full installation of + \LaTeX{}. There are many more available for download from + CTAN\index{CTAN@CTAN}.} +\label{fontable} +\begin{center} +\begin{tabular}{ll>{\sffamily}l>{\ttfamily}l}\multicolumn{1}{>{\bfseries\pbs{\raggedright}}b{23mm}}{\normalfont\bfseries\upshape Typeface (font family)}&\textbf{\normalfont\bfseries\upshape Example}&\textbf{\normalfont\bfseries\upshape Package}&\textbf{\normalfont\bfseries\upshape Family}\\[2pt]\hline\\[-.95\baselineskip] +\multicolumn{4}{c}{\vrule height1.5em width0pt\bfseries\itshape \mf{} fonts}\\[2pt] +\llap{* }Computer Modern&{\alphabet{cmr}}&\llap{(}default)&cmr\\ +CM\index{CM@CM} Sans&{\alphabet{cmss}}&\llap{(}default)&cmss\\ +CM\index{CM@CM} Typewriter&{\alphabet{cmtt}}&\llap{(}default)&cmtt\\ +Pandora&{\alphabet{panr}}&pandora&panr\\ +Pandora Sans&{\alphabet{pss}}&pandora&pss\\ +Universal&{\fontencoding{OT1}\fontfamily{uni}\selectfont + The quick brown fox jumps over + the lazy}&\mdash{}&uni\\ +\llap{* }Concrete&{\alphabet{ccr}}&concrete&ccr\\ +BB Dingbats&{\tiny\alphabet[U]{ding}}&\mdash{}&ding\tablefootnote{uenc}\\ +Cypriot&{\fontsize{5}{10}\selectfont + \alphabet{cypr}}&\mdash{}&cypr\\ +É{\fontfamily{cmr}\selectfont\i}reannach&{\fontencoding{OT1}\fontfamily{eiad}\selectfont + N\'{\char'151}l aon tinteán mar do thinteán + féin}&eiad&eiad\\ +Etruscan&{\scriptsize\alphabet{etr}}&\mdash{}&etr\\ +Linear `B'&{\tiny\alphabet{linb}}&\mdash{}&linb\\ +Phoenician&{\shortalphabet{phnc}}&\mdash{}&phnc\\ +Runic&{\fontencoding{OT1}\fontfamily{fut}\selectfont + THE QUICK BROWN FOX JUMPS OVER THE}&\mdash{}&fut\\ +Rustic&{\tiny\alphabet{rust}}&\mdash{}&rust\\ +Bard&{\tiny\alphabet[U]{zba}}&\mdash{}&zba\\ +Uncial&{\tiny\alphabet{uncl}}&\mdash{}&uncl\\ +Dürer&{\fontencoding{OT1}\fontfamily{zdu}\selectfont + THE QUICK BROWN FOX JUMPS OVER THE}&\mdash{}&zdu\\ +Fraktur&{\dalphabet[U]{yfrak}}&\mdash{}&yfrak\tablefootnote{uenc}\\ +Gothic&{\dalphabet[U]{ygoth}}&\mdash{}&ygoth\tablefootnote{uenc}\\ +Schwäbische&{\dalphabet[U]{yswab}}&\mdash{}&yswab\tablefootnote{uenc}\\ +\multicolumn{4}{c}{\vrule height1.5em width0pt\bfseries\itshape Adobe fonts}\\[2pt] +Bookman&{\alphabet{pbk}}&bookman&pbk\\ +Schoolbook&{\alphabet{pnc}}&newcent\tablefootnote{addhelv}&pnc\\ +Palatino&{\alphabet{ppl}}&palatino\tablefootnote{addag}&ppl\\ +\llap{\dag }Times&{\alphabet{ptm}}×\tablefootnote{addhelv}&ptm\\ +Avant Garde&{\alphabet{pag}}&avant&pag\\ +Helvetica&{\alphabet{phv}}&helvet&phv\\ +Zapf Chancery&{\fontencoding{OT1}\fontfamily{pzc}\itshape + \selectfont The quick brown fox jumps over the lazy + dog}&zapfchan&pzc\\ +Courier&{\fontencoding{OT1}\fontfamily{pcr}\selectfont + The quick brown fox jumps over the + lazy}&courier&pcr\\ +Zapf Dingbats&{\scriptsize\alphabet[U]{pzd}}&pifont&pzd\tablefootnote{uenc}\\ +Symbol&{\alphabet[U]{psy}}&\mdash{}&pzd\tablefootnote{uenc}\\ +\multicolumn{4}{c}{\vrule height1.5em width0pt\bfseries\itshape X Consortium fonts}\\[2pt] +Charter&{\alphabet{bch}}&charter&bch\\ +Nimbus Roman&{\alphabet{unm}}&\mdash{}&unm\\ +Nimbus Sans&{\alphabet{unms}}&\mdash{}&unms\\ +URW Antiqua&{\alphabet{uaq}}&\mdash{}&uaq\\ +URW Grotesk&{\bfseries\alphabet{ugq}}&\mdash{}&ugq\\ +Utopia&{{\fontencoding{OT1}\fontfamily{put}\selectfont{}(removed from \TeX{} + Live as it is not a free font)}}&utopia&put\\ +\end{tabular} +\renewcommand{\theenumi}{\textit{\alph{enumi}}}\footnotesize\begin{enumerate*}\item Uses specialised font encoding `U'.\label{uenc}\item Uses Helvetica as the sans-serif + font and Courier for monospace. Full names are + `New Century Schoolbook' and + `Times New Roman'.\label{addhelv}\item Uses Avant Garde as the + sans-serif font and Courier for monospace.\label{addag}\end{enumerate*}\par\smallskip\footnotesize +\begin{itemize*} +\item [\sffamily *] Full selection of mathematical symbols + available. +\item [\sffamily \dag ] Mathematical symbols available + both free and commercially. +\end{itemize*} +\end{center} +\end{table} + +In addition to CM\index{CM@CM}, there are + many other \mf{} fonts which can be downloaded from + CTAN\index{CTAN@CTAN}, including a large collection + of historical, symbol, initial, and non-Latin fonts. \LaTeX{} + also comes with the complete `Adobe 35' + collection of typefaces which are built into every laser + printer, so you have the same base set as other DTP\index{DTP@DTP} systems. There are some more fonts + included in PostScript\index{PostScript} Type 1 + format donated by the X Consortium which match those + distributed free with the X Window system. Plus, of + course, standard \LaTeX{} can use any of the thousands of + Type 1 fonts, and \product{pdflatex} can + use any of the thousands of TrueType fonts as well. +\index{fonts!TrueType}\index{fonts!metafont@\mf{}}\index{fonts!PostScript}\index{fonts!Type 1}\begin{warning} + +Just to make it clear: standard \LaTeX{} uses \mf{} + and PostScript\index{PostScript} Type 1 fonts + only. To use TrueType fonts as well, you must use + \product{pdflatex} instead. +\end{warning} +\subsection{Changing the default font family} +\index{fonts!changing the default} +\LaTeX{} expects to work with three font families as + defaults: +\index{fonts!families}\begin{center} +\begin{tabular}{l>{\ttfamily}l}\textbf{\normalfont\bfseries\upshape Font family}&\textbf{\normalfont\bfseries\upshape Code}\\[2pt]\hline\\[-.95\baselineskip] +Roman (serif, with tails on the uprights), the + default&rm\\ +Sans-serif, with no tails + on the uprights&sf\\ +Monospace (fixed-width or + typewriter)&tt\\ +\end{tabular} +\end{center} + +If you use one of the packages listed in Table~\ref{fontable}, it will replace the default of the + same type. For example, + \verb+\usepackage{bookman}+ makes the default + Roman font Bookman but leaves the sans-serif and monospace + fonts untouched. Equally, + \verb+\usepackage{helvet}+ changes the default + sans-serif font to Helvetica but leaves the serif (Roman) + and monospace fonts untouched. Using both commands will + change both defaults because they operate independently. + \emph{However}\dots as it is common to want + to change all three defaults at the same time, some of the + most common `suites' of typefaces are + provided as packages: +\begin{description} +\item[\sffamily \package{times}] +changes to Times/Helvetica/Courier. +\item[\sffamily \package{pslatex}] +same as \package{times} but uses a + specially narrowed Courier to save space (normal + Courier is rather inelegantly wide). This is the + preferred setting if you want Times.\footnote{The \package{pslatex} package + is also said to be outdated by some experts + because it implemented rather long-windedly what + can now be done in three commands. However, until + these replace the current version, I recommend + continuing to use \package{pslatex} + when you want Times with Helvetica and + Courier.} +\item[\sffamily \package{newcent}] +changes to New Century Schoolbook/Helvetica/Courier. +\item[\sffamily \package{palatino}] +changes to Palatino/Avant Garde/Courier. +\item[\sffamily \package{palatcm}] +changes the roman to Palatino only, but with + CM\index{CM@CM} mathematics +\end{description} + +Where no package name is given in Table~\ref{fontable}, it means the font is rarely used as + a default by itself except in special cases like users' own + homebrew packages. To use the font you have to specify it + manually, or make a little macro for yourself if you use it + more than once, as shown below. +\subsection{Changing the font family temporarily} +\label{fontfam} +\index{fonts!changing temporarily} +To shift to another font family on a temporary basis, + group the text within curly braces to limit the scope of the + font change, and use the commands + \command{fontencoding} (if needed), + \command{fontfamily}, and + \command{selectfont} commands \emph{immediately + inside} the opening curly brace, e.g. +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +{\fontfamily{phv}\selectfont Helvetica looks like this} +and {\fontencoding{OT1}\fontfamily{ppl} Palatino looks +like this}. + \end{Verbatim} +\end{sourcecode}\leavevmode\enspace +\begin{quote}\noindent +{\fontencoding{OT1}\fontfamily{phv}\selectfont{}Helvetica + looks like this} and {\fontencoding{OT1}\fontfamily{ppl}\selectfont{}Palatino looks like + this}.\end{quote}\end{example} + +In this example, the \command{fontencoding} + command has been used to ensure that the typeface will work + even if the sentence is used in the middle of something + typeset in a different encoding (like this document). +\begin{sidebar}\label{grouping} +\subsection*{Grouping}\index{grouping} +Notice the use of curly braces in a slightly different + way from their use to delimit the argument to a command. + This is called `grouping' and it + restricts the effect of changes made + \emph{inside} the group so that they do not + interfere with the text following. Any font changes made + within the curly braces cease when the closing curly brace + is processed. +\end{sidebar} +In a normal document, of course, random typeface changes + like this are very uncommon. You select your faces once at + the start of the document, and stick with them. Most cases + where people want to do unusual typeface changes involve + things like special symbols on a repetitive basis, and + \LaTeX{} provides much easier programmable ways to make these + changes into shorthand commands (called macros: see \chaptername~\ref{macros}). You could, for example, make a macro + called \command{product} which would let you + typeset product names in a distinct typeface: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +Andlinger has replaced \product{Splosh} with \product{SuperSplosh} + \end{Verbatim} +\end{sourcecode} + +This is one of \LaTeX{}'s most powerful features. It + means that if you needed to change your + \command{product} command at some later stage to + use a different font, you only have to change three + characters in the macro (the font family abbreviation), and + you don't need to edit your document text at + all! +\subsection{Changing font style} +\index{fonts!styles} +Within each typeface or font family there are usually + several different styles of type. \LaTeX{} distinguishes + between font \textbf{\textit{family}}\index{family@\textbf{\textit{family}}}, font + \textbf{\textit{shape}}\index{shape@\textbf{\textit{shape}}}, and font + \textbf{\textit{series}}\index{series@\textbf{\textit{series}}}: +\begin{center} +\begin{tabular}{l>{\ttfamily}ll}\textbf{\normalfont\bfseries\upshape Type style}&\textbf{\normalfont\bfseries\upshape Command}&\textbf{\normalfont\bfseries\upshape Example (using Computer Modern)}\\[2pt]\hline\\[-.95\baselineskip] +Upright (default)&\command{upshape}*&{\alphabet{cmr}}\\ +Italic&\command{itshape}&{\font\foo=cmti10 \foo + The quick brown fox jumps over the lazy dog}\\ +Slanted&\command{slshape}*&{\slshape\alphabet{cmr}}\\ +Small Capitals&\command{scshape}*&{\scshape\alphabet{cmr}}\\ +Bold&\command{bfseries}*&{\fontseries{b}\selectfont\alphabet{cmr}}\\ +Bold Extended&\command{bfseries}\dag &{\font\foo=cmbx10 \foo + The quick brown fox jumps over the lazy dog}\\ +Sans-serif&\command{sffamily}&{\alphabet{cmss}}\\ +Monospace&\command{ttfamily}&{\alphabet{cmtt}}\\ +\end{tabular} +\par\smallskip\footnotesize +\begin{itemize*} +\item [\sffamily *] Not all typefaces have all + variants! Some only have bold and italics. +\item [\sffamily \dag ] Some typefaces do not have + both bold and bold extended: by default \LaTeX{} uses + \command{bfseries} for bold extended. +\end{itemize*} +\end{center} + +These `shape', + `series', and + `family' commands are + \textbf{\textit{commutative}}\index{commutative@\textbf{\textit{commutative}}}, so you can combine a + shape with a series and/or a family, as in: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +...{\bfseries\itshape\sffamily bold italic sans-serif type}... + \end{Verbatim} +\end{sourcecode} + +This gives you {\sffamily{}\fontseries{bx}\fontshape{it}\selectfont{}bold italic sans-serif type}, but + beware of pushing your fonts beyond their limits unless you + are a typographer. It is not normally meaningful to combine + one shape or series class with another of the same class, + such as trying to get slanted-italics. It's an + impossibility to combine one family with another (such as a + seriffed sans-serif typeface!). Slanted plus italics, for + example, doesn't make sense, as italics are already + slanted (although it is technically possible); and while some + typefaces may well possess italic small caps, they are not + in common use. Sans-serif and monospace (typewriter) are + different fonts, and often different typeface families + entirely.\footnote{Although if you're a typographer wanting to + experiment with typewriter typefaces with and without + serifs, you can use \mf{} to do exactly this kind + of thing. But that's outside the scope of this + document.} + +There is an alternative syntax for the most common type + shape and series commands which uses curly braces in the + normal `argument' manner: +\begin{center} +\label{fontcmds} +\begin{tabular}{l>{\ttfamily}ll}\textbf{\normalfont\bfseries\upshape Type style}&\textbf{\normalfont\bfseries\upshape Command}&\textbf{\normalfont\bfseries\upshape Example}\\[2pt]\hline\\[-.95\baselineskip] +Italic&\verb+\textit{a few words}+&puts {\font\foo=cmti10 \foo a few + words} into italics\\ +Slanted&\verb+\textsl{a few words}+&puts {\fontencoding{OT1}\fontfamily{cmr}\fontshape{sl}\selectfont{}a few + words} into slanted type*\\ +Small Capitals&\verb+\textsc{a few words}+&puts {\fontencoding{OT1}\fontfamily{cmr}\fontshape{sc}\selectfont{}a few + words} into small caps\\ +Bold&\verb+\textbf{a few words}+&puts {\fontencoding{OT1}\fontfamily{cmr}\fontseries{b}\selectfont{}a few + words} into bold type\\ +Sans-serif&\verb+\textsf{a few words}+&puts {\fontencoding{OT1}\fontfamily{cmss}\selectfont{}a few + words} into sans-serif type\\ +Monospace&\verb+\texttt{a few words}+&puts {\fontencoding{OT1}\fontfamily{cmtt}\selectfont{}a few + words} into typewriter type\\ +\end{tabular} +\par\smallskip\footnotesize +\begin{itemize*} +\item [\sffamily *] If slanted is available separately + from italics. +\end{itemize*} +\end{center} + +You can nest these inside one another too: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +...\textbf{\itshape\textsf{bold italic sans-serif type}}... + \end{Verbatim} +\end{sourcecode} +\subsection{Font sizes} +\label{fontsize} +\index{fonts!sizes} +\LaTeX{} has built into its defaults a set of predefined + font size steps corresponding more or less to the + traditional sizes available to metal typesetters. This is + deliberate, as these sizes have grown up over 500 years of + printing as those which go best together for book-work, + which is where \TeX{} originated. + +These sizes are also reflected in the size steps at + which Computer Modern was designed. It often comes as a + surprise to new users that many typefaces are not designed + as a single font and just scaled up or down, but specially + drawn at different sizes to make them more legible. + +As an example, {\fontencoding{OT1}\fontfamily{cmr}\fontsize{11}{11}\selectfont{}here's 11pt Computer + Modern}, and {\font\cmbig=cmr5 + at11pt\cmbig here's 5pt Computer Modern scaled up to + 11pt}, and + {\font\cmsmall=cmr17 at11pt\cmsmall + here's 17pt Computer Modern scaled down to + 11pt} so you can see there really is a + significant difference. In general, you probably don't + want to go scaling fonts too much beyond their design size + because they will start to look very odd. + +The default sizes (and the commands that operate them) + are based on the use of a 10pt font. Using the larger + defaults (11pt and 12pt) for the body font will scale these + sizes up approximately in proportion. The exact sizes used + are listed in the macros in the Class Option files + \url+size10.clo+, + \url+size11.clo+ and + \url+size12.clo+. \TeX{}'s default fonts + above 10pt are in fact scaled by a factor of 1.2, as shown + in the fourth column of the table below. +\begin{center} +\begin{tabular}{llrl}\textbf{\normalfont\bfseries\upshape Command}&\textbf{\normalfont\bfseries\upshape Example}&\multicolumn{1}{>{\bfseries\pbs{\raggedleft}}b{.5in}}{\normalfont\bfseries\upshape Nominal point size}&\multicolumn{1}{>{\bfseries\pbs{\raggedright}}b{.4in}}{\normalfont\bfseries\upshape Exact point size}\\[2pt]\hline\\[-.95\baselineskip] +\command{tiny}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{5}{5}\selectfont{}The quick brown fox jumps over + the lazy dog}&5&5\\ +\command{scriptsize}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{7}{7}\selectfont{}The quick brown fox jumps over + the lazy dog}&7&7\\ +\command{footnotesize}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{8}{8}\selectfont{}The quick brown fox jumps + over the lazy dog}&8&8\\ +\command{small}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{9}{9}\selectfont{}The quick brown fox jumps over + the lazy dog}&9&9\\ +\command{normalsize}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{10}{10}\selectfont{}The quick brown fox jumps + over the lazy dog}&10&10\\ +\command{large}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{12}{12}\selectfont{}The quick brown fox jumps + over the lazy}&12&12\\ +\command{Large}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{14}{14}\selectfont{}The quick brown fox jumps + over t}&14&14.40\\ +\command{LARGE}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{18}{18}\selectfont{}The quick brown fox jumps + o}&18&17.28\\ +\command{huge}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{20}{20}\selectfont{}The quick brown fox + jum}&20&20.74\\ +\command{Huge}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{24}{24}\selectfont{}The quick brown + fox}&24&24.88\\ +\end{tabular} +\end{center} + +While this relieves the beginner of having + to worry about the `right' size for a + given task, when you need a specific size there is the + \command{fontsize} command: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\fontsize{22}{28}\selectfont This is 22pt type 6pt leaded + \end{Verbatim} +\end{sourcecode} + +This takes two arguments: the point size and the + baseline distance. The above example gives you 22pt type on + a 28pt baseline (i.e. with 6pt extra space or + `leading' between lines). +\begin{warning} + +Computer Modern fonts (the default) come fixed at the + named size steps shown in the table, and if you try to use + an odd size in between, \LaTeX{} will pick the closest step + instead. If you really need to use CM\index{CM@CM} at arbitrary sizes there is a + package \package{type1cm} which lets you + override the default steps. If you use PostScript\index{PostScript} + (Type 1) fonts, the step sizes do not apply and the + font scaling is infinitely variable. +\end{warning} +\subsection{Logical markup} + +All this playing around with fonts is very pretty but + you normally only do it for a reason, even if that reason is + just to be decorative. Italics, for example, are used for + many things: +\begin{center} +\begin{tabular}{l>{\itshape}l}\textbf{\normalfont\bfseries\upshape Cause}&\textbf{\normalfont\bfseries\upshape Example}\\[2pt]\hline\\[-.95\baselineskip] +Foreign words&ex officio\\ +Scientific names&Ranunculus ficaria\\ +Emphasis&must not\\ +Titles of documents&The \LaTeX{} Companion\\ +Product names&{{\upshape + Corel's}} WordPerfect\\ +Variables in maths&\(E=mc^{2}\)\\ +Subtitles or headings&How to get started\\ +Decoration&FREE UPGRADE!!!\\ +\end{tabular} +\end{center} + +Humans usually have no problem telling the difference + between these reasons, because they can read and understand + the meaning and context. Computers cannot (yet), so it has + become conventional to use descriptive names which make the + distinction explicit, even though the appearance may be the + same. + +\LaTeX{} has some of these built in, like + \command{emph}, which provides + \emph{emphasis}. This has a special feature + because \emph{when the surrounding text is + already italic, \emph{emphasis} + automatically reverts to upright type}, which is a + normal practice for typesetting. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +This has a special feature because {\itshape when the surrounding +text is already italic, \emph{emphasis} automatically reverts to +upright type, which is a normal practice for typesetting. + \end{Verbatim} +\end{sourcecode} + +\label{emph}% +This sensitivity to logic is programmed into + the definition of \command{emph} and it's not + hard to make up other commands of your own which could do + the same, such as \command{foreign} or + \command{product}. + +But why would you bother? In a short document it's + probably not important, but if you're writing a long + report, or a formal document like an article, a book, or a + thesis, it makes writing and editing hugely easier if you + can control whole groups of special effects with a single + command, such as italicising, indexing, or cross-referencing + to a glossary. If a format needs changing, you only have to + change the definition, and every occurrence automatically + follows suit. + +It also makes it possible to find and act on groups of + meanings\mdash{}such as making an index of scientific names + or product names (as in this document)\mdash{}if they are + identified with a special command. Otherwise you'd + spend weeks hunting manually through every + \command{textit} command to find the ones you + wanted. This is the importance of automation: it can save + you time and money. + +In \chaptername~\ref{macros} we will see how to make your + own simple commands like this. +\subsection{Colour} +\index{colour}\index{fonts!colour} +You can typeset anything in \LaTeX{} in any colour you + want using the \package{color} package. + First, you need to add the command + \verb+\usepackage{color}+ to your preamble (note + the US spelling of color!). This makes available a default + palette of primary colours: {\selectfont{}\color{red}red}, {\selectfont{}\color{green}green}, and {\selectfont{}\color{blue}blue} for the RGB\index{RGB@RGB} colour model used for emitted light + (television screens), and {\selectfont{}\color{cyan}cyan}, + {\selectfont{}\color{magenta}magenta}, and {\selectfont{}\color{yellow}yellow} to go with black for the + CMYK\index{CMYK@CMYK} colour model used for reflected light + (printing). + +For the occasional word or phrase in colour, use the command + \command{textcolor} with two arguments, the colour + name and the text: \verb+\textcolor{red}{like this}+. + There is a \command{color} command as well, for use + within groups: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +...{\color{blue}some text in blue}... + \end{Verbatim} +\end{sourcecode} + +If you have the PostScript\index{PostScript} printer driver + \product{dvips} installed, you also get a + separate 64-colour palette of predefined names + (representing approximately the colours in the big box of + \product{Crayola} colouring pencils much + favoured by artists and designers). This adds a new colour + model called + \verb+named+, so if you want the + \product{Crayola} colour RubineRed, you can + create a name of your own for it to use in colour-changing + commands: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\definecolor{myred}{named}{RubineRed} + \end{Verbatim} +\end{sourcecode} + +RubineRed looks {\selectfont{}\color{myred}like + this} (\verb+\textcolor{myred}{like this}+) if you're reading this in colour. + To use these names with + \product{pdflatex}, you need to use the + \opt{pdftex} option to the + \package{color} package. You can still look up the CMYK\index{CMYK@CMYK} codes in the file + \url+texmf/tex/latex/graphics/dvipsnam.def+ + and use \verb+cmyk+ as the colour model name, + if you have software which requires it. In that case you + would say: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\definecolor{myred}{cmyk}{0,1,0.13,0} + \end{Verbatim} +\end{sourcecode} + +You can define any shade you want by giving it a + name and providing the Red-Green-Blue (RGB)\index{RGB@RGB|textbf}\index{Acronyms@\textbf{Acronyms}, defined!RGB@RGB|textbf} or Cyan-Magenta-Yellow-Black (CMYK)\index{CMYK@CMYK|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CMYK@CMYK|textbf} colour + values expressed as decimals, using this + \command{definecolor} command. For example, an + RGB\index{RGB@RGB} shade given as (37,125,224) in + decimal (\#250FE0 in hexadecimal as used on the Web) + needs to be given as \begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\definecolor{midblue}{rgb}{0.145,0.490,0.882} + \end{Verbatim} +\end{sourcecode} + (divide each value by 255, the maximum for + each of the hues in the Red-Green-Blue colour model). The + \command{definecolor} command takes three + arguments: the name you want to refer to the shade by; the + name of the color model (here \verb+rgb+) and + the set of decimal-fraction values separated by commas. You + can then use \command{textcolor} with your new + colour name: {\selectfont{}\color{midblue}the midblue looks like + this if you're reading in colour.} + +The \package{color} package also provides + a colour version of \command{fbox} (see \S\thinspace\ref{fbox}) called + \command{colorbox}: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\colorbox{midblue}{\color{magenta}Magenta on midblue} + \end{Verbatim} +\end{sourcecode} + +{\colorbox{midblue}{\color{magenta}Magenta + on midblue}}: you can see how careful you + need to be with colours. +\section{Installing new fonts} +\label{instfonts} +\index{fonts!installing} +Different fonts come in a variety of packagings: the three + most common used with \TeX{} systems are + PostScript\index{PostScript} fonts, TrueType fonts, and + \mf{} fonts. How you install them and where they go + depends on how you installed \LaTeX{}: all I can deal with here + are the standard locations within the TDS\index{TDS@TDS}. + +Most typefaces come supplied as one or more font files. + PostScript\index{PostScript} fonts are supplied as a pair + of files: an outline and a metric, as described in \S\thinspace\ref{mffonts} and + \S\thinspace\ref{psfonts}. A TrueType font combines these in a + single file. For \LaTeX{} use you also need a style + (\url+.sty+) file and font definition + (\url+.fd+), which can easily be created if + they are not supplied. + +The instructions here assume the use of the New Font Selection Scheme (NFSS)\index{NFSS@NFSS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!NFSS@NFSS|textbf} used in + \LaTeXe{}. If you are running the obsolete \LaTeX{} 2.09, + upgrade it now. +\subsection{Installing \mf{} fonts} +\label{mffonts} + +This is the simplest installation. When you download + \mf{} fonts from CTAN\index{CTAN@CTAN}, + you'll usually find a large number of Outline files + (\url+.mf+ files) and maybe some other types + as well (see below). +\begin{enumerate} +\item \label{newsub}% +Create a new subdirectory named after the typeface + you're installing in + \url+texmf-local/fonts/source/public/+: +\begin{center} +\includegraphics[width=0.75\textwidth]{public} +\end{center} +\item +Copy all the \url+.mf+ (outline) + files to this directory. +\item +Copy the \url+.fd+ (Font Definition) + file[s] and the \url+.sty+ (style) file + to your \url+texmf/tex/latex/mfnfss+ + directory. +\item +Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}). +\end{enumerate} + +That's it. Unlike PostScript\index{PostScript} + fonts, \mf{} fonts can be used to generate the font + metric file (\url+.tfm+ files) automatically + on-the-fly the first time the typeface is used, so there + should be nothing else to install. Some \mf{} fonts + come with pre-generated \url+.tfm+ files + which you can install if your system is slow at generating + them itself: +\begin{enumerate} +\addtocounter{enumi}{\thehold}\item +Create a new subdirectory within + \url+texmf-local/fonts/tfm/public/+ named + the same as the one you created for the + \url+.mf+ files above. +\item +Copy all the \url+.tfm+ files into + this subdirectory. +\item +Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}). +\end{enumerate} +\setcounter{hold}{\theenumi} +In some rare cases, pre-generated packed bitmap fonts + (\url+.pk+ files) are also available from + CTAN\index{CTAN@CTAN} (normally your previewer and + print driver creates these automatically, but you can use + the pre-generated ones if you have a very slow system). If + you really want to install these, it's a similar + procedure to the \url+.tfm+ files: +\begin{enumerate} +\addtocounter{enumi}{\thehold}\item +Create a new subdirectory within + \url+texmf-local/fonts/pk/modeless/+ + named the same as the one you created for the + \url+.mf+ and \url+.tfm+ + files above. +\item +Copy all the \url+.nnnpk+ files into + this subdirectory (\(nnn\) is a + number reflecting the dot-density of the bitmap). On + Microsoft systems the files may just end in + \url+.pk+ and be kept in subdirectories + named after the dot-density, e.g. + \url+dpi360+. +\item +Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}). +\end{enumerate} +\setcounter{hold}{\theenumi} +Now you can put a \command{usepackage} command + in your preamble with whatever name the + \verb+.sty+ file was called, and read the + documentation to see what commands it gives to use the font + (refer to \S\thinspace\ref{packinst} and step~\ref{dtxdoc} in the procedure on p.\thinspace\pageref{dtxdoc}). + +If the font came \emph{without}\url+.fd+ or \url+.sty+ files, + you'll need to find someone who can make them for you (or + follow the outline in \S\thinspace\ref{psfonts}, step~\ref{fdfiles} in the procedure on p.\thinspace\pageref{fdfiles}). +\subsection{Installing PostScript fonts} +\label{psfonts} +\index{fonts!PostScript} +Lots of people will tell you that + PostScript\index{PostScript} fonts and PostScript + output are dead and that TrueType or OpenType fonts and PDF + output are the way to go. While this is true for many cases, + standard \LaTeX{} does not work with TrueType fonts and does + not produce PDF\index{PDF@PDF} directly. Only + \product{pdflatex} does that, and there are + still many printers whose typesetters and platemakers need + PostScript\index{PostScript} rather than PDF\index{PDF@PDF}. In addition, operating system + support for scalable fonts is still very poor on Unix + systems (including Linux), despite the advances in recent + years, so in many cases it still makes sense to use + \TeX{}'s built-in support for PostScript. + +PostScript (Adobe Type 1) fonts come in two halves, + just like \mf{} fonts: a Font Metric and an Outline. + Unlike \mf{} fonts, however, you must install both: you + cannot cause the the metrics to be generated from the + outline as you can with \mf{}. + +The two file types are \url+.afm+ (Adobe + Font Metric) and \url+.pfb+ + (PostScript Font Binary (PFB)\index{PFB@PFB|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PFB@PFB|textbf}) files. + \emph{You must have both for each font before you + start.} If you only have the near-obsolete + \url+.pfa+ (PostScript\index{PostScript} + Font ASCII\index{ASCII@ASCII}) files, it may be + possible to generate the \url+.pfb+ files + using the \product{t1binary} program from + the \product{t1utils} package (see \url+http://gnuwin32.sourceforge.net/packages/t1utils.htm+) + or the excellent \product{PFAedit} font + editor (from \url+http://pfaedit.sourceforge.net+). There are + unfortunately still some companies distributing Type 1 + fonts in \url+.pfa+ format (Mathematica is + one reported recently). +\begin{warning} + +The installation method I described in earlier + editions has worked perfectly for me for years, but I have + updated it here to use the facilities of the + \product{updmap} program (which comes + with your \TeX{} installation). This removes the need for + one of the steps I gave before, which required editing the + \url+psfonts.map+ file, as this is now + recreated by \product{updmap}. The + procedure below is \emph{not} the official + way (that's \product{fontinst}), but + it is the basis for a script I am working on called + \product{Gutta-Percha}\footnote{Yes, as in rubber.}, which automates the whole process. +\end{warning} + +I'll repeat this: before you start, make sure you + have all the \url+.afm+ and + \url+.pfb+ files for the typeface you want. + In the example below, I'm going to use a single font + from an imaginary typeface called Foo, so I have + \verb+foo.afm+ and + \verb+foo.pfb+ files. +\begin{enumerate} +\item \textbf{Put the files in your temporary directory}\\ +This is \url+/tmp+ on Linux, and + should be \url+C:\tmp+ or + \url+C:\temp+ or even + \url+C:\Windows\temp+ on Microsoft + Windows. +\item \textbf{Find out or decide on the short font name to use + inside \LaTeX{}.}\\ +This is \emph{not} the full + descriptive name (e.g. Baskerville Italic Bold + Extended) but an encoded font name in the format + \verb+fnnsseec+, devised by \person{Karl Berry}, which stores the same information in no + more than eight characters for compatibility with + systems which cannot handle long filenames. The letters + in the format above have the following meanings (see the + \product{fontname} documentation for + more details): +\begin{center} +\begin{tabular}{lll}\textbf{\normalfont\bfseries\upshape Letter}&\textbf{\normalfont\bfseries\upshape Meaning}&\textbf{\normalfont\bfseries\upshape Examples}\\[2pt]\hline\\[-.95\baselineskip] +\verb+f+&foundry&\verb+b+=Bitstream, + \verb+m+=Monotype, + \verb+p+=Adobe (PostScript)\\ +\verb+nn+&typeface name&\verb+ba+=Baskerville, + \verb+tm+=Times, + \verb+pl+=Palatino\\ +\verb+ss+&series/shape&\verb+r+=roman, + \verb+bi+=bold italic, etc.\\ +\verb+ee+&encoding&\verb+8a+=default 8-bit + ANSI, \verb+ly+=Y\amp Y's + \TeX{}'n'ANSI\\ +{\fontseries{b}\selectfont{}\verb+c+}&[small]caps&(this is a literal + `c' character, used only + if needed)\\ +\end{tabular} +\end{center} + +The \url+texmf/fontname+ directory in + your installation of \LaTeX{} has files for several foundries + giving fully-formed names like these for common fonts + (e.g. \verb+ptmr8a+ is + [Adobe] \uline{\textbf{P}}ost\-Script + \uline{\textbf{T}}i\uline{\textbf{m}}es + \uline{\textbf{R}}oman in an + \uline{\textbf{8}}\ndash{}bit \uline{\textbf{A}}NSI + encoding; + \verb+bgslly+ is \uline{\textbf{B}}itstream + \uline{\textbf{G}}ill \uline{\textbf{S}}ans + \uline{\textbf{L}}ight in Y\amp Y's \TeX{}'n'ANSI + encoding [\uline{\textbf{LY}}1]).\footnote{Confusingly, Bitstream fonts (and others from + similar sources) mostly have different names from + the original fonts, so what they call Humanist 521 + is actually Gill Sans. Until recently, US law only + allowed the \emph{names} of typefaces + to be copyrighted, not the font designs themselves, + leading to widespread piracy.} Read the documentation in \titlecite{fontname} + to find out how to make up your own short + names if the foundry and font you want is not shown in + the \url+fontname+ directory. + +In this example we'll call our mythical example + typeface `zork' (standing for + \uline{\textbf{Z}}fonts \uline{\textbf{Or}}dinary + Boo\uline{\textbf{k}}face, because + \verb+k+ is the letter used for Book + fonts, \verb+b+ being already the code + for bold) and we'll assume it + comes in the two files \url+foo.afm+ and + \url+foo.pfb+ that I mentioned + above. + +While the \product{fontname} + directories have ready-made lists of these names for + popular collections of typefaces, making them up + requires some knowledge of typographic terms and a + careful reading of the + \product{fontname} documentation. +\item \textbf{Decide on your encoding}\\ +This is what tripped me up the first few times until + someone pointed me at Y\amp Y's + \TeX{}'n'ANSI encoding which (to me) seems to + be the only one that includes the glyphs I want where I + want them.\index{fonts!encoding} Your mileage may vary. This encoding is + referred to as \verb+LY1+ within \LaTeX{} and + the encoding file is in + \url+texmf/dvips/base/texnansi.enc+. + Encoding is needed because Adobe fonts store their + characters in different places to the \TeX{} + standard. + +Copy this encoding file to the temporary directory + where you're doing all this stuff. If you're + using the 8a or 8r encoding (or some other encoding), + then copy that file instead + (\url+8a.enc+, + \url+8r.enc+). +\item \textbf{Convert \url+.afm+ files to + \url+.tfm+}\\\label{idfile}% +The \product{afm2tfm} program is a + standard utility in the \url+bin+ + directory of your \TeX{} installation. If it's not, + update your installation. + +In a command window, type: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\footnotesize] +afm2tfm foo.afm -v zorkly.vpl -p texnansi.enc rzorkly.tfm >zork.id + \end{Verbatim} +\end{sourcecode} + +This creates a special `raw' + \TeX{} Font Metric file (hence the special \verb+r+ + prefix) that \LaTeX{} can use, with a list of all its + properties encoded with LY1 (the + \url+.vpl+ or Virtual Property List + file). Many people will tell you that virtual fonts are + dead and that this is the wrong way to do it, but no-one + has ever shown me an alternative that works, so I stick + with it. +\item \textbf{Small caps (optional)}\\\label{sc}% +If you want a small caps variant faked up (perhaps + because the typeface family doesn't have a special + small-caps font), repeat the medicine like this: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\footnotesize] +afm2tfm foo.afm -V zorklyc.vpl -p texnansi.enc rzorkly.tfm >>zork.id + \end{Verbatim} +\end{sourcecode} + +Note the capital \verb+V+ option here. + Yes, it \emph{does} overwrite the + \url+rzorkly.tfm+ created in the first + command. Let it. And those are \emph{two} + of the `greater-than' signs + before the \url+zork.id+ filename because + we want to append to it, not overwrite it. +\item \textbf{Create the virtual font}\\ +Turn the \url+.vpl+ files into + \url+.vf+ and \url+.tfm+ + pairs. \LaTeX{} uses these to convert from Adobe's + encoding to its own. +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +vptovf zorkly.vpl zorkly.vf zorkly.tfm +vptovf zorklyc.vpl zorklyc.vf zorklyc.tfm + \end{Verbatim} +\end{sourcecode} + +Again, the \url+vptovf+ program is a + standard part of your \TeX{} distribution. +\item \textbf{Make directories to hold the files}\\ +Under your \url+texmf-local+ + directory there should be a \url+fonts+ + directory, and in there there should be + \url+afm+, \url+tfm+, + \url+type1+, and \url+vf+ + directories. Create them if they do not already + exist. +\begin{center} +\includegraphics[width=0.75\textwidth]{fonts} +\end{center} + +In each of these four, create a directory for the + foundry, and within them create a directory for the + typeface (using a human-readable typeface name, not the + short \person{Karl Berry} fontname). In our example, this + means: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +mkdir -p /usr/TeX/texmf-local/fonts/afm/zfonts/ordinary +mkdir -p /usr/TeX/texmf-local/fonts/tfm/zfonts/ordinary +mkdir -p /usr/TeX/texmf-local/fonts/type1/zfonts/ordinary +mkdir -p /usr/TeX/texmf-local/fonts/vf/zfonts/ordinary + \end{Verbatim} +\end{sourcecode} + +Or if you're lazy like me: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +(cd /usr/TeX/texmf-local/fonts;\ +for d in afm tfm type1 vf;do mkdir -p $d/zfonts/ordinary;done) + \end{Verbatim} +\end{sourcecode} + +For Microsoft Windows users, the path before + \url+texmf-local+ may look something like + \verb+C:\Program Files\TeXLive\+, depending + on how and where you have installed your \TeX{} + system. + +The \verb+-p+ is a Unix feature: it + automatically creates any missing intervening + subdirectories. If your directory-making command + doesn't do this, you'll have to make the + intervening directories by hand first. +\item \textbf{Copy the files to their rightful places}\\ +Copy the four groups of files to the four new + directories: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +cp *.afm /usr/TeX/texmf/fonts/afm/zfonts/ordinary/ +cp *.tfm /usr/TeX/texmf/fonts/tfm/zfonts/ordinary/ +cp *.pfb /usr/TeX/texmf/fonts/type1/zfonts/ordinary/ +cp *.vf /usr/TeX/texmf/fonts/vf/zfonts/ordinary/ + \end{Verbatim} +\end{sourcecode} + +You can of course do all this with a directory + window and mouse if you find it easier. +\item \textbf{Create a font map}\\ +The font map is what tells + \product{dvips} which PFB\index{PFB@PFB} file to use for which font. The + configuration file for \product{dvips} + is \url+texmf/dvips/config/config.ps+ and + it gets its entries from the program + \product{updmap} which reads map files + for each typeface. The configuration file for + \product{updmap} is + \url+texmf-var/web2c/updmap.cfg+\footnote{There is another one of these at + \url+texmf/web2c/updmap.cfg+, but + that contains the map references for the fonts which + came with your distribution of \TeX{}, so you should + not interfere with it.}, so it needs an entry for our new font, + using the three-letter font family abbreviation (the first + three letters of the Berry fontname (here + `\verb+zor+'): +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +Map zor.map + \end{Verbatim} +\end{sourcecode} + +We also have to create this map file + (\url+zor.map+) in a subdirectory of + \url+texmf-local/dvips/config/+ named + after the foundry, so we need to create + \url+texmf-local/dvips/config/zfonts+ as + well. +\begin{enumerate} +\item +Open + \url+/usr/TeX/texmf-var/web2c/updmap.cfg+ + in your editor. +\item +At the bottom, add the line: + \verb`Map zor.map` +\item +Save and close the file. +\end{enumerate} + +The font entries in our + \verb+zor.map+ will be on a + \emph{single} line each, with no + line-wrapping. Each entry gives the short name of the + font, the long (Adobe) name, the + PostScript\index{PostScript} encoding parameters + (in quotes), and then two filenames prefixed by input + redirects (less-than signs): the encoding file and the + PostScript\index{PostScript} outline file. +\begin{enumerate} +\item +First create the directory if it doesn't already + exist: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +mkdir -p /usr/TeX/texmf-local/dvips/config/zfonts + \end{Verbatim} +\end{sourcecode} +\item +Use your editor to open (create) the file + \url+/usr/TeX/texmf-local/dvips/config/zfonts/zor.map+. +\item \label{fullname}% +Insert the line: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\scriptsize] +rzorkly Ordinary-Blackface "TeXnANSIEncoding ReEncodeFont" <texnansi.enc <foo.pfb + \end{Verbatim} +\end{sourcecode} +\item +Save and close the file. +\end{enumerate} + +You get the full font name (here, + `Ordinary-Blackface') from the + \verb+zork.id+ which was created back in + step~\ref{idfile} in the procedure on p.\thinspace\pageref{idfile} when we ran + \product{afm2tfm}. You must get this + exactly right, because it's the + `official' full name of the font, + and PostScript\index{PostScript} files using this + font need to match it. +\item \textbf{Create a style file}\\ +\LaTeX{} needs a style file to implement the + interface to the font. Call it after the + typeface or something related; in this example we'll + call it \url+foozork.sty+. In it go + some details of the name and date we did this, what + version of \LaTeX{} it needs, and any other command + necessary to operate the font, like the font encoding and + whether it is to supersede the current default Roman font. +\begin{enumerate} +\item +Use your editor to open (create) + \url+foozork.sty+ in + \url+texmf-local/tex/latex/psnfss+. +\item +Insert the following lines: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +% foozork - created from foo for Zork +\def\fileversion{1.0} +\def\filedate{2002/12/03} +\def\docdate{2002/12/03} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{foozork}[\filedate\space\fileversion\space + Zfonts Ordinary PSNFSS2e package] +\RequirePackage[LY1]{fontenc} +\renewcommand{\rmdefault}{zor} +\endinput + \end{Verbatim} +\end{sourcecode} + +Note the following: +\begin{itemize} +\item +The first argument to + \command{ProvidesPackage} + \emph{must} be the same as this + style file name; and that the font family is + referred to as \verb+zor+, being the + foundry letter + plus the fontname abbreviation. This acts as a + prefix for any/all font variants (bold, italic, + etc.). + +\item +If you are not using Y\amp Y encoding, omit + the line referring to LY1 font encoding. + +\item +If this is a typewriter font, make the + renewed command \command{rmdefault} + into \command{ttdefault}. + +\item +If it's a sans-serif font, make it + \command{sfdefault} instead. + +\item +Omit the command completely if you + don't want the style file to supersede the + current defaults but simply to make the font + available. If you do this, you probably want to + write a new command or two to use it, typically + one for grouped use and one for argument + use: + +\end{itemize} +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\footnotesize] +\newcommand{\zorkfamily}{\fontencoding{LY1}\fontfamily{zor}\selectfont} +\newcommand{\textzork}[1]{{\zorkfamily#1}} + \end{Verbatim} +\end{sourcecode} +\item +Save and close the file. +\end{enumerate} +\item \textbf{Create the Font Definition file}\\\label{fdfiles}% +The last file to create is the \textbf{\textit{font definition}}\index{font definition@\textbf{\textit{font definition}}} + (\url+.fd+) file. This is named + following the pattern \verb+eeefnn.fd+, + using the same conventions as before, by prepending the + (lowercase) encoding abbreviation to the foundry letter + and fontname abbreviation, so our example would be + \verb+ly1zor.fd+ for the LY1 encoding and + the \verb+zor+ short font name. +\begin{enumerate} +\item +Use your editor to open (create) + \url+texmf-local/tex/latex/psnfss/ly1zor.fd+ +\item +Enter the following lines: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +\ProvidesFile{ly1zor.fd}[2002/03/03 v0.1 manual font + definitions for LY1/zor.] + +\DeclareFontFamily{LY1}{zor}{} + +\DeclareFontShape{LY1}{zor}{k}{n}{<-> zorkly}{} +\DeclareFontShape{LY1}{zor}{k}{sc}{<-> zorklyc}{} + \end{Verbatim} +\end{sourcecode} +\item +Save and close the file. +\end{enumerate} + +FD files typically use one + \command{DeclareFontFamily} command which + specifies the encoding and the short font name. Then as + many pairs of + \command{DeclareFontShape} commands as you + converted fonts (assuming you did + both normal and small caps for each font: see + step~\ref{sc} in the procedure on p.\thinspace\pageref{sc}; if you didn't, then only one such + command per font is needed here). The arguments to the + \command{DeclareFontShape} command to watch are + the 3rd (weight/width), 4th (shape), and 5th (font + outline name): the rest are static for each + \url+.fd+ file and simply identify the + encoding and the font family. + +The codes to use are given on + pages 190\ndash{}91 of the \titlecite{companion} and should also be in + your copies of + \url+texmf/fontnames/weight.map+ and + \url+texmf/fontnames/width.map+. The + rules for combining weight and width need care: RTFM\index{RTFM@RTFM} for + \package{fontname}. There is no + \url+shape.map+ in + \package{fontname} because it's not + part of font file names, it's purely a \LaTeX{} + creation, so here's what the same book says: +\begin{center} +\begin{tabular}{ll}\textbf{\normalfont\bfseries\upshape Character}&\textbf{\normalfont\bfseries\upshape Meaning}\\[2pt]\hline\\[-.95\baselineskip] +\verb+n+&normal (upright)\\ +\verb+it+&italic\\ +\verb+sl+&slanted\\ +\verb+sc+&small caps\\ +\verb+ui+&upright italic\\ +\verb+ol+&outline\\ +\end{tabular} +\end{center} + +Add your own for other oddities, but be consistent: + I use \verb+cu+ for cursive (scripts), for + example, and \verb+k+ for blackletter faces + (not to be confused with \verb+k+ as a + \emph{width} for + `book'). + +The default fontspec (5th) + argument above \verb+<->+ means + all sizes come from the same font outline (remember if + this was a \mf{} font with different design sizes + like CM it would be much more complex). + +If the face has only a few variants, you can create + any other entries for bold, italic, slanted, etc. with + the relevant weight and width and shape values pointing + at the relevant outline file. + +If you want one font to + substitute for a missing one (for example italics to + substitute for slanted in a typeface which has no + slanted variant of its own) give the + \verb+ssub+ (`silent + substitution') command in the fontspec: + for example to make all references to + \verb+sl+ (slanted) type use an existing + italic font, make the 5th argument like this: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +{<-> ssub * zor/m/it} + \end{Verbatim} +\end{sourcecode} + +If you find the x-height of a font too big or too + small to sort well with another font you are using, you + can specify an \verb+s+ + (`scale') factor in this argument + instead: this example will shrink the result to + 80\% of normal: +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +{<-> s * [0.8] zorkly} + \end{Verbatim} +\end{sourcecode} +\item \textbf{Update the index and the map files}\\ +Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}) so that + \product{updmap} can find the files it + needs. + +Then run \product{updmap} (just + type \verb+updmap+. This updates the + maps and runs the \TeX{} indexer program again + automatically. +\end{enumerate} + +Now you can \verb+\usepackage{foozork}+ in + your \LaTeX{} file to make it the default font. To use the + font incidentally instead of as the default, you can + say: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +This is {\zorkfamily ZORK} or \textzork{ZORK} + \end{Verbatim} +\end{sourcecode} +\subsection{Installing the Type 1 Computer Modern + fonts} +\label{type1cm} + +If your \LaTeX{} installation uses the + \mf{} (bitmap) versions of the Computer Modern + typeface, you may want to switch to the Type 1 + (PostScript\index{PostScript}) version, especially if + you are going to be using + \product{pdflatex} instead of standard + \LaTeX{} because Acrobat Reader makes such a hames of + displaying Type3 fonts. \product{GSview} + and \product{pdfview} handles them + correctly. + +To do this, install one of the sets of CM PostScript + fonts. There are several available: +\begin{itemize} +\item +The fonts from BlueSky Research at \url+http://www.ctan.org/tex-archive/fonts/cm/ps-type1/bluesky/+ + +\item +\person{Basil K. Malyshev}'s fonts at \url+http://www.ctan.org/tex-archive/fonts/cm/ps-type1/bakoma/+ + +\item +\person{Vladimir Volovich}'s CM-Super at \url+http://www.ctan.org/tex-archive/fonts/ps-type1/cm-super/+ + +\item +\person{Bogus\l{}aw Jackowski}'s Latin Modern at \url+ftp://cam.ctan.org/tex-archive/fonts/ps-type1/lm.tar.gz+ + +\end{itemize} + +The BaKoMa fonts include the American + Mathematical Society (AMS)\index{AMS@AMS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!AMS@AMS|textbf} fonts for extended + mathematics, but are more complex to install because they + come with a special set of TFM files. + +The BlueSky fonts are just PFB\index{PFB@PFB} + and AFM files, and are a drop-in replacement requiring no + further changes, as they use the same TFM files as the + \mf{} version. Follow the \url+README+ + file in the downloadable archive for installation + instructions. + +The Latin Modern and CM-Super fonts are new and I + haven't tested them but they are well spoken + of. Feedback on this is very welcome. + +The \TeX{} Live distribution uses Type 1 versions of + Computer Modern by default. There are more details in the + FAQ at \url+http://www.tex.ac.uk/cgi-bin/texfaq2html?label=uselmfonts+\thinspace{}. +\chapter{Programmability (macros)} +\label{macros} +\index{macros} +We've touched several times on the ability of \LaTeX{} + to be reprogrammed. This is one of its central features, and one + that still, after nearly a quarter of a century, puts it well + above many other typesetting systems, even those with macro + systems of their own. It's also the one that needs most + foreknowledge, which is why this chapter is in this + position. + +\LaTeX{} is in fact itself just a collection of + macros\mdash{}rather a big collection\mdash{}written in + \TeX{}'s internal typesetting language. These \textbf{\textit{macros}}\index{macros@\textbf{\textit{macros}}} are little program-like sets of + instructions with a name which can be used as shorthand for an + operation you wish to perform more than once. + +Macros can be arbitrarily complex. Many of the ones used in + the standard \LaTeX{} packages are several pages long, but as we + will see, even short ones can very simply automate otherwise + tedious chores and allow the author to concentrate on + \emph{writing}. +\section{Simple replacement macros} +\label{replacement} + +In its simplest form, a \LaTeX{} macro can just be a + straightforward text replacement of a phrase to avoid + misspelling something each time you need it, e.g. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\ef}{European Foundation for the Improvement of Living + and Working Conditions} + \end{Verbatim} +\end{sourcecode} + +Put this in your preamble, and you can then use + \command{ef} in your document and it will typeset it + as the full text. Remember that after a command ending in a + letter you need to leave a space to avoid the next word + getting gobbled up as part of the command (see + \S\thinspace\ref{swallow}). And when you want to force a space + to be printed, use a backslash followed by a space, e.g. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +The \ef\ is an institution of the Commission of the European Union. + \end{Verbatim} +\end{sourcecode} + +As you can see from this example, the + \command{newcommand} command takes two arguments: + \begin{inparaenum}[\itshape a\upshape)] \item the name you want to give the new command; and \item the expansion to be performed when you use it\end{inparaenum}, so there are always two sets of curly braces + after \command{newcommand}. +\section{Macros using information gathered previously} +\label{macinf} + +A more complex example is the macro + \command{maketitle} which is used in almost every + formal document to format the title block. In the basic + document classes (book, report, and article) it performs small + variations on the layout of a centred block with the title + followed by the author followed by the date, as we saw in + \S\thinspace\ref{titling}. + +If you inspect one of these document class files, such as + \url+texmf/tex/latex/base/report.cls+ you will + see \command{maketitle} defined (and several variants + called \command{@maketitle} for use in different + circumstances). It uses the values for the title, author, and + date which are assumed already to have been stored in the + internal macros \command{@title}, + \command{@author}, and \command{@date} by + the author using the matching \command{title}, + \command{author}, and \command{date} + commands in the document. + +This use of one command to store the information in + another is a common way of gathering the information from the + user. The use of macros containing the + \verb+@+ character prevents their accidental + misuse by the user: in fact to use them in your preamble we + have to allow the \verb+@+ sign to become a + `letter' so it can be recognised in a + command name, and remember to turn it off again + afterwards (see item~\ref{makeat} below). +\begin{sourcecode}\label{newtitle}\begin{Verbatim}[fontsize=\small] +\makeatletter +\renewcommand{\maketitle}{% + \begin{flushleft}% + \sffamily + {\Large\bfseries\color{red}\@title\par}% + \medskip + {\large\color{blue}\@author\par}% + \medskip + {\itshape\color{green}\@date\par}% + \bigskip\hrule\vspace*{2pc}% + \end{flushleft}% +} +\makeatother + \end{Verbatim} +\end{sourcecode} + +Insert this in the sample file on p.\thinspace\pageref{oldtitle} immediately before the + \verb+\begin{document}+ and remove the + \verb+\color{...}+ commands from the title, + author, and date. Re-run the file through \LaTeX{}, and you + should get something like this: +\begin{center} +\setlength{\fboxsep}{1cm}\includegraphics[width=0.75\textwidth]{newtitle} +\end{center} + +In this redefinition of \command{maketitle}, + we've done the following: +\begin{enumerate}\item\label{makeat} +Enclosed the changes in + \command{makeatletter} and + \command{makeatother} to allow us to use the + \verb+@+ sign in command names;\footnote{If you move all this preamble into a style file of + your own, you don't need these commands: the use + of \url+@+ signs in command names is + allowed in style and class files.} + +\item +Used \command{renewcommand} and put + \command{maketitle} in curly braces after it; + +\item +Opened a pair of curly braces to hold the new + definition. The closing curly brace is immediately before + the \command{makeatother}; + +\item +Inserted a \env{flushleft} environment + so the whole title block is left-aligned; + +\item +Used \command{sffamily} so the whole title + block is in the defined sans-serif typeface; + +\item +For each of \command{@title}, + \command{@author}, and \command{@date}, + we have used some font variation and colour, and enclosed + each one in curly braces to restrict the changes just to + each command. The closing \command{par} makes + sure that multiline title and authors and dates get + typeset with the relevant line-spacing; + +\item +Added some flexible space between the lines, and + around the \command{hrule} (horizontal rule) at + the end; + +\end{enumerate} + +Note the \verb+%+ signs after any line ending + in a curly brace, to make sure no intrusive white-space find its + way into the output. These aren't needed after simple + commands where there is no curly brace because excess + white-space gets gobbled up there anyway. +\section{Macros with arguments} +\label{macargs} + +But macros are not limited to text expansion. They can + take arguments of their own, so you can define a command to do + something with specific text you give it. This makes them much + more powerful and generic, as you can write a macro to do + something a certain way, and then use it hundreds of times + with a different value each time. + +We looked earlier (\S\thinspace\ref{emph}) at making new + commands to put specific classes of words into certain fonts, + such as product names into italics, keywords into bold, and so + on. Here's an example for a command + \command{product}, which also indexes the product + name and adds a trademark sign: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\product}[1]{% + \textit{#1}\texttrademark% + \index{#1@\textit{#1}}% +} + \end{Verbatim} +\end{sourcecode} + +If I now type \verb+\tmproduct{Velcro}+ then I + get \product{Velcro}\texttrademark{} typeset, and if + you look in the index, you'll find this page referenced + under `{\fontshape{it}\selectfont{}Velcro}'. Let's + examine what this does: +\begin{enumerate}\item +The macro is specified as having one argument (that's + the \verb+[1]+ in the definition). This will + be the product name you type in curly braces when you use + \command{product}. Macros can have up to nine + arguments. + +\item +The expansion of the macro is contained in the second + set of curly braces, spread over several lines (see item~\ref{macrolines} for why). + +\item +It prints the value of the first argument (that's + the \verb+#1+) in italics, which is + conventional for product names, and adds the + \command{texttrademark} command. + +\item +Finally, it creates an index entry using the same + value (\verb+#1+), making sure that it's + italicised in the index (see the list on p.\thinspace\pageref{indextypo} in \S\thinspace\ref{indextypo} to remind yourself of how indexing + something in a different font works). + +\item\label{macrolines} +Typing this macro over several lines makes it easier + for humans to read. I could just as easily have + typed +\begin{sourcecode}[\leftmargin]\begin{Verbatim}[fontsize=\small] +\newcommand{\product}[1]{\textit{#1}\index{#1@\textit{#1}}} + \end{Verbatim} +\end{sourcecode} + +but it wouldn't have been as clear what I was doing. + +One thing to notice is that to prevent unwanted + spaces creeping into the output when \LaTeX{} reads the + macro, I ended each line with a comment character + (\verb+%+). \LaTeX{} normally treats + newlines as spaces when formatting (remember \S\thinspace\ref{comment}), so this stops the end of line + being turned into an unwanted space when the macro is + used. \LaTeX{} always ignores spaces at the + \emph{start} of macro lines anyway, so + indenting lines for readability is fine. + +\end{enumerate} + +In (\S\thinspace\ref{hyph}) we mentioned the problem + of frequent use of unbreakable text leading to poor + justification or to hyphenation problems. A solution is to + make a macro which puts the argument into an + \command{mbox} with the appropriate font change, but + precedes it all with a conditional + \command{linebreak} which will make it more + attractive to \TeX{} to start a new line. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\var}[1]{\linebreak[3]\mbox{\ttfamily#1}} + \end{Verbatim} +\end{sourcecode} + +This only works effectively if you have a reasonably wide + setting and paragraphs long enough for the differences in + spacing elsewhere to get hidden. If you have to do this in + narrow journal columns, you may have to adjust wording and + spacing by hand occasionally. +\section{Nested macros} +\label{macnest} + +Here's a slightly more complex example, where one + macro calls another. It's common in normal text to refer + to people by their forename and surname (in that order), for + example \person{Don Knuth}, but to have them indexed as \emph{surname, + forename}. This pair of macros, + \command{person} and \command{reindex}, + automates that process to minimize typing and indexing. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\person}[1]{#1\reindex #1\sentinel} +\def\reindex #1 #2\sentinel{\index{#2, #1}} + \end{Verbatim} +\end{sourcecode} +\begin{enumerate}\item +The digit 1 in square brackets means that + \command{person} has one argument, so you put the + whole name in a single set of curly braces, e.g. + \verb+\person{Don Knuth}+. + +\item +The first thing the macro does is output + \verb+#1+, which is the value of what you typed, + just as it stands, so the whole name gets typeset exactly + as you typed it. + +\item +But then it uses a special feature of Plain \TeX{} + macros (which use \command{def} instead of + \LaTeX{}'s \command{newcommand}\footnote{Don't try this at home alone, children! This one + is safe enough, but you should strictly avoid + \command{def} for a couple of years. Stick to + \command{newcommand} for now.}): they too + can have multiple arguments but you can separate them with + other characters (here a space) to form a pattern which + \TeX{} will recognise when reading the arguments. + +In this example (\command{reindex}) it's + expecting to see a string of characters + (\verb+#1+) followed by a space, followed by + another string of characters (\verb+#2+) + followed by a dummy command (\command{sentinel}). + In effect this makes it a device for splitting a name into two + halves on the space between them, so the two halves can be + handled separately. The \command{reindex} command + can now read the two halves of the name separately. + +\item +The \command{person} command invokes + \command{reindex} and follows it with the name + you typed plus the dummy command + \command{sentinel} (which is just there to signal + the end of the name). Because \command{reindex} + is expecting two arguments separated by a space and + terminated by a \command{sentinel}, it sees + `\verb+Don+ and + \verb+Knuth+' as two separate + arguments. + +It can therefore output them using + \command{index} in reverse order, which is + exactly what we want. + +\end{enumerate} + +A book or report with a large number of personal names to + print and index could make significant use of this to allow + them to be typed as + \verb+\person{Leslie Lamport}+ and printed as + \person{Leslie Lamport}, but have them indexed as + `Lamport, Leslie' with virtually no effort + on the author's part at all. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{20}Other names} +\subsubsection*{Other names} +Try to work out how to make this + \command{person} feature work with names like: +\begin{itemize*} +\item Blanca Maria Bartosova de Paul +\item Patricia Maria Soria de Miguel +\item Arnaud de la Villèsbrunne +\item Prince +\item Pope John Paul II +\end{itemize*} + +Hints: the command \command{space} produces a + normal space, and one way around \LaTeX{}'s requirements + on spaces after command names ending with a letter is to + follow such commands with an empty set of curly braces + \verb+{}+. +\end{exercise} +\section{Macros and environments} +\label{macenv} + +As mentioned in \S\thinspace\ref{fancybox}, it is possible + to define macros to capture text in an environment and reuse it + afterwards. This avoids any features of the subsequent use + affecting the formatting of the text. + +One example of this uses the facilities of the + \package{fancybox} package, which defines a variety + of framed boxes to highlight your text, and a special + environment \env{Sbox} which + `captures' your text for use in these boxes. + +By putting the text (here in a + \env{minipage} environment because we want to + change the width) inside the \env{Sbox} + environment, it is typeset into memory and stored in the macro + \command{theSbox}. It can then be used afterwards as + the argument of the \command{shadowbox} command (and + in this example it has also been centred). +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{Sbox} +\begin{minipage}{3in} +This text is formatted to the specifications +of the minipage environment in which it occurs. + +Having been typeset, it is held in the Sbox +until it is needed, which is after the end of +the minipage, where you can (for example) centre +it and put it in a special framed box. +\end{minipage} +\end{Sbox} +\begin{center} +\shadowbox{\theSbox} +\end{center} + \end{Verbatim} +\end{sourcecode} +\begin{sidebar} +This text is formatted to the specifications +of the minipage environment in which it occurs. + +Having been typeset, it is held in the Sbox +until it is needed, which is after the end of +the minipage, where you can (for example) centre +it and put it in a special framed box. +\end{sidebar}\end{example} +\section{Reprogramming \sfLaTeX{}'s internals} +\label{reprog} + +\LaTeX{}'s internal macros can also be reprogrammed or + even rewritten entirely, although doing this can require a + considerable degree of expertise. Simple changes, however, are + easily done. + +Recall that \LaTeX{}'s default document structure for + the Report document class uses Chapters as the main unit of + text, whereas in reality most reports are divided into + Sections, not Chapters (\S\thinspace\ref{repchap}). The result + of this is that if you start off your report with + \verb+\section{Introduction}+, it will print + as + +{\Large{}\fontseries{b}\selectfont{}0.1\quad Introduction\emstrut} + +\noindent which is not at all what you want. The zero is + caused by it not being part of any chapter. But this numbering + is controlled by macros, and you can redefine them. In this + case it's a macro called \verb+\thesection+ + which reproduces the current section number counter (see \S\thinspace\ref{thecounter}). It's redefined afresh in each + document class file, using the command + \command{renewcommand} (in this case in + \url+texmf/tex/latex/base/report.cls+): +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand \thesection {\thechapter.\@arabic\c@section} + \end{Verbatim} +\end{sourcecode} + +You can see it invokes \command{thechapter} + (which is defined elsewhere to reproduce the value of the + \counter{chapter} counter), and it then prints a dot, + followed by the Arabic value of the counter called + \counter{section} (that \verb+\c@+ + notation is \LaTeX{}'s internal way of referring to + counters). You can redefine this in your preamble to simply + leave out the reference to chapters: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand{\thesection}{\arabic{section}} + \end{Verbatim} +\end{sourcecode} + +I've used the more formal method of enclosing the + command being redefined in curly braces. For largely + irrelevant historical reasons these braces are often omitted + in \LaTeX{}'s internal code (as you may have noticed in + the example earlier). And I've also used the + `public' macro + \command{arabic} to output the value of + \counter{section} (\LaTeX{}'s internals use a + `private' set of control sequences + containing \verb+@+-signs, designed to protect + them against being changed accidentally). + +Now the introduction to your report will start + with: + +{\Large{}\fontseries{b}\selectfont{}1\quad Introduction\emstrut} + +What's important is that you \emph{don't + ever} need to alter the original document class + file \url+report.cls+: you just copy the + command you need to change into your own document preamble, + and modify that instead. It will then override the + default. +\subsection{Changing list item bullets} +\label{bullets} + +As mentioned earlier (\S\thinspace\ref{labelitem}), + here's how to redefine a bullet for an itemized list, + with a slight tweak: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage{bbding} +\renewcommand{\labelitemi}{\raisebox{-.25ex}{\PencilRight}} + \end{Verbatim} +\end{sourcecode} + +Here we use the \package{bbding} package + which has a large selection of + `dingbats' or little icons, and we + make the label for top-level itemized lists print a + right-pointing pencil (the names for the icons are in the + package documentation: see \S\thinspace\ref{packagedoc} for how + to get it). + +In this case, we are using the + \command{raisebox} command within the redefinition + because it turns out that the symbols in this font are + positioned slightly too high for the typeface we're + using. The \command{raisebox} command takes two + arguments: the first is a dimension, how much to raise the + object by (and a negative value means + `lower': there is no + \verb+\lowerbox+ command!); and the second is the + text you want to affect. Here, we are shifting the symbol + down by ¼ex (see \S\thinspace\ref{dimensions} for a list + of dimensions \LaTeX{} can use). + +There is a vast number of symbols available: see + \titlecite{symbol-list} for a comprehensive list. +\chapter{Compatibility with other systems} +\label{compat} + +As we saw in \chaptername~\ref{plaintext}, \LaTeX{} uses + plain-text files, so they can be read and written by any standard + application that can open text files. This helps preserve your + information over time, as the plain-text format cannot be + obsoleted or hijacked by any manufacturer or sectoral interest, + and it will always be readable on any computer, from your + handheld (yes, \LaTeX{} is available for some PDA\index{PDA@PDA}s) to + the biggest supercomputer. + +However, \LaTeX{} is intended as the last stage of the + editorial process: formatting for print or display. If you have + a requirement to re-use the text in some other + environment\mdash{}a database perhaps, or on the Web or a CD-ROM\index{CD-ROM@CD-ROM} or DVD\index{DVD@DVD}, or in Braille + or voice output\mdash{}then it should be edited, stored, and + maintained in something neutral like XML, and only converted to + \LaTeX{} when a typeset copy is needed. + +Although \LaTeX{} has many structured-document features in + common with SGML\index{SGML@SGML} and XML\index{XML@XML}, it can still only be processed by the + \LaTeX{} and + \product{pdflatex} programs. Because its macro features + make it almost infinitely redefinable, processing it requires a + program which can unravel arbitrarily complex macros, and + \LaTeX{} and its siblings are the only programs which can do that + effectively. Like other typesetters and formatters (Quark + \product{XPress}, + \product{PageMaker}, + \product{FrameMaker}, Microsoft + \product{Publisher}, + \product[3]{3B2} etc.), \LaTeX{} is largely a + one-way street leading to typeset printing or display + formatting. + +Converting \LaTeX{} to some other format therefore means you + will unavoidably lose some formatting, as \LaTeX{} has features + that others systems simply don't possess, so they cannot be + translated. Similarly, converting other formats to \LaTeX{} + usually means editing back the stuff the other formats omit + because they only store appearances, not structure. +\section{Converting into \sfLaTeX{}} +\label{tolatex} + +There are several systems which will save their text in + \LaTeX{} format. The best known is probably the + \LyX{} editor, which is a + wordprocessor-like interface to \LaTeX{} for Windows and Unix. + Several maths packages like the + \product{EuroMath} editor, and the + \product{Mathematica} and + \product{Maple} analysis packages, can also + save material in \LaTeX{} format. + +In general, most wordprocessors and DTP systems don't + have the level of internal markup sophistication needed to + create a \LaTeX{} file, or any other kind of structured + document, because they only store what the text looks like, + not why it's there or what role it fulfills. There are two + ways out of this: +\begin{itemize} +\item +Use the \menuitem{File}{Save + As\dots } menu item to save the wordprocessor + file as HTML, rationalise the HTML using + \person{Dave Raggett}'s \product{HTML + Tidy}\footnote{\url+http://tidy.sourceforge.net/+}, and convert the resulting + XHTML to \LaTeX{} with any of the standard tools (see + below). + +\item +Use a specialist conversion tool like EBT's + \product{DynaTag} (now available from + Enigma, if you can persuade them to sell you a copy). + It's expensive and they don't advertise it, but + for bulk conversion of consistently-marked + \product{Word} files into XML it beats everything + else hands down. The \product{Word} files + \emph{must} be consistent, though, and must + use named styles from a stylesheet, otherwise no system on + earth is going to be able to guess what it means. + +\end{itemize} + +There is of course a third way, suitable for large volumes + only: send it off to the Pacific Rim to be retyped into XML. + There are hundreds of companies from India to Polynesia who do + this at high speed and low cost. It sounds crazy when the + document is already in electronic form, but it's a good + example of the low quality of wordprocessor markup that this + solution exists at all. + +You will have noticed that all the solutions lead to one + place: SGML\index{SGML@SGML} or XML\index{XML@XML}. As explained above and elsewhere, these + formats are the only ones devised so far capable of storing + sufficient information in machine-processable, + publicly-accessible form for a document to be recreated in + multiple output formats. Once your document is in XML\index{XML@XML} or + SGML\index{SGML@SGML}, there is a large range of software available to turn it + into other formats, including \LaTeX{}. Processors in any of + the common styling and processing languages like DSSSL\index{DSSSL@DSSSL}, XSLT\index{XSLT@XSLT}, + \product{Omnimark}, + \product{Metamorphosis}, + \product{Balise}, etc. can easily be written + to output \LaTeX{}, and this approach is extremely + common. + +Much of this will be simplified when wordprocessors + support native, arbitrary XML as a standard feature. + Sun's \product{Star Office} and its Open + Source sister, \product{OpenOffice}, have + used XML as their native Save format for several years, and + there is a project at the Organisation for + the Advancement of Structured Information Systems (OASIS)\index{OASIS@OASIS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!OASIS@OASIS|textbf} + for developing a common XML office file format based on those + used by these two packages. + \product{WordPerfect} has also had a native + SGML\index{SGML@SGML} (and now XML\index{XML@XML}) editor for many years, which will work + with any Document Type Definition (DTD)\index{DTD@DTD|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DTD@DTD|textbf} (but not a Schema). + Microsoft has had a half-hearted `Save + As\dots XML' for a while, using an internal + and largely undocumented Schema, but the + `Professional' versions of + \product{Word} and + \product{Excel} in + \product{Office 11} (Office 2003) now + have full support for arbitrary Schemas. + +When these efforts coalesce into generalised support for + arbitrary DTD\index{DTD@DTD}s and Schemas, it will + mean a wider choice of editing interfaces, and probably the + ability to run XSLT\index{XSLT@XSLT} conversion into + \LaTeX{} from within these editors, uch as is done at the + moment with \product{Emacs} or + \product{XML Spy}. +\section{Converting out of \sfLaTeX{}} +\label{latexto} + +This is much harder to do comprehensively. As noted + earlier, the \LaTeX{} file format really requires the \LaTeX{} + program itself in order to process all the packages and + macros, because there is no telling what complexities authors + have added themselves (what a lot of this booklet is + about!). + +There is an excellent program on CTAN\index{CTAN@CTAN} to do + \LaTeX{}-to-\product{Word} conversion, but it + only handles a subset of the built-in commands of default + \LaTeX{}, not packages or your own macros. + +One easy route into wordprocessing, however, is the + reverse of the procedures suggested in the preceding section: + convert \LaTeX{} to HTML, which many wordprocessors read + easily. The \product[latex2html]{\LaTeX{}2HTML} and + \product[tex4ht]{\TeX{}4HT} programs do + this quite well, given the limited formatting available + through Web browsers. + +If you have the full version of Adobe + \product{Acrobat}, you can open a PDF\index{PDF@PDF} file created by + \product{pdflatex}, select and copy all the + text, and paste it into \product{Word} and + some other wordprocessors, and retain some common formatting + of headings, paragraphs, and lists. Both solutions still + require the wordprocessor text to be edited into shape, but + they preserve enough of the formatting to make it worthwhile + for short documents. Otherwise, use the + \product{pdftotext} program to extract + everything from the PDF\index{PDF@PDF} file as + plain (paragraph-formatted) text. + +At worst, the \product{detex} program on + CTAN\index{CTAN@CTAN} will strip a \LaTeX{} file of + all markup and leave just the raw unformatted text, which can + then be re-edited. There are also programs to extract the raw + text from DVI\index{DVI@DVI} and PostScript (PS)\index{PS@PS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PS@PS|textbf} files. +\section{Going beyond \sfLaTeX{}} +\label{beyondlatex} + +The reader will have deduced by now that while \LaTeX{} is + possibly the best programmable formatter around, the \LaTeX{} + file format is not generally usable with anything except the + \LaTeX{} program. \LaTeX{} was originally written in the + mid-1980s, about the same time as the Standard Generalized Markup Language (SGML)\index{SGML@SGML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!SGML@SGML|textbf}, + but the two projects were not related. However, \TeX{} and + \LaTeX{} have proved such useful tools for formatting SGML\index{SGML@SGML} and more recently XML\index{XML@XML} that many users chose this route for + their output, using conversions written in the languages + already mentioned in \S\thinspace\ref{latexto}. + +Unfortunately, when the rise of the Web in the early 1990s + popularised SGML\index{SGML@SGML} using the HyperText Markup Language (HTML)\index{HTML@HTML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!HTML@HTML|textbf}, browser + writers deliberately chose to encourage authors to ignore the + rules of SGML\index{SGML@SGML}. Robust auto-converted + formatting therefore became almost impossible except via the + browsers' low-quality print routines. + +It was not until 1997, when the Extensible Markup Language (XML)\index{XML@XML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!XML@XML|textbf} was devised, + that it again became possible to provide the structural and + descriptive power of SGML\index{SGML@SGML} but + without the complex and rarely-used options which had made + standard SGML\index{SGML@SGML} so difficult to + program for. + +XML\index{XML@XML} is now becoming the + principal system of markup. Because it is based on the + international standard (SGML\index{SGML@SGML}), it is + not proprietary, so it has been implemented on most platforms, + and there is lots of free software supporting it as well as + many commercial packages. Like SGML\index{SGML@SGML}, + it is actually a meta-language to let you define your own + markup, so it is much more flexible than HTML\index{HTML@HTML}. Implementations of the companion + Extensible Stylesheet Language (XSL)\index{XSL@XSL|textbf}\index{Acronyms@\textbf{Acronyms}, defined!XSL@XSL|textbf} + provide a direct route to PDF\index{PDF@PDF} but at + the expense of reinventing most of the wheels which \LaTeX{} + already possesses, so the sibling Extensible Stylesheet Language: + Transformations (XSLT)\index{XSLT@XSLT|textbf}\index{Acronyms@\textbf{Acronyms}, defined!XSLT@XSLT|textbf} can be used instead to translate + to \LaTeX{} source code. This is usually much faster than + writing your own formatting from scratch in XSL\index{XSL@XSL}, and it means that you can take full + advantage of the packages and sophistication of \LaTeX{}. A + similar system is used for the Linux Documentation Project, + which uses SGML\index{SGML@SGML} transformed by the + Document Style Semantics and Specification + Language (DSSSL)\index{DSSSL@DSSSL|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DSSSL@DSSSL|textbf} to \TeX{} + +The source code of this booklet, available online at + \url+http://www.ctan.org/tex-archive/info/beginlatex/src/+ + includes XSLT which does exactly this. +\appendix +\chapter[GNU Free Documentation License]{GNU Free Documentation License\\\LARGE\itshape Version 1.2, November 2002} +\label{gfdl} +\begin{multicols}{2}\small\gfdl +\begin{quotation}\small\noindent +Copyright (C) 2000,2001,2002 Free Software Foundation, + Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not + allowed. +\end{quotation} +\setcounter{section}{-1} +\section{PREAMBLE} +\label{gfdl-0} + +The purpose of this License is to make a manual, textbook, + or other functional and useful document `free' in + the sense of freedom: to assure everyone the effective freedom + to copy and redistribute it, with or without modifying it, + either commercially or noncommercially. Secondarily, this + License preserves for the author and publisher a way to get + credit for their work, while not being considered responsible + for modifications made by others. + +This License is a kind of `copyleft', which + means that derivative works of the document must themselves be + free in the same sense. It complements the GNU General Public + License, which is a copyleft license designed for free + software. + +We have designed this License in order to use it for + manuals for free software, because free software needs free + documentation: a free program should come with manuals + providing the same freedoms that the software does. But this + License is not limited to software manuals; it can be used for + any textual work, regardless of subject matter or whether it + is published as a printed book. We recommend this License + principally for works whose purpose is instruction or + reference. +\section{APPLICABILITY AND DEFINITIONS} +\label{gfdl-1} + +\label{gfdl-doc}% +This License applies to any manual or other + work, in any medium, that contains a notice placed by the + copyright holder saying it can be distributed under the terms + of this License. Such a notice grants a world-wide, + royalty-free license, unlimited in duration, to use that work + under the conditions stated herein. The + `Document', below, refers to any such manual or + work. Any member of the public is a licensee, and is + addressed as `you'. You accept the license if + you copy, modify or distribute the work in a way requiring + permission under copyright law. + +\label{gfdl-mod-ver}% +A `Modified Version' of the + Document means any work containing the Document or a portion + of it, either copied verbatim, or with modifications and/or + translated into another language. + +\label{gfdl-secnd-sect}% +A `Secondary Section' is + a named appendix or a front-matter section of the Document + that deals exclusively with the relationship of the publishers + or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that + could fall directly within that overall subject. (Thus, if + the Document is in part a textbook of mathematics, a Secondary + Section may not explain any mathematics.) The relationship + could be a matter of historical connection with the subject or + with related matters, or of legal, commercial, philosophical, + ethical or political position regarding them. + +\label{gfdl-inv-sect}% +The `Invariant Sections' + are certain Secondary Sections whose titles are designated, as + being those of Invariant Sections, in the notice that says + that the Document is released under this License. If a + section does not fit the above definition of Secondary then it + is not allowed to be designated as Invariant. The Document + may contain zero Invariant Sections. If the Document does not + identify any Invariant Sections then there are none. + +\label{gfdl-cov-text}% +The `Cover Texts' are + certain short passages of text that are listed, as Front-Cover + Texts or Back-Cover Texts, in the notice that says that the + Document is released under this License. A Front-Cover Text + may be at most 5 words, and a Back-Cover Text may be at most + 25 words. + +\label{gfdl-transparent}% +A `Transparent' copy of + the Document means a machine-readable copy, represented in a + format whose specification is available to the general public, + that is suitable for revising the document straightforwardly + with generic text editors or (for images composed of pixels) + generic paint programs or (for drawings) some widely available + drawing editor, and that is suitable for input to text + formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in + an otherwise Transparent file format whose markup, or absence + of markup, has been arranged to thwart or discourage + subsequent modification by readers is not Transparent. An + image format is not Transparent if used for any substantial + amount of text. A copy that is not `Transparent' + is called `Opaque'. + +Examples of suitable formats for Transparent copies + include plain ASCII without markup, Texinfo input format, + LaTeX input format, SGML or XML using a publicly available + DTD, and standard-conforming simple HTML, + PostScript\index{PostScript} or PDF designed for human + modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats + that can be read and edited only by proprietary word + processors, SGML or XML for which the DTD and/or processing + tools are not generally available, and the machine-generated + HTML, PostScript\index{PostScript} or PDF produced by + some word processors for output purposes only. + +\label{gfdl-title-page}% +The `Title Page' means, + for a printed book, the title page itself, plus such following + pages as are needed to hold, legibly, the material this + License requires to appear in the title page. For works in + formats which do not have any title page as such, `Title + Page' means the text near the most prominent + appearance of the work's title, preceding the beginning + of the body of the text. + +\label{gfdl-entitled}% +A section `Entitled XYZ' + means a named subunit of the Document whose title either is + precisely XYZ or contains XYZ in parentheses following text + that translates XYZ in another language. (Here XYZ stands for + a specific section name mentioned below, such as + `Acknowledgements', `Dedications', + `Endorsements', or `History'.) To + `Preserve the Title' of such a section when you + modify the Document means that it remains a section + `Entitled XYZ' according to this + definition. + +The Document may include Warranty Disclaimers next to the + notice which states that this License applies to the Document. + These Warranty Disclaimers are considered to be included by + reference in this License, but only as regards disclaiming + warranties: any other implication that these Warranty + Disclaimers may have is void and has no effect on the meaning + of this License. +\section{VERBATIM COPYING} +\label{gfdl-2} + +You may copy and distribute the Document in any medium, + either commercially or noncommercially, provided that this + License, the copyright notices, and the license notice saying + this License applies to the Document are reproduced in all + copies, and that you add no other conditions whatsoever to + those of this License. You may not use technical measures to + obstruct or control the reading or further copying of the + copies you make or distribute. However, you may accept + compensation in exchange for copies. If you distribute a + large enough number of copies you must also follow the + conditions in section 3. + + +You may also lend copies, under the same conditions stated + above, and you may publicly display copies. +\section{COPYING IN QUANTITY} +\label{gfdl-3} + +If you publish printed copies (or copies in media that + commonly have printed covers) of the Document, numbering more + than 100, and the Document's license notice requires + Cover Texts, you must enclose the copies in covers that carry, + clearly and legibly, all these Cover Texts: Front-Cover Texts + on the front cover, and Back-Cover Texts on the back cover. + Both covers must also clearly and legibly identify you as the + publisher of these copies. The front cover must present the + full title with all words of the title equally prominent and + visible. You may add other material on the covers in + addition. Copying with changes limited to the covers, as long + as they preserve the title of the Document and satisfy these + conditions, can be treated as verbatim copying in other + respects. + +If the required texts for either cover are too voluminous + to fit legibly, you should put the first ones listed (as many + as fit reasonably) on the actual cover, and continue the rest + onto adjacent pages. + +If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, + or state in or with each Opaque copy a computer-network + location from which the general network-using public has + access to download using public-standard network protocols a + complete Transparent copy of the Document, free of added + material. If you use the latter option, you must take + reasonably prudent steps, when you begin distribution of + Opaque copies in quantity, to ensure that this Transparent + copy will remain thus accessible at the stated location until + at least one year after the last time you distribute an Opaque + copy (directly or through your agents or retailers) of that + edition to the public. + +It is requested, but not required, that you contact the + authors of the Document well before redistributing any large + number of copies, to give them a chance to provide you with an + updated version of the Document. +\section{MODIFICATIONS} +\label{gfdl-4} + +You may copy and distribute a Modified Version of the + Document under the conditions of sections 2 and 3 above, + provided that you release the Modified Version under precisely + this License, with the Modified Version filling the role of + the Document, thus licensing distribution and modification of + the Modified Version to whoever possesses a copy of it. In + addition, you must do these things in the Modified + Version: +\begin{enumerate}\renewcommand{\theenumi}{\Alph{enumi}}\item Use in the Title Page (and on the covers, + if any) a title distinct from that of the Document, and + from those of previous versions (which should, if there + were any, be listed in the History section of the + Document). You may use the same title as a previous + version if the original publisher of that version gives + permission. + +\item List on the Title Page, as authors, one or + more persons or entities responsible for authorship of the + modifications in the Modified Version, together with at + least five of the principal authors of the Document (all + of its principal authors, if it has fewer than five), + unless they release you from this requirement. + +\item State on the Title page the name of the + publisher of the Modified Version, as the + publisher. +\item Preserve all the copyright notices of the + Document. + +\item Add an appropriate copyright notice for + your modifications adjacent to the other copyright + notices. + +\item Include, immediately after the copyright + notices, a license notice giving the public permission to + use the Modified Version under the terms of this License, + in the form shown in the Addendum (\S\thinspace\ref{gfdl-addendum}) below. + +\item Preserve in that license notice the full + lists of Invariant Sections and required Cover Texts given + in the Document's license + notice. +\item Include an unaltered copy of this License. + +\item Preserve the section Entitled + `History', Preserve its Title, and add to it + an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title + Page. If there is no section Entitled + `History' in the Document, create one stating + the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the + Modified Version as stated in the previous sentence. + +\item Preserve the network location, if any, + given in the Document for public access to a Transparent + copy of the Document, and likewise the network locations + given in the Document for previous versions it was based + on. These may be placed in the `History' + section. You may omit a network location for a work that + was published at least four years before the Document + itself, or if the original publisher of the version it + refers to gives permission. + +\item For any section Entitled + `Acknowledgements' or + `Dedications', Preserve the Title of the + section, and preserve in the section all the substance and + tone of each of the contributor acknowledgements and/or + dedications given therein. + +\item Preserve all the Invariant Sections of the + Document, unaltered in their text and in their titles. + Section numbers or the equivalent are not considered part + of the section titles. + +\item Delete any section Entitled + `Endorsements'. Such a section may not be + included in the Modified Version. + +\item Do not retitle any existing section to be + Entitled `Endorsements' or to conflict in + title with any Invariant Section. + +\item Preserve any Warranty Disclaimers. + +\end{enumerate} + +If the Modified Version includes new front-matter sections + or appendices that qualify as Secondary Sections and contain + no material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do + this, add their titles to the list of Invariant Sections in + the Modified Version's license notice. These titles must + be distinct from any other section titles. + +You may add a section Entitled + `Endorsements', provided it contains nothing but + endorsements of your Modified Version by various parties--for + example, statements of peer review or that the text has been + approved by an organization as the authoritative definition of + a standard. + +You may add a passage of up to five words as a Front-Cover + Text, and a passage of up to 25 words as a Back-Cover Text, to + the end of the list of Cover Texts in the Modified Version. + Only one passage of Front-Cover Text and one of Back-Cover + Text may be added by (or through arrangements made by) any one + entity. If the Document already includes a cover text for the + same cover, previously added by you or by arrangement made by + the same entity you are acting on behalf of, you may not add + another; but you may replace the old one, on explicit + permission from the previous publisher that added the old + one. + +The author(s) and publisher(s) of the Document do not by + this License give permission to use their names for publicity + for or to assert or imply endorsement of any Modified + Version. +\section{COMBINING DOCUMENTS} +\label{gfdl-5} + +You may combine the Document with other documents released + under this License, under the terms defined in section 4 (\S\thinspace\ref{gfdl-4}) above for modified + versions, provided that you include in the combination all of + the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + +The combined work need only contain one copy of this + License, and multiple identical Invariant Sections may be + replaced with a single copy. If there are multiple Invariant + Sections with the same name but different contents, make the + title of each such section unique by adding at the end of it, + in parentheses, the name of the original author or publisher + of that section if known, or else a unique number. Make the + same adjustment to the section titles in the list of Invariant + Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled + `History' in the various original documents, + forming one section Entitled `History'; likewise + combine any sections Entitled `Acknowledgements', + and any sections Entitled `Dedications'. You + must delete all sections Entitled + `Endorsements'. +\section{COLLECTIONS OF DOCUMENTS} +\label{gfdl-6} + +You may make a collection consisting of the Document and + other documents released under this License, and replace the + individual copies of this License in the various documents + with a single copy that is included in the collection, + provided that you follow the rules of this License for + verbatim copying of each of the documents in all other + respects. + +You may extract a single document from such a collection, + and distribute it individually under this License, provided + you insert a copy of this License into the extracted document, + and follow this License in all other respects regarding + verbatim copying of that document. +\section{AGGREGATION WITH INDEPENDENT + WORKS} +\label{gfdl-7} + +A compilation of the Document or its derivatives with + other separate and independent documents or works, in or on a + volume of a storage or distribution medium, is called an + `aggregate' if the copyright resulting from the + compilation is not used to limit the legal rights of the + compilation's users beyond what the individual works + permit. When the Document is included an aggregate, this + License does not apply to the other works in the aggregate + which are not themselves derivative works of the + Document. + +If the Cover Text requirement of section 3 is applicable + to these copies of the Document, then if the Document is less + than one half of the entire aggregate, the Document's + Cover Texts may be placed on covers that bracket the Document + within the aggregate, or the electronic equivalent of covers + if the Document is in electronic form. Otherwise they must + appear on printed covers that bracket the whole + aggregate. +\section{TRANSLATION} +\label{gfdl-8} + +Translation is considered a kind of modification, so you + may distribute translations of the Document under the terms of + section 4. Replacing Invariant Sections with translations + requires special permission from their copyright holders, but + you may include translations of some or all Invariant Sections + in addition to the original versions of these Invariant + Sections. You may include a translation of this License, and + all the license notices in the Document, and any Warranty + Disclaimers, provided that you also include the original + English version of this License and the original versions of + those notices and disclaimers. In case of a disagreement + between the translation and the original version of this + License or a notice or disclaimer, the original version will + prevail. + +If a section in the Document is Entitled + `Acknowledgements', `Dedications', + or `History', the requirement (section 4) to + Preserve its Title (section 1) will typically require changing + the actual title. +\section{TERMINATION} +\label{gfdl-9} + +You may not copy, modify, sublicense, or distribute the + Document except as expressly provided for under this License. + Any other attempt to copy, modify, sublicense or distribute + the Document is void, and will automatically terminate your + rights under this License. However, parties who have received + copies, or rights, from you under this License will not have + their licenses terminated so long as such parties remain in + full compliance. +\section{FUTURE REVISIONS OF THIS + LICENSE} +\label{gfdl-10} + +The Free Software Foundation may publish new, revised + versions of the GNU Free Documentation License from time to + time. Such new versions will be similar in spirit to the + present version, but may differ in detail to address new + problems or concerns. See + http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing + version number. If the Document specifies that a particular + numbered version of this License `or any later + version' applies to it, you have the option of + following the terms and conditions either of that specified + version or of any later version that has been published (not + as a draft) by the Free Software Foundation. If the Document + does not specify a version number of this License, you may + choose any version ever published (not as a draft) by the Free + Software Foundation. +\section{ADDENDUM: How to use this License + for your documents} +\label{gfdl-addendum} + +To use this License in a document you have written, + include a copy of the License in the document and put the + following copyright and license notices just after the title + page: +\begin{quotation}\small\noindent + + Copyright (c) YEAR YOUR NAME. Permission is granted to + copy, distribute and/or modify this document under the terms + of the GNU Free Documentation License, Version 1.2 or any + later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no + Back-Cover Texts. A copy of the license is included in the + section entitled `GNU Free Documentation + License'. + +\end{quotation} + +If you have Invariant Sections, Front-Cover Texts and + Back-Cover Texts, replace the + `with\dots Texts.' line with this: +\begin{quotation}\small\noindent + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover + Texts being LIST. + +\end{quotation} + +If you have Invariant Sections without Cover Texts, or + some other combination of the three, merge those two + alternatives to suit the situation. + +If your document contains nontrivial examples of program + code, we recommend releasing these examples in parallel under + your choice of free software license, such as the GNU General + Public License, to permit their use in free software. + +\end{multicols} +\chapter{Configuring \TeX{} search paths} +\label{cnf} + +\TeX{} systems run on a huge variety of platforms, and are + typically made up of huge numbers of quite small files, so they + cannot easily use each operating system's built-in methods + of searching for a file when needed. + +Instead, they use a technique borrowed from the Unix world, + based on a simple index for each directory they need to look in. + This is known as the ls-R database, from the Unix command + (\verb+ls -R+) which creates it, and the program + which does it for \TeX{} is sometimes actually called + \product{mktexlsr}. This is the program referred + to in step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}. + +However, to know where to make these indexes, and thus where + to search, \TeX{} needs to be told about them. In a standard + \TeX{} installation this information is in + \url+texmf/web2c/texmf.cnf+. The file is similar + to a Unix script, but the only lines of significance for the + search paths are the following (this is how they appear in the + default Unix installation, omitting the comments): +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +TEXMFMAIN = /usr/TeX/texmf +TEXMFLOCAL = /usr/TeX/texmf-local +HOMETEXMF = $HOME/texmf +TEXMF = {$HOMETEXMF,!!$TEXMFLOCAL,!!$TEXMFMAIN} +SYSTEXMF = $TEXMF +VARTEXFONTS = /var/lib/texmf +TEXMFDBS = $TEXMF;$VARTEXFONTS + \end{Verbatim} +\end{sourcecode} + +As you can see, this defines where the main \TeX{}/\mf{} + directory is, where the local one is, and where the user's + personal (home) one is. It then defines the order in which they + are searched, and makes this the system-wide list. A temporary + directory for bitmap fonts is set up, and added to the list, + defining the places in which \product{texhash} + or \product{mktexlsr} creates its + databases. + +In some installations, the local directory is set up in + \url+/usr/local/share/texmf+ or + \url+/usr/share/texmf.local+ or similar + variations, so you would substitute this name for + \url+/usr/TeX/texmf-local+. Under Microsoft + Windows, the names will be full paths such as + \url+C:\Program Files\TeXLive\texmf+. On an Apple + Mac, it might be \url+Hard Disk:TeX:texmf+. + +If you edit plain-text configuration files with anything + other than a plain-text editor (e.g. a wordprocessor), or if you + edit them with a plain-text editor which has been set to + word-wrap long lines, make sure you turn line-wrapping + \emph{off} so that any long lines are preserved in + their correct format. +\chapter{\TeX{} Users Group membership} +\label{tugform} + +The \TeX{} Users Group was founded in 1980 for educational + and scientific purposes: to provide an organization for those + who have an interest in typography and font design, and are + users of the \TeX{} typesetting system invented by Donald Knuth. + TUG is run by and for its members and represents the interests + of \TeX{} users worldwide. +\subsection*{TUG membership benefits}\addcontentsline{toc}{subsection}{TUG membership benefits} + +Members of TUG help to support and promote the use of + \TeX{}, \mf{}, and related systems worldwide. All members + receive \titlecite{tugboat} \textsl{TUGboat}, the + journal of the \TeX{} Users Group, the \TeX{} Live software + distribution (a runnable \TeX{} system), and the CTAN\index{CTAN@CTAN} software distribution (containing most + of the CTAN\index{CTAN@CTAN} archive). + +In addition, TUG members vote in TUG elections, and + receive discounts on annual meeting fees, store purchases, and + TUG-sponsored courses. TUG membership (less benefits) is + tax-deductible, at least in the USA. See the TUG Web site for + details. +\subsection*{Becoming a TUG member}\addcontentsline{toc}{subsection}{Becoming a TUG member} + +Please see the forms and information at \url+http://tug.org/join.html+. You can join + online, or by filling out a paper form. The NTG (Dutch) and + UKTUG (United Kingdom) \TeX{} user groups have joint membership + agreements with TUG whereby you can receive a discount for + joining both user groups. To do this, please join via \url+http://www.ntg.nl/newmember.html+ (the NTG + membership page) or \url+http://uk.tug.org/Membership/+ (the UKTUG + page), respectively, and select the option for joint + membership. + +Each year's membership entitles you to the software and + TUGboat produced for that year (even if it is produced in a + subsequent calendar year, as is currently the case with + TUGboat). You can order older issues of TUGboat and \TeX{} + memorabilia through the TUG store (\url+http://tug.org/store+). + +The current TUG membership fee is \$65 (US) per year + for individuals and \$35 for students and seniors. Add + \$10 to the membership fee after May 31 to cover + additional shipping and processing costs. The current rate for + non-voting subscription memberships (for libraries, for + example) is \$85. The current institutional rate is + \$500, which includes up to seven individual + memberships. +\subsection*{Privacy}\addcontentsline{toc}{subsection}{Privacy} + +TUG uses your personal information only to mail you + products, publications, notices, and (for voting members) + official ballots. Also, if you give explicit agreement, we may + incorporate it into a membership directory which will be made + available only to TUG members. + +TUG neither sells its membership list nor provides it to + anyone outside of its own membership. +\renewcommand{\bibname}{References} +\bibliography{beginlatex} +\bibliographystyle{jurabib} +\begin{VerbatimOut}{beginlatex.bib} +@book{mathguide, + juraauthor = {AMS}, + author = {{American Mathematical Society}}, + title = {{Short Math Guide for \LaTeX{}}}, + juratitle = {Short Math Guide}, + publisher = {AMS}, + address = {Providence, RI}, + url = {http://www.ams.org/tex/short-math-guide.html}, + year = {2001}, + comment = {Written by XSLT} +} +@techreport{fontname, + author = {Karl Berry}, + title = {{Fontname: Filenames for \TeX{} fonts}}, + url = {http://www.ctan.org/tex-archive/info/fontname/}, + organisation = {\TeX{} Users Group}, + address = {Portland, OR}, + year = {June 2001}, + comment = {Written by XSLT} +} +@book{bull, + author = {RJ Bull}, + title = {{Accounting in Business}}, + publisher = {Butterworths}, + address = {London}, + year = {1972}, + isbn = {0-406-70651-4}, + comment = {Written by XSLT} +} +@techreport{teiguide, + author = {Lou Burnard and Michael Sperberg-McQueen}, + title = {{Guidelines for the Text Encoding Initiative}}, + juratitle = {TEI Guidelines}, + organisation = {OUP}, + address = {Oxford}, + year = {1995}, + comment = {Written by XSLT} +} +@book{davy, + author = {William Davy}, + title = {{A System of Divinity}}, + publisher = {Published by the author}, + address = {Lustleigh, Devon}, + year = {1806}, + comment = {Written by XSLT} +} +@techreport{gentle, + author = {Michael Doob}, + title = {{A Gentle Introduction to \TeX{}: A Manual for Self-Study}}, + juratitle = {Gentle Intro}, + organisation = {\TeX{} Users Group}, + address = {Portland, OR}, + year = {2002}, + url = {http://www.ctan.org/tex-archive/info/gentle/}, + comment = {Written by XSLT} +} +@book{bovary, + author = {Gustave Flaubert}, + title = {{Madame Bovary}}, + address = {Paris}, + year = {1857}, + comment = {Written by XSLT} +} +@book{htmlbook, + author = {Peter Flynn}, + title = {{The HTML Handbook}}, + juratitle = {The HTML Handbook}, + publisher = {International Thompson Computer + Press}, + address = {London}, + isbn = {1-85032-205-8}, + year = {1995}, + comment = {Written by XSLT} +} +@book{sgmltools, + author = {Peter Flynn}, + title = {{Understanding SGML and XML Tools}}, + juratitle = {SGML \amp XML Tools}, + publisher = {Kluwer}, + address = {Boston}, + isbn = {0-7923-8169-6}, + year = {1998}, + comment = {Written by XSLT} +} +@book{fg, + author = {John Fothergill}, + title = {{An Innkeeper's Diary}}, + publisher = {Penguin}, + address = {London}, + edition = {3rd}, + year = {1929}, + comment = {Written by XSLT} +} +@book{companion, + author = {Michel Goossens and Frank Mittelbach and Alexander Samarin}, + title = {{The \LaTeX{} Companion}}, + juratitle = {Companion}, + publisher = {Addison-Wesley}, + address = {Reading, MA}, + isbn = {0-201-54199-8}, + year = {1993}, + comment = {Written by XSLT} +} +@book{graphicscomp, + author = {Michel Goossens and Sebastian Rahtz and Frank Mittelbach}, + title = {{The \LaTeX{} Graphics Companion}}, + juratitle = {Graphics Companion}, + publisher = {Addison-Wesley}, + address = {Reading, MA}, + isbn = {0-201-85469-4}, + year = {1997}, + comment = {Written by XSLT} +} +@book{webcomp, + author = {Michel Goossens and Sebastian Rahtz and Ross Moore and Bob Sutor}, + title = {{The \LaTeX{} Web Companion}}, + juratitle = {Web Companion}, + publisher = {Addison-Wesley}, + address = {Reading, MA}, + isbn = {0-201-43311-7}, + year = {1999}, + comment = {Written by XSLT} +} +@article{goreham-ctt, + author = {Anthony Goreham}, + title = {{Re: Installing a new font: PFM, PFB}}, + juratitle = {Installing a new font}, + url = {news:comp.text.tex}, + number = {m3r8qj42o3.fsf@micawber.queens.ox.ac.uk}, + pages = {(all pages)}, + year = {28 November 2001}, + comment = {Written by XSLT} +} +@article{heller, + author = {Robert Heller}, + title = {{New To \LaTeX{}\dots Unlearning Bad Habits}}, + juratitle = {Bad habits}, + url = {news:comp.text.tex}, + number = {MPG.18d82140d65ddc5898968c@news.earthlink.net}, + pages = {(all pages)}, + year = {11 March 2003}, + comment = {Written by XSLT} +} +@techreport{fontinst, + author = {Alan Jeffrey and Rowland McDonnell}, + title = {{Font installation software for \TeX{}}}, + juratitle = {Fontinst}, + url = {http://www.tex.ac.uk/tex-archive/fonts/utilities/fontinst/}, + organisation = {\TeX{} Users Group}, + year = {30 June 1998}, + comment = {Written by XSLT} +} +@book{aocs, + author = {Donald Ervin Knuth}, + title = {{The Art of Computer Programming}}, + publisher = {Addison-Wesley}, + address = {Reading, MA}, + edition = {2nd}, + volume = {1}, + isbn = {0-201-89685-0}, + year = {1980}, + comment = {Written by XSLT} +} +@book{latexbook, + author = {Leslie Lamport}, + title = {{\LaTeX{}: A Document Preparation System}}, + publisher = {Addison-Wesley}, + address = {Reading, MA}, + isbn = {0-201-52983-1}, + edition = {2nd}, + year = {1994}, + comment = {Written by XSLT} +} +@book{macnamara, + author = {Matthew {Mac Namara}}, + title = {{La Textualisation de \emph{Madame + Bovary}}}, + publisher = {Rodopi}, + address = {Amsterdam}, + year = {2003}, + comment = {Written by XSLT} +} +@techreport{lshort, + author = {Tobias Oetiker and Hubert Partl and Irene Hyna and Elisabeth Schlegl}, + title = {{The (Not So) Short Guide to \LaTeXe{}: \LaTeXe{} in 131 Minutes}}, + juratitle = {Short Guide}, + organisation = {\TeX{} Users Group}, + url = {http://www.ctan.org/tex-archive/info/lshort/}, + year = {2001}, + edition = {3.2}, + comment = {Written by XSLT} +} +@techreport{symbol-list, + author = {Scott Pakin}, + title = {{A comprehensive list of symbols in \TeX{}}}, + juratitle = {Symbol list}, + organisation = {\TeX{} Users Group}, + url = {http://www.ctan.org/tex-archive/info/symbols/comprehensive/}, + year = {2002}, + comment = {Written by XSLT} +} +@techreport{begin, + juraauthor = {TUG}, + author = {{\TeX{} Users Group}}, + title = {{Getting Started with \TeX{}, \LaTeX{}, and friends}}, + juratitle = {Getting Started}, + organisation = {\TeX{} Users Group}, + url = {http://www.tug.org/begin.html}, + year = {November 2003}, + comment = {Written by XSLT} +} +@techreport{imported, + author = {Keith Reckdahl}, + title = {{Using imported graphics in \LaTeXe{}}}, + juratitle = {Imported graphics}, + organisation = {\TeX{} Users Group}, + url = {http://www.ctan.org/tex-archive/info/epslatex.pdf/}, + year = {1997}, + edition = {2.0}, + comment = {Written by XSLT} +} +@book{ryder, + author = {John Ryder}, + title = {{Printing for Pleasure}}, + publisher = {Bodley Head}, + address = {London}, + isbn = {0-370-10443-9}, + year = {1976}, + comment = {Written by XSLT} +} +@techreport{xmlfaq, + author = {Peter Flynn}, + title = {{The XML FAQ}}, + organisation = {University College Cork}, + address = {Cork, Ireland}, + url = {http://www.ucc.ie/xml/}, + year = {January 2003}, + comment = {Written by XSLT} +} +@techreport{gnufdl, + juraauthor = {FSF}, + author = {{Free Software Foundation}}, + title = {{The GNU Free Documentation License}}, + juratitle = {GNU FDL}, + organisation = {Free Software Foundation}, + address = {Boston, MA}, + url = {http://www.fsf.org/copyleft/fdl.html}, + year = {2003/02/10 23:42:49}, + comment = {Written by XSLT} +} +@proceedings{tugboat, + editor = {Barbara Beeton}, + title = {{TUGboat}}, + publisher = {\TeX{} Users Group}, + address = {Portland, OR}, + issn = {0896-3207}, + year = {Since 1980}, + comment = {Written by XSLT} +} +@proceedings{wired, + editor = {Chris Anderson}, + title = {{WIRED}}, + publisher = {Cond\'e Nast}, + address = {San Francisco, CA}, + issn = {1059-1028}, + year = {1993--}, + comment = {Written by XSLT} +} +\end{VerbatimOut} +\renewcommand{\indexname}{Index} +\clearpage\section*{\indexname} + +The same fonts are used here as in the text of the booklet + (see the Introduction) + to distinguish between different meanings: +\begin{center} +\begin{tabular}{ll}\textbf{\normalfont\bfseries\upshape Notation}&\textbf{\normalfont\bfseries\upshape Meaning}\\[2pt]\hline\\[-.95\baselineskip] +CTAN\index{CTAN@CTAN}&Acronyms (small caps in some typefaces)\\ +\command{command}&\LaTeX{} control sequences (monospace font)\\ +{\fontseries{b}\fontshape{it}\selectfont{}term}&Defining instance of a specialist term (bold + italics)\\ +\product{product}&program or product name (italics)\\ +\env{environment}&\LaTeX{} environment (sans-serif bold)\\ +\package{package}&\LaTeX{} package (sans-serif; all available from + CTAN\index{CTAN@CTAN})\\ +\opt{options}, + \counter{variables}&options and variables (oblique)\\ +\end{tabular} +\end{center} + +In the online version, these entries are all hyperlinked to + their source: for clarity the stylesheet recommends + retaining the traditional blue colour but removing the + underlining which most browsers use to indicate a link. + +Page numbers in {\fontseries{b}\selectfont{}bold type} + indicate the defining instance. +\par\parfillskip=0pt plus.5fil +\multicolsep=1.5pc\printindex +\end{document} diff --git a/info/beginlatex/src/old/beginlatex-typebook.tex b/info/beginlatex/src/old/beginlatex-typebook.tex new file mode 100644 index 0000000000..94b962baf9 --- /dev/null +++ b/info/beginlatex/src/old/beginlatex-typebook.tex @@ -0,0 +1,10425 @@ +\documentclass[12pt,a4paper,twoside]{report} +\usepackage{typebook} +\begin{document} +\title{Formatting information} +\subtitle{A beginner's introduction to typesetting with + \LaTeX{}} +\author{Peter Flynn} +\date{v.3.6 March 2005} +\legal{% +This document is Copyright © 1999\ndash{}2005 by + Silmaril Consultants under the terms of what is now the GNU + Free Documentation License (copyleft). + +Permission is granted to copy, distribute and/or modify + this document under the terms of the GNU Free Documentation + License, Version 1.2 or any later version published by the + Free Software Foundation; with no Invariant Sections, no + Front-Cover Texts, and no Back-Cover Texts. A copy of the + license is included in the section entitled \titlecite{gnufdl}. + +You are allowed to distribute, reproduce, and modify it + without fee or further requirement for consent subject to the + conditions in \S\thinspace\ref{gfdl-4}. The author has + asserted his right to be identified as the author of this + document. If you make useful modifications you are asked to + inform the author so that the master copy can be updated. See + the full text of the License in Appendix~\ref{gfdl}. + +}\maketitle +\subsubsection*{Acknowledgments} +This edition of \textsl{Formatting + Information} was prompted by the generous help I + have received from \TeX{} users too numerous to mention + individually. Shortly after TUGboat published the November + 2003 edition, I was reminded by a spate of email of the + fragility of documentation for a system like \LaTeX{} which is + constantly under development. There have been revisions to + packages; issues of new distributions, new tools, and new + interfaces; new books and other new documents; corrections to + my own errors; suggestions for rewording; and in one or two + cases mild abuse for having omitted package X which the author + felt to be indispensable to users.\par +I am grateful as always to the people who sent me + corrections and suggestions for improvement. Please keep them + coming: only this way can this booklet reflect what people + want to learn. The same limitation still applies, however: no + mathematics, as there are already a dozen or more excellent + books on the market\mdash{}as well as other online + documents\mdash{}dealing with mathematical typesetting in + \TeX{} and \LaTeX{} in finer and better detail than I am + capable of.\par +The structure remains the same, but I have revised and + rephrased a lot of material, especially in the earlier + chapters where a new user cannot be expected yet to have + acquired any depth of knowledge. Many of the screenshots have + been updated, and most of the examples and code fragments have + been retested.\par +As I was finishing this edition, I was asked to review + an article for \titlecite{practex}, which + grew out of the Practical \TeX{} Conference in 2004. The + author specifically took the writers of documentation to task + for failing to explain things more clearly, and as I read + more, I found myself agreeing, and resolving to clear up some + specific problems areas as far as possible. It is very + difficult for people who write technical documentation to + remember how they struggled to learn what has now become a + familiar system. So much of what we do is second nature, and a + lot of it actually has nothing to do with the software, but + more with the way in which we view and approach information, + and the general level of knowledge of computing. If I have + obscured something by making unreasonable assumptions about + \emph{your} knowledge, please let me know so + that I can correct it.\par +\par\vspace*{2pc}\noindent\ignorespaces +Peter Flynn is author of \titleof{htmlbook} and \titleof{sgmltools}, and editor of \titleof{xmlfaq}. +\par\vfill +\subsubsection*{Technical~note} +The text is written and + maintained in DocBook with a customization layer for + typographics. XSLT\index{XSLT@XSLT} is used to generate + HTML\index{HTML@HTML} (for the Web and plain-text + versions) and \LaTeX{} (for PDF\index{PDF@PDF} and + PostScript\index{PostScript}). The November 2003 edition + was published in \titlecite{tugboat}. This edition contains extensive + revisions and simplifications to the text, and many corrections + to the way in which the packages and their capabilities are + presented.\par\vfill +\renewcommand{\contentsname}{Contents} +\tableofcontents +\listofexercises +\listoftables +\prelim{Introduction}\label{intro} + +This book originally accompanied a 2-day course on using the + \LaTeX{} typesetting system. It has been extensively revised and + updated and can now be used for self-study or in the classroom. + It is aimed at users of Linux, Macintosh, or Microsoft Windows + but it can be used with \LaTeX{} systems on any platform, + including other Unix workstations, mainframes, and even your + Personal Digital Assistant (PDA)\index{PDA@PDA|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PDA@PDA|textbf}. +\subsection*{Who needs this book?}\addcontentsline{toc}{subsection}{Who needs this book?} + +The audience for the original training course was assumed + to be computer-literate and composed of professional, + business, academic, technical, or administrative computer + users. The readers of the book (you) are mostly assumed to be + in a similar position, but may also come from many other + backgrounds, including hobbyists, students, and just people + interested in quality typesetting. You are expected to have + one or more of the following or similar objectives: +\begin{itemize} +\item +producing typesetter-quality formatting; + +\item +formatting long, complex, highly-structured, + repetitive, or automatically-generated + documents;\footnote{\LaTeX{} can easily be used for once-off or short + and simple documents as well, but its real strengths + lie in consistency and automation.} + +\item +saving time and effort by automating common + tasks; + +\item +achieving or maintaining your independence from + specific makes or models of proprietary hardware, + software, or file formats (portability); + +\item +using Open Source software (free of restrictions, + sometimes also free of charge). + +\end{itemize} +\subsection*{Skills needed}\addcontentsline{toc}{subsection}{Skills needed} + +\LaTeX{} is a very easy system to learn, and requires no + specialist knowledge, although literacy and some familiarity + with the publishing process is useful. It is, however, assumed + that you are completely fluent and familiar with using your + computer before you start. Specifically, effective use of this + document requires that you already know and understand the + following very thoroughly: +\begin{itemize} +\item +how to use a good plain-text + editor (\emph{not} a wordprocessor like + \product{OpenOffice}, + \product{WordPerfect}, or Microsoft + \product{Word}, and + \emph{not} a toy like Microsoft + \product{Notepad});\marginal{ +2.1.3 +} + +\item +where to find all 95 of the printable ASCII\index{ASCII@ASCII} characters on your keyboard and + what they mean, and how to type accents and symbols, if + you use them;\marginal{ +3.2.1.2 +} + +\item +how to create, open, save, + close, rename, move, and delete files and folders + (directories);\marginal{ +2.3 +} + +\item +how to use a Web browser and/or File + Transfer Protocol (FTP)\index{FTP@FTP|textbf}\index{Acronyms@\textbf{Acronyms}, defined!FTP@FTP|textbf} program to + download and save files from the Internet;\marginal{ +7.3.1.6 +} + +\item +how to uncompress and unwrap (unzip or detar) + downloaded files.\marginal{ +2.3.7 +} + +\end{itemize} + +If you don't know how to do + these things yet, it's important to go and learn them + first. Trying to become familiar with the fundamentals of + using a computer \emph{at the same time} as + learning \LaTeX{} is not likely to be as effective as doing + them in order. + +These are not specialist + skills\mdash{}they are all included in the European Computer Driving + Licence (ECDL)\index{ECDL@ECDL|textbf}\index{Acronyms@\textbf{Acronyms}, defined!ECDL@ECDL|textbf} and the relevant sections of the ECDL\index{ECDL@ECDL} syllabus are noted in the margin + above, so they are well within the capability of anyone who + uses a computer. +\subsection*{Objectives of this book}\addcontentsline{toc}{subsection}{Objectives of this book} + +By the end of this book, you should be able to undertake + the following tasks: +\begin{itemize} +\item +use a plain-text editor to create and maintain your + documents; + +\item +add \LaTeX{} markup to identify + your document structure and formatting + requirements; + +\item +typeset \LaTeX{} documents, correct simple formatting + errors, and display or print the results; + +\item +identify, install, and use additional packages (using + CTAN\index{CTAN@CTAN} for downloading where + necessary); + +\item +recognise the limitations of procedural markup systems + and choose appropriate generic markup methods where + appropriate. + +\end{itemize} +\subsection*{Synopsis}\addcontentsline{toc}{subsection}{Synopsis} + +The original course covered the following topics as + separate sessions, which are represented in the book as + chapters: +\begin{enumerate}\item +Where to get and how to install + \LaTeX{} (\product{te\TeX{}}, + \product{fp\TeX{}}, or + \product{pro\TeX{}t} from the + \TeX{} Collection disks);\index{texlive@ Live}\index{texcollection@ Collection} + +\item +How to type \LaTeX{} documents: + using an editor to create files + (\product{WinShell}, + \product{WinEdt}, + \product{\TeX{}nicCenter}, or + \product{Emacs}); + +\item +Basic structures (the Document Class Declaration and + its layout options; the document environment with sections + and paragraphs); + +\item +Typesetting, viewing, and printing; + +\item +The use of packages and CTAN\index{CTAN@CTAN} + to adapt formatting using standard tools; + +\item +Other document structures (lists, tables, figures, + images, and verbatim text); + +\item +Textual tools (footnotes, marginal notes, + cross-references, indexes and glossaries, and + bibliographic citations); + +\item +Typographic considerations (white-space and typefaces; + inline markup and font changes; extra font installation + and automation); + +\item +Programmability and automation (macros and modifying + \LaTeX{}'s behaviour); + +\item +Conversion and compatibility with other systems + (XML\index{XML@XML}, + \product{Word}, etc.). + +\end{enumerate} + +A few changes have been made in the transition to printed + and online form, but the basic structure is the same, and the + document functions as a workbook for the course as well as a + standalone self-teaching guide. +\subsection*{Where's the math?}\addcontentsline{toc}{subsection}{Where's the math?} + +It is important to note that + the document \emph{does not cover} mathematical + typesetting, complex tabular material, the design of + large-scale macros and document classes, or the finer points + of typography or typographic design, although it does refer to + these topics in passing on a few occasions. +\index{mathematics} +There are several other guides, introductions, and + `get-started' documents on the Web and + on CTAN\index{CTAN@CTAN} which cover these topics and + more. Among the more popular are: +\begin{itemize} +\item +\titlecite{begin}, where all + beginners should start; + +\item +\titlecite{lshort} is a good + beginner's tutorial; + +\item +\titlecite{gentle} is a classic + tutorial on Plain \TeX{}; + +\item +\titlecite{imported} shows you how + to do (almost) anything with graphics: side-by-side, + rotated, etc.; + +\item +\titlecite{mathguide} gets you + started with the American Math Society's powerful + packages; + +\item +\titlecite{symbol-list} shows over + 2,500 symbols available. + +\end{itemize} + +This list was taken from the + CTAN\index{CTAN@CTAN} search page. There are also + lots of books published about \TeX{} and \LaTeX{}: the most + important of these for users of this document are listed in + the last paragraph of the Foreword on p.\thinspace\pageref{docs}. +\subsection*{Availability of \LaTeX{} systems}\addcontentsline{toc}{subsection}{Availability of \LaTeX{} systems}\label{availability} + +Because the \TeX{} program (the + `engine' which actually does the + typesetting) is separate from whichever editor you choose, + \TeX{}-based systems are available in a variety of different + modes using different interfaces, depending on how you want to + use them. +\subsubsection*{Graphical interface}\addcontentsline{toc}{subsubsection}{Graphical interface}\label{gui} + +The normal way to run \LaTeX{} is + to use a toolbar button (icon), a menu item, or a keystroke + in your editor. Click on it and your document gets saved and + typeset. All the other features of \LaTeX{} systems (the + typeset display, spellchecker, related programs like + \product{makeindex} and \BibTeX{}) are run + the same way. This works both in a normal Graphical User Interface (GUI)\index{GUI@GUI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!GUI@GUI|textbf} as well as in + text-only interfaces. + +In the popular \LaTeX{} editors like + \product{Emacs}, + \product{\TeX{}shell}, + \product{\TeX{}nicCenter}, + \product{WinShell}, or + \product{WinEdt}, a record of the + typesetting process is shown in an adjoining window so that + you can see the progress of pages being typeset, and any + errors or warnings that may occur.\footnote{Recent versions of some editors hide this display by + default unless errors occur in the typesetting.} +\subsubsection*{Command-line interface}\addcontentsline{toc}{subsubsection}{Command-line interface}\label{cli} + +However, the graphical interface + is useless if you want to run \LaTeX{} unattended, as part of an + automated system, perhaps in a web server or e-commerce + environment, where there is no direct connection between + user and program. The underlying \TeX{} engine does in fact + have a Command-Line Interface (CLI)\index{CLI@CLI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CLI@CLI|textbf}, + that is, it can be used as a + `console' program which you run from + a standard Unix or Mac terminal or shell window (or from an + MS-DOS command window in Microsoft Windows systems) by + typing the command + \verb+latex+ followed by the name of your + document file (see Figure~\ref{clidemo} in \S\thinspace\ref{cmdwin} for an example). + +Commands like these let you run \LaTeX{} in an automated + environment like a + Common Gateway Interface (CGI)\index{CGI@CGI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CGI@CGI|textbf} script + on a web server or a batch file on a document system. All + the popular distributions for Unix and Windows, both free + and commercial, include this interface as standard + (te\TeX{}, fp\TeX{}, MiK\TeX{}, pro\TeX{}t, + PC-\TeX{}, True\TeX{}, + etc.). +\subsubsection*{Typeset displays}\addcontentsline{toc}{subsubsection}{Typeset displays}\label{displays} + +\LaTeX{} usually displays your + typeset results in a separate window, redisplayed + automatically every time the document is reprocessed, + because the typesetting is done separately from the editing. + Some systems, however, can format the typesetting while you + type, at the expense of some flexibility. +\begin{description} +\item[\sffamily Asynchronous typographic displays]\label{async} +This method is called an \textbf{\textit{asynchronous typographic + display}}\label{asynchronous}\index{asynchronous typographic + display@\textbf{\textit{asynchronous typographic + display}}} because the typeset window only + updates \emph{after} you have typed + something and reprocessed it, not + \emph{while} you are still typing, as it + would with a wordprocessor.\footnote{Among other reasons, \TeX{} typesets whole + paragraphs at a time, not line-by-line as lesser + systems do, in order to get the hyphenation and + justification (H\amp J) right (see \S\thinspace\ref{handj}). + } +\item[\sffamily Synchronous typographic displays]\label{sync} +\label{synchro}% +Some distributions of \LaTeX{} + offer a \textbf{\textit{synchronous + typographic interface}}\label{synchronous}\index{synchronous + typographic interface@\textbf{\textit{synchronous + typographic interface}}}. In these, you type + directly into the typographic display, as with a + wordprocessor. Three popular examples are + \product{Textures}, + \product{Scientific Word}, and + \product{V\TeX{}} (see table below). + At least one free version (\LyX{}, see Figure~\ref{lyxwin} in \S\thinspace\ref{editors}) + offers a similar interface. + +With a synchronous display + you get Instant Textual Gratification\texttrademark{}, but your + level of control is restricted to that of the GUI\index{GUI@GUI} you use, which cannot provide + access to everything that \LaTeX{} can do. For + complete control of the formatting + you may still need access to your normal source + (input) file in the same way as for asynchronous + implementations. +\item[\sffamily Near-synchronous displays] +There are several other + methods available free for Unix and some other systems + for close-to-synchronous updates of the typeset + display (including \person{Jonathan Fine}'s \product{Instant + Preview} and the \TeX{} daemon), and + for embedding typographic fragments from the typeset + display back into the editor window (\person{David Kastrup}'s \package{preview-latex} + package). +\end{description} +\subsubsection*{Commercial distributions}\addcontentsline{toc}{subsubsection}{Commercial distributions}\label{commercial} + +Whatever method you choose, the + \TeX{} Collection CD and CTAN\index{CTAN@CTAN} are + not the only source of software. The vendors listed in Table~ offer excellent commercial + implementations of \TeX{} and \LaTeX{}, + and if you are in a position where their enhanced support + and additional features are of benefit, I urge you to + support them. In most cases their companies, founders, and + staff have been good friends of the \TeX{} and \LaTeX{} + communities for many years.\index{commercial implementations} +\begin{table}\small \caption{\small Popular commercial implementations of \TeX{} systems} +\label{vendors} +\begin{center} +\begin{tabular}{@{}p{.65in}p{1in}>{\pbs{\raggedright}}p{.9in}l@{}} +\textbf{\sffamily\upshape Product}&\textbf{\sffamily\upshape Platform}&\textbf{\sffamily\upshape Company}&\textbf{\sffamily\upshape URI}\\[2pt]\hline\\[-1.5\baselineskip] +PC\TeX{}&MS-Windows&Personal \TeX{}, Inc&\url+www.pctex.com/+\\ +True\TeX{}&MS-Windows&True \TeX{}&\url+truetex.com/+\\ +Textures&Apple Mac&Blue Sky Research&\url+www.bluesky.com/+\\ +Scientific Word&MS-Windows&Mackichan Software&\url+www.mackichan.com/+\\ +V\TeX{}&MS-Windows, Linux, OS/2&MicroPress, Inc&\url+www.micropress-inc.com/+\\ +\end{tabular} +\end{center} +\end{table} +\subsection*{Production note}\addcontentsline{toc}{subsection}{Production note}\label{prodnote} + +This document is written and maintained in XML\index{XML@XML}, using a customized version of the + \product{DocBook} DTD\index{DTD@DTD}. Conversions were made to HTML\index{HTML@HTML} and \LaTeX{} using XSLT\index{XSLT@XSLT} scripts and \person{Michael Kay}'s \product{Saxon} + processor. + +The complete source, with all ancillary files, is + available online at \url+http://www.ctan.org/tex-archive/info/beginlatex/src/+ + but if you want to try processing it yourself you must install + \product{Java} (from Sun, IBM\index{IBM@IBM}, or a number of + others) and \product{Saxon} (from \url+http://saxon.sourceforge.net/+), in addition + to \LaTeX{}. + +This document is published under the terms and conditions + of the GNU\index{GNU@GNU} Free Documentation + License. Details are in Appendix~\ref{gfdl}. +\clearpage\subsection*{Symbols and conventions}\addcontentsline{toc}{subsection}{Symbols and conventions}\label{symbols} + +The following typographic notations are used: +\begingroup\small \begin{center} +\label{symboltable} +\begin{tabular}{@{}lp{3.5in}@{}} +\textbf{\sffamily\upshape Notation}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip] +\command{command}&Control sequences which perform an + action, e.g. \command{newpage}\\ +\length{length}&Control sequences which store a dimension + (measurement in units), e.g. \length{parskip}\\ +\counter{counter}&Values used for counting (whole numbers, as + opposed to measuring in units), e.g. \counter{secnumdepth}\\ +\textbf{\textit{term}}\label{term}\index{term@\textbf{\textit{term}}}&Defining instance of a + new term\\ +\env{environment}&A \LaTeX{} formatting environment\\ +\package{package}&A \LaTeX{} package (available from CTAN\index{CTAN@CTAN})\\ +\product{product}&Program or product name\\ +\verb+typewriter type+&Examples of source code (stuff you + type)\\ +{\ttfamily{}\selectfont{}\uline{mybook}} or {\ttfamily{}\fontshape{sl}\selectfont{}value}&Mnemonic examples of + things you have to supply real-life values for\\ +\key{x}&A key on your keyboard\\ +\key{Ctrl}--\key{x}~&Two keys pressed together\\ +\key{Esc}\thinspace{}\key{q}&Two keys pressed one after another\\ +\guiicon{Submit}&On-screen button to click\\ +\menuitem{Menu}{Item}&Drop-down menu with items\\ +\end{tabular} +\end{center} +\endgroup +Examples of longer fragments of input are shown with a + border round them. Where necessary, the formatted output is + shown immediately beneath. Warnings are shown with a shaded + background. Exercises are shown with a double border. +\prelim{Foreword}\label{foreword} + +As noted in the Introduction on p.\thinspace\pageref{intro}, + this document accompanies a two-day introductory training course. + It became obvious from repeated questions in class and + afterwards, as well as from general queries on \url+comp.text.tex+ that many people do + not read the FAQ\index{FAQ@FAQ}s, do not use the + TUG\index{TUG@TUG} web site, do not buy the books and + manuals, do not use the newsgroups and mailing lists, and do not + download the free documentation. Instead, they try to get by + using the training technique known as `sitting by + Nelly', which involves looking over a + colleague's shoulder in the office, lab, library, pub, or + classroom, and absorbing all his or her bad habits. + +In the summer of 2001 I presented a short proposal on the + marketing of \LaTeX{} to the annual conference of the \TeX{} Users + Group held at the University of Delaware, and showed an example + of a draft + brochure\footnote{\url+http://www.silmaril.ie/documents/latex-brochure/leaflet.pdf+} designed to persuade newcomers to try \LaTeX{} + for their typesetting requirements. As a result of questions and + suggestions, it was obvious that it needed to include a pointer + to some documentation, and I agreed to make available a revised + form of this document, expanded to be used outside the + classroom, and to include those topics on which I have had most + questions from users over the years. + +It turned out to mean a significant + reworking of a lot of the material. Some of it appears in almost + every other manual and book on \LaTeX{} but it is essential to + the beginner and therefore bears repetition. Some of it appears + other forms elsewhere, and is included here because it needs + explaining better. And some of it appears nowhere else but this + document. I took the opportunity to revise the structure of the + training course in parallel with the book (expanding it from its + original one day to two days), and to include a more + comprehensive index. It is by no means perfect (in both senses), + and I would be grateful for comments and corrections to be sent + to me at the address given under the credits. + +I had originally hoped that the \LaTeX{} version of the + document would be processable by any freshly-installed default + \LaTeX{} system, but the need to include font samples which go + well beyond the default installation, and to use some packages + which the new user is unlikely to have installed, means that + this document itself is not really a simple piece of \LaTeX{}, + however simply it may describe the process itself. + +However, as the careful reader will have already noticed, + the master source of the document is not maintained in \LaTeX{} + but in XML\index{XML@XML}. A future task is therefore + to compare the packages required with those installed by + default, and flag portions of the document requiring additional + features so that an abbreviated version can be generated which + can be guaranteed to process even with a basic \LaTeX{} + installation. + +\label{docs}% +If you are just starting with \LaTeX{}, at an early + opportunity you should buy or borrow a copy of \titlecite{latexbook} which is the original + author's manual. More advanced users should get the + \titlecite{companion} or one of its + successors. In the same series there are also the \titlecite{graphicscomp} and the \titlecite{webcomp}. Mathematical users might want to + read \titlecite{mathguide}. +\prelim{Preface}\label{preface} + +Many people discover \LaTeX{} after + years of struggling with wordprocessors and desktop publishing + systems, and are amazed to find that \TeX{} has been around for + over 25 years and they hadn't heard of it. It's not a + conspiracy, just `a well-kept secret known only to a few + million people', as one anonymous user has put + it. + +Perhaps a key to why it has remained + so popular is that it removes the need to fiddle with the + formatting while you write. Although playing around with fonts + and formatting is attractive to the newcomer, it is completely + counter-productive for the serious author or editor who wants to + concentrate on \emph{writing}\mdash{}ask any + journalist or professional writer. + +A few years ago a new \LaTeX{} user expressed concern on + the \url+comp.text.tex+ newsgroup about + `learning to write in \LaTeX{}'. Some + excellent advice\footnote{\url+news:comp.text.tex/MPG.18d82140d65ddc5898968c@news.earthlink.net+} was posted in response to this query, + which I reproduce with permission below [the bold text is my + emphasis]: +\begin{quotation}\small\begingroup \ttfamily\raggedright\setlength{\spaceskip}{.375em}\noindent +No, the harder part might be \emph{writing}, + period. \TeX{}/\LaTeX{} is actually easy, once you relax and + stop worrying about appearance as a be-all-and-end-all. Many + people have become `Word Processing + Junkies' and \emph{\textbf{no longer + `write' documents, they + `draw' them}}, almost at the + same level as a pre-literate 3-year old child might pretend to + `write' a story, but is just creating a + sequence of pictures with a pad of paper and box of + \product{Crayola}s\mdash{}this is perfectly + normal and healthy in a 3-year old child who is being + creative, but is of questionable usefulness for, say, a grad + student writing a Master's or PhD thesis or a business + person writing a white paper, etc. For this reason, + \emph{I} strongly recommend + \emph{not} using any sort of fancy GUI\index{GUI@GUI} `crutch'. + Use a plain vanilla text editor and treat it like an + old-fashioned typewriter. Don't waste time playing with + your mouse. + +Note: I am \emph{not} saying that you should + have no concerns about the appearance of your document, just + that you should \emph{write} the document + (completely) first and tweak the appearance + later\dots \emph{not} [spend time on] lots of + random editing in the bulk of the document itself. +\par\endgroup\smallskip\footnotesize\noindent [\citeauthortitleyear{heller}]\end{quotation} + +Learning to write well can be hard, but authors shouldn't + have to make things even harder for themselves by using + manually-driven systems which break their concentration every + few seconds for some footling adjustment to the appearance, + simply because the software is incapable of doing it right by + itself. + +\label{mathtex}% +\person{Don Knuth} originally wrote \TeX{} to typeset mathematics for + the second edition of his master-work \titlecite{aocs}, and it remains pretty much the only + typesetting program to include fully-automated mathematical + formatting done the way mathematicians want it. But he also + published a booklet called \titlecite{mathwrite} which shows how + important it is to think about what you write, and how the + computer should be able to help, not hinder. + +And \TeX{} is much more than math: + it's a programmable typesetting system which can be used + for almost any formatting task, and \LaTeX{} has made it usable by + almost anyone. Professor Knuth generously placed the entire system in the + public domain, so for many years there was no publicity of the + commercial kind which would have got \TeX{} noticed outside the + technical field. + +Nowadays, however, there are many companies + selling \TeX{} software or services,\footnote{See, for example, the list of \TeX{} vendors on p.\thinspace\pageref{vendors}, and the list of consultants + published by TUG\index{TUG@TUG}.} dozens + of publishers accepting \LaTeX{} documents for + publication, and hundreds of thousands of users using \LaTeX{} + for millions of documents.\footnote{A guesstimate. With free software it's impossible + to tell how many people are using it, but it's a + \emph{lot}.} + +To count yourself as a \TeX{} or \LaTeX{} user, visit the + \TeX{} Users Group's + `\TeX{} Counter' web site\footnote{\url+http://www.tug.org/tex/counter/+} + (and get a nice certificate!). + +There is occasionally some confusion among newcomers between + the two main programs, \TeX{} and \LaTeX{}: +\begin{itemize} +\item +\TeX{} is a typesetting program, originally written by + Prof Knuth at Stanford around 1978. It implements a + macro-driven typesetters' programming language of some + 300 basic operations and it has formed the core of many + other desktop publishing (DTP)\index{DTP@DTP|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DTP@DTP|textbf} + systems. Although it is still possible to write in the raw + \TeX{} language, you need to study it in depth, and you need + to be able to write macros (subprograms) to perform even the + simplest of repetitive tasks. + +\item +\LaTeX{} is a user interface for \TeX{}, designed by + \person{Leslie Lamport} at Digital Equipment + Corporation (DEC)\index{DEC@DEC|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DEC@DEC|textbf} in 1985 to automate all the common + tasks of document preparation. It provides a simple way for + authors and typesetters to use the power of \TeX{} without + having to learn the underlying language. \LaTeX{} is the + recommended system for all users except professional + typographic programmers and computer scientists who want to + study the internals of \TeX{}. + +\end{itemize} + +Both \TeX{} and \LaTeX{} have been + constantly updated since their inception. Knuth has now frozen + development of the \TeX{} engine so that users and developers + can have a virtually bug-free, rock-stable platform to work + with\footnote{Knuth still fixes bugs, although the chances of finding + a bug in \TeX{} these days approaches zero.}. Typographic programming development continues with + the New Typesetting System (NTS)\index{NTS@NTS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!NTS@NTS|textbf}, planned + as a successor to \TeX{}. The \LaTeX{}3 project has taken over + development of \LaTeX{}, and the current version is + \LaTeXe{}, which is what we are concentrating on here. Details + of all developments can be had from the TUG\index{TUG@TUG} at \url+http://www.tug.org+ +\begin{sidebar}\label{myths} +\subsection*{Debunking the mythology} +Naturally, over all the years, a few myths have grown up + around \LaTeX{}, often propagated by people who should know + better. So, just to clear up any potential + misunderstandings\dots +\begin{description} +\item[\sffamily MYTH: `\LaTeX{} has only got one + font'] +Most \LaTeX{} systems can use any OpenType, + TrueType, Adobe (PostScript\index{PostScript}) + Type1 or Type3, or \mf{} font. This is more than + most other known typesetting system. + \LaTeX{}'s default font is Computer Modern (based + on Monotype Series 8: see + the table on p.\thinspace\pageref{fontable-mf}), not Times Roman, and some + people get upset because it `looks + different' to Times. Typefaces differ: + that's what they're for\mdash{}get used to it. +\item[\sffamily MYTH: `\LaTeX{} isn't WYSIWYG\index{WYSIWYG@WYSIWYG}'] +Simply not true. DVI\index{DVI@DVI} + and PDF\index{PDF@PDF} preview is better + WYSIWYG\index{WYSIWYG@WYSIWYG} than any wordprocessor + and most DTP\index{DTP@DTP} systems. What + people mean is that \LaTeX{}'s typographic display + is asynchronous with the edit window. This is only true + for the default CLI\index{CLI@CLI} + implementations. See the Introduction on p.\thinspace\pageref{synchro} for details of synchronous + versions. +\item[\sffamily MYTH: `\LaTeX{} is obsolete'] +Quite the opposite: it's under constant + development, with new features being added almost + weekly. Check the \url+comp.text.tex+ for messages about recent + uploads to CTAN\index{CTAN@CTAN}. It's + arguably more up-to-date than most other systems: + \LaTeX{} had the Euro (\EUR{}) before anyone else, it had + Inuktitut typesetting before the Inuit got their own + province in Canada, and it still produces better + mathematics than anything else. +\end{description} +\end{sidebar}\begin{sidebar}\label{myths2} +\subsection*{More mythology}\begin{description} +\item[\sffamily MYTH: `\LaTeX{} is a Unix system'] +People are also heard saying: + `\LaTeX{} is a Windows system', + `\LaTeX{} is a Mac system', etc., + etc. \emph{ad nauseam}. + \TeX{} systems run on almost every computer in use, from + some of the biggest supercomputers down to handhelds + (PDA\index{PDA@PDA}s like the Sharp + \product{Zaurus}). That includes + Windows and Linux PCs, Macs, and all other Unix systems. + If you're using something \TeX{} doesn't run + on, it must be either incredibly new, incredibly old, or + unbelievably obscure. +\item[\sffamily MYTH: `\LaTeX{} is ``too + difficult''\thinspace'] +This has been heard from + physicists who can split atoms; from mathematicians who + can explain why \(\pi\) exists; from business people who can + read a balance sheet; from historians who can grasp + Byzantine politics; from librarians who can understand + LoC and MARC; and from linguists who can decode Linear + `B'. It's nonsense: most people grasp + \LaTeX{} in 20 minutes or so. It's not rocket + science (or if it is, I know any number of unemployed + rocket scientists who will teach it to you). +\item[\sffamily MYTH: `\LaTeX{} is ``only for + scientists and + mathematicians''\thinspace'] +Untrue. Although it grew up + in the mathematical and computer science fields, two of + its biggest growth areas are in the humanities and + business, especially since the rise of XML\index{XML@XML} brought new demands for automated + web-based typesetting. +\end{description} +\end{sidebar}\chapter{Installing \TeX{} and \LaTeX{}} +\label{get} +\pagenumbering{arabic} +\index{tetex@te}\index{fptex@fp}\index{texniccenter@nicCenter}\index{miktex@MiK}\index{Linux}\index{Unix}\index{Microsoft Windows}\index{Mac OS X}\index{Apple Mac}\index{OS X} +This course is based on using one of + the following distributions of \TeX{} on the 2004 \TeX{} + Collection DVD or the 2003 \TeX{} Live CD: +\begin{description} +\item[\sffamily te\TeX{}] +for Linux and other Unix-like systems, including Mac + OS\thinspace{}X (\person{Thomas Esser}); +\item[\sffamily pro\TeX{}t] +for Microsoft Windows (\person{Thomas Feuerstack}), based on \person{Christian Schenk}'s + Mik\TeX{}; +\item[\sffamily fp\TeX{}] +for Microsoft Windows (\person{Fabrice Popineau}) from the 2003 \TeX{} Live CD. +\end{description} + +Many other implementations of \TeX{}, + such as \person{Tom Kiffe}'s CMac\TeX{} for the Apple Macintosh, can be + downloaded from CTAN\index{CTAN@CTAN}. \LaTeX{} is + included with all modern distributions of \TeX{}. + +The \TeX{} Collection CD is issued + annually on behalf of most of the local \TeX{} user groups + around the world (see \url+http://www.tug.org/lugs.html+ for addresses), + and edited by \person{Sebastian Rahtz}, \person{Karl Berry}, \person{Manfred Lotz}, and the authors of the software mentioned above. + These people give an enormous amount of their personal time and + energy to building and distributing these systems, and they + deserve the thanks and support of the user community for all + they do. + +There are many other distributions of \LaTeX{} both free and + commercial, as described in the Introduction on p.\thinspace\pageref{intro}: they all process \LaTeX{} identically, but + there are some differences in size, speed, packaging, and (in + the case of commercial distributions) price, support, and extra + software provided. + +One final thing before we start: publicly-maintained + software like \TeX{} is updated faster than commercial software, + so \emph{always check to see if there is a more recent + version of the installation}. See the list on p.\thinspace\pageref{latest} in \S\thinspace\ref{latest} for more details. +\section{Editing and display} +\label{editdis} + +When you install \LaTeX{} you will + have the opportunity to decide \begin{inparaenum}[\itshape a\upshape)] \item which plain-text editor[s] you want to use to create + and maintain your documents; and \item which preview programs you want to use to see your + typesetting\end{inparaenum}. This isn't much use to you if you're + unfamiliar with editors and previewers, so have a look at the + table below, and maybe flip ahead to \S\thinspace\ref{editors} for a moment, where there are + descriptions and screenshots. + +The best bet is probably to install more than one\mdash{}if + you've got the disk space\mdash{}or maybe all of them, because + you can always delete the ones you don't like. +\begin{description} +\item[\sffamily Editors] +There is a wide range of editors available: probably + no other piece of software causes more flame-wars in + Internet and other discussions than your choice of + editor. It's a highly personal choice, so feel free + to pick the one you like. My personal biases are + probably revealed below, so feel equally free to ignore + them. +\item[\sffamily Previewers] +For displaying your + typesetting before printing, you will need a previewer. + All systems come with a DVI\index{DVI@DVI} + previewer for standard \LaTeX{}, + but if you are intending to produce industry-standard + PostScript\index{PostScript} or PDF\index{PDF@PDF} (Adobe Acrobat) files you will + need a previewer for those formats. + \product{GSview} displays both + PostScript\index{PostScript} and PDF\index{PDF@PDF} files; + \product{xpdf} and Adobe's own + \product{Acrobat Reader} just display + PDF\index{PDF@PDF} files. +\end{description} + +For brief details of some of the most popular editors used + for \LaTeX{}, see \S\thinspace\ref{editors}. +\begin{warning} +\label{pdfurl} +\subsubsection*{Additional downloads} +For licensing reasons, the + \product{GSview} PostScript/PDF previewer, + the \product{Acrobat Reader} PDF previewer, + and the \product{WinEdt} editor could not + be distributed on the 2003 CDs. In those cases you have to + download and install them separately. +\begin{itemize} +\item +\product{GSview} is available for + all platforms from \url+http://www.ghostscript.com/gsview/index.htm+ + (on Unix and VMS systems it's also available as + \product{GhostView} and + \product{gv}: see \url+http://www.cs.wisc.edu/~ghost/+) + +\item +\product{Acrobat Reader} (all + platforms) can be downloaded from \url+http://www.adobe.com/products/acrobat/readstep2.html+ + +\item +\product{WinEdt} (Microsoft Windows + only) comes from \url+http://www.winedt.com+ + +\end{itemize} +\end{warning} +\section{Installation for Linux and Unix} +\label{lininst} + +Make sure your system libraries and utilities are up to + date. If you are using Red Hat Linux, use + \product{yum} or + \product{up2date} to download and install + updates. For Debian and other distributions, use + \product{apt-get} or similar. On Red Hat + systems, remove any RPM version of te\TeX{} and associated + utilities which may have been + preinstalled, in order to avoid version conflicts. + +If you are installing \TeX{} Live to a new partition, and + you have the opportunity to reformat the partition before use, + use \product{mkfs} with a granularity as + small as it will go (usually 1024 bytes). This avoids the + partition running out of inodes because \TeX{} uses very large + numbers of very small files. + +Plan the installation carefully if you are installing for + multiple users (a shared machine): read \S\thinspace\ref{pkginst} for some comments on where to put additional + files downloaded later, and see the FAQ on the same topic at + \url+http://www.tex.ac.uk/cgi-bin/texfaq2html?label=wherefiles+ + +Above all, Read The Fine + Manual (RTFM)\index{RTFM@RTFM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!RTFM@RTFM|textbf}. The documentation is in + \url+live.html+ and + \url+live.pdf+ on the disk in the directory + \url+texlive2004/texmf-doc/doc/english/texlive-en/+ +\begin{figure}\small +\caption{\small \TeX{} Live installation manual} +\begin{center} +\includegraphics[width=0.75\textwidth]{tlcdoc} +\end{center} +\end{figure} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small,commandchars=\\\{\}] +# cd /\textsl{\uline{mnt/cdrom}}/texlive2004 +# sh install-tl.sh + \end{Verbatim} +\end{sourcecode} + +The installer runs in a shell window, so it can be done + even from headless systems (those with no X Window client), + but it does need to be installed as root if you want to stick + with the default directory locations or install it system-wide + for multiple users. To install, just type the commands shown + above. + +The options are mostly self-explanatory, and beginners + should pick the recommended scheme and leave all other + settings at their defaults. The character-driven interface + lets you browse around the settings changing things and + looking at options before you commit to installing + anything. +\begin{figure}\small +\caption{\small The Unix installation program} +\begin{sourcecode}\begin{Verbatim}[fontsize=\scriptsize] +==================> TeX Live installation procedure <================= + +===> Note: Letters/digits in <angle brackets> indicate menu items <=== +===> for commands or configurable options <=== + + Proposed platform: Intel x86 with GNU/Linux + <P> over-ride system detection and choose platform + <B> binary systems: 1 out of 10 + <S> Installation scheme (scheme_recommended) + [customizing installation scheme: + <C> standard collections <L> language collections] + 20 out of 75, disk space required: 246857 kB + <D> directories: + TEXDIR (The main TeX directory) : /usr/TeX + TEXMFLOCAL (Directory for local styles etc): /usr/TeX/texmf-local + VARTEXMF (Directory for local config) : /usr/TeX/texmf-var + <O> options: + [ ] alternate directory for generated fonts () + [ ] create symlinks in standard directories + [ ] do not install macro/font doc tree + [ ] do not install macro/font source tree + <R> do not install files, set up to run off CD or DVD + <I> start installation + <H> help, <Q> quit + +Enter command: + \end{Verbatim} +\end{sourcecode} +\end{figure} + +`Collections' (the {\slshape\verb`C`} and + {\slshape\verb`L`} options) are groups of \LaTeX{} packages + that you can include or exclude. It's best to leave this + alone unless you know you need something specific. The only + options I sometimes set are under {\slshape\verb`O`}: the + `alternate directory for generated fonts' may + need to be on a different partition for performance reasons on + a shared system; and I always select `create symlinks in + standard directories' so that the system works + immediately after the post-installation configuration (after + installation, run \product{texconfig} to + adjust your local settings. +\begin{figure}\small +\caption{\small Running the post-installation program + \emph{texconfig}} +\begin{center} +\includegraphics[width=0.75\textwidth]{texconfig} +\end{center} +\end{figure} + +Note that the Linux/Unix installation does not install any + editors: it is assumed you can do this yourself from your + distribution's standard package system (most likely + you will already be using \product{Emacs} or + \product{vi} anyway). +\section{Installation for Apple Mac} +\label{macinst} + +This is exactly the same interface as for the Linux/Unix + installation. You need the \product{bash} + shell (see the warning in the manual for users of older systems). + +There is a choice of graphical editors for the Mac: two + are included on the DVD, \product{\TeX{}Shop} + and \product{I\TeX{}Mac}, but they need to be + installed separately, after installing \TeX{}. +\section{Installation for Microsoft Windows} +\label{wininst} +\begin{figure}\small +\caption{\small \TeX{} Collection 2004 DVD} +\begin{center} +\includegraphics[width=0.75\textwidth]{tcdvddir} +\end{center} +\end{figure} + +Before you install \TeX{}, make + sure you have enough disk space: the default installation + takes about 350Mb on a modern filesystem. The installation + assumes you have a fully updated version of Windows, so visit + the Microsoft Web site first (\url+http://www.microsoft.com/+) and click on + \product{Windows Update}. Select and install + all the relevant updates for your operating system (Windows + 95, 98, ME, 2000, NT, or XP). You should be doing this + regularly anyway, to keep your system healthy. You may want to + run \product{ScanDisk} and give your hard + disks a full surface check. \TeX{} consists of a very large + number of quite small files, so it's important that your + disk is in good order. + +When you insert the distribution + DVD or CD, it should start the setup program automatically. If + you have auto-run turned off, open \product{My + Computer}, double-click on the DVD or CD drive, + and then double-click \product{Autorun} to + start the setup program.\footnote{Some builds of Windows seem to have a bug that stops + \product{Autorun} starting the + installation. In that case (for the \TeX{} Collection 2004 + DVD) double-click \url+Setup.exe+ instead, + or (for the \TeX{} + Collection 2003 CD) go to the \url+tpm+ + folder and double-click on + \url+TeXSetup.exe+.} +\subsection{pro\TeX{}t (\TeX{} Collection 2004)} + +For pro\TeX{}t from the \TeX{} + Collection DVD, follow the instructions in the PDF + documentation which opens automatically when you start + the setup. +\begin{figure}\small +\caption{\small pro\TeX{}t comes with its own installation + guide} +\begin{center} +\includegraphics[width=0.5\textwidth]{tcptpdf} +\end{center} +\end{figure} + +The documentation contains links (in large blue type) + that you click on in sequence to run the installation + process. (This is actually very good: everything worked + first time when I did it on XP.) Basically, you need to + install \begin{inparaenum}[\itshape a\upshape)] \item \product{MIK\TeX{}}; \item either + \product{WinEdt} (with or without + some of its add-ons) or + \product{\TeX{}nicCenter}; and \item \product{GhostScript} and + \product{GSview}\end{inparaenum}. +\begin{warning} + +You only need to install items step~\ref{nldi} in the procedure on p.\thinspace\pageref{nldi} + to step~\ref{td} in the procedure on p.\thinspace\pageref{td} if you install + \product{WinEdt}. +\end{warning} +\begin{figure}[b]\small +\caption{\small First document in + \emph{\TeX{}nicCenter}} +\label{tcpt1} +\begin{center} +\includegraphics[width=0.75\textwidth]{tcptfirstdoc} +\end{center} +\end{figure} +\begin{enumerate} +\item \textbf{Install \emph{MIK\TeX{}}}\\ +\product{pro\TeX{}t} uses the + \product{MIK\TeX{}} distribution as its + core, a long-established and popular distribution for + Windows. +\item \textbf{Install \emph{WinEdt}}\\ +This is optional: it's a good editor, + especially for the heavy user of a + \product{MIK\TeX{}}-based system. This is + a free month's trial\mdash{}after that it reminds you to cough + up and register. +\item \textbf{Install the \emph{WinEdt} New \LaTeX{} Document Interface}\\\label{nldi}% +Optional again, and only applicable if you installed + \product{WinEdt} anyway. It lets you + save commonly-used document settings for use in other + documents of the same type. +\item \textbf{Install the \emph{WinEdt} + Graphics Interface}\\ +Another optional add-on for + \product{WinEdt} to provide drag-and-drop + graphics insertion. +\item \textbf{Install the \emph{WinEdt} Table + Designer}\\\label{td}% +Last optional add-on for + \product{WinEdt}, providing a new table editor. +\item \textbf{Install \emph{\TeX{}nicCenter}}\\ +This is a free equivalent to + \product{WinEdt}. The interface is + slightly different (see Figure~\ref{tcpt1}) but it + is becoming very popular. +\item \textbf{Install \emph{GhostScript} and + \emph{GSview}}\\ +These are essential for viewing the PostScript and + PDF output, especially if you don't have any other PDF + viewer installed. +\end{enumerate} + +You get a choice of editors, + but the one which features in + \product{pro\TeX{}t} is + \product{\TeX{}nicCenter}. This is an + Integrated Development + Environment (IDE)\index{IDE@IDE|textbf}\index{Acronyms@\textbf{Acronyms}, defined!IDE@IDE|textbf} which lets you manage all the files + related to each document. In many cases, of course, you'll + only have one (the text itself) but if you are working with + anything beyond simple articles, you'll probably have + illustrations (images or diagrams), and possibly separate + chapter files for larger documents, plus indexes, + glossaries, bibliographies, etc. I recommend that you create + a new project for each new document, even if it's a + single-file article, as I did for the example in Figure~\ref{tcpt1}. +\subsection{\TeX{} Live (\TeX{} Collection 2003)} +\par\smallskip\noindent\textbf{\itshape Once the installation program is running:} +\begin{enumerate} +\item \textbf{\LaTeX{}}\\ +Install \LaTeX{} itself from the + \menuitem{TeXLive Software}{Install on + Hard Disk} menu. If you're new to + \LaTeX{}, pick Quick Install on the following screen. This + gives you everything you need to get started, and + doesn't ask any questions, it just installs it all + straight away. + +If you're installing under Windows NT, 2000, or + XP, you may want to click on the option to install for + all users if you have other users on your system. + +If you want to use \product{Emacs} + as your editor, click the option for Xem\TeX{} + Support.\footnote{Note this unfortunate choice of name is nothing + to do with \person{Eberhard Matthes}' MS-DOS implementation of \TeX{} + called em\TeX{}\mdash{}the `Xem' is + short for \product{Xemacs}.} +\item \textbf{Emacs}\\ +After installation, right-click and drag + \url+Xemacs.exe+ from the + \url+C:\Program Files\TeXLive\bin\win32+ + folder out onto your desktop and let go, then pick + `Create Shortcut'. This places + \product{Emacs} on your desktop for + easy access. +\item \textbf{WinShell and WinEdt}\\ +If you want to install + \product{WinShell}, run the installer + program in the \url+support/winshell+ + directory. For \product{WinEdt} you + must go to their Web site (\url+http://www.winedt.com/+) for a + downloadable version. + +You don't have to install just one editor: if + you've got the space, install them all so you can + try them out. You can always uninstall the ones you + don't want afterwards. +\item \textbf{GSView}\\ +Ghostscript is installed automatically, but for + \product{GSView} you need to go to + \url+http://www.cs.wisc.edu/~ghost/gsview/+, + and download the most recent version. + +If you use \product{GSView}, please + register your copy with Ghostgum, Pty. (\url+http://www.ghostgum.com.au/+). +\end{enumerate} +\begin{warning} + +Please read the \TeX{} Live update pages at \url+http://www.tug.org/texlive/bugs.html+ for + details of any changes since the disks were released, and + download and install any additional software + required. +\end{warning} +\subsection{Installation problems} + +It's always annoying when a program that's supposed to + install painlessly causes trouble, and none the more so when + everyone else seems to have been able to install it without + problems. I've installed \TeX{} hundreds of times and very + rarely had any difficulties, but these are a few of the + occasions when I did. +\begin{description} +\item[\sffamily Bad hard disks] +As recommended in \S\thinspace\ref{wininst}, run a + scan and defragmentation of your hard disk[s] before + you start. It should take under an hour on a modern + machine unless you have a very large disk, and it may + need overnight on an older machine. Clean your CD or DVD + drive if it's been in heavy use. \TeX{} uses a very + large number of very small files, so there is a lot of + disk activity during an installation. As also + recommended in \S\thinspace\ref{lininst}, if you have + the chance to reformat the hard disk, pick the + smallest granularity (cluster size) possible. +\item[\sffamily Registry errors] +This only affects Microsoft Windows users. The + Registry is where Microsoft want software companies + automatically to store details of all the programs you + install. Unfortunately the Registry is grossly abused + by marketing departments to try and foist undesirable + links on you, the user. You will see this with many + commercial programs, where a particular type of file + you've been able to double-click on for years suddenly + runs a different program. Some programs install + obsolete or broken copies of program libraries (DLL + files), overwriting ones which were working perfectly. + Worse, the viruses, trojans, and worms which typically + infect unprotected Windows systems can leave unwanted + links to web pages, or change some of the ways in + which Windows operates. The overall effect can be that + the whole machine slows down, or that files which are + expected to do one thing do another. The best + solution is a thorough Registry clean-out, using one + of the many programs available for the purpose. +\item[\sffamily Use the latest versions]\label{latest} +Before installing, check the CTAN\index{CTAN@CTAN} web site (\url+http://www.ctan.org/+ for any updated + copy of the installation program. This is called + \url+install-tl.sh+ for Linux and Mac + systems, and \url+Setup.exe+ for + Microsoft Windows (on the \TeX{} Collection 2003 CD it + was called \url+TeXSetup.exe+). Just + occasionally a bug slips through onto the production + CD or DVD, and although it's always fixed and notified + on \url+comp.text.tex+, + that's a high-volume newsgroup and even the sharpest + eyes may miss an announcement. +\item[\sffamily Stick to the defaults] +Unless you're a computer scientist or a software + engineer, I suggest you never change or fiddle with + the default directories for installation. I know some + of them look odd, but they're that way for a purpose, + especially when it comes to avoiding directories will + spaces in their names, like the notorious + \verb+C:\Program Files+. Although most + modern systems cope happily with spaces in filenames + and directory names, they are usually A Bad Design + Idea, and should be avoided like the plague (spaces + are forbidden in web addresses for the same reason: + the people who designed them knew the pitfalls). It + may look snazzier to put the installation in + \verb+My Cute Stuff+, but please + don't: you'll just make it harder to find, harder to + fix problems, and more embarrassing if you have to + explain it to someone else trying to help you. +\end{description} +\chapter[Using your editor to create documents]{Using your editor \newline{}to create documents} +\label{plaintext} + +\LaTeX{} documents are all \textbf{\textit{plain-text}}\label{plain-text}\index{plain-text@\textbf{\textit{plain-text}}} files.\footnote{`Plain-Text' + originally meant just the 95 printable characters of the + American Standard Code for Information + Interchange (ASCII)\index{ASCII@ASCII|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!ASCII@ASCII|textbf}\mdash{}see Table~\ref{asciicodes}\mdash{}but now more commonly includes + both these \emph{and} the relevant 8-bit + characters from \emph{one} (only) character + set such as ISO-8859-1 (Western Latin\ndash{}1) or + ISO-8859-15 (Western Latin plus the Euro sign). These are + international standards which work everywhere: you should + avoid using manufacturers' proprietary character sets + like Microsoft Windows\ndash{}1252 or Apple Macintosh + Roman\ndash{}8, because they may make your documents unusable + on some other systems.} You can edit them with any editor, and transfer + them to any other computer system running \LaTeX{} and they will + format exactly the same. Because they are plain text they cannot + corrupt your system, as they cannot be used for hiding or + transporting virus infections as binary wordprocessor files can. + Everything you can see is in the file and everything in the file + is there for you to see: there is nothing hidden or secret and + there are no manufacturers' proprietary + `gotchas' like suddenly going out of date + with a new version. +\section{Markup} +\label{mark-up} + +In a \LaTeX{} document, you type your text along with + \textbf{\textit{markup}}\label{markup}\index{markup@\textbf{\textit{markup}}} which identifies the + important parts of your document by name, for example + `title', `section', + `figure', etc. \LaTeX{} does all the formatting + for you automatically, using the markup to guide its internal + rules and external stylesheets for typesetting. +\begin{sidebar}\subsection*{Markup} +This is a term from printing, and originally meant the + notes on how to lay the document out, or the instructions + which a proofreader might add during correction. It now also + means instructions or descriptions added to a computer + document to act as guidelines for identification or + formatting. Markup has been around for + \emph{ages}. +\begingroup\small \begin{center} +\begin{tabular}{@{}l>{\pbs{\raggedright}}b{.75in}r@{}} +\vrule height4pt width0pt \includegraphics[width=2in]{55-1L-part}&\multicolumn{2}{l}{\titlecite{tain}}\\[4pt] +\includegraphics[width=2in]{23-part}&\multicolumn{2}{l}{\titlecite{varmints}}\\[4pt] +\verb+.h1 Interest Rates+&Runoff&\emph{c.}1970\\[4pt] +\verb+\section{Interest Rates}+&\LaTeX{}&1984\\[4pt] +\verb+<sec><ttl>Interest Rates</ttl>...+&SGML\index{SGML@SGML}&1985\\[4pt] +\verb+<H1>Interest Rates</H1>+&HTML\index{HTML@HTML}&1991\\[4pt] +\end{tabular} +\end{center} +\endgroup\end{sidebar} +You do not need to format any of your text \emph{in + your editor}, because \LaTeX{} does it + all by itself when it typesets. You can of course regularise + or neaten its appearance \emph{in your editor} + for ease of editing (for example, keeping each item in a list + on a separate line), but this is not required. + +You will often hear \LaTeX{} markup referred to as + `commands' or sometimes `control + sequences' (the proper \TeX{}nical term for them). + For + all practical purposes these terms all mean the same + thing. + +This course assumes that users have one of + \product{\TeX{}shell}, + \product{\TeX{}nicCenter}, + \product{WinShell}, or + \product{WinEdt} (Windows only), or + \product{Emacs} or \LyX{} (any platform) + installed. These are discussed briefly in \S\thinspace\ref{editors}, and the menus and toolbars for running + \LaTeX{} are explained in \chaptername~\ref{process}. +\section{Quick start for the impatient} +\label{quickstart} + +If you already know all this stuff about editors and + plain-text files and running programs, and you know your system + is already correctly installed (including your editor), + you'd probably like to type something in and see \LaTeX{} + do its job. If you don't, then skip forward to \S\thinspace\ref{commands} and read a bit more about \LaTeX{} + first. +\begin{figure}\small +\caption{\small Sample document} +\label{sampledoc} +\begin{sourcecode}\begin{Verbatim}[fontsize=\footnotesize] +\documentclass[12pt]{article} +\usepackage{palatino,url} +\begin{document} +\section*{My first document} + +This is a short example of a \LaTeX\ document I wrote +on \today. It shows a few simple features of automated +typesetting, including + +\begin{itemize} +\item setting the default font size to 12pt; +\item specifying `article' type for formatting; +\item using the Palatino typeface; +\item adding special formatting for URIs; +\item formatting a heading in `section' style; +\item using the \LaTeX\ logo; +\item generating today's date; +\item formatting a list of items; +\item centering and italicizing; +\item autonumbering the pages. +\end{itemize} + +\subsection*{More information} + +This example was taken from `Formatting Information', +which you can download from +\url{http://www.ctan.org/tex-archive/info/beginlatex/} +and use as a teach-yourself guide. + +\begin{center} +\textit{Have a nice day!} +\end{center} + +\end{document} + \end{Verbatim} +\end{sourcecode} +\end{figure} +\par\smallskip\noindent\textbf{\itshape Up and running in a few minutes} +\begin{enumerate} +\item \textbf{Install the software}\\ +Make sure you have a + properly-installed \LaTeX{} system and a copy of a + suitable editor. +\item \textbf{Create a sample document}\\\label{demodoc}% +Open your editor and type in + the text \emph{exactly} as shown in Figure~\ref{sampledoc}. Do \emph{not} make any + changes or miss anything out or add anything different at + this stage. +\item \textbf{Save the document}\\ +Save the document as + \url+demo.tex+ +\item \textbf{Run \LaTeX{} or \emph{pdf\LaTeX{}}}\\ +Click on the \guiicon{\LaTeX{}} or + \guiicon{pdf\LaTeX{}} toolbar icon or the + \menuitem{\TeX{}}{\TeX{} + File} menu item; or type \verb+latex demo+ or \verb+pdflatex demo+ in a + command window. +\item \textbf{Preview the typesetting}\\ +Click on the \guiicon{DVI} or + \guiicon{PDFview} toolbar icon or the + \menuitem{\TeX{}}{\TeX{} + View} menu item; or type your previewer + command in a terminal shell. + +(Note that there may be a pause the first time you use + your DVI\index{DVI@DVI} viewer, while WYSIWYG\index{WYSIWYG@WYSIWYG} font files are + created.\footnote{DVI\index{DVI@DVI} previewers use their + own font files specially created from the font + outlines (TrueType, OpenType, PostScript, \mf{}, + etc). The first time you use a font at a size not used + before, there will be a second or two's pause + while it gets created. The more you use \LaTeX{}, the + less this + happens.}) +\item \textbf{Print it}\\ +Click on the \guiicon{Print} toolbar icon + within the viewer, or use the + \menuitem{\TeX{}}{\TeX{} Print} + menu item, or type + \verb+dvips -f demo | lpr+ + (Unix/Linux). +\end{enumerate} + +If you encounter any errors, it means you + \emph{do} need to study this chapter after + all! +\section{Editors} +\label{editors} +\index{editors} +All the text of your documents can + be typed into your + \LaTeX{} document from a standard keyboard using any decent + plain-text editor. However, it is more convenient to use an + editor with special features to make using \LaTeX{} easier. + Some of the most popular are + \product{\TeX{}shell}\product{WinShell}, \product{\TeX{}nic + Center}, and \product{WinEdt} + (Windows only); and \product{Emacs} (all + platforms). +\subsection{\LyX{}} +\begin{figure}\small +\caption{\small The \LyX{} document editor} +\label{lyxwin} +\begin{center} +\includegraphics[width=0.75\textwidth]{lyx} +\end{center} +\end{figure} + +The \LyX{} document editor (all platforms) is a special + case, as it uses the What You See Is + What You Mean (WYSIWYM)\index{WYSIWYM@WYSIWYM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!WYSIWYM@WYSIWYM|textbf} model of synchronous typographic + editing as opposed to What You See Is + What You Get (WYSIWYG)\index{WYSIWYG@WYSIWYG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!WYSIWYG@WYSIWYG|textbf}, and many users prefer this + interface (but see the reservations in the Introduction on p.\thinspace\pageref{sync}). + +\LyX{} makes a strong case for using synchronous + typographical editing: it is possible to create even quite + large and complex documents without seeing a backslash very + often, although with math or complex macros there is + probably no way to avoid having to do some manual insertion + of + \LaTeX{} code. + +The free availability on multiple platforms makes this a + clear answer to the myth of `having to edit like a + programmer', and as it is an Open Source project, + there is constant improvement, both to the facilities and to + the interface. + +Probably the only real reservation is that it does not + save native \LaTeX{} files by default. It uses its own + internal format, and it can export \LaTeX{} for use in other + editors, but the exported files are not designed for human + legibility, only for \LaTeX{} processing. In a co-operative + environment this would be a serious drawback, but for the + individual user this interface is an excellent tool. +\subsection{\TeX{}shell} +\label{texshell} +\begin{figure}\small +\caption{\small The \TeX{}shell editor} +\label{texshellwin} +\begin{center} +\includegraphics[width=0.75\textwidth]{texshell} +\end{center} +\end{figure} + +This is one of the simplest of all the plaintext Windows + editors, but it has most of the tools needed to begin with. + Sectioning, lists, and graphics can be inserted from the + menus, and there are buttons for running \LaTeX{} on the + open document and for previewing the typeset + document. + +The syntactic highlighting distinguishes between + commands and your text, and it comes with options for + spellchecking (you need to install + \product{ispell}), and for adding math, + Greek (math), and some symbol characters from a pickchart. + The typeset display is done using your installed DVI\index{DVI@DVI} viewer (there is no provision for + PDF\index{PDF@PDF}, although as it is + configurable, that could probably be edited into the + menus). + +Download the \url+.tar.gz+ file from CTAN\index{CTAN@CTAN} in the + \url+support/TeXshell/+ directory and unwrap + it into somewhere like \url+C:\Program + Files\TeXshell\+.\footnote{Yes, I know I said don't use directory names with + spaces in them\mdash{}and so you shouldn't, for your + \LaTeX{} documents\mdash{}but Windows programs are usually safe + enough in them.} There is a \product{tsconfig} + program in the same directory on CTAN\index{CTAN@CTAN}, which is designed to help with + reconfiguring \TeX{}shell. +\subsection{WinShell} +\label{winshell} +\begin{figure}\small +\caption{\small The WinShell editor} +\label{winshellwin} +\begin{center} +\includegraphics[width=0.75\textwidth]{winshell} +\end{center} +\end{figure} + +This is another free Windows editor for beginners with + \LaTeX{}. Despite its simplicity, it is capable of a + considerable amount of document management and assistance + with editing. As well as handling stand-alone \LaTeX{} + files, you can create a `Project' for larger + documents, which helps you keep track of additional files + like separate chapters, illustrations, diagrams, indexes, + etc. + +You run \LaTeX{} direct from the toolbar icons or with + F-key shortcuts. Both standard \LaTeX{} and + \product{pdf\LaTeX{}} are supported, as well + as creation and previewing of + PostScript\index{PostScript} and PDF\index{PDF@PDF} output. There are additional toolbars + for math characters, and there is a `Table + Wizard' for handling tables. The syntax + highlighting distinguishes between commands (in blue) and + delimiters (in red), leaving your text in black. + +Download the + \texttt{WinShell\textsl{\uline{nn}}.exe} + program (self-contained setup: the + \textsl{nn} changes with the version) from + CTAN\index{CTAN@CTAN} in the + \url+systems/win32/winshell/+ directory and + double-click it to start the setup. +\subsection{\TeX{}nicCenter} +\label{texniccenter} +\begin{figure}\small +\caption{\small The \TeX{}nicCenter editor} +\label{texniccenterwin} +\begin{center} +\includegraphics[width=0.75\textwidth]{texniccenter} +\end{center} +\end{figure} + +\product{\TeX{}nicCenter} is a powerful + Windows editor suitable both for the beginner and the more advanced + user. Its `Project' environment keeps track of + multiple files, and the processing function (the bit which + actually runs \LaTeX{}, here called + `Build') tries to ensure that all the files you + need for a large or complex document are in place before you + start typesetting, to avoid errors like missing + illustrations. + +It's a much more wordprocessor-like control + interface, with configurable toolbars and button-controls + for lists, math, tables, and previewing options. + +Download the + \texttt{TXCSetup\textsl{\uline{xxx}}.exe} + program (self-contained setup: the + \textsl{xxx} bit changes with the version) + from CTAN\index{CTAN@CTAN} in the + \url+systems/win32/TeXnicCenter/+ directory + and double-click it to start the setup. +\subsection{WinEdt} +\label{winedt} +\begin{figure}\small +\caption{\small The \emph{WinEdt} editor} +\label{winedtpic} +\begin{center} +\includegraphics[width=0.75\textwidth]{winedt} +\end{center} +\end{figure} + +\product{WinEdt} is a highly + configurable plain-text editor for Windows. It comes with a + host of special functions and shortcuts for + \TeX{} and \LaTeX{}, based on the Mik\TeX{} distribution. It + is supplied on the \TeX{} Collection 2004 DVD and the + \product{pro\TeX{}t} CD. You can also + download it from \url+http://www.winedt.com+\mdash{}in either case + there's a 1-month free trial, then it reminds you to + buy it. + +\product{WinEdt} uses a built-in + toolbar of configurable buttons, preset for use with + \LaTeX{}, and it provides syntactic coloring of + \LaTeX{} commands. Both the positioning and effect of the + buttons can be changed, using an editable file of icons and + a configuration panel. This flexibility lets you bind a + program and arguments (equivalent to a typed command) to a + particular icon. + +There are default buttons on the toolbar for one-click + typesetting, previewing, and + PostScript\index{PostScript} or PDF\index{PDF@PDF} generation from \LaTeX{} documents, + and it manages multi-file document projects like most of the + other editors. \product{Winedt} is also + used by many people for normal plaintext file-editing tasks, + in preference to more limited programs like + \product{Notepad}. If you're using the + fp\TeX{} which came with the 2003 \TeX{} + Collection, some editing of the menus is required (explained + in the local installation document) because the default + setup is for + Mik\TeX{}/pro\TeX{}t. +\subsection{GNU Emacs} +\begin{figure}\small +\caption{\small Emacs editing \LaTeX{}} +\begin{center} +\includegraphics[width=0.75\textwidth]{emacs} +\end{center} +\end{figure} + +\product{Emacs} is a product of the + GNU\index{GNU@GNU} Project.\footnote{`GNU's Not + Unix (GNU)\index{GNU@GNU|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!GNU@GNU|textbf}' is a project to make a + computing environment completely free of + restrictions.} Versions are available for all makes and models + of computer, and it has a \LaTeX{}-mode which provides + syntactic colouring (`fontification' + in \product{Emacs}-speak) and mouseclick + processing from a menu or toolbar. + +\product{Emacs} + is a very large and powerful editor, with + `modes' (plug-ins) to handle almost + everything you do on a computer. Many users run + \product{Emacs} once on logging in, and + never leave it for the rest of the day\mdash{}or month. As + well as edit, you can use it to read your mail, browse the + Web, read Usenet news, do wordprocessing and spreadsheets, + compile programs, help you write in any computer + language\mdash{}including XML\index{XML@XML} and + \LaTeX{}\mdash{}and it provides a few games as well. + +\product{Emacs} + knows about \LaTeX{} and how to process it, so it comes with + a menu full of \LaTeX{} operations to click on. If you are + editing complex documents with mathematics, there is a mode + (\product{AUC\TeX{}}) which has even more + functionality. \LaTeX{} support is well-developed, and there + is a hierarchy of newsgroups for + \product{Emacs} support. + +Because \product{Emacs} runs on + Microsoft Windows, Macs, Linux, and most other platforms, + many \LaTeX{} users who have multiple machines (and those + who have multiple users to support) prefer it to other + editors because it provides the same environment regardless + of which platform they are using. + +It's sometimes criticised for a steep learning + curve, but in fact it's no worse in this respect than + any other editor, given the power that it provides, and it + is significantly better than most which lack many of the + authorial tools available in Emacs. +\subsection{Mac editors} + +Mac users will be disappointed that I haven't included + any of the Mac interfaces here. It's simple: I don't have a + Mac right now to try them out on. I hope to remedy this for a + future edition. +\section{\LaTeX{} commands} +\label{commands} + +\label{bsol}% +\LaTeX{} commands all begin with a + \textbf{\textit{backslash}}\label{backslash}\index{backslash@\textbf{\textit{backslash}}} + (\verb+\+)\footnote{Do not confuse the backslash + with the forward slash (\url+/+). They are + two different characters. The forward slash is used on the + Web and on Unix systems to separate directory names and + filenames. The backslash is used in Microsoft Windows + (only) for the same purpose, and in \LaTeX{} to begin a + command.} and are usually made up of lowercase + letters only, for example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\tableofcontents + \end{Verbatim} +\end{sourcecode} + +The + \command{tableofcontents} command is an instruction + to \LaTeX{} to insert the Table of Contents at this point. You + would usually use this in a book or report (or perhaps a very + long article) somewhere close to the beginning. You don't have + to do anything else. Provided that you have used the + sectioning commands described in \S\thinspace\ref{sections}, + all the formatting and numbering for the Table of Contents is + completely automated. +\subsection{Simple commands} +\label{simplecmd} + +\label{swallow}% +Simple one-word commands like + \command{tableofcontents} must be separated from + any following text with \textbf{\textit{white-space}}\label{wsp}\index{white-space@\textbf{\textit{white-space}}}. This means a + normal space, or a newline [linebreak] or a TAB character. + For example either of these two forms will work: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\tableofcontents Thanks to Aunt Mabel for all her help +with this book. + \end{Verbatim} +\end{sourcecode} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\tableofcontents +Thanks to Aunt Mabel for all her help with this book. + \end{Verbatim} +\end{sourcecode} + +If you forget the white-space, as in the following + example, \LaTeX{} will try to read it as a command + called \verb+\tableofcontentsThanks+. There's no + such command, of course, so \LaTeX{} will complain at you by + displaying an error message (see \S\thinspace\ref{undefcs}). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\tableofcontentsThanks to Aunt Mabel for all her help +with this book. + \end{Verbatim} +\end{sourcecode} + +\LaTeX{} swallows any white-space which follows a command + ending in a letter. It does this automatically, so you + don't get unwanted extra space in your typeset output, + but it does mean that any simple command which ends in a + letter and has no arguments (see below) must be followed by + white-space before normal text starts again, simply to keep + it separate from the text. +\subsection{Commands with arguments} +\label{cmdargs} + +Many \LaTeX{} commands are followed by one or more + \textbf{\textit{arguments}}\label{arguments}\index{arguments@\textbf{\textit{arguments}}}, a term from + the field of Computer Science, meaning information to be acted + upon. Here are two examples: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\chapter{Poetic Form} +\label{pform} + \end{Verbatim} +\end{sourcecode} + +Such arguments always go in + \verb+{+\textbf{\textit{curly + braces}}\label{curly}\index{curly + braces@\textbf{\textit{curly + braces}}}\verb+}+ like + those\index{braces|see{curly braces}} shown above. Be careful not to confuse the + curly braces on your keyboard with round parentheses + \verb+( )+, square brackets + \verb+[ ]+, or angle brackets + \verb+< >+. They are all + different and they do different things. + +With commands that take arguments you do + \emph{not} need to use extra white-space after + the command, because there is an argument following it + which will keep it separate from any normal text with + follows after that. The following is therefore perfectly + correct (although unusual because it's harder to edit: + normally you'd leave a blank line between the chapter title or + label and the start of the first paragraph). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\chapter{Poetic Form}\label{pform}The shape of poetry +when written or printed distinguishes it from prose. + \end{Verbatim} +\end{sourcecode} +\subsection{White-space in \LaTeX{}} +\label{white-space} +\index{white-space} +In \LaTeX{} documents, all \emph{multiple} + spaces, newlines (linebreaks), and TAB characters are + treated as if they were a \emph{single} space + or newline during typesetting. \LaTeX{} does its own spacing + and alignment using the instructions you give it, so you + have extremely precise control. You are therefore free to + use extra white-space in your editor for optical ease and + convenience when editing. + + + The following is therefore exactly equivalent to the example + in the preceding section: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\chapter {Poetic + Form}\label + {pform} + +The shape of poetry when written or printed +distinguishes it from prose. + \end{Verbatim} +\end{sourcecode} + +That is, it will get typeset exactly the same. In + general, just leave a blank line between paragraphs and a + single space between words and sentences. \LaTeX{} will take + care of the formatting. +\section{Special characters} +\label{specials} +\index{special characters} +There are ten keyboard characters which have special + meaning to \LaTeX{}, and cannot be used on their own except for + the following purposes: +\begingroup\small \begin{center} +\setlength{\tabcolsep}{1mm} +\begin{tabular}{clcc} +\textbf{\sffamily\upshape Key}&\textbf{\sffamily\upshape Meaning}&\multicolumn{1}{>{\bfseries\pbs{\centering}}b{1.5in}}{\normalfont\bfseries\upshape \emph{If you need the actual character itself, + type:}}&\textbf{\sffamily\upshape Character}\\[2pt]\hline\\[-1.5\baselineskip] +\key{$\backslash$}&The command character&\command{textbackslash}&$\backslash$\\ +\key{\$}&Math typesetting delimiter&\command{\$}&\$\\ +\key{\%}&The comment character&\command{\%}&\%\\ +\key{{\char'136}}&Math superscript character&\command{{\char'136}}&{\char'136}\\ +\key{\amp }&Tabular column separator&\command{\amp }&\amp \\ +\key{{\ttfamily\char'137}}&Math subscript character&\command{{\ttfamily\char'137}}&\texttt{\_}\\ +\key{{\char'176}}&Non-breaking space&\command{{\char'176}}&{\char'176}\\ +\key{\#}&Macro parameter symbol&\command{\#}&\#\\ +\key{{\ttfamily\char'173}}&Argument start delimiter&\texttt{\$}\command{{\ttfamily\char'173}}\texttt{\$}&$\{$\\ +\key{{\ttfamily\char'175}}&Argument end delimiter&\texttt{\$}\command{{\ttfamily\char'175}}\texttt{\$}&$\}$\\ +\end{tabular} +\end{center} +\endgroup +These characters were deliberately chosen, either because + they are rare in normal text, or (in the case of \$, + \#, \amp , and \%) they already had an + established special meaning on computers as \textbf{\textit{metacharacters}}\label{metacharacters}\index{metacharacters@\textbf{\textit{metacharacters}}} (characters + standing as symbols for something else) by the time \TeX{} was + written, and it would have been misleading to choose + others. +\subsection{Using the special characters} + +We have already seen (the first paragraph of \S\thinspace\ref{bsol}) how + to use the backslash to start a command, and curly braces to + delimit an argument. The remaining special + characters are: +\begin{description} +\item[\sffamily \key{\$}] +Because of the special mathematical meaning + \LaTeX{} uses for the dollar-sign on its own, if you + want to print \$35.99 you type + \verb+\$35.99+ +\item[\sffamily \key{\%}] +\label{comment}% +The \textbf{\textit{comment character}}\label{commentchar}\index{comment character@\textbf{\textit{comment character}}} makes + \LaTeX{} ignore the remainder of the line in your + document, so you can see it in your editor, but it + will never get typeset. For example \verb+Today's price per Kg is £22.70 % get Mike to update this+\\If you want to print 45\% you need + to type \verb+45\%+ +\item[\sffamily \key{{\char'136}}] +The caret sign lets you type + \verb+\(E=mc^2\)+ to get \(E=mc^{2}\). If you need the circumflex accent + on a letter like ê, just type the letter or use the + symbolic notation \verb+\^e+. +\item[\sffamily \key{\amp }] +The ampersand is used in tables to separate + columns (see \S\thinspace\ref{tables}). If you want to + print AT\amp T you need to type + \verb+AT\&T+. +\item[\sffamily \key{{\ttfamily\char'137}}] +The underscore lets you type + \verb+\(r_2\)+ for \(r_{2}\). If you want to underline text + (extremely rare in typesetting) see the last paragraph of \S\thinspace\ref{uline}. +\item[\sffamily \key{{\char'176}}]\label{tilde} +The tilde prints as a space, but prevents a + linebreak ever occurring at that point. It's often + used between a person's initials and their surname, eg + \verb+Prof D.E.~Knuth+ +\item[\sffamily \key{\#}] +If you want a + \textbf{\textit{hash mark}}\label{hash}\index{hash mark@\textbf{\textit{hash mark}}} (the + \textbf{\textit{octothorpe}}\label{octothorpe}\index{octothorpe@\textbf{\textit{octothorpe}}} or + American number or `pound' [weight] sign) + you type \verb+\#+. For a pound + (sterling)\index{pound@£} + sign £, now nearly obsolete except in the UK and + some of its former dependencies, use your + \key{£} key or type + \command{textsterling}. +\end{description} + +While we're on the subject of money, an unusual but + interesting serif-font Euro\index{euro@\euro{}} sign {\rmfamily{}\selectfont{}\euro{}} + is got with the \command{texteuro} command from the + \package{textcomp} package. The standard + sans-serif {\sffamily{}\selectfont{}\EUR{}} needs the + \package{marvosym} package and is done with + the \command{EUR} command.\footnote{The European Commission has specified that everyone + use the sans-serif design, even in serif text, but this + is amazingly ugly and most designers rightly ignore + it.} +\section{Quotation marks} +\label{quotes} +\index{quotation marks} +Do \emph{not} use the unidirectional + typewriter keyboard \ttkey{"} key for quotation + marks. Correct typographic quotes are got with the \ttkey{\`{}} key and the \ttkey{'} key, doubled if you want double + quotes: +\begin{example} +\begin{sourcecode}\fontencoding{T1}\fontfamily{pcr}\selectfont\renewcommand{\ttdefault}{pcr}\begin{Verbatim}[fontsize=\small] +He said, ``I'm just going out.'' + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent + +{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}He said, + ``I'm just going out.''} +\end{quote}\end{example} + +This ensures you get real left-hand + and right-hand (opening and closing) quotes (usually shaped + like tiny + \textsuperscript{66} and \textsuperscript{99} + or as symmetrically-balanced strokes). If you are using + \product{Emacs} as your editor, the + \key{"} key is specially programmed in + \LaTeX{}-mode to think for itself and produce correct {\ttfamily{}\selectfont{}\`{}\`{}} and + \verb+''+ characters (so this is one occasion when + you \emph{can} use the \key{"} + key). +\begin{warning} + +If you are reading this in a + browser, or if you have reprocessed the file using different + fonts, it may not show you real quotes (some old browser + fonts are defective) and the \command{thinspace} + below may be too wide. Download the typeset (PDF\index{PDF@PDF}) version of this document to see the + real effect. +\end{warning} + +\label{thinspace}% +When typing one quotation inside another, + there is a special command \command{thinspace} which + provides just enough separation between double and single + quotes (a normal space is too much and could allow an unwanted + linebreak): +\begin{example} +\begin{sourcecode}\fontencoding{T1}\fontfamily{pcr}\selectfont\renewcommand{\ttdefault}{pcr}\begin{Verbatim}[fontsize=\small] +He said, `Her answer was ``never''\thinspace'. + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent + +He said, `Her answer was + ``never''\thinspace{}'. +\end{quote}\end{example} +\section{Accents} +\label{accents} +\index{accents} +For accented letters in western + European languages\footnote{ISO 8859-1 (Latin\ndash{}1, Western European) to + 8859-15 (includes the Euro).} or other Latin-alphabet character sets just use + the accented keys on your keyboard\mdash{}if you have the right + ones. You must also tell \LaTeX{} what character repertoire + (`input encoding') you are using. You + specify this by using the \package{inputenc} + package\footnote{We haven't covered the use of + packages yet. Don't worry, see \S\thinspace\ref{packages} + if you're curious.} in your preamble + with the relevant option. For example, to tell \LaTeX{} you + will be typing ISO Latin\ndash{}1 accented characters, + use: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage[latin1]{inputenc} + \end{Verbatim} +\end{sourcecode} + +If you have a real Unicode editor, which lets you insert + any letter or symbol from any language on the planet (for + example, mixed European, Asian, and other languages), use + \verb+utf8+ instead of \verb+latin1+. + The encoding definitions that are available on your system are + in \url+/texmf/tex/latex/base+ (all files + ending in \url+.def+). +\begin{sidebar}\label{keystrokes} +\subsection*{If you don't have accented letters} +This is for users whose keyboards do not have native + accent characters on them. See your Operating System manual + for full details. Here are two common examples: +\begin{itemize} +\item +Under Linux systems the letter + é is usually got with + \key{AltGr}--\key{;}~\thinspace{}\key{e}. Refer to the + \product{xkeycaps} utility for a table + of key codes and combinations (get it from \url+http://www.jwz.org/xkeycaps/+). + +\item +Under Microsoft Windows the letter é is got with + \key{Ctrl}--\ttkey{'}~\thinspace{}\key{e} or by holding down the + \thinspace{}\key{Alt} key and typing + \thinspace{}\key{0}\thinspace{}\key{1}\thinspace{}\key{3}\thinspace{}\key{0} + on the numeric keypad (\emph{not} the top + row of shifted numerals). Refer to the + \product{charmap} utility for a table + of key codes and combinations (find it in the + \url+C:\Windows+ folder). + +\end{itemize} +\end{sidebar} +If you don't have accented letter keys on your + keyboard, you'll need to use your operating system's + standard keyboard \key{Ctrl} or + \key{Alt} key combinations to generate the + characters (see the panel `If you don't have accented letters' \testpage[above]{keystrokes}). + +If you cannot generate accented characters from your + keyboard at all, or if you need additional accents or symbols + which are not in any of the keyboard tables, you can use the + symbolic notation in Table~\ref{accentcodes}. In fact, + this can be used to put any accent over any letter: if you + particularly want a \~g you can have one with the command + \command{{\char'176}}\verb+g+ (and Welsh + users can get \^w with + \command{{\char'136}}\verb+w+). + +If you use this symbolic method only, you do not need to + use the \package{inputenc} package. Before the + days of keyboards and screens with their own real accented + characters, the symbolic notation was the + \emph{only} way to get accents, so you may come + across a lot of older documents (and users!) using this method + all the time: it does have the advantage in portability that + the \LaTeX{} file remains plain ASCII\index{ASCII@ASCII}, which will work on all machines + everywhere, regardless of their internal encoding, and even + with very old \TeX{} installations.\footnote{Remember not everyone is lucky enough to be able to + install new software: many users on corporate and academic + networks still have to use old versions of \TeX{} because + their system administrators are too busy to + install new ones.} +\begin{table}\small \caption{\small Built-in \LaTeX{} accents} +\label{accentcodes} +\begin{center} +\begin{tabular}{lcc} +\textbf{\sffamily\upshape Accent}&\textbf{\sffamily\upshape Example}&\textbf{\sffamily\upshape Characters to type}\\[2pt]\hline\\[-1.5\baselineskip] +Acute (fada)&é&\verb+\'e+\\ +Grave&è&\verb+\`e+\\ +Circumflex&ê&\verb+\^e+\\ +Umlaut or diæresis&ë&\verb+\"e+\\ +Tilde&ñ&\verb+\~n+\\ +Macron&\=o&\verb+\=o+\\ +Bar-under&{\b o}&\verb+\b o+\\ +Dot-over (sé{\fontfamily{cmr}\selectfont\i}\.m{\fontfamily{cmr}\selectfont\i}ú)&{\.m}&\verb+\.m+\\ +Dot-under&{\d s}&\verb+\d s+\\ +Breve&\u u&\verb+\u u+\\ +Há\v cek (caron)&\v u&\verb+\v u+\\ +Long umlaut&\H o&\verb+\H o+\\ +Tie-after&{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}\t oo}&\verb+\t oo+\\ +Cedilla&\c c&\verb+\c c+\\ +O-E ligature&\oe , \OE &\verb+\oe+, + \verb+\OE+\\ +A-E ligature&\ae , \AE &\verb+\ae+, + \verb+\AE+\\ +A-ring&\aa , \AA &\verb+\aa+, + \verb+\AA+\\ +O-slash& \o , \O &\verb+\o+, + \verb+\O+\\ +Soft-l&{\fontencoding{T1}\fontfamily{cmr}\selectfont{}\l{}, \L{}}&\verb+\l+, + \verb+\L+\\ +Ess-zet (scharfes-S)&\ss &\verb+\ss+\\ +\end{tabular} +\end{center} +\end{table} + +Irish and Turkish dotless-{\fontfamily{cmr}\selectfont\i} is done with the + special command \command{i}, so an {\fontfamily{cmr}\selectfont\'\i}-fada + (which is normally typed with \key{{\fontfamily{cmr}\selectfont\'\i}}) + requires \verb+\'\i+ if you need to type it in + the long format, followed by a backslash-space or dummy pair of + curly braces if it comes at the end of a word and there is no + punctuation, because of the rule that \LaTeX{} control + sequences which end in a letter (see the first paragraph of \S\thinspace\ref{swallow}) always absorb any following space. So + what you might see as \textsl{Rí + Tea\.mra\.c} has to be \verb+R\'\i\ Tea\.mra\.c+ when typed in full (there are not + usually any keyboard keys for the dotless-{\fontfamily{cmr}\selectfont\i} or the + lenited characters). A similar rule applies to dotless-{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}{\fontfamily{cmr}\selectfont\j}} and to uppercase + \'I. +\section{Dimensions, hyphenation, justification, and breaking} +\label{handj} +\index{dimensions}\index{hyphenation}\index{justification}\index{hj@H\amp J|see{hyphenation, justification}} +\LaTeX{}'s internal measurement system is + extraordinarily accurate. The underlying \TeX{} engine + conducts all its business in units smaller than the wavelength + of visible light, so if you ask for 15mm space, that's + what you'll get\mdash{}within the limitations of your + screen or printer, of course. Most screens cannot show + dimensions of less than + \(\frac{1}{96}\)$''$ without resorting to magnification + or scaling; and on printers, even at 600dpi, fine oblique + lines or curves can still sometimes be seen to stagger the + dots. + +At the same time, many dimensions in \LaTeX{}'s + preprogrammed formatting are specially set up to be flexible: + so much space, plus or minus certain limits to allow the + system to make its own adjustments to accommodate variations + like overlong lines, unevenly-sized images, and non-uniform + spacing around headings. + +\TeX{} uses a very sophisticated + justification algorithm to achieve a smooth, even texture to + normal paragraph text. The programming for this has been + borrowed by a large number of other DTP systems, and users of + these are often quite unaware that they are in fact using a + significant part of \TeX{} in their work. + Occasionally, however, you will need to hand-correct an + unusual word-break or line-break, and there are facilities for + doing this on individual occasions as well as throughout a + document. +\subsection{Specifying size units} +\label{dimensions} +\index{dimension}\index{units} +Most people in printing and publishing habitually use + points and picas and ems. Some designers use cm and mm. Many + English-language speakers still use inches. You can specify + lengths in \LaTeX{} in any of these units, plus some others + (see Table~\ref{units}). +\index{pt (points)}\index{points}\index{pc (picas)}\index{picas}\index{bp (big points)}\index{sp (scaled points)}\index{dd (Didot points)}\index{cc (Ciceros)}\index{em (relative measure)}\index{ex (relative measure)}\index{mm (millimeters)}\index{cm (centimeters)}\index{in (inches)}\begin{table}\small \caption{\small Units in \LaTeX{}} +\label{units} +\begin{center} +\begin{tabular}{@{}l>{\pbs{\raggedright}}p{4in}} +\textbf{\sffamily\upshape Unit}&\textbf{\sffamily\upshape Size}\\[2pt]\hline\\[-1.5\baselineskip] +\vrule height1.5em width0pt\bfseries\itshape &\vrule height1.5em width0pt\bfseries\itshape Printers' fixed measures\\[2pt] +pt&Anglo-American standard points (72.27 to the + inch)\\ +pc&pica ems (12pt)\\ +bp&Adobe `big' points (72 + to the inch)\\ +sp&\TeX{} `scaled' points + (65,536 to the pt)\\ +dd&Didot (European standard) points (67.54 to the + inch)\\ +cc&Ciceros (European pica ems, 12dd)\\ +\vrule height1.5em width0pt\bfseries\itshape &\vrule height1.5em width0pt\bfseries\itshape Printers' relative measures\\[2pt] +em&ems of the current point size (historically the + width of a letter `M' but see + below)\\ +ex&x-height of the current font (height of letter + `x')\\ +\vrule height1.5em width0pt\bfseries\itshape &\vrule height1.5em width0pt\bfseries\itshape Other measures\\[2pt] +cm¢imeters (2.54 to the inch)\\ +mm&millimeters (25.4 to the inch)\\ +in&inches\\ +\end{tabular} +\end{center} +\end{table} + +The em can cause beginners some puzzlement because + it's based on the `point size' + of the type, which is itself misleading. The point size + refers to the depth of the metal body on which foundry type + was cast in the days of metal typesetting, + \emph{not} the printed height of the letters + themselves. Thus the letter-size of 10pt type in one face + can be radically different from 10pt type in another (look + at the table on p.\thinspace\pageref{fontable-adobe}, where all the examples are + 10pt). An em is the height of the type-body in a specific size, + so 1em of 10pt type is 10pt and 1em of 24pt type is + 24pt. + +Another name for a 1em space is a + `quad', and \LaTeX{} has a command + \command{quad} for leaving exactly that much + horizontal space. A special name is given to the 12pt em, a + `pica' em, as it has become a fixed + measure in its own right. + +If you are working with other DTP users, watch out for + those who think that Adobe points (bp) are the only ones. + The difference is only .27pt per inch, but in 10$''$ of + text (a full page of A4) that's 2.7pt, which is nearly + 1mm, enough to be clearly visible if you're trying to + align one sample with another. +\subsection{Hyphenation} +\label{hyph} + +\LaTeX{} hyphenates automatically according to the + language you use (see \S\thinspace\ref{langs}). To specify + different breakpoints for an individual word, you can insert + soft-hyphens\index{hyphens!soft} (discretionary hyphens, done with + \command{-}) wherever you need them, for + example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +When in Mexico, we visited Popoca\-tépetl by helicopter. + \end{Verbatim} +\end{sourcecode} + +To specify hyphenation points for all occurrences of a + word, use the \command{hyphenation} command in your + preamble (see the panel `The Preamble' \testpage[below]{preamble}) with one or more + words in its argument, separated by spaces. This will even + let you break `helico-\linebreak pter' correctly. In this command + you use normal hyphens, not soft-hyphens.\index{hyphens!discretionary} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\hyphenation{helico-pter Popoca-tépetl +im-mer-sion} + \end{Verbatim} +\end{sourcecode} + +If you have frequent hyphenation problems with long, + unusual, or technical words, ask an expert about changing + the value of \length{spaceskip}, + which controls the flexibility of the space between words. + This is not something you would normally want to do, as it + can change the appearance of your document quite + significantly. + +If you are using a lot of unbreakable text (see next + section and also \S\thinspace\ref{inlineverb}) it may also + cause justification problems. One possible solution to this + is shown in \S\thinspace\ref{macargs}. +\subsection{Unbreakable text} + +To force \LaTeX{} to treat a word as unbreakable, use + the \command{mbox} command: + \verb+\mbox{pneumonoultramicroscopicsilicovolcanoconiosis}+. + This may have undesirable results, however, if + you change margins or the width of the text: + \mbox{pneumonoultramicroscopicsilicovolcanoconiosis}\dots + +To tie two words together with an unbreakable + space\index{hard space}\index{white-space!hard} (hard space), use a tilde (\verb+~+) + instead of the space (see the list on p.\thinspace\pageref{tilde} in \S\thinspace\ref{tilde}). This + will print as a normal space but + \LaTeX{} will never break the line at that point. You should + make this standard typing practice for things like + people's initials followed by their surname, as in + Prof. D. E. Knuth: + \verb+Prof.\ D.~E.~Knuth+. +\begin{warning} + +Note that a full point after a lowercase letter is + treated as the end of a sentence, and creates more space + before the next word. Here, after + `Prof.', it's + \emph{not} the end of a sentence, and the + backslash-space forces \LaTeX{} to insert just an ordinary + word-space because it's OK to break the line after + `Prof.', whereas it would look + wrong to have initials separated with Prof. D.E. Knuth broken over a line-end. +\end{warning} +\subsection{Dashes} + +For a long dash\mdash{}what printers call an + `em rule' like this\mdash{}use three + hyphens typed together, \verb+like~--- this+, + and bind them to the preceding word with a tilde to avoid + the line being broken before the dash. It's also common + to see the dash printed without spaces---like that: the + difference is purely æsthetic. \emph{Never} + use a single hyphen for this purpose. + +Between digits like page ranges (35\ndash{}47), it is + normal to use the short dash (what printers call an en-rule) + which you get by typing two hyphens together, as in + \verb+35--47+. If you want a minus sign, use math + mode (\S\thinspace\ref{math}). +\subsection{Justification} + +The default mode for typesetting is justified (two + parallel margins, with word-spacing adjusted automatically + for the best optical fit). In justifying, \LaTeX{} will never + add space between letters, only between words. There is a + special package called \package{so} + (`space-out') if you need special + effects like letter-spacing, but these are best left to the + expert. + +There are two commands + \command{raggedright} and + \command{raggedleft} which set ragged-right (ranged + left) and ragged-left (ranged right). Use them inside a + group (see the panel `Grouping' \testpage[below]{grouping}) to confine their + action to a part of your text. + +{\raggedleft +These modes also exist as + `environments' (see the last paragraph of \S\thinspace\ref{environments}) called + \env{raggedright} and + \env{raggedleft} which are more convenient + when applying this formatting to a whole paragraph or more, + like this one. +\par}\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{raggedleft} +These modes also exist as environments called raggedright +and raggedleft which is more convenient when applying this +formatting to a whole paragraph or more, like this one. +\end{raggedleft} + \end{Verbatim} +\end{sourcecode} + +Ragged setting turns off hyphenation. There is a package + \package{ragged2e} which retains hyphenation + in ragged setting, useful when you have a lot of long + words. +\subsection{Languages} +\label{langs} + +\LaTeX{} can typeset in the native manner for several + dozen languages. This affects hyphenation, word-spacing, + indentation, and the names of the parts of documents used as + headings (e.g. Table of Contents). + +Most distributions of \LaTeX{} come with US English and + one or more other languages installed by default, but it is + easy to add the \package{babel} package and + specify any of the supported languages or variants, for + example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage[frenchb]{babel} +... +\selectlanguage{frenchb} + \end{Verbatim} +\end{sourcecode} + +Changing the language with + \package{babel} automatically changes the + names of the structural units and identifiers like + `Abstract', + `Index', etc. to their + translated version. For example, using French as above, + chapters will start with + `\emph{Chapitre}'. +\section{Mathematics} +\label{math} +\index{mathematics} +As explained in the Preface on p.\thinspace\pageref{mathtex}, \TeX{} was + originally written to automate the typesetting of books + containing mathematics. The careful reader will already have + noticed that mathematics is handled differently from normal + text, which is why it has to be typeset specially. This + document does not cover mathematical typesetting, which is + explained in detail in many other books and Web pages, so all + we will cover here is the existence of the math mode commands, + and some characters which have special meaning, so they + don't trip you up elsewhere. + +In addition to the 10 special characters listed in \S\thinspace\ref{specials}, there are three more characters which + only have any meaning inside mathematics mode:\index{math characters} +\begingroup\small \begin{center} +\begin{tabular}{cl} +\textbf{\sffamily\upshape Key}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip] +\key{$|$}&Vertical bar\\ +\ttkey{<}&Less-than\\ +\ttkey{>}&Greater-than\\ +\end{tabular} +\end{center} +\endgroup +If you type any of these in normal text (ie outside math + mode), you will get very weird things happening and lots of + error messages. If you need to print these characters, you + \emph{must} type them using math mode, or use + their symbolic names from the \env{textcomp} + package (\command{textbrokenbar}, + \command{textlangle}, and + \command{textrangle}). + +The hyphen also has an extra meaning in math mode: it + typesets as a minus sign, so if you want to write about + negative numbers you need to type the number in math mode so + the minus sign and the spacing come out right. + +To use math mode within a paragraph, enclose your math + expression in \command{(} and \command{)} + commands. You can get the much-quoted equation + \(E=mc^{2}\) by typing + \verb+\(E=mc^2\)+, and to get a temperature like + \ifmmode-\else$-$\fi{}30° you need to type + \verb+\(-30\)°+.\footnote{Bear in mind that the degree symbol is a non-ASCII\index{ASCII@ASCII} character, so you must specify + what input encoding you are using if you want to type it: + see the example of the \package{inputenc} + package in \S\thinspace\ref{accents}. If you don't + want to use non-ASCII\index{ASCII@ASCII} characters + (or if you are using a system which cannot generate them), + you can use the command \command{textdegree} to + get the degree sign.} + +To typeset a math expression as `displayed + math' (centered between paragraphs), enclose it + in the commands \command{[} and + \command{]}.\footnote{You will also see dollar signs used for math mode. + This is quite common but deprecated: it's what plain + \TeX{} used in the days before \LaTeX{}, and the habit got + ingrained in many mathematicians. It still works as a + convenient shorthand like \url+$x=y$+, as do + double-dollars for display-mode math like + \url+$$E=mc^2$$+, but they are only mentioned + here to warn readers seeing them in other authors' + work that \command{(}\dots \command{)} + and \command{[}\dots \command{]} are + the proper \LaTeX{} commands.} +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\[\bar n^*_j(s)=\frac{\left\{s\sum_{i=1}^k +n_i(0)p^*{i,k+1}(s)+M^*(s)\right\}\sum_{i=1}^k +p_{0i}p^*{ij}(s)}{1-s\sum_{i=1}^kp_{0i}p^*_{i, +k+1}(s)}+\sum_{i=1}^kn_i(0)p^*_{ij}(s)[j= +1,2,\dots,k].\] + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent + + \(\bar n^*_j(s)= + \frac{\left\{s\sum^k_{i=1}n_i(0)p^*_{i,k+1}(s)+M^*(s)\right\} + \sum^k_{i=1}p_{0i}p^*{ij}(s)}{1-s\sum^k_{i=1}p_{0i}p^*_{i,k+1}(s)} + +\sum^k_{i=1}n_i(0)p^*_{ij}(s)\,\rlap{[j=1,2,\dots,k]}\) + +\end{quote}\end{example} + +Displayed equations can be auto-numbered with the + \env{equation} environment instead of the + \command{[} and \command{]} commands. +\chapter{Basic document structures} +\label{basic} +\index{sections} +\LaTeX{}'s approach to formatting is to aim for + consistency. This means that as long as you identify each + \textbf{\textit{element}}\label{element}\index{element@\textbf{\textit{element}}} of your document + correctly, it will be typeset in the same way as all the other + elements like it, so that you achieve a consistent finish with + minimum effort. Consistency helps make documents easier to read + and understand. + +Elements are the component parts of a document, all the + pieces which make up the whole. Almost everyone who reads books, + newspapers, magazines, reports, articles, and other classes of + documents will be familiar with the popular structure of + chapters, sections, subsections, subsubsections, paragraphs, + lists, tables, figures, and so on, even if they don't + consciously think about it. + +Consistency is also what publishers look for. They have a + house style, and often a reputation to keep, so they rightly + insist that if you do something a certain way once, you should + do it the same way each time. + +To help achieve this consistency, every \LaTeX{} document + starts by declaring what \textbf{\textit{document + class}}\label{documentclass}\index{document + class@\textbf{\textit{document + class}}} it belongs to. +\section{The Document Class Declaration} +\label{docdecl} +\index{document class} +To tell \LaTeX{} what class of document you are going to + create, you type a special first line into your file which + identifies it.\footnote{Readers familiar with SGML\index{SGML@SGML}, + HTML\index{HTML@HTML}, or XML\index{XML@XML} will recognize the concept as + similar to the Document Type + Declaration.} To start a report, for + example, you would type the \command{documentclass} + command like this as your first line: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass{report} + \end{Verbatim} +\end{sourcecode} + +There are four built-in classes provided, and many others + that you can download (some may already be installed for + you): +\begin{description} +\item[\sffamily \package{report}] +for business, technical, legal, academic, or + scientific reports; +\item[\sffamily \package{article}] +for white papers, magazine or journal articles, + reviews, conference papers, or research notes; +\item[\sffamily \package{book}] +for books and theses; +\item[\sffamily \package{letter}] +for letters.\footnote{The built-in \package{letter} + class is rather idiosyncratic: there are much better + ones you can download, such as + the \package{memoir} and + \package{komascript} packages.} +\end{description} + +The \package{article} class in particular + can be used (some would say `abused') for almost + any short piece of typesetting by simply omitting the titling + and layout (see below). + +The built-in classes are intended as starting-points, + especially for drafts and for compatibility when exchanging + documents with other \LaTeX{} users, as they come with every + copy of \LaTeX{} and are therefore guaranteed to format + identically everywhere. \emph{They are \emph{\textbf{not}} intended as final-format + publication-quality layouts.} For most other + purposes, especially for publication, you use + add-in packages (\S\thinspace\ref{packages}) to extend + these classes to do what you need: +\begin{itemize} +\item +The \package{memoir} and + \package{komascript} packages contain + more sophisticated replacements for all the built-in + classes; + +\item +Many academic and scientific publishers provide their + own special class files for articles and books (often on + their Web sites for download); + +\item +Conference organisers may also provide class files for + authors to write papers for presentation; + +\item +Many universities provide their own thesis document + class files in order to ensure exact fulfillment of their + formatting requirements; + +\item +Businesses and other organizations can provide their + users with corporate classes on a central server and + configure \LaTeX{} installations to look there first for + packages, fonts, etc. + +\end{itemize} + +Books and journals are not usually printed on office-size + paper. Although \LaTeX{}'s layouts are designed to fit on + standard A4 or Letter stationery for draft purposes, it makes + them look odd: the margins are too wide, or the positioning is + unusual, or the font size is too small, because the finished + job will normally be trimmed to a different size + entirely\mdash{}try trimming the margins of the PDF\index{PDF@PDF} version of this book to 185mm by 235mm + (the same as \titlecite{companion} series) + and you'll be amazed at how it changes the appearance! + +\subsection{Document class options} +\label{doclayout} +\index{paper sizes} +The default layouts are designed to fit as drafts on US + Letter size paper.\footnote{Letter size is 8½$''$$\times$11$''$, which is the + trimmed size of the old Demi Quarto, still in use in + North America. The other common US office size is + `Legal', which is + 8½$''$$\times$14$''$, a bastard cutting close to + the old Foolscap (8¼$''$$\times$13¼$''$). ISO + standard `A', + `B', and + `C' paper sizes are still + virtually unknown in many parts of North America.} To create documents with the correct proportions + for standard A4 paper, you need to specify the paper size in + an optional argument in square brackets before the document + class name, e.g. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[a4paper]{report} + \end{Verbatim} +\end{sourcecode} + +The two most common options are \opt{a4paper} + and \opt{letterpaper}. However, many European + distributions of \TeX{} now come preset for A4, not Letter, and + this is also true of all distributions of + \product{pdf\LaTeX{}}. + +The other default settings are for: \begin{inparaenum}[\itshape a\upshape)] \item 10pt type (all document classes); \item two-sided printing (books and reports) or + one-sided (articles and letters); and \item separate title page (books and reports + only)\end{inparaenum}. These can be modified with the following + document class options which you can add in the same set of + square brackets, separated by commas: +\index{fonts!sizes}\begin{description} +\label{docfontsize} +\item[\sffamily \opt{11pt}] +to specify 11pt type (headings, footnotes, + etc. get scaled up or down in + proportion); +\item[\sffamily \opt{12pt}] +to specify 12pt type (again, headings + scale); +\item[\sffamily \opt{oneside}] +to format one-sided printing for books and + reports; +\item[\sffamily \opt{twoside}] +to format articles for two-sided printing; +\item[\sffamily \opt{titlepage}] +to force articles to have a separate title + page; +\item[\sffamily \opt{draft}] +makes \LaTeX{} indicate hyphenation and + justification problems with a small square in the + right-hand margin of the problem line so they can be + located quickly by a human. +\end{description} + +If you were using pdf\LaTeX{} for a report to be in 12pt + type on Letter paper, but printed one-sided in draft mode, you + would use: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[12pt,letterpaper,oneside,draft]{report} + \end{Verbatim} +\end{sourcecode} + +There are extra preset options for other type sizes + which can be downloaded separately, but 10pt, 11pt, and 12pt + between them cover probably 99\% of all document + typesetting. In addition there are the hundreds of add-in + packages which can automate other layout and formatting + variants without you having to program anything by hand or + even change your text. +\begin{exercise} +\label{firstline} +\addcontentsline{loe}{section}{\numberline{1}Create a new document} +\subsubsection*{Create a new document}\begin{enumerate}\item +Use your editor to create a new document. + +\item +Type in a Document Class Declaration as shown + above. + +\item +Add a font size option if you wish. + +\item +In North America, omit the + \opt{a4paper} option or change it to + \opt{letterpaper}. + +\item +Save the file (make up a name) ensuring the name + ends with \url+.tex+ + +\end{enumerate} +\end{exercise} +\section{The document environment} +\label{docenv} + +After the Document Class Declaration, the text of your + document is enclosed between two commands which identify the + beginning and end of the actual document: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} + +\begin{document} +... +\end{document} + \end{Verbatim} +\end{sourcecode} + +(You would put your text where the dots are.) The reason + for marking off the beginning of your text is that \LaTeX{} + allows you to insert extra setup specifications before it + (where the blank line is in the example above: we'll be + using this soon). The reason for marking off the end of your + text is to provide a place for \LaTeX{} to be programmed to do + extra stuff automatically at the end of the document, like + making an index. + +A useful side-effect of marking the end of the document + text is that you can store comments or temporary text + underneath the \verb+\end{document}+ in the + knowledge that \LaTeX{} will never try to typeset them. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +... +\end{document} +Don't forget to get the extra chapter from Jim! + \end{Verbatim} +\end{sourcecode} + +\label{environments}% +This + \command{begin}\thinspace{}\dots \command{end} + pair of commands is an example of a common \LaTeX{} structure called an + \textbf{\textit{environment}}\label{environment}\index{environment@\textbf{\textit{environment}}}. + Environments enclose text which is to be handled in a particular + way. All environments start with + \verb+\begin{...}+ and end with + \verb+\end{...}+ (putting the name of the + environment in the curly braces). +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{2}Adding the document environment} +\subsubsection*{Adding the document environment}\begin{enumerate}\item +Add the \env{document} environment to + your file. + +\item +Leave a blank line between the Document Class + Declaration and the \verb+\begin{document}+ + (you'll see why later). + +\item +Save the file. + +\end{enumerate} +\end{exercise} +\section{Titling} +\label{titling} +\index{titles} +The first thing you put in the + \env{document} environment is almost always the + document title, the author's name, and the date (except + in letters, which have a special set of commands for + addressing which we'll look at later). The title, author, + and date are all examples of \textbf{\textit{metadata}}\label{metadata}\index{metadata@\textbf{\textit{metadata}}} or \textbf{\textit{metainformation}}\label{metainformation}\index{metainformation@\textbf{\textit{metainformation}}} (information + \emph{about} information). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} + +\begin{document} + +\title{Practical Typesetting} +\author{Peter Flynn\\Silmaril Consultants} +\date{December 2004} +\maketitle + +\end{document} + \end{Verbatim} +\end{sourcecode} + +The \command{title}, \command{author}, + and \command{date} commands are + self-explanatory. You put the title, author name, and date in + curly braces after the relevant command. The title and author + are usually compulsory; if you omit the + \command{date} command, \LaTeX{} uses today's + date by default. + +You always finish the metadata with the + \command{maketitle} command, which tells + \LaTeX{} that it's complete and it can typeset the titling + information at this point. If you omit + \command{maketitle}, the titling will never be + typeset. This command is reprogrammable so you can alter the + appearance of titles (like I did for the printed version of + this document). + +The double backslash (\verb+\\+) is the + \LaTeX{} command for forced linebreak. \LaTeX{} normally decides by + itself where to break lines, and it's usually right, but + sometimes you need to cut a line short, like here, and start a + new one. I could have left it out and just used a comma, so my + name and my company would all appear on the one line, but I + just decided that I wanted my company name on a separate line. + In some publishers' document classes, they provide a special + \command{affiliation} command to put your company + or institution name in instead. + +When this file is typeset, you get something like this + (I've cheated and done it in + colour (\S\thinspace\ref{colorpkg}) for fun\mdash{}yours will be in black and white + for the moment): +\begin{center} +\fbox{\includegraphics[width=\textwidth]{title}} +\end{center} +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{3}Adding the metadata} +\subsubsection*{Adding the metadata}\begin{enumerate}\item +Add the \command{title}, + \command{author}, \command{date}, and + \command{maketitle} commands to your + file. + +\item +Use your own name, make up a title, and give a + date. + +\end{enumerate} + +The order of the first three commands is not important, + but the \command{maketitle} command must come + last. +\end{exercise} + +The document isn't really ready for printing like this, + but if you're really impatient, look at \chaptername~\ref{process} to see how to typeset and display + it. +\section{Abstracts and summaries} +\label{abstracts} +\index{abstracts}\index{summaries} +In reports and articles it is normal for the author + to provide an Summary or Abstract, in which you describe + briefly what you have written about and explain its + importance. Abstracts in articles are usually only a few + paragraphs long. Summaries in reports can run to several + pages, depending on the length and complexity of the report + and the readership it's aimed at. + +In both cases (reports and articles) the Abstract or + Summary is optional (that is, \LaTeX{} doesn't force you + to have one), but it's rare to omit it because readers want + and expect it. In practice, of course, you go back and type + the Abstract or Summary \emph{after} having + written the rest of the document, but for the sake of the + example we'll jump the gun and type it now. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} +\usepackage[latin1]{inputenc} +\renewcommand{\abstractname}{Summary} +\begin{document} + +\title{Practical Typesetting} +\author{Peter Flynn\\Silmaril Consultants} +\date{December 2004} +\maketitle + +\begin{abstract} +This document presents the basic concepts of +typesetting in a form usable by non-specialists. It +is aimed at those who find themselves (willingly or +unwillingly) asked to undertake work previously sent +out to a professional printer, and who are concerned +that the quality of work (and thus their corporate +æsthetic) does not suffer unduly. +\end{abstract} + +\end{document} + \end{Verbatim} +\end{sourcecode} + +After the \command{maketitle} you use the + \env{abstract} environment, in which you simply + type your Abstract or Summary, leaving a blank line between + paragraphs if there's more than one (see \S\thinspace\ref{paragraphs} for this convention). + +In business and technical documents, the Abstract is often + called a Management Summary, or Executive Summary, or Business + Preview, or some similar phrase. \LaTeX{} lets you change the + name associated with the \env{abstract} + environment to any kind of title you want, using the + \command{renewcommand} command to give the command + \command{abstractname} a new value: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand{\abstractname}{Executive Summary} + \end{Verbatim} +\end{sourcecode} +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{4}Using an Abstract or Summary} +\subsubsection*{Using an Abstract or Summary}\begin{enumerate}\item +Add the \command{renewcommand} as shown + above to your Preamble. + +The Preamble is at the start of the document, in + that gap \emph{after} the + \command{documentclass} line but + \emph{before} the + \verb+\begin{document}+ (remember I said + we'd see what we left it blank for: see the panel `The Preamble' \testpage[below]{preamble}). + +\item +Add an \env{abstract} environment + after the \command{maketitle} and type in a + paragraph or two of text. + +\item +Save the file (no, I'm not paranoid, just + careful). + +\end{enumerate} +\end{exercise} + +Notice how the name of the command you are renewing (here, + \command{abstractname}) goes in the first set of + curly braces, and the new value you want it to have goes in + the second set of curly braces (this is an example of a + command with two arguments). The environment you use is still + called \env{abstract} (that is, you still type + \verb+\begin{abstract}+\dots \verb+\end{abstract}+). + What the \command{abstractname} does is change the + name that gets displayed and printed, not the name of the + environment you store the text in. + +If you look carefully at the example document, you'll + see I sneakily added an extra command to the Preamble. + We'll see later what this means (Brownie points for + guessing it, though, if you read \S\thinspace\ref{accents}). +\begin{sidebar}\label{preamble} +\subsection*{The Preamble} +Modifications which you want to affect a whole document + go at the start of your \LaTeX{} file, immediately + after the \command{documentclass} line and before + the \verb+\begin{document}+ line: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} +\renewcommand{\abstractname}{Sneak Preview} +\begin{document} +... +\end{document} + \end{Verbatim} +\end{sourcecode} + +This position, between the Document Class Declaration + and the beginning of the \env{document} + environment, is called the \textbf{\textit{preamble}}\label{pre}\index{preamble@\textbf{\textit{preamble}}}, and it is used for small or + temporary modifications to the style and behaviour of the + document. Major or permanent modifications should go in a + \url+.sty+ file and be invoked with a + \command{usepackage} command. +\end{sidebar}\section{Sections} +\label{sections} +\index{sections} +In the body of your document, \LaTeX{} provides seven + levels of division or sectioning for you to use in structuring + your text. They are all optional: it is perfectly possible to + write a document consisting solely of paragraphs of + unstructured text. But even novels are normally divided into + chapters, although short stories are often made up solely of + paragraphs. + +Two of these divisions, Parts and Chapters, are only + available in the \package{book} and + \package{report} document classes, because they + don't have any meaning in articles and letters.\footnote{It is arguable that chapters also have no place in + reports, either, as these are conventionally divided into + sections as the top-level division. \LaTeX{}, however, + assumes your reports have chapters, but this is only the + default, and can be changed very simply (see + \S\thinspace\ref{reprog}).\label{repchap}} +\begingroup\small \begin{center} +\label{secdepths} +\begin{tabular}{@{}clll@{}} +\textbf{\sffamily\upshape Depth}&\textbf{\sffamily\upshape Division}&\textbf{\sffamily\upshape Command}&\textbf{\sffamily\upshape Notes}\\[2pt]\hline\\[-1.5\baselineskip] +\(\ifmmode-\else$-$\fi{}1\)&Part&\command{part}&Books and reports\\ +0&Chapter&\command{chapter}&Books and reports\\ +1&Section&\command{section}&Not in letters\\ +2&Subsection&\command{subsection}&Not in letters\\ +3&Subsubsection&\command{subsubsection}&Not in letters\\ +4&Titled paragraph&\command{paragraph}&Not in letters\\ +5&Titled subparagraph&\command{subparagraph}&Not in letters\\ +\end{tabular} +\end{center} +\endgroup +In each case the title of the part, chapter, section, + etc. goes in curly braces after the command. \LaTeX{} + automatically calculates the correct numbering and prints the + title in bold. You can turn section numbering off at a + specific depth: details in \S\thinspace\ref{secnum}. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\section{New recruitment policies} +... +\subsection{Effect on staff turnover} +... +\chapter{Business plan 2005--2007} + \end{Verbatim} +\end{sourcecode} + +There are packages\footnote{Details of how to use \LaTeX{} packages are in \S\thinspace\ref{packages}.} to let you control the typeface, style, spacing, + and appearance of section headings: it's much easier to + use them than to try and reprogram the headings manually. Two + of the most popular are the \package{ssection} + and \package{sectsty} packages. + +Headings also get put automatically into the Table of + Contents, if you specify one (it's optional). But if you + make manual styling changes to your heading, for example a + very long title, or some special line-breaks or unusual + font-play, this would appear in the Table of Contents as well, + which you almost certainly \emph{don't} + want. \LaTeX{} allows you to give an optional extra version of + the heading text which only gets used in the Table of Contents + and any running heads, if they are in effect (\S\thinspace\ref{runningheads}). This optional alternative + heading goes in [square brackets] before the curly + braces: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\section[Effect on staff turnover]{An analysis of the +effect of the revised recruitment policies on staff +turnover at divisional headquarters} + \end{Verbatim} +\end{sourcecode} +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{5}Start your document text} +\subsubsection*{Start your document text}\begin{enumerate}\item +Add a \command{chapter} command after your + Abstract or Summary, giving the title of your first + chapter. + +\item +If you're planning ahead, add a few more + \command{chapter} commands for + subsequent chapters. Leave a few blank lines between + them to make it easier to add paragraphs of text + later. + +\item +By now I shouldn't need to tell you what to do + after making significant changes to your document + file. + +\end{enumerate} +\end{exercise} +\subsection{Section numbering} +\label{secnum} +\index{section numbering} +All document divisions get numbered automatically. Parts + get Roman numerals (Part I, Part II, etc.); + chapters and sections get decimal numbering like this + document, and Appendixes (which are just a special case of + chapters, and share the same structure) are lettered (A, B, + C, etc.). + +You can change the depth to which section numbering + occurs, so you can turn it off selectively. In this document + it is set + to \arabic{secnumdepth}. + If you only want parts, chapters, and sections numbered, not + subsections or subsubsections etc., you can change the + value of the \counter{secnumdepth} + counter using the the \command{setcounter} command, + giving the depth value from the table on p.\thinspace\pageref{secdepths}: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setcounter{secnumdepth}{1} + \end{Verbatim} +\end{sourcecode} + +A related counter is \counter{tocdepth}, which specifies what + depth to take the Table of Contents to. It can be reset in + exactly the same way as \counter{secnumdepth}. The current setting + for this document is \arabic{tocdepth}. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setcounter{tocdepth}{3} + \end{Verbatim} +\end{sourcecode} + +To get an \emph{unnumbered} section + heading which does \emph{not} go into the + Table of Contents, follow the command name with an asterisk + before the opening curly brace: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\subsection*{Shopping List} + \end{Verbatim} +\end{sourcecode} + +All the divisional commands from + \command{part*} to \command{subparagraph*} + have this `starred' version which can + be used on special occasions for an unnumbered heading when + the setting of \counter{secnumdepth} + would normally mean it would be numbered. +\section{Ordinary paragraphs} +\label{paragraphs} + +After section headings comes your text. Just type it and + leave a blank line between paragraphs. That's all + \LaTeX{} needs. + +The blank line means `start a new paragraph + here': it does \emph{not} (repeat: + \emph{\textbf{not}}) mean you get a blank + line in the typeset output. Now read this paragraph + again and again until that sinks in. + +The spacing between paragraphs is a separately definable + quantity, a \textbf{\textit{dimension}}\label{dimension}\index{dimension@\textbf{\textit{dimension}}} or + \textbf{\textit{length}}\label{length}\index{length@\textbf{\textit{length}}} called \length{parskip}. This is normally zero + (no space between paragraphs, because that's how books + are normally typeset), but you can easily set it to any size + you want with the \command{setlength} command in the + Preamble: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\parskip}{1cm} + \end{Verbatim} +\end{sourcecode} + +\label{paraspace}% +This will set the space between paragraphs + to 1cm. See \S\thinspace\ref{dimensions} for details of the + various size units \LaTeX{} can use. \emph{Leaving + multiple blank lines between paragraphs in your source + document achieves nothing}: all extra blank lines + get ignored by \LaTeX{} because the space between paragraphs + is + controlled only by the value of \length{parskip}. + +White-space in \LaTeX{} can also be made flexible (what + \authorof{latexbook} calls + `rubber' lengths). This means that + values such as \length{parskip} can + have a default dimension plus an amount of expansion minus an + amount of contraction. This is useful on pages in complex + documents where not every page may be an exact number of + fixed-height lines long, so some give-and-take in vertical + space is useful. You specify this in a + \command{setlength} command like this: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\parskip}{1cm plus4mm minus3mm} + \end{Verbatim} +\end{sourcecode} + +Paragraph indentation can also be set with the + \command{setlength} command, although you would + always make it a fixed size, never a flexible one, otherwise + you would have very ragged-looking paragraphs. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\parindent}{6mm} + \end{Verbatim} +\end{sourcecode} + +By default, the first paragraph after a heading follows + the standard Anglo-American publishers' practice of + \emph{no} indentation. Subsequent paragraphs are + indented by the value of \length{parindent} (default + 18pt).\footnote{Paragraph spacing and indentation are cultural + settings. If you are typesetting in a language other than + English, you should use the \package{babel} + package, which alters many things, including the spacing + and the naming of sections, to conform with the standards + of different countries and languages.} You can change this in the same way as any other + length. + +In the printed copy of this document, the paragraph + indentation is set to \the\parindent and the space + between paragraphs is set to \the\parskip. These values do not + apply in the Web (HTML\index{HTML@HTML}) version because not all browsers are + capable of that fine a level of control, and because users can + apply their own stylesheets regardless of what this document + proposes. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{6}Start typing!} +\subsubsection*{Start typing!}\begin{enumerate}\item +Type some paragraphs of text. Leave a blank line + between each. Don't bother about line-wrapping or + formatting\mdash{}\LaTeX{} will take care of all + that. + +\item +If you're feeling adventurous, add a + \command{section} command with the title of a + section within your first chapter, and continue typing + paragraphs of text below that. + +\item +Add one or more \command{setlength} + commands to your Preamble if you want to experiment with + changing paragraph spacing and indentation. + +\end{enumerate} +\end{exercise} + +To turn off indentation completely, set it to zero (but + you still have to provide units: it's still a + measure!). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\parindent}{0in} + \end{Verbatim} +\end{sourcecode} + +If you do this, though, and leave \length{parskip} set to zero, your readers + won't be able to tell easily where each paragraph begins! + If you want to use the style of having no indentation with a + space between paragraphs, use the + \package{parskip} package, which does it for + you (and makes adjustments to the spacing of lists and other + structures which use paragraph spacing, so they don't get + too far apart). +\section{Table of contents} +\label{toc} +\index{table of contents!automated entries} +All auto-numbered headings get entered in the Table of + Contents (ToC) automatically. You don't have to print a + ToC, but if you want to, just add the command + \command{tableofcontents} at the point where you want + it printed (usually after the Abstract or Summary). + +Entries for the ToC are recorded each time you process + your document, and reproduced the \emph{next} + time you process it, so you need to re-run \LaTeX{} one extra + time to ensure that all ToC page-number references + are correctly calculated. + +We've already seen in \S\thinspace\ref{sections} how + to use the optional argument to the sectioning commands to add + text to the ToC which is slightly different from the one + printed in the body of the document. It is also possible to + add extra lines to the ToC, to force extra or unnumbered + section headings to be included. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{7}Inserting the table of contents} +\subsubsection*{Inserting the table of contents}\begin{enumerate}\item +Go back and add a \command{tableofcontents} + command after the \verb+\end{abstract}+ command + in your document. + +\item +You guessed. + +\end{enumerate} +\end{exercise} + +\label{loflot}% +The commands \command{listoffigures} + and \command{listoftables} work in exactly the same + way as \command{tableofcontents} to automatically + list all your tables and figures. If you use them, they + normally go after the \command{tableofcontents} + command. + +The \command{tableofcontents} command normally + shows only numbered section headings, and only down to the + level defined by the \counter{tocdepth} counter (see \S\thinspace\ref{secnum}), but you can add extra entries with the + \command{addcontentsline} command. For example if you + use an unnumbered section heading command to start a + preliminary piece of text like a Foreword or Preface, you can + write:\index{table of contents!adding manual entry} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\subsection*{Preface} +\addcontentsline{toc}{subsection}{Preface} + \end{Verbatim} +\end{sourcecode} + +This will format an unnumbered ToC entry for + `Preface' in the + `subsection' style. You can use + the same mechanism to add lines to the List of Figures or List + of Tables by substituting \url+lof+ or + \url+lot+ for \url+toc+. +\chapter{Typesetting, viewing and printing} +\label{process} +\index{typesetting}\index{viewing}\index{printing} +We've now got far enough to typeset what you've + entered. I'm assuming at this stage that you have typed + some sample text in the format specified in the previous + chapter, and you've saved it in a plain-text file with a + filetype of + \verb+.tex+ and a name of your own choosing. +\index{filenames}\begin{exercise} +\addcontentsline{loe}{section}{\numberline{8}Saving your file} +\subsubsection*{Saving your file} +If you haven't already saved your file, do so now + (some editors and interfaces let you typeset the document + without saving it!). + +Pick a sensible filename in a sensible directory. Names + should be short enough to display and search for, but + descriptive enough to make sense. See the panel `Picking suitable filenames' \testpage[below]{filenames} for more details. +\end{exercise} +\begin{sidebar}\label{filenames} +\subsection*{Picking suitable filenames} +Never, ever use directories (folders) or file names + which contain spaces. Although your operating system + probably supports them, some don't, and they will + only cause grief and tears with \TeX{}. + +Make filenames as short or as long as you wish, but + strictly avoid spaces. Stick to upper- and lower-case + letters without accents (A\ndash{}Z and a\ndash{}z), the + digits 0\ndash{}9, the hyphen (\verb+-+), and + the full point or period (\verb+.+), (similar + to the conventions for a Web URI\index{URI@URI}): it will let you refer to \TeX{} + files over the Web more + easily and make your files more portable. +\end{sidebar}\section{Typesetting} +\label{setting} + +Typesetting your document is usually done by clicking + on a button in a toolbar or an entry in a menu. Which one you + click on depends on what output you want\mdash{}there are two + formats available: +\begin{itemize} +\item +The standard (default) \LaTeX{} program produces a + device-independent (DVI)\index{DVI@DVI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DVI@DVI|textbf} file which + can be used with any \TeX{} previewer or printer driver on any + make or model of computer. There are dozens of these + available: at least one of each (previewer and printer + driver) should have been installed with your distribution + of \TeX{}. + +\item +The \product{pdf\LaTeX{}} program + produces an Adobe Acrobat PDF\index{PDF@PDF} + file which can be used with any suitable previewer, such + as \product{GSview}, + \product{PDFview}, + \product{Xpdf}, the + \product{Opera} browser, or Adobe's + own \product{Acrobat Reader}. + +\end{itemize} + +Depending on which one you choose, you may have to + [re]configure your editor so that it runs the right program. + They can all do all of them, but they don't always come + pre-set with buttons or menus for every possible option, + because they can't guess which one you want. +\subsection{Standard \LaTeX{}} + +There are also two ways of running \LaTeX{}: from the + toolbar or menu, or from the command line. Toolbars and + menus are most common in graphical systems, and are the + normal way to run \LaTeX{}. Command lines are used in + non-graphical systems and in automated processes where + \LaTeX{} is run + unattended (so-called `batch' or + `scripted' processing). + +Whichever way you run \LaTeX{}, it will process your + file and display a log or record of what it's doing + (see Exercise~\ref{terminal}: it looks the + same no matter what system you use). This is to let you see + where (if!) there are any errors or problems. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{9}Running from the toolbar or menu} +\subsubsection*{Running \LaTeX{} from the toolbar or menu} +Run \LaTeX{} on your file according to which system + you're using: +\begin{itemize} +\item +In \product{WinEdt}, click the + \guiicon{\LaTeX{}} toolbar icon; + +\item +In \product{Emacs}, click the + \menuitem{\TeX{}}{\TeX{} + File} menu item. + +\end{itemize} + +Your editor may suggest you save your file if you + haven't already done so. Do it. +\end{exercise} + +If \LaTeX{} reports any errors\mdash{}easily identifiable + as lines in the log beginning with an exclamation mark + (!)\mdash{}\emph{don't panic!} Turn to \S\thinspace\ref{errmsg}, identify what went wrong, and fix it in + your input file. Then re-run \LaTeX{}. If there were no + errors, your file is ready for displaying or + printing. +\subsection{Running \LaTeX{} from a command window} +\label{cmdwin} + +This is worth practising even if you normally use a + GUI\index{GUI@GUI}, so that you understand what it + does. See Figure~\ref{cliex} for an example. +\begin{exercise} +\label{terminal} +\addcontentsline{loe}{section}{\numberline{10}Running in a terminal or console + window} +\subsubsection*{Running \LaTeX{} in a terminal or console + window}\begin{itemize} +\item +Under graphical Unix-based systems (Linux and Mac) + you open a command (shell) window by clicking on the + shell or screen icon in the control panel at the + bottom of your screen. + +\item +Under Microsoft Windows you open a command window + by clicking on the + \menuitem{Start}{Programs}[MS-DOS] + or + \menuitem{Start}{Command + Prompt} menu item. + +\end{itemize} + +When the command window appears, type +\begin{sourcecode}\begin{Verbatim}[fontsize=\small,commandchars=\\\{\}] +cd \textsl{\uline{documents}} +latex \textsl{\uline{mybook}} + \end{Verbatim} +\end{sourcecode} + +Substitute the relevant directory and file name. + Remember to press the \key{Enter} key at the + end of each line. +\end{exercise} +\begin{figure}\small +\caption{\small Command-line usage} +\label{cliex} +\begin{center} +\label{clidemo}\includegraphics[width=0.75\textwidth]{terminal} +\end{center} +\end{figure} +\subsection{pdf\LaTeX{}} + +If you have configured your system to generate PDF\index{PDF@PDF} files direct instead of DVI\index{DVI@DVI} files (by using the + \product{pdf\LaTeX{}} program instead of + standard \LaTeX{}), then you can click the + \guiicon{pdf\LaTeX{}} icon in + \product{WinEdt} or type the command + \verb+pdflatex+ instead of + \verb+latex+ in a terminal (console) window. + \product{Emacs} does not have a default + menu configured for + \product{pdf\LaTeX{}}. +\section{Errors and warnings} +\label{errmsg} + +\LaTeX{} describes what it's typesetting while it does it, + and if it encounters something it doesn't understand or can't + do, it will display a message saying what's wrong. It may + also display warnings for less serious conditions. +\begin{center} +\includegraphics[width=0.5\textwidth]{dontpanic} +\end{center} + +\emph{Don't panic if you see error + messages}: it's very common for beginners to + mistype or mis-spell commands, forget curly braces, type a + forward slash instead of a backslash, or use a special + character by mistake. Errors are easily spotted and easily + corrected in your editor, and you can then run \LaTeX{} again + to check you have fixed everything. Some of the most common + errors are described in \S\thinspace\ref{errmsg} with an + explanation of how to fix them. +\subsection{Error messages} +\label{errs} + +The format of an error message is always the same. Error + messages begin with an exclamation mark at the start of the + line, and give a description of the error, followed by another + line starting with the number, which refers to the line-number + in your document file which \LaTeX{} was processing when the + error was spotted. Here's an example, showing that the user + mistyped the \command{tableofcontents} + command: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +! Undefined control sequence. +l.6 \tableofcotnetns + \end{Verbatim} +\end{sourcecode} + +When \LaTeX{} finds an error like this, it displays the + error message and pauses. You must type one of the following + letters to continue: +\begingroup\small \begin{center} +\begin{tabular}{cp{4in}} +\textbf{\sffamily\upshape Key}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip] +\key{x}&Stop immediately and e\emph{\textbf{x}}it the program.\\ +\key{q}&Carry on \emph{\textbf{q}}uietly as best you can and + don't bother me with any more error + messages.\\ +\key{e}&Stop the program but re-position the text in my + \emph{\textbf{e}}ditor at the point + where you found the error.\tablefootnote{TF-1}\\ +\key{h}&Try to give me more \emph{\textbf{h}}elp.\\ +\key{i}&(followed by a correction) means \emph{\textbf{i}}nput the correction in + place of the error and carry on.\tablefootnote{TF-2}\\ +\end{tabular} +\renewcommand{\theenumi}{\textit{\alph{enumi}}}\footnotesize\begin{enumerate*}\item This only works if you're using an editor + which \LaTeX{} can communicate with.\label{TF-1}\item This is only a temporary fix to get the file + processed. You still have to make that + correction in the editor.\label{TF-2}\end{enumerate*}\end{center} +\endgroup +Some systems (\product{Emacs} is one + example) run \LaTeX{} with a + `non-stop' switch turned on, so it + will always process through to the end of the file, + regardless of errors, or until a limit is reached. +\subsection{Warnings} +\label{warn} + +Warnings don't begin with an exclamation mark: they are + just comments by \LaTeX{} about things you might want to look + into, such as + overlong or underrun lines (often caused by unusual hyphenations, for + example), pages running short or long, and other typographical + niceties (most of which you can ignore until later). + +Unlike other systems, which try to hide unevennesses in + the text\mdash{}usually unsuccessfully\mdash{}by interfering + with the letter-spacing, \LaTeX{} takes the view that the + author or editor should be able to contribute. While it is + certainly possible to set \LaTeX{}'s parameters so that + the spacing is sufficiently sloppy that you will almost never + get a warning about badly-fitting lines or pages, you will + almost certainly just be delaying matters until you start to + get complaints from your readers or publishers. +\subsection{Examples} + +Only a few common error messages are given here: those + most likely to be encountered by beginners. If you find + another error message not shown here, and it's not + clear what you should do, ask for help. Most error messages + are self-explanatory, but because some errors can only be + righted by humans who can read and understand what it's + supposed to mean, they don't get spotted by \LaTeX{} + until much later, leading to several + messages in a row. + +Newcomers should remember to check the list of special + characters in (\S\thinspace\ref{specials}): a very large + number of errors when you are learning \LaTeX{} are due to + accidentally typing a special character when you didn't + mean to. This disappears after a few days as you get used to + them. +\subsubsection{Too many {\ttfamily\char'175}'s} +\label{toomany} +\index{Too many {\ttfamily\char'175}'s}\index{Error messages!Too many {\ttfamily\char'175}'s}\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +! Too many }'s. +l.6 \date December 2004} + \end{Verbatim} +\end{sourcecode} + +The reason \LaTeX{} thinks there are too many + \verb+}+'s here is that the opening curly + brace is missing after the \command{date} control + sequence and before the word \verb+December+, + so the closing curly brace is seen as one too many (which + it is!). + +In fact, there are other things which can follow the + \command{date} command apart from a date in curly + braces, so \LaTeX{} cannot possibly guess that + you've missed out the opening curly brace\mdash{}until + it finds a closing one! +\subsubsection{Undefined control sequence} +\label{undefcs} +\index{Undefined control sequence}\index{Error messages!Undefined control sequence}\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +! Undefined control sequence. +l.6 \dtae + {December 2004} + \end{Verbatim} +\end{sourcecode} + +In this example, \LaTeX{} is complaining that it has + no such command (`control + sequence') as \verb+\dtae+. + Obviously it's been mistyped, but only a human can + detect that fact: all \LaTeX{} knows is + that \verb+\dtae+ is not a command it knows + about\mdash{}it's undefined. +\subsubsection{Runaway argument} +\label{runaway} +\index{Runaway argument}\index{Error messages!Runaway argument}\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +Runaway argument? +{December 2004 \maketitle +! Paragraph ended before \date was complete. +<to be read again> + \par +l.8 + \end{Verbatim} +\end{sourcecode} + +In this error, the closing curly brace has been + omitted from the date. It's the opposite of the error in + \S\thinspace\ref{toomany}, and it results in + \command{maketitle} trying to format the title + page while \LaTeX{} is still expecting more text for the + date! As + \command{maketitle} creates new paragraphs on the + title page, this is detected and \LaTeX{} complains that + the + previous paragraph has ended but \command{date} + is not yet finished. +\subsubsection{Underfull hbox} +\label{underfull} +\index{Underfull hbox}\index{Error messages!Underfull hbox}\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +Underfull \hbox (badness 1394) in paragraph +at lines 28--30 +[][]\LY1/brm/b/n/10 Bull, RJ: \LY1/brm/m/n/10 +Ac-count-ing in Busi- +[94] + \end{Verbatim} +\end{sourcecode} + +This is a warning that \LaTeX{} cannot stretch the + line wide enough to fit, without making the spacing bigger + than its currently permitted maximum. The + \textbf{\textit{badness}}\label{badness}\index{badness@\textbf{\textit{badness}}} (0\ndash{}10,000) indicates + how severe this is (here you can probably ignore a badness + of 1394). It says what lines of your file it was + typesetting when it found this, and the number in square + brackets is the number of the page onto which the + offending line was printed. + +The codes separated by slashes are the typeface and + font style and size used in the line. Ignore them for the + moment: details are in step~\ref{fdfiles} in the procedure on p.\thinspace\pageref{fdfiles} if you're + curious. +\subsubsection{Overfull hbox} +\label{overfull} +\index{Overfull hbox}\index{Error messages!Overfull hbox}\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +[101] +Overfull \hbox (9.11617pt too wide) in paragraph +at lines 860--861 +[]\LY1/brm/m/n/10 Windows, \LY1/brm/m/it/10 see +\LY1/brm/m/n/10 X Win- + \end{Verbatim} +\end{sourcecode} + +And the opposite warning: this line is too + long by a shade over 9pt. The chosen hyphenation point + which minimises the error is shown at the end of the line + (\emph{Win-}). Line numbers and page numbers + are given as before. In this case, 9pt is too much to + ignore (over 3mm or more than \(\frac{1}{8}\)$''$), and a manual correction needs + making (such as a change to the hyphenation), or the + flexibility settings need changing (outside the scope of + this book). +\subsubsection{Missing package} +\label{nopkg} +\index{File not found}\index{Error messages!File not found}\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +! LaTeX Error: File `paralisy.sty' not found. + +Type X to quit or <RETURN> to proceed, +or enter new name. (Default extension: sty) + +Enter file name: + \end{Verbatim} +\end{sourcecode} + +When you use the \command{usepackage} command + to request \LaTeX{} to use a certain package, it will look + for a file with the specified name and the filetype + \url+.sty+. In this case the user has + mistyped the name of the \package{paralist} + package, so it's easy to fix. However, if you get the name + right, but the package is not installed on your machine, + you will need to download and install it before continuing + (see \chaptername~\ref{ctan}). +\section{Screen preview} +\label{dvi} +\index{preview} +Once the file has been processed without errors (or even + if there are still errors, but you want to see what it's + doing with them), standard \LaTeX{} will have created a + DVI\index{DVI@DVI} file with the same name as your + document but the filetype + \verb+.dvi+. If you're using + \product{pdf\LaTeX{}}, a PDF\index{PDF@PDF} file will have been created, and you + can skip to + \S\thinspace\ref{pdfview}. +\subsection{Previewing DVI output} +\label{dvipreview} + +To see the typeset output, click on the + \menuitem{TeX}{TeX View} + menu item in \product{Emacs} or the + \guiicon{dvi} Preview toolbar icon in + \product{WinEdt}. A What You See Is What You Get (WYSIWYG)\index{WYSIWYG@WYSIWYG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!WYSIWYG@WYSIWYG|textbf} + preview window will appear with your typeset display (see + Figure~\ref{dviview}). +\begin{warning} +\label{bitmappreview} +\subsubsection*{Bitmap preview fonts in DVI viewers} +The first time you display your DVI\index{DVI@DVI} output with a new installation of + \TeX{}, there may be a short pause if the previewer needs + to create the special bitmaps used for screen previews of + some fonts. These give greater accuracy on low-resolution + devices like screens. As you continue to work with + \LaTeX{} and your system accumulates these font files, the + pause for generating them will disappear. Recent versions + of \TeX{} work directly with Type 1 fonts, however, + and don't have this delay. +\end{warning} +\begin{figure}\small +\caption{\small DVI preview} +\label{dviview} +\begin{center} +\includegraphics[width=0.75\textwidth]{xdvi} +\end{center} +\end{figure} + +Most previewers have a wide range of scaling, zooming, + and measuring functions, but remember this is a + \emph{picture} of your output: you cannot edit + the image. To change it, you always edit your source text + and reprocess the file. + +With \product{xdvi} and its derivatives + like \product{dviview}, you can leave the + display window open, and after you've reprocessed your + document through \LaTeX{}, moving your mouse back into the + window will make the display update automatically (click + your mouse if your windowing system needs a + click to focus). + +Figure~\ref{dviview} shows + \product{xdvi} displaying a page. With a + standard three-button mouse you get three levels of + micro-zoom to let you inspect fine details. +\subsection{Previewing with PostScript} +\label{makeps} + +PostScript\index{PostScript} is a page description + language invented by Adobe and used in laser printers and + high-end typesetters. It's been the universal standard + for electronically-formatted print files for nearly two + decades, and all printers and publishers are accustomed to + using it. PDF\index{PDF@PDF} is a descendant of + PostScript, and is rapidly taking over, but + PostScript\index{PostScript} itself is still extremely + common, largely because it is very robust, and is usually an + ASCII\index{ASCII@ASCII} file, which makes it very + portable and easy to generate (it is actually a programming + language in its own right). The drawback is the large size + of PostScript\index{PostScript} files, especially if + they contain bitmapped graphics. + +The \product{dvips} program which comes + with all \TeX{} systems is used to generate + PostScript\index{PostScript} files directly from your + DVI\index{DVI@DVI} output. These + \url+.ps+ files can be viewed, printed, sent + to a platemaker or filmsetter, or put online for + downloading. + +DVI\index{DVI@DVI} viewers cannot render some + PostScript\index{PostScript} graphical manipulations + like rotating and deforming, so an alternative to viewing + the DVI file direct is to generate a + PostScript\index{PostScript} file and use a + PostScript\index{PostScript} viewer. You may have to to + do this for your publisher anyway, and many editors can be + configured to do this by default. Look for a + \guiicon{dvips} toolbar icon or menu entry and + click on it. + +It's also very simple to do manually: let's + assume your \LaTeX{} file was called + \url+mydoc.tex+, so processing it has created + \url+mydoc.dvi+. Just type: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +dvips -o mydoc.ps mydoc + \end{Verbatim} +\end{sourcecode} + +\noindent in a command window (see Exercise~\ref{terminal} for how to use one) + and \product{dvips} will create + \url+mydoc.ps+ which can be used both for + previewing and printing. + +To view a PostScript\index{PostScript} file, you + need a PostScript\index{PostScript} previewer like + \product{GSview}, which works with the + PostScript\index{PostScript} interpreter + \product{Ghostscript}, which should have + been installed automatically along with your \TeX{} system + (if not, install both now: \product{GSview} + is separately licensed and cannot legally be included in + some older \TeX{} distributions, so you may have to download + it yourself). + +\product{GSview} can be set to watch + the PostScript\index{PostScript} file and automatically + update the display any time the file is changed, without you + even having to click on the window. +\subsection{Previewing with PDF} +\label{pdfview} + +The Portable Document Format (PDF)\index{PDF@PDF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PDF@PDF|textbf} + is a derivative of PostScript\index{PostScript}. + Whereas PostScript\index{PostScript} is a programming + language in itself, PDF\index{PDF@PDF} is in effect + the \emph{result} of processing a document + through PostScript\index{PostScript}: it's a binary + file format, extremely compact, and well-supported on all + platforms. + +If your system is configured to generate PDF\index{PDF@PDF} files direct instead of DVI\index{DVI@DVI} files, just open the + \url+.pdf+ file using any PDF\index{PDF@PDF} previewer or browser. + +Most editors are configured to display a toolbar icon + which will pop up \product{Acrobat Reader} + or some other viewer with the current PDF\index{PDF@PDF} output file. + +Adobe's \product{Acrobat Reader} + cannot automatically update the view if you reprocess your + document, in the way that \product{xdvi} + and \product{GSview} can. You + have to close the display with \key{Ctrl}--\key{W}~ and reload the file with \key{Alt}--\key{F}~\thinspace{}\key{1}. +\begin{warning} +\subsubsection*{Bitmap preview fonts in Acrobat Reader} +Acrobat Reader is extremely poor at rendering + Type 3 (bitmap) fonts. If you are using these (either + in an old \LaTeX{} installation which has not been + upgraded to Type 1, or with files using specialist + fonts only available in Type 3 format), you will see + a very fuzzy display at low magnifications. It will print + perfectly, but Acrobat Reader's display is + disappointing. The solution is to use a better previewer + or to upgrade to the Type 1 versions of the fonts + if possible, or both. If you need to + use Type 3 fonts in PDF\index{PDF@PDF}s, + you probably need to warn your readers to expect a fuzzy + display from Acrobat Reader (but good printout), and to + change to a better reader if they can. +\end{warning} +\section{Printer output} +\label{print} +\index{printing} +\TeX{} systems print on almost anything from the simplest + dot-matrix printers to the biggest phototypesetters, including + all the laser printers and a host of other devices in between. + \emph{How} you do it varies slightly according + to how you do your typesetting and previewing: +\begin{description} +\item[\sffamily If you are using DVI] +and you have a previewer which has a + \textbf{print} function configured for your + printer, you can use that. If not, create a + PostScript\index{PostScript} file and use + \product{GSview} instead. +\item[\sffamily If you are using PDF] +you can print directly from your PDF\index{PDF@PDF} viewer. Be careful about using + the `Fit to page' options, as they will + change the size of your document so all your + measurements will be different. +\item[\sffamily Non-PostScript\index{PostScript} printers] +You can create a PostScript\index{PostScript} + file with \product{dvips} (see \S\thinspace\ref{makeps}) and use + \product{GSview} to print it + (\product{GSview} can print + PostScript\index{PostScript} files to almost any + make or model of non-PostScript\index{PostScript} + printer). + + +\item[\sffamily If you have a real PostScript\index{PostScript} + printer] +or you are using a system with built-in + PostScript\index{PostScript} printing support (such + as Linux or Mac), you can create and send + PostScript\index{PostScript} output directly from + your editor to the printer without the need to open it + in a previewer first. In + \product{Emacs}, for example, this is + what happens when you use the + \menuitem{\TeX{}}{\TeX{} + Print} menu item. +\end{description} + +Both the \product{dvips} program and all + the previewers that print tend to have facilities for printing + selected pages, printing in reverse, scaling the page size, + \index{page size!scaling}\index{printing!reverse order}\index{printing!selected pages} and printing only odd or even pages for two-sided + work. If you are using PostScript\index{PostScript} there + are programs for manipulating the output + (\product{pstops}), for example to perform + page imposition to get 4, 8, or 16 pages to a sheet for making + booklets (\product{psnup}). +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{11}Print it!} +\subsubsection*{Print it!} +Show that you have understood the process of + typesetting, previewing, and printing, by displaying your + document and printing it. +\end{exercise} + +If you need a + non-PostScript\index{PostScript}/\product{Ghostscript} + solution, install a separate \TeX{} print driver for your + printer. Some + may be supplied with your \TeX{} installation, and there are + dozens more on CTAN\index{CTAN@CTAN}. Their names all + start with \url+dvi+ and are followed by an + abbreviation for the printer make or model like + \product{dvieps} for Epson, + \product{dvihp} for Hewlett-Packard, + \product{dvialw} for Apple LaserWriters, + etc.. Configure the driver to print directly to the print + queue, or pipe it to the print queue manually. On Linux with + an HP printer, for example, this would be +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +dvihp mydoc | lpr + \end{Verbatim} +\end{sourcecode} + +Microsoft Windows has no easy way to bypass the print + spool, but you can do it from an MS-DOS command window + with (using a HP printer as an example): +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +dvihp mydoc -o mydoc.hp +copy /b mydoc.hp LPT1: + \end{Verbatim} +\end{sourcecode} + +Read the documentation for the driver, as the options and + defaults vary. +\chapter[CTAN, packages, and online help]{CTAN, packages, \newline{}and online help} +\label{ctan} + +The Comprehensive \TeX{} Archive + Network (CTAN)\index{CTAN@CTAN|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CTAN@CTAN|textbf} is a repository of Web and FTP\index{FTP@FTP} servers worldwide which contain copies of + almost every piece of free software related to \TeX{} and + \LaTeX{}. + +CTAN\index{CTAN@CTAN} is based on three main + servers, and there are several online indexes available. There + are complete \TeX{} and \LaTeX{} systems for all platforms, + utilities for text and graphics processing, conversion programs + into and out of \LaTeX{}, printer drivers, extra typefaces, and + (possibly the most important) the \LaTeX{} packages. The three + main servers are: +\begin{itemize} +\item +\TeX{} Users Group: \url+http://www.ctan.org/+ + +\item +UK \TeX{} Users Group: \url+http://www.tex.ac.uk/+ + +\item +Deutschsprachige Anwendervereinigung \TeX{} e.V. (DANTE, + the German-speaking \TeX{} Users Group); \url+http://dante.ctan.org/+ + +\end{itemize} +\begin{sidebar} +CTAN\index{CTAN@CTAN} should + \emph{always} be your first port of call when + looking for a software update or a feature you want to use. + Please don't ask the network help + resources (\S\thinspace\ref{help}) until you have checked CTAN\index{CTAN@CTAN} and the FAQ\index{FAQ@FAQ} (\S\thinspace\ref{faq}). +\end{sidebar}\section{Packages} +\label{packages} +\index{packages!using} +Add-on features for \LaTeX{} are known as \textbf{\textit{packages}}\label{pack}\index{packages@\textbf{\textit{packages}}}. Dozens of these are + pre-installed with \LaTeX{} and can be used in your documents + immediately. They should all be stored in subdirectories of + \url+texmf/tex/latex+ named after each package. + To find out what other packages are available and what they + do, you should use the CTAN\index{CTAN@CTAN} search page\footnote{\url+http://www.ctan.org/search+} which includes a + link to Graham Williams' comprehensive package + catalogue. + +A package is a file or collection of files containing + extra \LaTeX{} commands and programming which add new styling + features or modify those already existing. Installed package + files all end with \url+.sty+ (there may be + ancillary files as well). + +When you try to typeset a document which requires a + package which is not installed on your system, \LaTeX{} will + warn you with an error message that it is missing (see \S\thinspace\ref{nopkg}), and you can + then download the package and install it using the + instructions in \S\thinspace\ref{pkginst}. You can also + download updates to packages you already have (both the ones + that were installed along with your version of \LaTeX{} as + well as ones you added). + +There is no limit to the number of packages you can have + installed on your computer (apart from disk space!), but there + is probably a physical limit to the number that can be used + inside any one \LaTeX{} document at the same time, although it + depends on how big each package is. In practice there is no + problem in having even a couple of dozen packages active (the + style file for this document uses over 30). +\subsection{Using an existing package} +\label{colorpkg} + +To use a package already installed on your system, + insert a \command{usepackage} command in your + document preamble with the package name in curly braces, as + we have already seen in earlier chapters. For example, to + use the \package{color} package, which lets + you typeset in colours (I warned you this was + coming!), you could type: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} +\usepackage{color} +\begin{document} +... +\end{document} + \end{Verbatim} +\end{sourcecode} + +You can include several package names in one + \command{usepackage} command by separating the + names with commas, and you can have more than one + \command{usepackage} command. + +Some packages allow optional settings in square + brackets. If you use these, you must give the package its + own separate \command{usepackage} command, like + \package{geometry} shown below: +\begin{sourcecode}\label{oldtitle}\begin{Verbatim}[fontsize=\small] +\documentclass[11pt,a4paper,oneside]{report} +\usepackage{pslatex,palatino,avant,graphicx,color} +\usepackage[margin=2cm]{geometry} +\begin{document} + +\title{\color{red}Practical Typesetting} +\author{\color{blue}Peter Flynn\\Silmaril Consultants} +\date{\color{green}December 2005} +\maketitle + +\end{document} + \end{Verbatim} +\end{sourcecode} + +(Incidentally, this is a rather crude way to do colours in + titling on a once-off basis: if it's for a repeatable + style we'll see in \chaptername~\ref{macros} how it can + be automated and kept out of the author's way.) + +Many packages can have additional formatting + specifications in optional arguments in square brackets, in + the same way as \package{geometry} + does. Read the documentation for the package concerned to + find out what can be done. +\begin{exercise} +\label{geoex} +\addcontentsline{loe}{section}{\numberline{12}Add colour} +\subsubsection*{Add colour} +Use the \package{color} package to add + some colour to your document. Stick with primary colours + for the moment. + +Use the \package{geometry} + package to change the margins. + +Reprocess and print your document if you have a colour + printer (monochrome printers should print it in shades of + grey). +\end{exercise} +\subsection{Package documentation} +\label{packagedoc} +\index{packages!documentation} +To find out what commands a package provides (and thus + how to use it), you need to read the documentation. In the + \url+texmf/doc+ subdirectory of your + installation there should be directories full of + \url+.dvi+ files, one for every package + installed. These can be previewed or printed like any other + DVI\index{DVI@DVI} file (see + \S\thinspace\ref{dvipreview}). If your installation + procedure has not installed the documentation, the DVI\index{DVI@DVI} files can all be downloaded from + CTAN\index{CTAN@CTAN}. + +Before using a package, you should read the + documentation carefully, especially the subsection usually + called `User Interface', which + describes the commands the package makes available. You + cannot just guess and hope it will work: you have to read it + and find out. + +See the next section for details of how to create the + documentation \url+.dvi+ file for additional + packages you install yourself. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{13}Read all about it} +\subsubsection*{Read all about it} +Find and view (or print) the documentation on the + \package{geometry} package you used in + Exercise~\ref{geoex}. + +Investigate some of the other package documentation + files in the directory. +\end{exercise} +\section{Downloading and installing packages} +\label{pkginst} +\index{packages!downloading}\index{packages!installing} +Once you have identified a package you need and + haven't already got (or you have got it and need to + update it), use the indexes on any CTAN\index{CTAN@CTAN} server to find the package you need + and the directory where it can be downloaded from. +\subsection{Downloading packages} +\label{downloadpkg} + +What you need to look for is always \emph{two + files}, one ending in \url+.dtx+ + and the other in \url+.ins+. The first is a + DOC\TeX{}\index{DOC} file, which combines the package program and its + documentation in a single file. The second is the + installation routine (much smaller). You \emph{must + always} download \emph{both} + files. + +If the two files are not there, it means one of two + things: +\begin{itemize} +\item +\emph{Either} the package is part of a + much larger bundle which you shouldn't normally update + unless you change version of \LaTeX{};\footnote{For example, there is no + \url+color.dtx+ and + \url+color.ins+ for the + \package{color} package because it + forms part of the \package{graphics} + bundle, which is installed on all \LaTeX{} systems + anyway. Such packages change very rarely, as they + + form part of the core of \LaTeX{} and are very + stable. In + general you should never try to update these + packages in isolation.} + +\item +\emph{or} it's one of a few rare or + unusual packages still supplied as a single + \url+.sty+ file intended for the now + obsolete \LaTeX{}\thinspace{}2.09.\footnote{You can try to use these if you wish but they + are not guaranteed to work, and have now almost all + been replaced by \LaTeXe{} versions. Always look for + the + \url+.dtx+ and + \url+.ins+ pair of files + first.} + +\end{itemize} + +\label{packinst}% +Download both files to a \textbf{\textit{temporary directory}}\label{tempdir}\index{temporary directory@\textbf{\textit{temporary directory}}}. If you use + Windows, keep a folder like \url+C:\tmp+ or + \url+C:\temp+ for this; Mac and Linux systems + already have a \url+/tmp+ directory. +\subsection{Installing a package} +\label{installpkg} + +There are four steps to installing a \LaTeX{} + package: +\index{packages!installing}\begin{enumerate} +\item \textbf{Extract the files}\\\label{extract}% +Run \LaTeX{} on the \url+.ins+ file. + That is, open the file in your editor and process it as + if it were a \LaTeX{} document (which is it), or if you + prefer, type \verb+latex+ followed by the + \url+.ins+ filename in a command window + in your temporary directory. + +This will extract all the files needed from the + \url+.dtx+ file (which is why you must + have both of them present in the temporary directory). + Note down or print the names of the files created if + there are a lot of them (read the log file if you want + to see their names again). +\item \textbf{Create the documentation}\\\label{dtxdoc}% +Run \LaTeX{} on the \url+.dtx+ file + twice. This will create a \url+.dvi+ file + of documentation explaining what the package is for and + how to use it. Two passes through \LaTeX{} are needed in + order to resolve any internal crossreferences in the + text (a feature we'll come onto later). If you + prefer to create PDF\index{PDF@PDF} then run + \product{pdf\LaTeX{}} instead. View or + print this file in the usual manner (see \S\thinspace\ref{dvi}). +\item \textbf{Install the files}\\ +While the documentation is printing, move or copy + the files created in step~\ref{extract} + from your temporary directory to the right place[s] in + your \TeX{} \emph{local} installation + directory tree\mdash{}always your `local' + directory tree, \begin{inparaenum}[\itshape a\upshape)] \item to prevent your new package accidentally + overwriting files in the main \TeX{} + directories; and \item to avoid your newly-installed files being + overwritten when you next update your version of + \TeX{}\end{inparaenum}. +\begin{table}\small \caption{\small Where to put files from packages} +\label{where} +\begin{center} +\begin{tabular}{@{}l>{\ttfamily}l>{\pbs{\raggedright}\footnotesize}p{1.5in}@{}} +\textbf{\sffamily\upshape Type}&\textbf{\sffamily\upshape Directory (under + \url+texmf-local/+)}&\textbf{\sffamily\upshape Description}\\[2pt]\hline\\[-1.5\baselineskip] +\url+.cls+&tex/latex/base&Document class file\\ +\url+.sty+&tex/latex/\textsl{packagename}&Style file: the normal package + content\\ +\url+.bst+&bibtex/bst/\textsl{packagename}&\BibTeX{} style\\ +\url+.mf+&fonts/source/public/\textsl{typeface}&\mf{} outline\\ +\url+.fd+&tex/latex/mfnfss&Font Definition files for \mf{} fonts\\ +\url+.fd+&tex/latex/psnfss&Font Definition files for PostScript + Type 1 fonts\\ +\url+.pfb+&/fonts/type1/\textsl{foundry}/\textsl{typeface}&PostScript Type 1 outline\\ +\url+.afm+&/fonts/afm/\textsl{foundry}/\textsl{typeface}&Adobe Font Metrics for Type 1 + fonts\\ +\url+.tfm+&/fonts/tfm/\textsl{foundry}/\textsl{typeface}&\TeX{} Font Metrics for \mf{} and + Type 1 fonts\\ +\url+.vf+&/fonts/vf/\textsl{foundry}/\textsl{typeface}&\TeX{} virtual fonts\\ +\url+.dvi+&/doc&package documentation\\ +\url+.pdf+&/doc&package documentation\\ +others&tex/latex/\textsl{packagename}&other types of file unless instructed + otherwise\\ +\end{tabular} +\end{center} +\end{table} + +`The right place' sometimes causes + confusion, especially if your \TeX{} installation is old + or does not conform to the \TeX{} + Directory Structure (TDS)\index{TDS@TDS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TDS@TDS|textbf}. For a TDS\index{TDS@TDS}-conformant system, this is either + \begin{inparaenum}[\itshape a\upshape)] \item for \LaTeX{} packages, a suitably-named + subdirectory of + \url+texmf-local/tex/latex/+\footnote{See \S\thinspace\ref{rightplace} for how + to create a parallel structure in your local + directory if your installation didn't create + one for you.}; or \item a suitably-named subdirectory of + \url+texmf-local/+ for files like + \BibTeX{} styles which are not just for \LaTeX{} but can + be used in other \TeX{} systems\end{inparaenum}. + +`Suitably-named' means sensible and + meaningful (and probably short). For a package like + \package{paralist}, for example, I'd call + the directory \url+paralist+. + +Often there is just a \url+.sty+ file + to move but in the case of complex packages there may be + more, and they may belong in different locations. For + example, new \BibTeX{} packages or font packages will + typically have several files to install. This is why it + is a good idea to create a subdirectory for the package + rather than dump the files into + \url+misc+ along with other unrelated + stuff. + +If there are configuration or other files, read the + documentation to find out if there is a special or + preferred location to move them to. +\item \textbf{Update your index}\\\label{texindex}%\index{packages!indexing} +Finally, run your \TeX{} indexer program to update + the package database. This program comes with every + modern version of \TeX{} and is variously called + \product{texhash}, + \product{mktexlsr}, or even + \product{configure}, or it might just + be a mouse click on a button or menu in your editor. + Read the documentation that came with your installation + to find out which it is. +\end{enumerate} +\begin{warning} + +This last step is \emph{utterly + essential}, otherwise nothing will + work. +\end{warning} +\begin{exercise} +\label{insttest} +\addcontentsline{loe}{section}{\numberline{14}Install a package} +\subsubsection*{Install a package} +Download and install the + \package{paralist} package (which + implements inline lists). +\end{exercise} + +The reason this process has not been automated widely is + that there are still thousands of installations which do not + conform to the TDS\index{TDS@TDS}, such as old + shared Unix systems and some Microsoft Windows systems, so + there is no way for an installation program to guess where + to put the files: \emph{you} have to know + this. There are also systems where the owner, user, or + installer has chosen \emph{not} to follow the + recommended TDS\index{TDS@TDS} directory + structure, or is unable to do so for political or security + reasons (such as a shared system where she cannot write to a + protected directory). + +The reason for having the + \url+texmf-local+ directory (called + \url+texmf.local+ on some systems) is to + provide a place for local modifications or personal updates, + especially if you are a user on a shared or managed system + (Unix, Linux, VMS, Windows NT/2000/XP, etc.) where you may + not have write-access to the main \TeX{} + installation directory tree. You can also have a personal + \url+texmf+ subdirectory in your own login + directory. Your installation must be configured to look in + these directories first, however, so that any updates to + standard packages will be found there + \emph{before} the superseded copies in the + main \url+texmf+ tree. All modern \TeX{} + installations should do this anyway, but if not, you can + edit \url+texmf/web2c/texmf.cnf+ yourself. + There is an example in Appendix~\ref{cnf}. +\subsection{Replicating the TDS} +\label{rightplace} + +I find it useful to make the directory structure of + \url+texmf-local+ the same as that of + \url+texmf+. Examine the subdirectories of + \url+texmf/tex/latex/+ for examples. For + updates of packages which came with your \LaTeX{} + distribution (as distinct from new ones you are adding + yourself), you can then use the same subdirectory name and + position in \url+texmf-local/...+ as the + original used in \url+texmf/...+. + +If you want to create the entire subdirectory structure + ready for use, you can do it under Unix with the following + commands: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +cd /usr/TeX/texmf +find . -type d -exec mkdir -p /usr/TeX/texmf-local/{} \; + \end{Verbatim} +\end{sourcecode} + +If you are using Microsoft Windows, you can download + \product{Cygwin}, which provides you with + the standard Unix tools in a shell window. The above command + should also work on a Mac running OS\thinspace{}X. In all cases, + if your installation directory is not + \url+/usr/TeX+, you need to substitute the + actual paths to your \url+texmf+ and + \url+texmf-local+ directories. +\section{Online help} +\label{help} +\index{help} +The indexes and documentation files on CTAN\index{CTAN@CTAN} are the primary online resource for + self-help on specific packages, and you should read these + carefully before asking questions about packages. +\subsection{The FAQ} +\label{faq} + +For general queries you should read the Frequently-Asked Questions (FAQ)\index{FAQ@FAQ|textbf}\index{Acronyms@\textbf{Acronyms}, defined!FAQ@FAQ|textbf} document so + that you avoid wasting online time asking about things for + which there is already an easily-accessible answer. + +The FAQ\index{FAQ@FAQ} is managed by the UK + \TeX{} Users Group and can be found at \url+http://www.tex.ac.uk/faq/+\thinspace{}. +\subsection{The \TeX{}hax mailing list} + +Another support resource is the mailing list \url+texhax@tug.org+. Again, feel free to ask + questions, but again, try to answer the question yourself + first (and say what you've tried in your + message). +\subsection{Web sites} + +The \TeX{} Users Group, as well as most local user + groups, maintains a web site (\url+http://tug.org+) with lots of information + about various aspects of the \TeX{} + system. See Appendix~\ref{tugform} for information on + joining TUG. +\subsection{News} + +The Usenet newsgroup \url+comp.text.tex+ is the principal forum for other + questions and answers about \LaTeX{}. Feel free to ask + questions, but + please do not ask frequently-asked questions: read the + FAQ\index{FAQ@FAQ} instead. The people who answer + the questions do so voluntarily, unpaid, and in their own + time, so please don't treat this as a commercial + support service. + +To access Usenet news, type the following URI\index{URI@URI} into your browser's + `Location' or + `Address' window: + \verb+news:comp.text.tex+ (if your browser + doesn't support Usenet news properly, change it for one + that does, like \product{Mozilla}\footnote{\url+http://www.mozilla.org/+}), or download one of the many free newsreaders.\footnote{Note that this means newsreaders for the Usenet News + (NNTP) service. It does \emph{not} mean + syndication readers for RSS, which are a different thing + entirely\mdash{}these are unfortunately also sometimes + referred to as `newsreaders'.} +\subsection{Commercial support} + +If you need commercial levels of support, such as + 24-hour phone contact, or macro-writing services, you can + buy one of the several excellent commercial versions of + \TeX{}, or contact a consultancy which deals with \TeX{} + (details on the TUG Web site). +\chapter{Other document structures} +\label{otherdoc} + +It is perfectly possible to write whole documents using + nothing but section headings and paragraphs. As mentioned in + \S\thinspace\ref{sections}, novels, for example, usually consist + just of chapters divided into paragraphs. However, it's more + common to need other features as well, especially if the + document is technical in nature or complex in structure. + +It's worth pointing out that + `technical' doesn't necessarily mean + `computer technical' or + `engineering technical': it just means it + contains a lot of $\tau\eta\chi\nu\epsilon$~(\emph{tekne}), the + specialist material or artistry of its field. A literary + analysis such as \titlecite{macnamara} (on the + marginal notes in the manuscripts of \authorof{bovary}'s novel) is every bit as + technical in the literary or linguistic field as the maintenance + manual for the Airbus 380 is in the aircraft engineering + field. + +This chapter covers the most common features needed in + writing structured documents: lists, tables, figures (including + images), sidebars like boxes and panels, and verbatim text + (computer program listings). In \chaptername~\ref{texttools} we + will cover footnotes, cross-references, citations, and other + textual tools. +\section{A little think about structure} +\label{briefstruct} + +It's very easy to sit down at a keyboard with a + traditional wordprocessor and just start typing. If it's + a very short document, or something transient or relatively + unimportant, then you just want to type it in and make it look + `right' by highlighting with the mouse + and clicking on font styles and sizes. + +In doing so, you may achieve the effect you wanted, but + your actions have left no trace behind of + \emph{why} you made these changes. This is + usually unimportant for trivial or short-term documents, but + if you write longer or more complex documents, or if you often + write documents to a regular pattern, then making them + consistent by manual methods becomes a nightmare. + \LaTeX{}'s facilities for automation are based on you + providing this `why' + information. + +If your documents have any of the features below, then you + have probably already started thinking about structure. +\begin{itemize} +\renewcommand{\labelitemi}{\raisebox{-.25ex}{\Square}} +\item +The document naturally divides into sections (parts, + chapters, etc.). + +\item +The document is long. + +\item +There is lots of repetitive formatting in the + document. + +\item +The document is complex (intellectually or + visually). + +\item +There are lots of figures or tables (or examples, + exercises, panels, sidebars, etc.). + +\item +Accuracy is important in formatting the + document. + +\item +A master copy is needed for future reference or + reprinting. + +\item +This is a formal or official document needing special + care and attention. + +\item +It's \emph{my} thesis, book, + leaflet, pamphlet, paper, article, etc. + \emph{That}'s why I care. + +\item +The document (or part of it) may need ongoing or + occasional re-editing and republishing. + +\end{itemize} + +If you've got that far, you're over half-way + done. Using a structural editor\mdash{}even a simple + outliner\mdash{}can make a huge difference to the quality of + your thinking because you are consciously organising your + thoughts before setting them down. And it can make just as big + a difference to your formatting as well: more consistent, + better presented, easier for the reader to navigate through, + and more likely to be read and understood\mdash{}which is + presumably why you are writing the document in the first + place. +\section{Lists} +\label{lists} +\index{lists} +Lists are useful tools for arranging thoughts in a + digestible format, usually a small piece of information at a + time. There are four basic types of list, shown in Table~\ref{listtypes}. +\begin{table}\small \caption{\small Types of lists} +\label{listtypes} +\begin{center} +\begin{tabular}{@{}>{\pbs{\raggedright}}p{0.48\columnwidth}>{\pbs{\raggedright}}p{0.48\columnwidth}@{}} +\begin{description}\item[\sffamily Random or arbitrary lists](sometimes called + `itemized' or + `bulleted' lists) where the + order of items is unimportant. The + items are often prefixed with a bullet or other + symbol for clarity or decoration, but are + sometimes simply left blank, looking like + miniature paragraphs (when they are known as + `simple' or + `trivial' lists).\end{description}&\begin{description}\item[\sffamily Enumerated or sequential lists](sometimes called + `numbered' lists) where the + order of items is critical, such as sequences of + instructions or rankings of importance. The + enumeration can be numeric (Arabic or Roman), or + lettered (uppercase or lowercase), and can even be + programmed to be hierarchical (1.a.viii, 2.3.6, + etc.).\end{description}\\ +\begin{description}\item[\sffamily Descriptive or labelled lists](sometimes called + `discussion' lists), which + are composed of subheadings or topic labels + (usually unnumbered but typographically distinct), + each followed by one or more indented paragraphs + of discussion or explanation.\end{description}&\begin{description}\item[\sffamily Inline lists]which are sequential in nature, just like + enumerated lists, but are + \begin{inparaenum}[\itshape a\upshape)] \item formatted \emph{within} + their paragraph; and \item usually labelled with letters,\end{inparaenum} like this example. The items + are often mutually inclusive or exclusive, with + the final item prefixed by + `and' or + `or' respectively.\end{description}\\ +\end{tabular} +\end{center} +\end{table} + +There are actually two other types, segmented lists and + reference lists, but these are much rarer, and outside the + scope of this document. +\index{environment} +The structure of lists in \LaTeX{} is identical for each + type, but with a different environment name. Lists are another + example of this \LaTeX{} technique (environments), where a pair + of matched commands surrounds some text which needs special + treatment. + +Within a list environment, list items are always + identified by the command \command{item} (followed by + an item label in [square brackets] in the case of labelled + lists). You don't type the bullet or the number or the + formatting, it's all automated. +\subsection{Itemized lists} +\index{lists!itemized}\index{lists!bulleted} +To create an itemized list, use the the + \env{itemize} environment: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{itemize} + +\item Itemized lists usually have a bullet; + +\item Long items use `hanging indentation', +whereby the text is wrapped with a margin +which brings it clear of the bullet used in +the first line of each item; + +\item The bullet can be changed for any other +symbol, for example from the \textsf{bbding} +or \textsf{pifont} package. + +\end{itemize} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begin{itemize} +\label{labelitem} +\renewcommand{\labelitemi}{\raisebox{-.25ex}{\raisebox{-.25ex}{\PencilRight}}} +\item +Itemized lists usually have a bullet; + +\item +Long items use `hanging + indentation', whereby the text is + wrapped with a margin which brings it clear of the + bullet used in the first line of each item; + +\item +The bullet can be changed for any other symbol, + for example from the \package{bbding} + or \package{pifont} package. + +\end{itemize} +\end{quote}\end{example} + +The default list bullet is round and solid\footnote{If your browser font doesn't show it, don't + worry: most don't. \LaTeX{} will.} (\textbullet{}) which is also available with the + command \command{textbullet} if you load the + \package{textcomp} package. See \S\thinspace\ref{bullets} for details of how to change the + settings for list item bullets. +\subsection{Enumerated lists} +\index{lists!numbered}\index{lists!enumerated} +To create an enumerated list, use the + \env{enumerate} environment: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{enumerate} + +\item Enumerated lists use numbering on each +item (can also be letters or roman numerals); + +\item Long items use `hanging indentation' +just the same as for itemized lists; + +\item The numbering system can be changed for +any level. + +\end{enumerate} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begin{enumerate}\item +Enumerated lists use numbering on each + item (can also be letters or roman numerals); + +\item +Long items use `hanging + indentation', just the same as for + itemized lists; + +\item +The numbering system can be changed for any + level. + +\end{enumerate} +\end{quote}\end{example} + +See \S\thinspace\ref{numberschemes} for details of how + to change the numbering schemes for each level. + +In standard \LaTeX{} document classes, the vertical + spacing between items, and above and below the lists as a + whole, is more than between paragraphs. If you want + tightly-packed lists, use the + \package{mdwlist} package, which provides + `starred' versions + (\env{itemize*}, + \env{enumerate*}, etc). +\subsection{Description lists} +\label{desc} +\index{lists!description}\index{lists!discussion} +To create a description list, use the + \env{description} environment: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{description} + +\item[Identification:] description lists +require a topic for each item given in +square brackets; + +\item[Hanging indentation:] Long items use +this in the same way as all other lists; + +\item[Reformatting:] Long topics can be +reprogrammed to fold onto multiple lines. + +\end{description} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begin{description} +\item[\sffamily Identification:] +description lists require a topic for each item + given in square brackets; +\item[\sffamily Hanging indentation:] +Long items use this in the same way as all other + lists; +\item[\sffamily Reformatting:] +Long topics can be reprogrammed to fold onto + multiple lines. +\end{description} +\end{quote}\end{example} + +All three of these types of lists can have multiple + paragraphs per item: just type the additional paragraphs in + the normal way, with a blank line between each. So long as + they are still contained within the enclosing environment, + they will automatically be indented to follow underneath their + item. +\subsection{Inline lists} +\label{inlinelists} +\index{lists!inline} +Inline lists are a special case as they require the use + of the \package{paralist} package which + provides the \env{inparaenum} environment + (with an optional formatting specification in square + brackets): +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage{paralist} +... +\textbf{\itshape Inline lists}, which are +sequential in nature, just like enumerated +lists, but are \begin{inparaenum}[\itshape +a\upshape)]\item formatted within their +paragraph; \item usually labelled with +letters; and \item usually have the final +item prefixed with `and' or +`or'\end{inparaenum}, like this example. + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent + +\textbf{\textit{Inline lists}}\label{inlines}\index{Inline lists@\textbf{\textit{Inline lists}}}, + which are sequential in nature, just like enumerated + lists, but are \begin{inparaenum}[\itshape a\upshape)] \item formatted within their paragraph; \item usually labelled with letters; and \item usually have the final + item prefixed with `and' or + `or'\thinspace\end{inparaenum}, like this example. +\end{quote}\end{example} + +See \chaptername~\ref{typo} for details of the + font-changing commands used in the optional argument to + \env{inparaenum}. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{15}List practice} +\subsubsection*{List practice} +Add some lists to your document. Pick any two of the + ones described here to practise with. + +If you successfully installed + \package{paralist} in Exercise~\ref{insttest} then you can use inline lists as + described in \S\thinspace\ref{inlinelists}. +\end{exercise} +\subsection{Reference lists and segmented lists} + +Reference lists are visually indistinguishable from + numbered or lettered lists, but the numbering or lettering + does \emph{not} imply a sequence. The numbers + or letters are just used as labels so that the items can be + referred to from elsewhere in the text (as in `see + item 501(c)3'). In this sense they are really a + kind of sub-sectional division, and \LaTeX{}'s + \command{paragraph} or + \command{subparagraph} commands (with appropriate + renumbering) would probably be a far better solution than + using a list. Label them and refer to them with + \command{label} and \command{ref} as for + any other cross-reference (see \S\thinspace\ref{xrefs}). + +Segmented lists are a highly specialised structure and + outside the scope of this document. For details of their + usage, see the the chapter `Segmentation and + Alignment' in \titlecite{teiguide}. +\subsection{Lists within lists} +\label{numberschemes} + +You can start a new list environment within the item of + an existing list, so you can embed one list inside another + up to four deep. The lists can be of any type, so you can + have a description list containing an item in which there is + a numbered sub-list, within which there is an item + containing a bulleted sub-sub-list. +\begin{enumerate}\item +by default an outer enumerated list is numbered in + Arabic numerals; +\begin{enumerate}\item +an embedded enumerated list is lettered in + lowercase; +\begin{enumerate}\item +a third level is numbered in lowercase Roman + numerals; +\begin{enumerate}\item +the fourth level uses uppercase + alphabetic letters. + +\end{enumerate} + +\end{enumerate} + +\end{enumerate} + +\end{enumerate} + +Multiple embedded lists automatically change the bullet + or numbering scheme so that the levels don't get + confused, and the spacing between levels is adjusted to + become fractionally tighter for more deeply nested + levels. + +These are only defaults and can easily be changed by + redefining the relevant set of values. You could also add a + fifth and further levels, although I suspect that would mean + your document structure needed some careful analysis, as + lists embedded five deep will probably confuse your + readers. + +The values for lists come in pairs: for each level there + is a counter to count the items and a command to produce the + label:\footnote{In fact, any time you define a counter in \LaTeX{}, + you automatically get a command to reproduce its value. + So if you defined a new counter \counter{example} to use in a teaching + book, by saying \url+\newcounter{example}+, + that automatically makes available the command + \url+\theexample+ for use when you want to + display the current value of \counter{example}.} +\begingroup\small \begin{center} +\begin{tabular}{rcll} +\textbf{\sffamily\upshape Level}&\textbf{\sffamily\upshape Default}&\textbf{\sffamily\upshape Counter}&\textbf{\sffamily\upshape Label command}\\[2pt]\hline\\[-1.5\baselineskip] +1&digit.&\counter{enumi}&\command{theenumi}\\ +2&(letter)&\counter{enumii}&\command{theenumii}\\ +3&roman.&\counter{enumiii}&\command{theenumiii}\\ +4&LETTER.&\counter{enumiv}&\command{theenumiv}\\ +\end{tabular} +\end{center} +\endgroup +Note that each counter and command ends with the Roman + numeral value of its level (this is to overcome the rule + that \LaTeX{} commands can only be made of + letters\mdash{}digits wouldn't work here). To + change the format of a numbered list item counter, just + renew the meaning of its label: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand{\theenumi}{\Alph{enumi}} +\renewcommand{\theenumii}{\roman{enumii}} +\renewcommand{\theenumiii}{\arabic{enumiii}} + \end{Verbatim} +\end{sourcecode} + +\noindent \label{thecounter}% +This would make the + outermost list use uppercase letters, the second level use + lowercase roman, and the third level use ordinary Arabic + numerals. The fourth level would remain unaffected. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{16}Nesting} +\subsubsection*{Nesting} +Extend your use of lists by nesting one type inside a + different one. +\end{exercise} +\begin{warning} +\subsubsection*{Lists: a caution to the unwary} +Treat lists with care: people sometimes use tables for + labelled information which is really a list and would be + better handled as such. They often do this because their + wordprocessor has no way to do what they want (usually to + place the item label level with the description or + explanation) \emph{except} by using a table, + hence they are misled into believing that their text is + really a table when it's actually not. +\end{warning} +\section{Tables} +\label{tables} +\index{tables} +Tabular typesetting is the most complex and time-consuming + of all textual features to get right. This holds true whether + you are typing in plain-text form, using a wordprocessor, + using \LaTeX{}, using HTML\index{HTML@HTML} or + XML\index{XML@XML}, using a DTP\index{DTP@DTP} system, or some other text-handling + package. Fortunately, \LaTeX{} provides a + table model with a mixture of defaults and configurability to + let it produce very high quality tables with a minimum of + effort. +\begin{warning} +\subsubsection*{Terminology} +\LaTeX{}, in common with standard typesetting + practice, uses the word `Table' to + mean a formal textual feature, numbered and with a caption, + referred to from the text (as in `See + Table 5'). Sometimes you can get + `informal' tables, which simply occur + between two paragraphs, without caption or number. + +The arrangement of information in rows and columns + \emph{within} either of these structures is + called a `tabulation' or + `tabular matter'. + +It is important to keep this distinction firmly in mind + for this section. +\end{warning} +\subsection{Floats} +\label{floats} +\index{floats} +Tables and Figures are what printers refer to as + `floats'. This means they are not + part of the normal stream of text, but separate entities, + positioned in a part of the page to themselves (top, middle, + bottom, left, right, or wherever the designer specifies). + They always have a caption describing them and they are + always numbered so they can be referred to from elsewhere in + the text. + +\LaTeX{} automatically floats Tables and Figures, + depending on how much space is left on the page at the point + that they are processed. If there is not enough room on the + current page, the float is moved to the top of the next + page. This can be changed by moving the Table or Figure + definition to an earlier or later point in the text, or by + adjusting some of the parameters which control automatic + floating. + +Authors sometimes have many floats occurring in rapid + succession, which raises the problem of how they are + supposed to fit on the page and still leave room for text. + In this case, \LaTeX{} stacks them all up and prints them + together if possible, or leaves them to the end of the + chapter in protest. The skill is to space them out within + your text so that they intrude neither on the thread of your + argument or discussion, nor on the visual balance of the + typeset pages. But this is a skill few authors have, and + it's one point at which professional typographic advice + or manual intervention may be needed. + +There is a \env{float} package which lets + you create new classes of floating object (perhaps Examples + or Exercises). +\subsection{Formal tables} + +To create a \LaTeX{} Table, use the \env{table} + environment containing a \command{caption} command + where you type the caption, and a \command{label} + command to give the Table a label by which you can refer to + it. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{table} +\caption{Project expenditure to year-end 2006} +\label{ye2006exp} +... +\end{table} + \end{Verbatim} +\end{sourcecode} + +Numbering is automatic, but the \command{label} + command \emph{must follow} the + \command{caption} command, not precede it. The + numbering automatically includes the chapter number in + document classes where this is appropriate (but this can of + course be overridden). The \command{caption} + command has an optional argument to provide a short caption + if the full caption would be too long for the List of Tables (\S\thinspace\ref{loflot}): +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\caption[Something short]{Some very long caption that +will only look reasonable in the full figure.} + \end{Verbatim} +\end{sourcecode} +\subsection{Tabular matter} + +Within a Table, you can either typeset the tabular + matter using \LaTeX{}, or include a table captured as an + image from elsewhere. We will see how to include images in + \S\thinspace\ref{figures} on Figures, where they are more + common. + +To typeset tabular matter, use the + \env{tabular} environment. The + \verb+\begin{tabular}+ command must be followed + by a compulsory second argument in curly braces giving the + alignment of the columns. These are specified for each + column using one of single letters \verb+l+, + \verb+c+, and \verb+r+ for + left-aligned, centered, or right-aligned text, or the letter + \verb+p+ followed by a width argument if you + want a long entry to wrap to several lines (a miniature + paragraph as a single cell on each row). + +\TeX{}'s original tabular settings were designed + for classical numerical tabulations, where each cell + contains a single value. The \verb+p+ + specification allows a cell to be a miniature paragraph set + to a specific width. These are \verb+p+ column + specifications are \emph{not} multi-row + entries, they are single cells which contain multiple lines + of typesetting: the distinction is very important. + Auto-adjusting cell sizes like you see in a Web browser (the + `Netscape' table model) are possible + with the \package{tabularx} package, but + these are often inelegant in print, however convenient they + may be in a Web browser. + +The \package{array} package provides for + many other typographic variations such as left-aligned, + right-aligned, and centred multi-line columns, and other + packages provide decimal-aligned columns, row-spanning and + column-spanning, multi-page, and rotated (landscape format) + tables. +\begin{table}[b]\small \caption{\small Project expenditure to year-end 2006} +\label{ye2006exp} +\begin{center} +\begin{tabular}{clr} +\textbf{\sffamily\upshape }&\textbf{\sffamily\upshape Item}&\textbf{\sffamily\upshape \EUR{} Amount}\\[2pt]\hline\\[-1.5\baselineskip] +a)&Salaries (2 research assistants)&28,000\\ +&Conference fees and travel expenses&14,228\\ +&Computer equipment (5 workstations)&17,493\\ +&Software&3,562\\ +b)&Rent, light, heat, etc.&1,500\\ +\cline{3-3}\vrule height1.1em width0pt \textbf{}&\textbf{Total}&\textbf{64,783}\\ +\end{tabular} +\par\smallskip\footnotesize +The Institute also contributes to (a) and + (b).\end{center} +\end{table} + +As an example, a tabular setting with three columns, the + first one centered, the second left-aligned, and the third + one right-aligned, would therefore be specified as + \verb+{clr}+, as in the example below. Note the + use of indentation to make the elements of the table clear + for editing, and note also how the typeset formatting is + unaffected by this (see Table~\ref{ye2006exp}). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{table} + \caption{Project expenditure to year-end 2006} + \label{ye2006exp} + \begin{center} + \begin{tabular}{clr} + &Item&\EUR\ Amount\\ + \hline + a)&Salaries (2 research assistants)&28,000\\ + &Conference fees and travel expenses&14,228\\ + &Computer equipment (5 workstations)&17,493\\ + &Software&3,562\\ + b)&Rent, light, heat, etc.&1,500\\\cline{3-3} + &Total&64,783 + \end{tabular} + \par\medskip\footnotesize +The Institute also contributes to (a) and (b). + \end{center} +\end{table} + \end{Verbatim} +\end{sourcecode} + +You do not need to format the tabular data in your + editor: \LaTeX{} does this for you when it typesets the + table, using the column specifications you provided. Extra + space is automatically added between columns, and can be + adjusted by changing the \length{tabcolsep} dimension. + \person{Takaaki Ota} provides an excellent Tables mode for + \product{Emacs} which provides a + spreadsheet-like interface and can generate \LaTeX{} table + source code (see Figure~\ref{tabmode}). +\begin{figure}\small +\caption{\small Tables mode for + \emph{Emacs}} +\label{tabmode} +\begin{center} +\includegraphics[width=0.75\textwidth]{table} +\end{center} +\end{figure} + +It is conventional to centre the tabular setting within + the Table, using the \env{center} environment + (note US spelling) or the \command{centering} + command. The entries for each cell are separated by an + ampersand character (\verb+&+) and the end + of a row is marked by + the double-backslash (\verb+\\+). + +The \command{hline} command draws a rule across + all columns and the \command{cline} command draws a + rule across a range of columns (here, under column three + only\mdash{}the argument needs a range). If used, these commands \emph{follow} + the + \verb+\\+ of the row they apply to. There are + some extra formatting commands after the tabular material in + the example. These are explained in + \chaptername~\ref{typo}. + +If there is no data for a cell, just don't type + anything\mdash{}but you still need the + \verb+&+ separating it from the next + column's data. The astute reader will already have + deduced that for a table of + \(n\) columns, there must always be + \(n\ifmmode-\else$-$\fi{}1\) ampersands in each row. The exception to + this is when the \command{multicolumn} command is + used to create cells which span multiple columns. There is + also a package (\env{multirow}) to enable + cells to span multiple rows, but both of these techniques + are outside the scope of this document. +\subsection{Tabular techniques for alignment} + +As mentioned earlier, it's also perfectly possible + to typeset tabular matter outside a formal Table, where you + want to lay out an informal tabulation between paragraphs + where a fully floating formal Table would be unnecessary + (these are usually quite short: there are several of them in + this document). + +Tabular mode can also be used wherever you need to align + material side by side, such as in designing letterheads, + where you may want your company logo and address on one side + and some other information on the other. + +By default, \LaTeX{} typesets + \env{tabular} environments inline to the + surrounding text, so if you want your alignment displayed by + itself, put it inside a positioning environment like + \env{center}, + \env{flushright}, or + \env{flushleft}, or leave a blank line or + \command{par} before and after so it gets typeset + separately. + +There is much more to tabular setting: + full details are in the manuals mentioned in + the last paragraph of the Foreword on p.\thinspace\pageref{docs}. One final note to remind you of the + automated crossreferencing features: because the example + table is labelled, it can be referenced from anywhere in the + document as Table~\ref{ye2006exp} just by using + \verb+\ref{ye2006exp}+, regardless of how much + the surrounding document or structure is moved or + edited. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{17}Create a tabulation} +\subsubsection*{Create a tabulation} +Create one of the following in your document: +\begin{itemize} +\item +a formal Table with a caption showing the number + of people in your class broken down by age and + sex; + +\item +an informal tabulation showing the price for three + products; + +\item +the logo \setlength{\fboxsep}{-3pt}\setlength{\fboxrule}{.4pt} + \fbox{\begin{tabular}{cc}\tiny YEAR\\[-.8em]\tiny 2 + 0 0 0\vrule depth1em + width0pt\end{tabular}} (hint: \S\thinspace\ref{fbox}) + +\end{itemize} +\end{exercise} +\section{Figures} +\label{figures} +\index{figures}\index{floats} +As explained in \S\thinspace\ref{floats}, Figures and + Tables float to a vacant part of the page, as they are not + part of the sequence of sentences making up your text, but + illustrative objects that you refer to. + +Figures can contain text, diagrams, pictures, or any other + kind of illustration. To create a figure, use the + \env{figure} environment: like Tables, they + automatically get numbered, and must include a caption (with a + label after the caption, if needed, exactly the same as for + Tables) +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{figure} +\caption{Total variable overhead variance (after + \citeauthor[p.191]{bull}} +\label{workeff} +\begin{center} +\includegraphics[width=.75\columnwidth]{diagram} +\end{center} +\end{figure} + \end{Verbatim} +\end{sourcecode} +\begin{figure}\small +\caption{\small Total variable overhead variance (after \citeauthoryear{bull} \textsl{p.191})} +\label{workeff} +\begin{center} +\includegraphics[width=0.75\textwidth]{diagram} +\end{center} +\end{figure} + +You can see that the structure is very similar to the + \env{table} environment, but in this case we + have a graphic included. Details of this command + (\command{includegraphics}) are in the next section. + Details of the bibliographic citation mechanism are in \S\thinspace\ref{bib} + +The content of the Figure could of course also be textual, + in the form of a list or a text diagram. \LaTeX{} has a simple + drawing environment called \env{picture}, which + lets you create a limited set of lines and curves, but for a + diagram of any complexity, you should use a standard vector + drawing program (see \S\thinspace\ref{graphictypes}). +\section{Images} +\label{images} +\index{images}\index{graphics} +Images (graphics) can be included anywhere in a \LaTeX{} + document, although in most cases of formal documents they will + occur in Figures (see preceding section). To use graphics, you + need to use the \package{graphicx} package in + your preamble: + \verb+\usepackage{graphicx}+\footnote{You may find a lot of old files which use a package + called \package{epsf}. Don't use it. + It's obsolete.} + +This enables the command + \command{includegraphics} which is used to insert an + image in the document. The command is followed by the name of + your graphics file \emph{without the filetype}, + for example: \verb+\includegraphics{myhouse}+ + (we'll see in a minute why you don't include the + filetype). + +In most cases you should just make sure the image file is + in the same folder (directory) as the document you use it in. + This avoids a lot of messing around remembering where you put + the files. If you have images you want to use in several + different documents in different places on your disk, there is + a way to tell \LaTeX{} where to look (see \S\thinspace\ref{graphicsdir}). + +For standard \LaTeX{} with + \product{dvips}, graphics files + \emph{must} be in Encapsulated + PostScript (EPS)\index{EPS@EPS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!EPS@EPS|textbf} format: this has been the publishing + industry standard for portable graphics for many years, and no + other format will work portably in standard \LaTeX{}.\footnote{Some distributions of \TeX{} systems allow other + formats to be used, such as PNG\index{PNG@PNG}, + Microsoft Bitmap (BMP)\index{BMP@BMP|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!BMP@BMP|textbf} files, + Hewlett-Packard's Printer Control + Language (PCL)\index{PCL@PCL|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!PCL@PCL|textbf} files, and others; but you cannot + send such documents to other \LaTeX{} users and expect + them to work if they don't have the same distribution + installed as you have. Stick to EPS\index{EPS@EPS}.} + +All good graphics packages can save images as EPS\index{EPS@EPS}, but be very careful because some + packages, especially on Microsoft Windows platforms, use a + very poor quality driver, which creates very poor quality + EPS\index{EPS@EPS} files. If in doubt, check with + an expert. If you find an EPS\index{EPS@EPS} + graphic doesn't print, the chances are it's been + badly made by the graphics software. Download Adobe's own + PostScript driver from their Web site instead. + +For \product{pdf\LaTeX{}}, graphics files + can be in Portable Network + Graphic (PNG)\index{PNG@PNG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PNG@PNG|textbf}, Joint Photographic + Experts Group (JPG)\index{JPG@JPG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!JPG@JPG|textbf}, or PDF\index{PDF@PDF} + format, \emph{not} EPS\index{EPS@EPS}. This means if you want to use both + standard \LaTeX{} as well + as \product{pdf\LaTeX{}}, you need to keep + your graphics in two formats, EPS\index{EPS@EPS} + and one of the others. This is why you don't include the + filetype in the filename you give with + \command{includegraphics}: \LaTeX{} will assume + EPS\index{EPS@EPS} and + \product{pdf\LaTeX{}} will look for JPG\index{JPG@JPG}, PNG\index{PNG@PNG} or + PDF\index{PDF@PDF} files matching the name. + +The \command{includegraphics} command can take + optional arguments within square brackets before the filename + to specify either the height or width, and the other dimension + will automatically change to scale. If you specify both, the + image will be distorted to fit. You can scale an image by a + factor instead of specifying height or width; clip it to + specified coordinates; and rotate it in either direction. + Multiple optional arguments are separated with commas. +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{center} +\includegraphics[width=3cm]{twithcat} +\end{center} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begin{center} +\includegraphics[width=3cm]{twithcat} +\end{center} +\end{quote}\end{example} + +For details of all the arguments, see the documentation on + the \package{graphicx} package or a copy of the + \titlecite{companion}. This package also + includes commands to \raisebox{1ex}{\rotatebox{180}{rotate}}, + \scalebox{-1}[1]{mirror}, and + \scalebox{2}[1]{scale} text. + \index{rotate}\index{mirror}\index{scale} + +It is in fact possible to tell \LaTeX{} to generate the + right file format by itself, but this requires an external + command-line graphics converter, and as it gets done afresh + each time, it slows things down rather a lot. + +EPS\index{EPS@EPS} files, especially bitmaps, + can be very large indeed, because they are stored in ASCII\index{ASCII@ASCII} format. + \person{Staszek Wawrykiewicz} has drawn my attention to a useful program to + overcome this, called \product{cep} + (`Compressed Encapsulated Postscript') available + from CTAN\index{CTAN@CTAN} in the + \url+support/pstools+ directory, which can + compress EPS\index{EPS@EPS} files to a fraction of + their original size. The original file can be replaced by the + new smaller version and still used directly with + \command{includegraphics}. +\subsection{Making images} +\label{graphictypes} + +There are two types of image: bitmaps and + vectors. +\begin{description} +\item[\sffamily Bitmaps] +Bitmap images are made of coloured dots, so if you + enlarge them, they go jagged at the edges, and if you + shrink them, they go blurry. Bitmaps are fine for + photographs, where every dot is a different colour, + and no-one will notice if you don't shrink or enlarge + too much. Bitmaps for diagrams and drawings, however, + are almost always the wrong choice, and + often disastrously bad. +\item[\sffamily Vectors] +Vector drawings are made from instructions (eg + `draw this from here to here, using a line this + thick'). They can be enlarged or shrunk as + much as you like, and never lose accuracy, because + they \emph{get redrawn} automatically at + any size. You can't do photographs as vectors, but + it's the only acceptable method for drawings or + diagrams. +\end{description} + +Vector graphic packages are also better suited for + saving your image directly in EPS\index{EPS@EPS} + or PDF\index{PDF@PDF} format (both of which use + vectors internally). All the major graphics-generating + packages in all disciplines output vector formats: + \product{AutoCAD}, + \product{ChemDraw}, + \product{MathCAD}, + \product{Maple}, + \product{Mathematica}, + \product{ArcInfo}, and so on. EPS\index{EPS@EPS} is the universally-accepted format + for creating vector graphics for publication, with PDF\index{PDF@PDF} a close second. Most of the major + graphics (drawing) packages can also save as EPS\index{EPS@EPS}, such as + \product{PhotoShop}, \product{PaintShop + Pro}, Adobe + \product{Illustrator}, Corel + \product{Draw}, and + \product{GIMP}. There are also some free + vector plotting and diagramming packages available like + \product{tkPaint} and + \product{GNUplot} which do the same. Never, + ever (except in the direst necessity) save any + \emph{diagram} as a bitmap. +\begin{figure}\small +\caption{\small The diagram from Figure~\ref{workeff} shrunk and + enlarged} +\begin{center} +\fbox{\includegraphics[width=3.95cm]{diagram}}\quad\fbox{\includegraphics[scale=2,viewport=250 250 300 300,clip]{diagram}} +\end{center} +\end{figure} + +Bitmap formats like JPG\index{JPG@JPG} and + PNG\index{PNG@PNG} are ideal for photographs, as + they are also able to compress the data substantially + without too much loss of quality. However, compressed + formats are bad for screenshots, if you are documenting + computer tasks, because too much compression makes them + blurry. The popular Graphics Interchange + Format (GIF)\index{GIF@GIF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!GIF@GIF|textbf} is good for screenshots, but is not + supported by \TeX{}: use PNG\index{PNG@PNG} + instead, with the compression turned down to minimum. Avoid + uncompressible formats like BMP\index{BMP@BMP} as + they produce enormous and unmanageable files. The Tagged Image File Format (TIFF)\index{TIFF@TIFF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TIFF@TIFF|textbf}, popular with + graphic designers, should also be avoided because far too + many companies have designed and implemented non-standard, + conflicting, proprietary extensions to the format, making it + virtually useless for transfer between different types of + computers (except in faxes, where it's still used in a + much stricter version). +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{18}Adding pictures} +\subsubsection*{Adding pictures} +Add \verb+\usepackage{graphicx}+ to the + preamble of your document, and copy or download an image + you want to include. Make sure it is a JPG\index{JPG@JPG}, PNG\index{PNG@PNG}, or + PDF\index{PDF@PDF} image if you use + \product{pdf\LaTeX{}}, or an EPS\index{EPS@EPS} image if you use standard + \LaTeX{}. + +Add \command{includegraphics} and the + filename in curly braces (without the filetype), and + process the document and preview or print it. + +Make it into a figure following the example in \S\thinspace\ref{figures}. + +Be aware that some DVI\index{DVI@DVI} + previewers are not able to display all types of graphics, + and some cannot display colour. For best results, use + PDF\index{PDF@PDF} or + PostScript\index{PostScript} preview. +\end{exercise} +\subsection{Graphics storage} +\label{graphicsdir} + +I mentioned earlier that there was a way to tell + \LaTeX{} where to look if you had stored images centrally + for use in many different documents. The answer is in a + command \command{graphicspath} which you supply + with an argument giving the name of an additional directory + path you want searched when a file uses the + \command{includegraphics} command, for + example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\graphicspath{c:\mypict~1\camera} +\graphicspath{/var/lib/images} +\graphicspath{HardDisk:Documents:Reports:Pictures} + \end{Verbatim} +\end{sourcecode} + +I've used the `safe' + (MS-DOS) form of the Windows \url+My + Pictures+ folder because it's A Bad Idea to + use directory names containing spaces (see the panel `Picking suitable filenames' \testpage[above]{filenames}). Using + \command{graphicspath} does make your file less + portable, though, because file paths tend to be specific + both to an operating system and to your computer, like the + examples above. +\section{Verbatim text} +\label{verbatim} +\index{verbatim text} +If you are documenting computer procedures, you probably + need fixed-width type for examples of programming or data + input or output. Even if you are writing about completely + non-computer topics, you may often want to quote a URI\index{URI@URI} or email address which needs to be + typeset specially. It is particularly important in these two + examples to avoid hyphenating them if they have to break over + a line-end, because the hyphen might be taken by the user as a + part of the address. + +Standard \LaTeX{} includes two features for handling + fixed-format text, and there are many more available in + packages. +\subsection{Inline verbatim} +\label{inlineverb} + +To specify a word or phrase as verbatim text in + typewriter type within a sentence, use the special command + \command{verb}, followed by your piece of text + surrounded by any suitable character which does + \emph{not} occur in the text itself. This is a + very rare exception to the rule that arguments go in curly + braces. I often use the plus sign for this, for example to + show a \LaTeX{} command, I type + \verb`\verb+\includegraphics[width=3in]{myhouse}+` + in order to display + \verb+\includegraphics[width=3in]{myhouse}+, but + sometimes I use the + \textbf{\textit{grave accent}}\label{grave}\index{grave accent@\textbf{\textit{grave accent}}} (\textbf{\textit{backtick}}\label{backtick}\index{backtick@\textbf{\textit{backtick}}} or open-quote) or the + vertical bar when the phrase already has a plus sign in it, + like \verb`\verb|\(y=a+2x^2\)|` when + illustrating the \LaTeX{} equation + \verb|\(y=a+x^2\)|. + +This command has the advantage that it turns off all + special characters (see \S\thinspace\ref{specials}) except + the one you use as the delimiter, so you can easily quote + sequences of characters in any computer syntax without + problems. However, \LaTeX{} will never break the argument of + \command{verb} at a line-end when formatting a + paragraph, even if it contains spaces, so if it happens to + be long, and falls towards the end of a line, it will stick + out into the margin. See \S\thinspace\ref{hyph} for more + information on line-ends and hyphenation. + +The \package{url} package avoids this by + providing the command \command{url} which works in + the same way as \command{verb}, with the argument + enclosed in a pair of characters, but performs a hyphenless + break at punctuation characters, as in \urlhttp://www.ucc.ie:8080/cocoon/cc/ docs/siteowner.xmlhttp://www.ucc.ie:8080/cocoon/cc/docs/siteowner.xmlhttp://www.ucc.ie:8080/cocoon/cc/ docs/siteowner.xml. + It was designed for Web URI\index{URI@URI}s,\footnote{The original term Uniform Resource + Locator (URL)\index{URL@URL|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!URL@URL|textbf} is now strongly deprecated in the Web + community in favour of the more accurate Uniform Resource Indicator (URI)\index{URI@URI|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!URI@URI|textbf}. For + details see \url+http://www.w3.org/Addressing/+. + Unfortunately the older term still persists, especially + in \LaTeX{} and XML\index{XML@XML} + markup.} so it understands their syntax and will never + break mid-way through an unpunctuated word, only at slashes + and full points. Bear in mind, however, that spaces are + forbidden in URI\index{URI@URI}s, so using spaces + in \command{url} arguments will fail, as will using + other non-URI\index{URI@URI}-valid + characters. +\subsection{Display verbatim} + +For longer (multiline) chunks of fixed-format text, use + the \env{verbatim} environment: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{verbatim} +\documentclass[11pt,a4paper,oneside]{report} +\begin{document} + +\title{Practical Typesetting} +\author{Peter Flynn\\Silmaril Consultants} +\date{December 2004} +\maketitle + +\end{document} +\end{verbatim} + \end{Verbatim} +\end{sourcecode} + +Like \command{verb}, this turns off all special + characters, so you can include anything at all in the + verbatim text except the exact line + \verb+\end{verbatim}+ + +For more control over formatting, however, I recommend + the use of the \package{fancyvrb} package, + which provides a \env{Verbatim} environment + (note the capital letter) which lets you draw a rule round + the verbatim text, change the font size, and even have + typographic effects inside the \env{Verbatim} + environment. It can also be used in conjunction with the + \package{fancybox} package (see \S\thinspace\ref{fancybox}), and it can add reference line numbers + (useful for chunks of data or programming), and it can even + include entire external files. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{19}Try some fixed-format text} +\subsubsection*{Try some fixed-format text} +Add your email address and home page URI\index{URI@URI} using the \command{verb} + and \command{url} commands. You'll need to + \verb+\usepackage{url}+ for the latter. + +If you know some programming, try a few lines enclosed + in \env{verbatim} and + \env{Verbatim} environments. +\end{exercise} +\section{Boxes, sidebars, and panels} +\label{boxes} +\index{boxes}\index{sidebars}\index{panels} +\LaTeX{}, like most typesetting systems, works by setting + text into boxes. The default box is the width of the current + page, and works like an old compositor's galley (tray) + from the days of metal type: it accumulates typeset text until + it's a bit longer than the specified page height. At this + stage \LaTeX{} works out how much of it really will fit on a + page, snips it off and ships it out to the DVI\index{DVI@DVI} or PDF\index{PDF@PDF} file, + and puts the rest back into the galley to accumulate towards + the following page. +\subsection{Boxes of text} +\label{boxtext} + +Because of this `box' model, + \LaTeX{} can typeset any text into a box of any width + wherever on the page you need it. + +The simplest command for small amounts of text is + \command{parbox}. This command needs two arguments + in curly braces: the first is the width you want the text + set to, and the second is the text itself, for + example: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\parbox{1in}{Please make sure you send in your + completed forms by January 1st + next year, or the penalty clause + 2(a) will apply} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begingroup\small \begin{center} +\begin{tabular}{p{1in}} +Please make sure you send in your completed + forms by January 1st next year, or the penalty + clause 2(a) will apply\\ +\end{tabular} +\end{center} +\endgroup\end{quote}\end{example} + +The text is typeset to the required width, and the box + is extended downwards for as long as is required to fit the + text. Note that the baseline of a \command{parbox} + is set to the midpoint of the box; that is, if you include a + \command{parbox} in mid-sentence, the centre of the + box will be lined up with the line of type currently being + set.\parbox{1cm}{ +{\scriptsize{}\selectfont{}Like + this small paragraph.\par} +} You can specify that it should be the top or + bottom by adding an optional \opt{t} or + \opt{b} in square brackets before the width. For + example, + \verb+\parbox[t]{1in}{...}+ will produce + \parbox[t]{1in}{ +a box with the baseline aligned with the top line of + the text in the box. +} + +Notice that when setting very narrow measures with type + that is too large, the spacing may become uneven and there + may be too much hyphenation. Either use + \command{raggedright} or reduce the type size, or + (in extreme cases) reword the text or break each line by + hand. It is rare for \LaTeX{} to need this: the example above + was deliberately chosen to be obtuse as an + illustration. + +Where the contents is more extensive or more + complicated, you can use the \env{minipage} + environment. + +Within this you can use virtually everything + that occurs in normal text (e.g. lists, paragraphs, + tabulations, etc.) with the exception of floats like + tables and figures. The \env{minipage} + environment has an argument just like + \command{parbox} does, and it means the same: the + width you want the text set to. + +Note that in \env{minipage}s and + \command{parbox}es, the paragraph indentation + (\length{parindent}) is + reset to zero. If you need to change it, set it inside the + \env{minipage} or \command{parbox} + using the \command{setlength} command (see \S\thinspace\ref{paragraphs}). +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{minipage}{3in} +Please make sure you send in your completed +forms by January 1st next year, or the +penalty clause 2(a) will apply. +\begin{itemize} +\item Incomplete forms will be returned to +you unprocessed. +\item Forms must be accompanied by the +correct fee. +\item There is no appeal. The adjudicators' +decision is final. +\end{itemize} +\end{minipage} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begingroup\small \begin{center} +\begin{tabular}{p{3in}} +Please make sure you send in your + completed forms by January 1st next year, or the + penalty clause 2(a) will + apply.\begin{itemize} +\item +Incomplete forms will be returned to you + unprocessed. + +\item +Forms must be accompanied by the correct + fee. + +\item +There is no appeal. The + adjudicators' decision is final. + +\end{itemize} +\\ +\end{tabular} +\end{center} +\endgroup\end{quote}\end{example} + +There are two other ways of typesetting text to widths + other than the normal text width: you can use a one-row, + one-cell \env{tabular} environment with the + \verb+p+ column type specification, or you + can use the \command{vbox} command, which is raw + \TeX{}, and outside the scope of this document. +\subsection{Framed boxes} +\label{fbox} + +To put a frame round \fbox{some text}, use the + \command{fbox} command: + \verb+\fbox{some text}+. This works for a few + words in mid-line, but the framed box and its contents + won't break over the end of a line. To typeset + multiline text in a box, put it in a + \command{parbox}, or use a + \env{minipage} or + \env{tabular} environment as described above, + and enclose the whole thing in a + \command{fbox}. +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\fbox{\begin{minipage}{3in} +This multiline text is more flexible than +a tabular setting: +\begin{itemize} +\item it can contain any type of normal +\LaTeX{} typesetting; +\item it can be any specified width; +\item it can even have its own +footnotes\footnote{Like this}. +\end{itemize} +\end{minipage}} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begin{center}\setlength{\fboxrule}{1pt} +\begin{minipage}{3in} + +This multiline text is more flexible than a + tabular setting: +\begin{itemize} +\item +it can contain any type of normal \LaTeX{} + typesetting; + +\item +it can be any specified width; + +\item +it can even have its own footnotes.\footnote{Like this.} + +\end{itemize} +\end{minipage} +\end{center} +\end{quote}\end{example} + +The spacing between text and box is controlled by the + value of \length{fboxsep}, and + the thickness of the line by \length{fboxrule}. The following values + were used above: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\setlength{\fboxsep}{1em} +\setlength{\fboxrule}{2pt} + \end{Verbatim} +\end{sourcecode} + +As we saw before, setting justified text in narrow + measures will produce poor spacing: either use the + \command{raggedright} command, or change the font + size, or add explicit extra hyphenation points. + +Note the \verb+\begin{tabular}+ and + \verb+\begin{minipage}+ commands still need the + width specifying: in the case of the + \verb+\begin{tabular}+ by the use of the + \verb+p+ column type with its width + specification, and in the case of + \verb+\begin{minipage}+ by the second + argument. +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\fbox{\begin{tabular}{p{1in}} +Multiline text in a box typeset using +\textsf{tabular} +\end{tabular}} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begingroup\small \begin{center} +\setlength{\tabcolsep}{6pt} +\begin{tabular}{|p{1in}|}\hline +Multiline text in a box typeset using + \package{tabular}\\ +\hline +\end{tabular} +\end{center} +\endgroup\end{quote}\end{example} +\subsection{Sidebars and panels} +\label{fancybox} + +The \package{fancybox} package lets you + extend the principle of \command{fbox} with + commands to surround text in square, oval (round-cornered), + and drop-shadow boxes (e.g. \command{ovalbox}, + \command{shadowbox}, etc.: see the documentation + for details). + +You can create panels of any size with these borders by + using the \env{minipage} environment to + typeset the text inside a special \env{Sbox} + environment which \package{fancybox} defines. + The \env{minipage} formats the text but the + \env{Sbox} `captures' + it, allowing you to put the frame round it as it + prints. + +The printed version of this document uses this extensively and + there is a useful example shown in \S\thinspace\ref{macenv}. +\chapter{Textual tools} +\label{texttools} +\index{tools} +Every text-handling system needs to support a repertoire of + tools for doing things with text. \LaTeX{} implements many + dozens, of which a small selection of the most frequently used + is given here: +\begin{itemize} +\item +offset quotations (sometimes called `block + quotes'); + +\item +footnotes and end-notes; + +\item +marginal notes; + +\item +cross-references, both normal ones and bibliographic + citations; + +\item +indexes and glossaries; + +\item +typesetting in multiple columns. + +\end{itemize} +\section{Quotations} +\label{quotations} + +Direct speech and short quotes within a sentence + `like this' are done with simple + quotation marks as described in \S\thinspace\ref{quotes}. Sometimes, however, you may want longer + quotations set as a separate paragraph. Typically these are + indented from the surrounding text. \LaTeX{} has two + environments for doing this. + +Such quotations are often set in a smaller size of type, + although this is not the default, hence the use of the + \command{small} command in the second example. The + inclusion of the bibliographic citation at the end is + optional: here it is done with a non-standard command + \command{citequote} which I invented for this example + (there is more about how to do things like this in \chaptername~\ref{macros}). +\begin{description} +\item[\sffamily The {\fontseries{m}\selectfont{}\package{quote}} + environment] +is for up to a line of text each per (short) + quotation, with the whole thing indented from the + previous paragraph but with no additional indentation on + each quote; +\begin{example} +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] + +\begin{quote} +Do, Ronny, Do. \textit{Nancy Reagan} + +Da Do Ron Ron. \textit{The Crystals} +\end{quote} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent + +Do, Ronny, Do. {\fontshape{it}\selectfont{}Nancy + Reagan} + +Da Do Ron Ron. {\fontshape{it}\selectfont{}The + Crystals} +\end{quote}\end{example} +\item[\sffamily The {\fontseries{m}\selectfont{}\package{quotation}} + environment] +is for longer passages (a paragraph or more) of a + single quotation, where not only is the block of text + indented, but each paragraph of it also has its own + extra indentation on the first line. +\begin{example} +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +\begin{quotation}\small +At the turn of the century William Davy, +a Devonshire parson, finding errors in +the first edition of his \titleof{davy}, +asked for a new edition to be printed. +His publisher refused and Davy purchased +a press, type, and paper. He harnessed +his gardener to the press and apprenticed +his housemaid to the typesetting. After +twelve years' work, a new edition +of fourteen sets of twenty-six volumes +was issued---which surely indicates that, +when typomania is coupled with religious +fervour, anything up to a miracle may be +achieved.\citequote[p.76]{ryder} +\end{quotation} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begin{quotation}\small\begingroup +At the turn of the century William Davy, a + Devonshire parson, finding errors in the first + edition of his \titlecite{davy}, + asked for a new edition to be printed. His publisher + refused and Davy purchased a press, type, and paper. + He harnessed his gardener to the press and + apprenticed his housemaid to the typesetting. After + twelve years' work, a new edition of fourteen + sets of twenty-six volumes was issued---which surely + indicates that, when typomania is coupled with + religious fervour, anything up to a miracle may be + achieved. +\par\endgroup\smallskip\footnotesize\noindent [\citeauthortitleyear{ryder}], p.76\end{quotation} +\end{quote}\end{example} +\end{description} +\section{Footnotes and end-notes} +\label{footnotes} +\index{footnotes} +The command \command{footnote}, followed by the + text of the footnote in curly braces, will produce an + auto-numbered footnote with a raised small number where you + put the command, and the numbered text automatically printed + at the foot of the page.\footnote{Like this.} The number is reset to 1 at the start of each + chapter (but you can override that and make them run + continuously throughout the document, or even restart at 1 on + each page or section). + +\LaTeX{} automatically creates room for the footnote, and + automatically reformats it if you change your document in such + a way that the point of attachment and the footnote would move + to the next (or preceding) page. + +Because of the way \LaTeX{} reads the whole footnote before + doing anything with it, you can't use + \command{verb} (\S\thinspace\ref{inlineverb}) alone + in footnotes: either precede it with + \command{protect} or use [abuse?] the + \command{url} command instead, which you should be + using for Web and email addresses in any case). + +Footnotes inside minipages (see \S\thinspace\ref{boxes}) produce lettered notes instead of + numbered ones, and they get printed at the bottom of the + minipage, \emph{not} the bottom of the physical + page (but this too can be changed). + +There is a package to hold over your footnotes and make + them print at the end of the chapter instead + (\package{endnote}) or at the end of the whole + document, and there is a package to print many short footnotes + in several columns so they take up less space + (\package{fnpara}). It is also possible to have + several separate series of footnotes active simultaneously, + which is useful in critical editions or commentaries: a + numbered series may be used to refer to an original + author's notes; a lettered series can be used for notes + by a commentator or authority; and a third series is available + for your own notes. It is also possible to format footnotes + within footnotes. + +If your footnotes are few and far between, you may want to + use footnote symbols instead of numbers. You can do this by + redefining the output of the footnote counter to be the + \command{fnsymbol} command: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand{\thefootnote{\fnsymbol{footnote}} + \end{Verbatim} +\end{sourcecode} + +There are also ways to refer more than once to the + same footnote, and to defer the positioning of the footnote if + it occurs in a float like a Table or Figure, where it might + otherwise need to move to a different page. +\section{Marginal notes} +\label{marginals} +\index{marginal notes} +You can add marginal notes to your text\marginal{Like this.} instead of + (or as well as) footnotes. You need to make sure that you have + a wide-enough margin, of course: use the + \package{geometry} package (see \S\thinspace\ref{colorpkg}) to allocate enough space, otherwise + the notes will be too cramped. There are several packages to + help with formatting marginal notes, but the simplest way is + to define it yourself. Add this new command to your + preamble: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\marginal}[1]{% + \leavevmode\marginpar{\tiny\raggedright#1\par}} + \end{Verbatim} +\end{sourcecode} + +Then you can use \verb+\marginal{Some text}+\marginal{Some text where you need + it.} Be careful, however, because marginal + notes are aligned with the line where the command starts, so a + very long one followed too closely by another will cause + \LaTeX{} to try and + adjust the position so they don't overlap. + +We're jumping ahead a bit here, as we haven't + covered how to define your own commands yet. I won't even + try to explain it here, although the attentive reader can + probably deduce some of it by inspection. See \chaptername~\ref{macros} for more information about making up your + own commands. +\section{Cross-references} +\label{xrefs} +\index{cross-references} +This is one of the most powerful features of \LaTeX{}. You + can label any point in a document with a name you make up, and + then refer to it by that name from anywhere else in the + document, and \LaTeX{} will always work out the cross-reference + number for you, no matter how much you edit the text or move + it around. + +A similar method is used to cite documents in a + bibliography or list of references, and there are packages to + sort and format these in the correct manner for different + journals. +\subsection{Normal cross-references} +\label{normalxref} + +You label a place in your document by using the command + \command{label} followed by a short name you make + up, in curly braces:\footnote{This section is labelled + `\url+normalxref+', + for example.} we've already seen this done for labelling + Figures and Tables. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\section{New Research} +\label{newstuff} + \end{Verbatim} +\end{sourcecode} + +You can then refer to this point from anywhere in the + same document with the command \command{ref} + followed by the name you used, e.g. +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +In \S~\ref{newstuff} there is a list of recent +projects. + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent + +In \S\thinspace\ref{normalxref} + there is a list of recent projects. +\end{quote}\end{example} + +(The \command{S} command produces a section + sign (\S) and the + \command{P} command produces a paragraph sign + (\P).) + +If the label is in normal text, the reference will + provide the current chapter or section number or both + (depending on the current document + class).\footnote{Thus I can + refer here to + \url+\ref{normalxref}+ and get the + value \S\thinspace\ref{normalxref}.} If the label + was inside a Table or Figure, the reference provides the + Table number or Figure number prefixed by the chapter + number. A label in an enumerated list will provide a + reference to the item number. If there is no apparent + structure to this part of the document, the reference will + be null. Labels must be unique (that is, each value must + occur only \emph{once} as a label within a + single document), but you can have as many references to + them as you like. + +Note the use of the unbreakable space + (\verb+~+) between the \command{ref} + and the word before it. This prints a space but prevents the + line ever breaking at that point, should it fall close to + the end of a line. + +The command \command{pageref} followed by any + of your label values will provide the page number where the + label occurred, regardless of the document structure. This + makes it possible to refer to something by page number as + well as its \command{ref} number, which is useful + to readers in very long documents. + +Unresolved references are printed as three question + marks, and also cause a warning message at the end of the + log file. There's never any harm in having + \command{label}s you don't refer to, but using + \command{ref} when you don't have a matching + \command{label} is an error. +\subsection{Bibliographic references} +\label{bib} +\index{bibliographies}\index{references} +The mechanism used for references to reading lists and + bibliographies is almost identical to that used for normal + cross-references. Although it is possible to type the + details of each citation manually, there is a companion + program to \LaTeX{} called \BibTeX{}, which manages + bibliographic references automatically. This reduces the time + needed to maintain and format them, and dramatically + improves accuracy. Using \BibTeX{} means you only ever have + to type the bibliographic details of a work once. You can + then cite it in any document you write, and it will get + formatted automatically to the style you specify. +\subsubsection{Citing references} +\label{citation} + +\BibTeX{} works exactly the same way as other + bibliographic databases: you keep details of every + document you want to refer to in a separate file, using + \BibTeX{}'s own format (see example below). Many + writers make a habit of adding the details of every book + and article they read, so that when they write a document, + these entries are always available for reference. You give + each entry a short label, just like you do with normal + cross-references (see \S\thinspace\ref{normalxref}), and + it is this label you use to refer to in your own documents + when you cite the work using the \command{cite} + command: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +...as has clearly been shown by Fothergill~\cite{fg}. + \end{Verbatim} +\end{sourcecode} + +By default, this creates a cross-reference number in + square brackets [1] which is a common style in the + Natural Sciences (see \S\thinspace\ref{othercite} for + details of how to change this). There are dozens of + alternative citation formats in extra packages, including + the popular author/year format: +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +...as has clearly been shown +by~\citeauthoryear{fg}. + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent + +\dots as has clearly been shown by \citeauthoryear{fg}. +\end{quote}\end{example} + +Note that in this case you don't type the + author's name because it is automatically extracted + by \BibTeX{}. There are lots of variants on this technique + in many packages, allowing you to phrase your sentences + with references in as natural a way as possible, and rely + on \BibTeX{} to insert the right data. (If you examine the + source of this document you'll find I use some + homebrew commands like \command{authorof} and + \command{titleof} which I use for a similar + purpose.) + +To print the bibliographic listing (usually called + `References' in articles and + `Bibliography' in books and + reports), add these two lines towards the end of your + document, or wherever you want it printed, substituting + the name of your own \BibTeX{} file and the name of your + chosen bibliography style: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\bibliographystyle{ieeetr} +\bibliography{mybib} + \end{Verbatim} +\end{sourcecode} +\begin{itemize} +\item +The \command{bibliography} command is + followed by the filename of your \BibTeX{} file + \emph{without} the + \url+.bib+ extension. + +\item +The \command{bibliographystyle} command + is followed by the name of any of \LaTeX{}'s + supported bibliography styles, of which there are many + dozens available from CTAN\index{CTAN@CTAN}.\footnote{The style + shown in the example here provides formatting + according to the specifications for Transactions + of the IEEE (revised).} + +\end{itemize} + +The styles \opt{plain} and + \opt{alpha} are two common generic styles used + for drafts. The example above uses Transactions of the Institute of Electrical + and Electronics Engineers (IEEETR)\index{IEEETR@IEEETR|textbf}\index{Acronyms@\textbf{Acronyms}, defined!IEEETR@IEEETR|textbf}. +\subsubsection{Running \emph{bibtex}} +\label{bibtex} + +When you run the \product{bibtex} + program, the details of every document you have cited will + be extracted from your database, formatted according to + the style you specify, and stored in a temporary + bibliographic (\url+.bbl+) file with a + label corresponding to the one you used in your citation, + ready for \LaTeX{} to use. This is entirely automatic: all + you do is cite your references in your \LaTeX{} document + using the labels you gave the entries in your \BibTeX{} + file, and run the \product{bibtex} + program. + +After processing your file with \LaTeX{}, run \BibTeX{} + on it by clicking on the \guiicon{\BibTeX{}} + toolbar icon (\product{WinEdt}) or the + \menuitem{TeX}{BibTeX + File} menu entry + (\product{Emacs}) or by typing the + command \verb+bibtex+ followed by the name of + your document (without the \url+.tex+ + extension). When you run \LaTeX{} again it uses the + \url+.bbl+ file to add the references where + you tell it to, and a subsequent run of \LaTeX{} will + format the correct citation numbers (or author/year, or + whatever format you are using). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +$ latex mybook +$ bibtex mybook +$ latex mybook +$ latex mybook + \end{Verbatim} +\end{sourcecode} + +Because of this three-stage process, you always get a + warning message about an `unresolved + reference' the first time you add a new + reference to a previously uncited work. This will + disappear after subsequent runs of + \product{bibtex} and \LaTeX{}. + +In practice, authors tend to run \LaTeX{} from time to + time during writing anyway, so they can preview the + document. Just run \BibTeX{} after adding a new + \command{cite} command, and subsequent runs of + \LaTeX{} will incrementally incorporate all references + without you having to worry about it. You only need to + follow the full formal sequence (\LaTeX{}, \BibTeX{}, + \LaTeX{}, \LaTeX{}) when you have finished writing and want + to ensure that all references have been resolved. +\subsubsection{\BibTeX{} format} +\label{bibspec} + +The format for the \BibTeX{} file is specified in the + \BibTeX{} documentation (see \S\thinspace\ref{packagedoc} + for how to find and print it). You create a file with a + name ending in \url+.bib+, and add your + entries, for example: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +@book{fg, + title = {{An Innkeeper's Diary}}, + author = {John Fothergill}, + edition = {3rd}, + publisher = {Penguin}, + year = 1929, + address = {London} +} + \end{Verbatim} +\end{sourcecode} + +There is a prescribed set of fields for each of a + dozen or so types of document: book, article (in a + journal), article (in a collection), chapter (in a book), + thesis, report, paper (in a Proceedings), etc. Each entry + identifies the document type after the + `\verb+@+' sign, + followed by the entry label that you make up, and then + each field (in any order), using the format: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +keyword = {value}, + \end{Verbatim} +\end{sourcecode} + +Most \TeX{}-sensitive editors have a \BibTeX{} mode + which understands these entries. + \product{Emacs} automatically uses its + \url+bibtex-mode+ whenever you open a + filename ending in \url+.bib+. When editing + \BibTeX{} databases, the rules are simple: +\begin{itemize} +\item +Omit the comma after the last field in the entry + (only\mdash{}eg after \verb+{London}+ in + the example). + +\item +Titles may have their case changed in some styles: + to prevent this, enclose the title in double curly + braces as in the example. + +\item +Values which are purely numeric (e.g. years) + may omit the curly braces. + +\item +Fields can occur in any order but the format must + otherwise be strictly observed. + +\item +Fields which are not used do not have to be + included (so if your editor automatically inserts them + as blank or prefixed by \verb+OPT+ + [optional], you can safely delete them as unused + lines). + +\end{itemize} + +To help with this, there are several interfaces to + creating and maintaining \BibTeX{} files, such as + \product{tkbibtex} (see Figure~\ref{tkbibtex}), or + \product{pybliographic}. +\begin{figure}\small +\caption{\small tk\BibTeX{}, one of several graphical interfaces to + \BibTeX{} databases} +\label{tkbibtex} +\begin{center} +\includegraphics[width=0.75\textwidth]{tkbibtex} +\end{center} +\end{figure} +\subsubsection{Changing the layout} +\label{bibstyle} + +To change the title printed over the reference + listing, just change the value of + \command{refname} (articles) or + \command{bibname} (books and reports) by adding a + line like this in your preamble: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand{\bibname}{Reading List} + \end{Verbatim} +\end{sourcecode} + +The formatting specifications (\BibTeX{} styles) are + based on standard settings for journals and books from + dozens of publishers: you just pick the one you want by + name. The \url+texmf/bib/bst+ subdirectory + of your installation contains the ones installed by + default, and you can search on CTAN\index{CTAN@CTAN} + for others (look for \url+.bst+ files). + Many of them are named after university press styles + (e.g. \product{harvard}, + \product{oxford}) or the publisher or + journal which specified them (e.g. + \product{elsevier}, + \product{kluwer}, etc.). + +Some of them have an accompanying package + (\url+.sty+) file which + you need to include with the normal + \command{usepackage} command in your preamble. In + this case the format may be distributed as + \url+.dtx+ and \url+.ins+ + files and will need installing in the same way as any + other package (see \S\thinspace\ref{pkginst}). Always read + the documentation, because most of the formats are very + specific to the journal they were designed for, and may have + fairly absolute requirements. +\begin{warning} + +If you are writing for a specific publisher, you + should remember that the rules or formats are laid down + by the typographic designer of that journal or + publisher: you cannot arbitrarily change the format just + because you don't happen to like it: it's not + your choice! +\end{warning} + +It is also possible to write your own \BibTeX{} + (\url+.bst+) style files, although it uses + a language of its own which really needs a computer + science background to understand. However, this is + rendered unnecessary in most cases: there is an extensive + program (actually written in \LaTeX{}) called + \product{makebst}, which makes + \url+.bst+ files by asking you a (long) + series of questions about exactly how you want your + citations formatted. Just type + \verb+latex makebst+ in a command window, but + give it a dummy run first, because some of the questions + are very detailed, so you need to have thought through how + you want your citations to appear before you start. +\subsubsection{Other modes of citation} +\label{othercite} + +The method of citing a work by numeric reference is + common in the Natural Sciences but is not used in Law or + the Humanities. In these fields, citations are usually + done with short references (author/short-title/year) in a + numbered footnote. Sometimes they are actually called + `footnotes' to the exclusion of + ordinary footnotes, although they are really citations + which happen by convention to be + \emph{displayed} as footnotes: an important + distinction rarely appreciated by authors until they come + to need a normal footnote. + +For these fields, the bibliography at the back of the + document is printed \emph{unnumbered} in + alphabetic order of author, or perhaps chronologically if + the time-frame is very large. This unnumbered format is + why it is conventionally called + `References' rather than + `Bibliography': a sufficient working + citation has already been provided in the footnote, and + the list at the back is for reference purposes only; + whereas in the Natural Sciences, the citation is just a + number, or possibly an author and year only, so the full + listing is called a Bibliography. + +The \package{jurabib} package + (originally intended for German law articles but now + extended to other fields in the Humanities, and to other + languages) has extensive features for doing this style of + citation and is strongly recommended. +\section{Indexes and glossaries} +\label{indexes} +\index{indexes}\index{glossaries} +\LaTeX{} has a powerful, automated indexing facility which + uses the standard \product{makeindex} + program. To use indexing, use the package + \package{makeidx} and include the + \command{makeindex} command in your preamble: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage{makeidx} +\makeindex + \end{Verbatim} +\end{sourcecode} + +When you want to index something, using the command + \command{index} followed by the entry in curly + braces, as you want it to appear in the index, using one of + the following formats: +\begin{description} +\item[\sffamily Plain entry] +Typing \verb+\index{beer}+ will create + an entry for `beer' with the + current page + number.\index{beer} +\item[\sffamily Subindex entry] +For an entry with a subentry use an exclamation mark + to separate them: + \verb+\index{beer!lite}+.\index{beer!lite} Subsubentries like + \verb+\index{beer!lite!American}+ work to + another level deep.\index{beer!lite!American} +\item[\sffamily Cross-references] +`See' entries are done with + the vertical bar (one of the rare times it does + \emph{not} get interpreted as a math + character): + \verb+\index{Microbrew|see{beer}}+\index{Microbrew|see{beer}} +\item[\sffamily Font changes]\label{indextypo} +To change the style of an entry, use the @-sign + followed by a font change command: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +\index{beer!Rogue!Chocolate + Stout@\textit{Chocolate Stout}} + \end{Verbatim} +\end{sourcecode} + +\noindent This example\index{Chocolate Stout@\textit{Chocolate Stout}} indexes `\product{Chocolate + Stout}' and italicises it + at the same time. Any of the standard + \verb+\text...+ font-change commands work + here: see the table on p.\thinspace\pageref{fontcmds} for details. + +You can also change the font of the index number on + its own, as for first-usage references, by using the + vertical bar in a similar way to the + `see' entries above, but + substituting a font-change command name + (\emph{without} a backslash) such as + \verb+textbf+ for bold-face text (see the + index)\index{Chocolate Stout|textbf}: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +\index{beer!Rogue!Chocolate Stout|textbf} + \end{Verbatim} +\end{sourcecode} +\item[\sffamily Out of sequence] +The same method can be used as for font changes, + but using the alternate index word instead of the font + command name, so + \verb+\index{Oregon Brewing Company@Rogue}+\index{Oregon Brewing Company@Rogue} will add an entry for + `Rogue' in the + `O' section of the index, as if + it was spelled `Oregon Brewing + Company'. +\end{description} + +When the document has been processed through \LaTeX{} it + will have created a \url+.idx+ file, which you + run through the \product{makeindex} program + by typing (for example): +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +makeindex mythesis + \end{Verbatim} +\end{sourcecode} + +Some editors may have a button or menu entry for this. The + program will look for the \url+.idx+ file and + output a \url+.ind+ file. This gets used by the + command \command{printindex} which you put at the end + of your document, where you want the index printed. The + default index format is two columns. + +Glossaries are done in a similar manner using the command + \command{makeglossary} in the preamble and the + command \command{glossary} in the same way as + \command{index}. There are some subtle differences in + the way glossaries are handled: both the books by \citeauthoryear{latexbook} and by \citeauthoryear{companion} duck the issue, but + there is some documentation on \url+glotex+ on + CTAN\index{CTAN@CTAN}. +\section{Multiple columns} +\label{multicols} +\index{columns} +Use the \package{multicol} package: the + environment is called \env{multicols} (note the + plural form) and it takes the number of columns as a separate + argument in curly braces: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage{multicol} +... +\begin{multicols}{3} +... +\end{multicols} + \end{Verbatim} +\end{sourcecode} +\begin{multicols}{3} +\setlength{\parskip}{0pt}\footnotesize\noindent +\LaTeX{} has built-in support for two-column typesetting + via the \verb+twocolumn+ option in the standard + Document Class Declarations, but it is relatively inflexible + in that you cannot change from full-width to double-column + and back again on the same page, and the final page does not + balance the column heights. However, it does feature special + \env{figure*} and \env{table*} + environments which typeset full-width figures and tables + across a double-column setting. + +The more extensive solution is the + \package{multicol} package, which will set up + to 10 columns, and allows the number of columns to be + changed or reset to one in mid-page, so that full-width + graphics can still be used. It also balances the height of + the final page so that all columns are the same + height\mdash{}if possible: it's not always + achievable\mdash{}and you can control the width of the gutter + by setting the \command{columnsep} length to a new + dimension. + +Multi-column work needs some skill in typographic + layout, though: the narrowness of the columns makes + typesetting less likely to fit smoothly because it's hard to + hyphenate and justify well when there is little space to + man\oe uvre in. +\end{multicols} +\chapter{Fonts and layouts} +\label{typo} +\index{typographics} +This is the chapter that most users want first, because they + come to structured documents from a wordprocessing environment + where the \emph{only} way to convey different + types of information is to fiddle with the font and size + drop-down menus. + +As I hope you have seen, this is normally completely + unnecessary in \LaTeX{}, which does most of the hard work for you + automatically. However, there are occasions when you need to + make manual typographic changes, and this chapter is about how + to do them. +\section{Changing layout} +\label{layouts} + +The design of the page can be a very subjective matter, + and also rather a subtle one. Many organisations large and + small pay considerable sums to designers to come up with page + layouts to suit their purposes. Styles in page layouts change + with the years, as do fashions in everything else, so what may + have looked attractive in 1991 may look rather dated in + 2011. + +As with most aspects of typography, making the document + readable involves making it consistent, so the reader is not + interrupted or distracted too much by apparently random + changes in margins, widths, or placement of objects. However, + there are a number of different occasions where the layout + usually \emph{does} change, related to the + frequency with which the format appears. +\begin{itemize} +\item +The title page, the half-title, copyright page, + dedication, and other one-page preliminaries (if you use + them) are usually designed individually, as the information + on it only occurs once in that format anywhere in the + document. + +\item +The table of contents and other related lists like + figures and tables all need to share one + design. + +\item +The prelims like Foreword, Introduction, and Preface + should likewise follow the same format between + them. + +\item +Chapter and Appendix start pages usually share a + layout. + +\item +Other (normal) pages have a single layout, but it may + specify individual variations to handle tables, lists, + figures, sidebars, exercises, footnotes, etc. + +\end{itemize} + +If you are going to design a whole document, it's + probably a good idea to read a couple of books on layout + design first, to get a feel for the conventions which + contribute to making the reader comfortable reading. + +While unusual or radical layouts have an important role in + attention-grabbing, or in making a socio-political statement + (\titlecite{wired} magazine is an obvious + recent example), they are usually out of place in business + reports, white papers, books, theses, and journals. In + ephemera, on the other hand, as in advertising, they are + probably critical. +\subsection{Spacing} +\label{spacing} +\index{page size!margins}\index{margins} +We mentioned in \S\thinspace\ref{marginals} and + elsewhere the existence of the + \package{geometry} package which lets you + change margins. It also lets you set the text-area height + and width and a lot of other layout settings: read the + documentation for details (see \S\thinspace\ref{packagedoc} for how to read package + documentation). +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage[left=2cm,top=1cm,bottom=2cm,right=3cm, + nohead,nofoot]{geometry} + \end{Verbatim} +\end{sourcecode} + +The spacing around the individual textual components + (headings, paragraphs, lists, footnotes, etc.) can + also be changed on a document-wide basis, as we saw with + paragraph spacing and indentation in \S\thinspace\ref{paraspace}. + +Changing the spacing of section headings for the whole + document can be done with the + \package{sectsty} package, designed to let + you adjust section-head spacing without having to know about + the internal \LaTeX{} coding, which is quite complex. + +The spacing for lists can be adjusted with the + \package{mdwlist} package. In both cases the + user with highly specific requirements such as a + publisher's Compositor's Specification should read + the relevant sections in the \titlecite{companion} or ask for expert help, as + there are many internal settings which can also be changed + to fine-tune your design, but which need some knowledge of + \LaTeX{}'s internals. + +All the above are for automating changes so that they + occur every time in a consistent manner. You can also make + manual changes whenever you need: +\index{space|see{white-space}}\begin{description} +\item[\sffamily Flexible vertical space]\index{white-space!vertical!flexible} +There are three commands + \command{smallskip}, + \command{medskip}, and + \command{bigskip}. These output flexible + (dynamic, or `rubber') space, + approximately 3pt, 6pt, and 12pt high respectively, + and they will automatically compress or expand a + little, depending on the demands of the rest of the + page (for example to allow one extra line to fit, or a + heading to be moved to the next page without anyone + except a typographer noticing the change). These + commands can only be used after a paragraph break (a + blank line or the command + \command{par}). +\item[\sffamily Fixed vertical space]\index{white-space!vertical!fixed}\index{white-space!vertical!disappearing} +For a fixed-height space which will + \emph{not} stretch or shrink, use the + command \command{vspace} followed by a length + in curly braces, e.g. \verb+\vspace{18pt}+ + (again, this has to be after a paragraph break). Bear + in mind that extra space which ends up at a page-break + when the document is formatted \emph{will get + discarded entirely} to make the bottom and + top lines fall in the correct places. To force a + vertical space to remain and be taken into account + even after a page break (very rare), use the starred + variant \command{vspace*}, e.g. + \verb+\vspace*{19pt}+. +\item[\sffamily Double spacing]\index{white-space!double-spacing}\index{double-spacing} +Double-spacing normal lines of text is usually a + bad idea, as it looks very ugly. It is still + unfortunately a requirement in some universities for + thesis submission, a historical relic from the days of + typewriters. Nowadays, 1\Frac13 or 1½ line + spacing is considered acceptable, according to your + font size. If your institution still thinks they + should have double line spacing, they are probably + wrong, and just don't understand that the world has + moved on since the typewriter. Show them this + paragraph and explain that they need to enter the 21st + century and adapt to the features of computer + typesetting. If they still insist, use the + \package{setspace} package,which has + commands for double line-spacing and one-and-a-half + line spacing, but be prepared for some very ugly + output (so warn your supervisor and extern). + +The space between lines is defined by the value of + the length variable \length{baselineskip} multiplied + by the value of the \command{baselinestretch} + command. In general, \emph{don't meddle with + \length{baselineskip} at + all}, and with + \command{baselinestretch} only if you know + what you are doing. (Both can, however, safely be used + as reference values in commands like + \verb+\vspace{\baselineskip}+ to leave a + whole line space.) +\index{spacing|see{white-space}} +The value of \length{baselineskip} changes with + the font size (see \S\thinspace\ref{fontsize}) but is conventionally set to + 1.2 times the current nominal font size. This is a + value derived from long experience: only change it if + you understand what it means and what effect it will + have. + +Quite separately, there are some perfectly genuine + and normal reasons for wanting wide line spacing, + \index{spacing|see{double-spacing}} for example when typesetting a proof of a + critical or variorum edition, where editors and + contributors are going to want to add notes manually + by writing between the lines, or where the text is + going to be overprinted by something else like + Braille, or in advertising or display text for special + effects. +\item[\sffamily Horizontal space]\index{white-space!horizontal} +There is a horizontal equivalent to the + \command{vspace} command: + \command{hspace}, which works in the same + way, so I can force a 1$''$ space like + this\hspace*{1in}in + mid-paragraph. There are also some predefined + (shorter) spaces available: +\begin{itemize} +\item +\command{thinspace} (\Frac1{12}em), + which we saw between single and double quotes in + the last paragraph of \S\thinspace\ref{thinspace}. It's also + sometimes used between the full point after + abbreviations and a following number, as in page + references like p.\thinspace{}199, where a word space + would look too big, and setting it solid would + look too tight. + +\item +\command{enspace} (½em). + There is no direct equivalent predefined in + \LaTeX{} for mid and thick spaces as used by metal + typesetters, although it would be possible to + define them. The en as a unit is often used as the + width of a single digit in some fonts, as a + convenience so that tables of figures are easy to + line up. + +\item +\command{quad} (1em). + +\item +\command{qquad} (2em). + +\end{itemize} + +Beyond this, all horizontal space within + paragraphs is automatically flexible, + \index{tracking|see{letterspacing}}\index{letterspacing} as this is what + \LaTeX{} uses to achieve justification. Never be + tempted to try and change the spacing between letters + unless you have some professional training in + typography. Some systems use letterspacing + (incorrectly called `tracking') as an aid + to justification and it is almost always wrong to do + so (and looks it). While it \emph{is} + possible to change letterspacing (with the + \package{soul} package), it should only + be done by a typographer, and then only very rarely, + as the settings are very subtle and beyond the scope + of this book. +\end{description} +\subsection{Headers and footers} +\label{runningheads} + +\LaTeX{} has built-in settings to control the page style + of its default page layouts. These are implemented with the + \command{pagestyle} command, which can take one of + the following arguments. +\begin{description} +\item[\sffamily \opt{plain}] +for a page number centered at the bottom; +\item[\sffamily \opt{empty}] +for nothing at all, not even a page number; +\item[\sffamily \opt{headings}] +for running heads based on the current chapter and + section; +\item[\sffamily \opt{myheadings}] +which lets you use your own reprogrammed + definitions of how \command{markright} and + \command{markboth} commands, which control + how chapter and section titles get into page + headers. +\end{description} + +The command \command{thispagestyle} (taking the + same arguments) can be used to force a specific style for + the current page only. + +However, the easiest way is to use the + \package{fancyhdr} package, which lets you + redefine the left-hand, centre, and right-hand page headers + and footers for both odd and even pages (twelve objects in + all). These areas can contain a page number, fixed text, + variable text (like the current chapter or section title, or + the catch-words of a dictionary), or even a small image. + They can also be used to do page backgrounds and frames, by + making one of them the top corner of an invisible box which + `hangs' text or images down over the whole + page. + +The settings for the downloadable version of this + document can be used as an example: for the whole story you + have to read the documentation. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\pagestyle{fancy}\fancyhead{} +\renewcommand\headrulewidth{.1pt} +\fancyhead[LO,RE]{\footnotesize\sffamily\lite\leftmark} +\fancyhead[LE,RO]{\footnotesize\sffamily\lite\itshape + \rightmark} +\fancyfoot[C]{} +\fancyfoot[LE,RO]{\setlength{\fboxsep}{2pt}\ovalbox% + {\footnotesize\sffamily\thepage}} +\fancyfoot[LO,RE]{\footnotesize\sffamily\lite\@title} +\fancypagestyle{plain}{\fancyhf{} + \fancyfoot[R]{\setlength{\fboxsep}{2pt}\ovalbox{% + \footnotesize\sffamily\thepage}} + \fancyfoot[L]{\footnotesize\sffamily\lite\@title} + \renewcommand{\headrulewidth}{0pt}} + \end{Verbatim} +\end{sourcecode} + +This is probably more complex than most documents, but + it illustrates some common requirements: +\begin{enumerate}\item +Settings are prefixed by making the + \command{pagestyle} `fancy' + and setting the \command{fancyhead} to + null to zap any predefined values. + +\item +The thickness of the rule at the top of the page can + be changed (or set to 0pt to make it disappear). + +\item +The header and footer settings are specified with L, + C, and R for left, centre, and right; and with O and E + for Odd and Even numbered pages. In each setting, the + typeface style, size, and font can be specified along + with macros which implement various dynamic texts (here, + the current chapter and section titles, which \LaTeX{} + stores in \command{rightmark} and + \command{leftmark}). + +\item +The `plain' variant is used for chapter + starts, and resets some of the parameters + accordingly. + +\end{enumerate} +\section{Using fonts} +\label{fontuse} +\index{fonts!in general} +The default typeface in \LaTeX{} is Computer Modern (CM)\index{CM@CM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CM@CM|textbf}. This typeface was + designed by Knuth for use with \TeX{} because it is a book + face, and he designed \TeX{} originally for typesetting books. + Because it is one of the very few book typefaces with a + comprehensive set of fonts, including a full suite of + mathematics, it has remained the default, rather than the + Times you find in wordprocessors, because until recently the + mathematical symbols for Times were a commercial product often + unavailable to users of free software. + +\index{fonts!\mf{}}\index{fonts!Computer Modern}{\fontencoding{OT1}\fontfamily{cmr}\fontsize{12pt}{12pt}\selectfont{}Computer Modern is based on + a 19th-century book typeface from Monotype, which is why it + looks a little like an old-fashioned school book. This + paragraph is set in Computer Modern so you can see what it + looks like. The typeface was designed using \mf{}, the + font-drawing program made by Knuth to accompany \TeX{} + systems, but it is now also available in Type 1 and + TrueType formats.} +\begin{warning} + +If you are reading this in a web browser, the above + paragraph is only a low-resolution copy because browsers + don't usually have the Computer Modern font available. + All the rest of this document is set in \rmfontfamilyname{}, with + \sffontfamilyname{} for some of the headings and \ttfontfamilyname{} for the + fixed-width type. +\end{warning} + +In addition to CM\index{CM@CM}, there are + many other \mf{} fonts which can be downloaded from + CTAN\index{CTAN@CTAN}, including a large collection + of historical, symbol, initial, and non-Latin fonts. \LaTeX{} + also comes with the `Adobe 35' + typefaces which are built into laser printers and other + DTP\index{DTP@DTP} systems, and some more fonts + donated by the X Consortium. Plus, of course, standard + \LaTeX{} can use any of the thousands of + Type 1 fonts available, and + \product{pdf\LaTeX{}} can use any of the + thousands of TrueType fonts as well. + +In the following lists, if there is a package available, + its name is given in parentheses after the name of the + typeface. The font-family name is shown on the right-hand + side. If a non-standard font-encoding is needed, its name is + shown before the font-family name. +\index{fonts!TrueType}\index{fonts!metafont@\mf{}}\index{fonts!PostScript}\index{fonts!Type 1}\begingroup\small \subsubsection*{Latin-alphabet typefaces (\mf{})}\label{fontable-mf}\addcontentsline{lot}{subsubsection}{Latin-alphabet typefaces (\mf{})}\par\smallskip\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Computer Modern Roman\hfill\texttt{cmr}}\\{\fontencoding{OT1}\fontfamily{cmr}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Computer Modern Sans\hfill\texttt{cmss}}\\{\fontencoding{OT1}\fontfamily{cmss}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Computer Modern Typewriter\hfill\texttt{cmtt}}\\{\fontencoding{OT1}\fontfamily{cmtt}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Pandora\quad{\fontseries{m}\selectfont(\package{pandora})}\hfill\texttt{panr}}\\{\fontencoding{OT1}\fontfamily{panr}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Pandora Sans\hfill\texttt{pss}}\\{\fontencoding{OT1}\fontfamily{pss}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Pandora Typewriter\hfill\texttt{pntt}}\\{\fontencoding{OT1}\fontfamily{pntt}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Universal\hfill\texttt{uni}}\\{\fontencoding{OT1}\fontfamily{uni}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Concrete\quad{\fontseries{m}\selectfont(\package{ccr})}\hfill\texttt{ccr}}\\{\fontencoding{OT1}\fontfamily{ccr}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut É{\fontfamily{cmr}\selectfont\i}reannach\quad{\fontseries{m}\selectfont(\package{eiad})}\hfill\texttt{eiad}}\\{\fontencoding{OT1}\fontfamily{eiad}\selectfont +N{\fontfamily{cmr}\selectfont\'\i}l aon tinteán mar do thinteán f\'ein}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Rustic\hfill\texttt{rust}}\\{\fontencoding{OT1}\fontfamily{rust}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Uncial\hfill\texttt{uncl}}\\{\fontencoding{OT1}\fontfamily{uncl}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Dürer\hfill\texttt{zdu}}\\{\fontencoding{OT1}\fontfamily{zdu}\selectfont +THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Fraktur\hfill\texttt{U\enspace yfrak}}\\{\fontencoding{U}\fontfamily{yfrak}\selectfont +Fuch\char'215 , Du hast die Gan\char'215 gestohlen, gib sie wieder her!}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Gothic\hfill\texttt{U\enspace ygoth}}\\{\fontencoding{U}\fontfamily{ygoth}\selectfont +Fuch\char'215 , Du hast die Gan\char'215 gestohlen, gib sie wieder her!}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Schwäbische\hfill\texttt{U\enspace yswab}}\\{\fontencoding{U}\fontfamily{yswab}\selectfont +Fuch\char'215 , Du hast die Gan\char'215 gestohlen, gib sie wieder her!}\strut +\hrule height.2pt \endgroup\begingroup\small \subsubsection*{Latin-alphabet typefaces (PostScript Type 1) from + Adobe}\label{fontable-adobe}\addcontentsline{lot}{subsubsection}{Latin-alphabet typefaces (PostScript Type 1) from + Adobe}\par\smallskip\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Avant Garde\quad{\fontseries{m}\selectfont(\package{avant})}\hfill\texttt{pag}}\\{\fontencoding{OT1}\fontfamily{pag}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Bookman\footnote{Uses Avant Garde as the sans-serif and Courier for + monospace.}\quad{\fontseries{m}\selectfont(\package{bookman})}\hfill\texttt{pbk}}\\{\fontencoding{OT1}\fontfamily{pbk}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Courier\quad{\fontseries{m}\selectfont(\package{courier})}\hfill\texttt{pcr}}\\{\fontencoding{OT1}\fontfamily{pcr}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Helvetica\quad{\fontseries{m}\selectfont(\package{helvet})}\hfill\texttt{phv}}\\{\fontencoding{OT1}\fontfamily{phv}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut New Century Schoolbook\footnote{Uses Helvetica as the sans-serif font and Courier + for monospace.}\quad{\fontseries{m}\selectfont(\package{newcent})}\hfill\texttt{pnc}}\\{\fontencoding{OT1}\fontfamily{pnc}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Palatino\footnote{Uses Avant Garde as the sans-serif and Courier for + monospace.}\quad{\fontseries{m}\selectfont(\package{palatino})}\hfill\texttt{ppl}}\\{\fontencoding{OT1}\fontfamily{ppl}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Symbol\hfill\texttt{U\enspace psy}}\\{\fontencoding{U}\fontfamily{psy}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Times New Roman\footnote{Uses Helvetica as the sans-serif font and Courier + for monospace. Mathematical symbols for Times are + available both free and commercially.}\quad{\fontseries{m}\selectfont(\package{times})}\hfill\texttt{ptm}}\\{\fontencoding{OT1}\fontfamily{ptm}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Zapf Chancery\quad{\fontseries{m}\selectfont(\package{zapfchan})}\hfill\texttt{pzc}}\\{\fontencoding{OT1}\fontfamily{pzc}\selectfont\itshape +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Zapf Dingbats\quad{\fontseries{m}\selectfont(\package{pifont})}\hfill\texttt{U\enspace pzd}}\\{\fontencoding{U}\fontfamily{pzd}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt \endgroup\par\medskip +As mentioned in \S\thinspace\ref{print}, the + `Adobe 35' fonts can be used with any + printer, not just a laser printer or typesetter. The + \product{Ghostscript} interpreter and the + \product{GSview} viewer come with a large set + of printer drivers, so you just create PostScript output and + print from \product{GSview}. + +Incidentally, the 35 refers to the total number of fonts + for the 10 typefaces, including their bold, italic, and + bold-italic variants. + +Postscript Type 1 fonts have been the mainstay of the + graphic arts industries for many years, as they allow much + better definition of variance + (`hinting') than most other formats. + However, the font format remains proprietary to Adobe, even + though they have released it for public use, which means they + could change it without warning. A new format called + `OpenType' is designed to overcome + this, and some versions of \TeX{} are + already able to use OpenType fonts. +\begingroup\small \subsubsection*{Latin-alphabet fonts (PostScript Type 1) from the X + Consortium}\label{fontable-x}\addcontentsline{lot}{subsubsection}{Latin-alphabet fonts (PostScript Type 1) from the X + Consortium}\par\smallskip\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Charter\quad{\fontseries{m}\selectfont(\package{charter})}\hfill\texttt{bch}}\\{\fontencoding{OT1}\fontfamily{bch}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Nimbus Roman\hfill\texttt{unm}}\\{\fontencoding{OT1}\fontfamily{unm}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Nimbus Sans\hfill\texttt{unms}}\\{\fontencoding{OT1}\fontfamily{unms}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut URW Antiqua\hfill\texttt{uaq}}\\{\fontencoding{OT1}\fontfamily{uaq}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut URW Grotesk\hfill\texttt{ugq}}\\{\fontencoding{OT1}\fontfamily{ugq}\selectfont\bfseries +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Utopia\footnote{Removed from recent distributions as it is not + free.}\quad{\fontseries{m}\selectfont(\package{utopia})}\hfill\texttt{put}}\\{\fontencoding{OT1}\fontfamily{put}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt \endgroup\par\medskip \begingroup\small \subsubsection*{Non-Latin-alphabet typefaces (\mf{})}\label{fontable-nonlat}\addcontentsline{lot}{subsubsection}{Non-Latin-alphabet typefaces (\mf{})}\par\smallskip\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut BB Dingbats\hfill\texttt{U\enspace ding}}\\{\fontencoding{U}\fontfamily{ding}\selectfont +\fontsize{9}{0}\selectfont The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Cypriot\hfill\texttt{cypr}}\\{\fontencoding{OT1}\fontfamily{cypr}\selectfont +\fontsize{8}{0}\selectfont The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Etruscan\hfill\texttt{etr}}\\{\fontencoding{OT1}\fontfamily{etr}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Linear `B'\hfill\texttt{linb}}\\{\fontencoding{OT1}\fontfamily{linb}\selectfont +\fontsize{9}{0}\selectfont The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Phoenician\hfill\texttt{phnc}}\\{\fontencoding{OT1}\fontfamily{phnc}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Runic\hfill\texttt{fut}}\\{\fontencoding{OT1}\fontfamily{fut}\selectfont +THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG}\strut +\hrule height.2pt\par\noindent{\sffamily\scriptsize\lite\emstrut Bard\hfill\texttt{U\enspace zba}}\\{\fontencoding{U}\fontfamily{zba}\selectfont +The quick brown fox jumps over the lazy dog}\strut +\hrule height.2pt \endgroup\begin{warning} + +Just to make it clear: standard \LaTeX{} uses only + \mf{} and PostScript\index{PostScript} Type 1 + fonts. \product{pdf\LaTeX{}} can use TrueType + fonts as well. +\end{warning} +\subsection{Changing the default font family} +\index{fonts!changing the default} +\LaTeX{} expects to work with three font families as + defaults: +\index{fonts!families}\begingroup\small \begin{center} +\begin{tabular}{l>{\ttfamily}l} +\textbf{\sffamily\upshape Font family}&\textbf{\sffamily\upshape Code}\\[2pt]\hline\\[-1.5\baselineskip] +Roman (serif, with tails on the uprights), the + default&rm\\ +\sffamily{}Sans-serif, with no tails on + the uprights&sf\\ +\ttfamily{}Monospace (fixed-width or + typewriter)&tt\\ +\end{tabular} +\end{center} +\endgroup +The start-up default for \LaTeX{} equates the + \verb+rm+ default with the + {\slshape\verb`cmr`} font-family (Computer Modern Roman), + \verb+sf+ with {\slshape\verb`cmss`}, and + \verb+tt+ with {\slshape\verb`cmtt`}. If you + use one of the packages listed in the tables on pp.\thinspace\pageref{fontable-mf}--\pageref{fontable-nonlat}, it will + replace the defaults of the same type: for example, + \verb+\usepackage{bookman}+ makes the default + \verb+rm+ font-family Bookman + ({\slshape\verb`pbk`}), but leaves the sans-serif + (\verb+sf+) and monospace + (\verb+tt+) families untouched. Equally, + \verb+\usepackage{helvet}+ changes the default + sans-serif family to Helvetica but leaves the serif (Roman) + and monospace families untouched. Using both commands will + change both defaults because they operate + independently. + +\emph{However}\dots as it is common to + want to change all three defaults at the same time, some of + the most common `suites' of typefaces + are provided as packages: +\begin{description} +\item[\sffamily \package{times}] +changes to Times/Helvetica/Courier. +\item[\sffamily \package{pslatex}] +same as \package{times} but uses a + specially narrowed Courier to save space (normal + Courier is rather inelegantly wide). This is the + preferred setting if you want Times.\footnote{The \package{pslatex} package + is also said to be outdated by some experts + because it implements rather long-windedly what + can now be done in three commands. However, until + these replace the current version, I recommend + continuing to use \package{pslatex} + when you want Times with Helvetica and narrow + Courier.} +\item[\sffamily \package{newcent}] +changes to New Century + Schoolbook/Helvetica/Courier. +\item[\sffamily \package{palatino}] +changes to Palatino/Avant Garde/Courier. +\item[\sffamily \package{palatcm}] +changes the roman to Palatino only, but with + CM\index{CM@CM} mathematics +\end{description} + +Where no package name is given in the tables on pp.\thinspace\pageref{fontable-mf}--\pageref{fontable-nonlat}, it means the + font is rarely used as a default by itself except in special + cases like users' own homebrew packages. To use such a + font you have to specify it manually, or make a little macro + for yourself if you use it more than once. +\subsection{Changing the font-family temporarily} +\label{fontfam} +\index{fonts!changing temporarily} +To shift to another font family on a temporary basis, + use the commands \command{fontencoding} (if + needed), \command{fontfamily}, and + \command{selectfont}, and \emph{enclose the + commands \textbf{and} the text in curly + braces}. Note that this is a + \emph{different} way of using curly braces to + how we have used them before: it limits the effect of a + change to the material inside the braces. +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +{\fontfamily{phv}\selectfont +Helvetica looks like this}: +{\fontencoding{OT1}\fontfamily{bch}\selectfont +Charter looks like this}. + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent + +{\fontfamily{phv}\selectfont{}Helvetica + looks like this}: {\fontencoding{OT1}\fontfamily{bch}\selectfont{}Charter looks like + this}. +\end{quote}\end{example} + +In this example, the \command{fontencoding} + command has been used to ensure that the typeface will work + even if the sentence is used in the middle of something + typeset in a different encoding (like this + document).\footnote{Test for the observant reader: in what typeface will + the colon (:) in the example be set?} +\begin{sidebar}\label{grouping} +\subsection*{Grouping}\index{grouping} +Note carefully this use of curly braces to restrict + the scope of a change rather than delimit the argument to + a command. This is called + `grouping' and it makes the effect + any changes made \emph{inside} the braces + local, so that they do not interfere with the text + following. Any changes to fonts or other values made + within the curly braces cease when the closing curly brace + is processed. +\end{sidebar} +In a normal document, of course, random typeface changes + like this are rather rare. You select your typeface[s] once + at the start of the document, and stick with them. + +Most cases where people want to do unusual typeface + changes involve things like special symbols on a repetitive + basis, and \LaTeX{} provides much easier programmable ways + to make these changes into shorthand commands (called + macros: see \chaptername~\ref{macros}). You could, for + example, make a macro called \command{product} + which would let you typeset product names in a distinct + typeface: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +Andlinger, Inc., has replaced \product{Splosh} with +\product{SuperSplosh}. + \end{Verbatim} +\end{sourcecode} + +This is one of \LaTeX{}'s most powerful features. + It means that if you needed to change your + \command{product} command at some later stage to + use a different font, you only have to change three + characters in the macro (the font-family name), and + you don't need to edit your document text at all! + What's more, a macro could do other things at the same time, + like add an entry to an index of products. + +However, vastly more common are changes to type + \emph{style}, while staying with the same + font-family. +\subsection{Changing font style} +\index{fonts!styles} +Within each typeface or font family there are usually + several different `looks' to the type + design. \LaTeX{} distinguishes between font \textbf{\textit{family}}\label{family}\index{family@\textbf{\textit{family}}}, font \textbf{\textit{shape}}\label{shape}\index{shape@\textbf{\textit{shape}}}, and font \textbf{\textit{series}}\label{series}\index{series@\textbf{\textit{series}}}: +\begingroup\small \begin{center} +\begin{tabular}{@{}l>{\ttfamily}ll@{}} +\textbf{\sffamily\upshape Type style}&\textbf{\sffamily\upshape Command}&\textbf{\sffamily\upshape Example (using Computer Modern)}\\[2pt]\hline\\[-1.5\baselineskip] +Upright&\command{upshape}*&{\fontencoding{OT1}\fontfamily{cmr}\selectfont{}The quick brown fox jumps over the + lazy d}\\ +Italic&\command{itshape}&{\fontencoding{OT1}\fontfamily{cmr}\fontshape{it}\selectfont{}\font\foo=cmti10 + \foo The quick brown fox jumps over the lazy + dog}\\ +Slanted&\command{slshape}*&{\fontencoding{OT1}\fontfamily{cmr}\fontshape{sl}\selectfont{}The quick brown fox + jumps over the lazy d}\\ +Small Capitals&\command{scshape}*&{\fontencoding{OT1}\fontfamily{cmr}\fontshape{sc}\selectfont{}The quick brown fox + jumps over the}\\ +Bold&\command{bfseries}*&{\fontencoding{OT1}\fontfamily{cmr}\fontseries{b}\selectfont{}The quick brown fox + jumps over the lazy d}\\ +Bold Extended&\command{bfseries}\dag &{\fontencoding{OT1}\fontfamily{cmr}\fontseries{bx}\selectfont{}\font\foo=cmbx10 + \foo The quick brown fox jumps over the + lazy}\\ +Sans-serif&\command{sffamily}&{\fontencoding{OT1}\fontfamily{cmss}\selectfont{}The quick brown fox jumps over the + lazy dog}\\ +Monospace&\command{ttfamily}&{\fontencoding{OT1}\fontfamily{cmtt}\selectfont{}The quick brown fox jumps over the + laz}\\ +\end{tabular} +\par\smallskip\footnotesize +\begin{itemize*} +\item [\sffamily *] Not all typefaces have all + variants! Some only have bold and italics. +\item [\sffamily \dag ] Some typefaces do not have + both bold and bold extended: by default \LaTeX{} uses + \command{bfseries} for bold + extended. +\end{itemize*} +\end{center} +\endgroup +These `shape', + `series', and + `family' commands are \textbf{\textit{commutative}}\label{commutative}\index{commutative@\textbf{\textit{commutative}}}, so you can + combine a shape with a series and/or a family, without the + need to use \command{selectfont}: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +This gives you {\bfseries\itshape\sffamily bold +italic sans-serif type}, but beware + \end{Verbatim} +\end{sourcecode} + +This gives you {\sffamily{}\fontseries{b}\fontshape{it}\selectfont{}bold italic sans-serif type}, but + beware of pushing your fonts beyond their limits unless you + are a typographer. It is not normally meaningful to combine + one shape or series class with another of the same class, + such as trying to get slanted-italics. It's an + impossibility to combine one family with another (such as a + seriffed sans-serif typeface!). Slanted plus italics, for + example, doesn't make sense, as italics are already + slanted (although it is technically possible); and while + some typefaces may well possess italic small caps, they are + not in common use. Sans-serif and monospace (typewriter) are + different fonts, and often different typeface families + entirely.\footnote{Although if you're a typographer wanting to + experiment with typewriter typefaces with and without + serifs, you can use \mf{} to do exactly this kind + of thing. But that's way outside the scope of this + document.} + +There is an alternative syntax for the most common type + shape and series commands which uses curly braces in the + normal `argument' manner: +\begingroup\small \begin{center} +\label{fontcmds} +\begin{tabular}{@{}l>{\ttfamily}ll@{}} +\textbf{\sffamily\upshape Type style}&\textbf{\sffamily\upshape Command}&\textbf{\sffamily\upshape Example}\\[2pt]\hline\\[-1.5\baselineskip] +Italic&\verb+\textit{text}+&puts {\fontshape{it}\selectfont{}text} + into italics\\ +Slanted&\verb+\textsl{text}+&puts {\fontencoding{OT1}\fontfamily{cmr}\fontshape{sl}\selectfont{}text} into + slanted type*\\ +Small Capitals&\verb+\textsc{text}+&puts {\fontshape{sc}\selectfont{}text} into + small caps\\ +Bold&\verb+\textbf{text}+&puts {\fontseries{b}\selectfont{}text} into + bold type\\ +Sans-serif&\verb+\textsf{text}+&puts {\sffamily{}\selectfont{}text} + into sans-serif type\\ +Monospace&\verb+\texttt{text}+&puts {\ttfamily{}\selectfont{}text} into + typewriter type\\ +\end{tabular} +\par\smallskip\footnotesize +\begin{itemize*} +\item [\sffamily *] If slanted is available separately + from italics. +\end{itemize*} +\end{center} +\endgroup +You can nest these inside one another too: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +...\textbf{\itshape\textsf{bold italic +sans-serif type}}... + \end{Verbatim} +\end{sourcecode} + +\label{uline}% +Underlining isn't a font, and it is extremely + rare in typography except for special purposes. If you think + you need it, use the \package{ulem} package + with the \verb+normalem+ option, and the + \command{uline} command. +\subsection{Font sizes} +\label{fontsize} +\index{fonts!sizes} +\LaTeX{} has built into its defaults a set of predefined + font size steps corresponding more or less to the + traditional sizes available to metal typesetters. This is + deliberate, as these sizes have grown up over 500 years of + printing as those which go best together for book-work, + which is where \TeX{} originated. + +These sizes are also reflected in the size steps at + which Computer Modern was designed. It often comes as a + surprise to new users that many typefaces are not designed + as a single font and just scaled up or down, but specially + drawn at different sizes to make them more legible. + +As an example, {\fontencoding{OT1}\fontfamily{cmr}\fontsize{12}{12}\selectfont{}here's 12pt Computer + Modern}, and {\font\cmbig=cmr5 + at12pt\cmbig here's 5pt Computer Modern scaled up to + 12pt}, and + {\font\cmsmall=cmr17 at12pt\cmsmall + here's 17pt Computer Modern scaled down to + 12pt} so you can see there really is a + significant difference. In general, you probably don't + want to go scaling fonts too much beyond their design size + because they will start to look very odd. + +The default sizes (and the commands that operate them) + are based on the use of a 10pt font, which is the normal + size for most texts. Using the larger defaults (11pt and + 12pt) for the body font will scale these sizes up + approximately in proportion. The exact sizes used are listed + in the macros in the Class Option files + \url+size10.clo+, + \url+size11.clo+ and + \url+size12.clo+. \TeX{}'s default fonts + above 10pt are in fact scaled by a factor of 1.2, as shown + in the fourth column of the table below. +\begingroup\small \begin{center} +\begin{tabular}{@{}llrr@{}} +\textbf{\sffamily\upshape Command}&\textbf{\sffamily\upshape Example}&\multicolumn{1}{>{\bfseries\pbs{\raggedleft}}b{.6in}}{\normalfont\bfseries\upshape Nominal point + size}&\multicolumn{1}{>{\bfseries\pbs{\raggedleft}}b{.5in}}{\normalfont\bfseries\upshape Exact point + size}\\[2pt]\hline\\[-1.5\baselineskip] +\command{tiny}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{5}{5}\selectfont{}The quick brown fox + jumps over the lazy dog}&5&5\\ +\command{scriptsize}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{7}{7}\selectfont{}The quick brown + fox jumps over the laz}&7&7\\ +\command{footnotesize}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{8}{8}\selectfont{}The quick + brown fox jumps over the l}&8&8\\ +\command{small}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{9}{9}\selectfont{}The quick brown fox + jumps over th}&9&9\\ +\command{normalsize}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{10}{10}\selectfont{}The quick + brown fox jumps over}&10&10\\ +\command{large}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{12}{12}\selectfont{}The quick brown fox + jumps}&12&12\\ +\command{Large}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{14}{14}\selectfont{}The quick brown fox + ju}&14&14.40\\ +\command{LARGE}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{18}{18}\selectfont{}The quick brown + fo}&18&17.28\\ +\command{huge}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{20}{20}\selectfont{}The quick + brown}&20&20.74\\ +\command{Huge}&{\fontencoding{OT1}\fontfamily{cmr}\fontsize{24}{24}\selectfont{}The quick + bro}&24&24.88\\ +\end{tabular} +\end{center} +\endgroup +While these `shorthand' commands + relieve the beginner of having to worry about the + `right' size for a given task, when + you need a specific size there is the + \command{fontsize} command: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\fontsize{22}{28}\selectfont This is 22pt +type 6pt leaded + \end{Verbatim} +\end{sourcecode} + +`Leading' comes from the old metal-type + practice of adding a lead strip between lines to increase the + spacing. + +The \command{fontsize} command takes two + arguments: the point size and the baseline distance. The + above example gives you 22pt type on a 28pt baseline + (i.e. with 6pt extra space or + `leading' between the lines). +\begin{warning} + +Computer Modern fonts (the default) come fixed at the + named size steps shown in the table, and if you try to use + an odd size in between, \LaTeX{} will pick the closest + step instead. If you really need to use CM\index{CM@CM} at arbitrary sizes there is a + package \package{type1cm} which lets you + override the default steps. If you use + PostScript\index{PostScript} (Type 1) fonts, the + step sizes do not apply and the font scaling is infinitely + variable. +\end{warning} +\subsection{Logical markup} + +All this playing around with fonts is very pretty but + you normally only do it for a reason, even if that reason is + just to be decorative. Italics, for example, are used for + many things: +\begingroup\small \begin{center} +\begin{tabular}{l>{\itshape}l} +\textbf{\sffamily\upshape Cause}&\textbf{\sffamily\upshape Effect}\\[2pt]\hline\\[-1.5\baselineskip] +Foreign words&ex officio\\ +Scientific names&Ranunculus ficaria\\ +Emphasis&must not\\ +Titles of documents&The \LaTeX{} Companion\\ +Product names&{\upshape + Corel's} WordPerfect\\ +Variables in maths&\(E=mc^{2}\)\\ +Subtitles or headings&How to get started\\ +Decoration&FREE UPGRADE!!!\\ +\end{tabular} +\end{center} +\endgroup +Humans usually have no problem telling the difference + between these reasons, because they can read and understand + the meaning and context. Computers cannot (yet), so it has + become conventional to use descriptive names which make the + distinction explicit, even though the appearance may be the + same. + +\LaTeX{} has some of these built in, like + \command{emph}, which provides + \emph{emphasis}. This has a special feature + because {\fontshape{it}\selectfont{}when the surrounding text is + already italic, \emph{emphasis} + automatically reverts to \emph{upright + type}}, which is the normal practice + for typesetting. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +This has a special feature because {\itshape when the +surrounding text is already italic, \emph{emphasis} +automatically reverts to upright type, which is the + \end{Verbatim} +\end{sourcecode} + +\label{emph}% +This sensitivity to logic is programmed into + the definition of \command{emph} and it's not + hard to make up other commands of your own which could do + the same, such as \command{foreign} or + \command{product}. + +But why would you bother? In a short document it's + probably not important, but if you're writing a long + report, or a formal document like an article, a book, or a + thesis, it makes writing and editing hugely easier if you + can control whole groups of special effects with a single + command, such as italicising, indexing, or cross-referencing + to a glossary. If a format needs changing, you only have to + change the definition, and every occurrence automatically + follows suit. +\begin{warning} + +Beware of this `vaine conceipt of simple men, + which judge things by ther effects, and not by ther + causes'. (Edmund Spenser, 1633) It's hugely + more efficient to have control of the cause than the + effect. +\end{warning} + +It also makes it possible to find and act on groups of + meanings\mdash{}such as making an index of scientific names + or product names (as in this document)\mdash{}if they are + identified with a special command. Otherwise you'd + spend weeks hunting manually through every + \command{textit} command to find the ones you + wanted. This is the importance of automation: it can save + you time and money. + +In \chaptername~\ref{macros} we will see how to make your + own simple commands like this. +\subsection{Colour} +\index{colour}\index{fonts!colour} +You can typeset anything in \LaTeX{} in any colour you + want using the \package{color} package. + First, you need to add the command + \verb+\usepackage{color}+ to your preamble (note + the US spelling of color!). This makes available a default + palette of primary colours: {\color{red}red}, {\color{green}green}, and {\color{blue}blue} for the RGB\index{RGB@RGB} colour model used for emitted light + (television screens), and {\color{cyan}cyan}, {\color{magenta}magenta}, {\color{yellow}yellow}, and black for the + CMYK\index{CMYK@CMYK} colour model used for + reflected light (printing). + +For the occasional word or phrase in colour, use the + command \command{textcolor} with two arguments, the + colour name and the text: \verb+\textcolor{red}{like this}+. There is a \command{color} + command as well, for use within groups: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +...{\color{blue}some text in blue}... + \end{Verbatim} +\end{sourcecode} + +If you have the PostScript\index{PostScript} + printer driver \product{dvips} installed, + you also get a separate 64-colour palette of predefined + \textbf{\textit{color names}}\label{colornames}\index{color names@\textbf{\textit{color names}}}. These + represent approximately the colours in the big box of + \product{Crayola} colouring pencils much + favoured by artists and designers. This adds a new colour + model called `\verb+named+', so if + you want the \product{Crayola} colour + {\color[named]{FF00DD}RubineRed}, you can use the + \command{color} or \command{textcolor} + commands with a preceding optional argument + `\opt{named}': +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\color[named]{RubineRed} +\textcolor[named]{RubineRed}{some red text} +\end{Verbatim} +\end{sourcecode} + +As some of the `\verb+named+' + colour names are quite long, you can create a short name of + your own for colours you use frequently, using the + \command{definecolor} command: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\definecolor{mb}{named}{MidnightBlue} + \end{Verbatim} +\end{sourcecode} + +The \command{definecolor} command needs three + arguments: your shorthand name, the name of the colour model, + and the colour specification. In the case of the + `\verb+named+' model, the last + argument is one of the 64 colour names. To + use these names with \product{pdf\LaTeX{}}, + you need to use the \opt{pdftex} option to the + \package{color} package. + +Using the \command{definecolor} command, you + can define any colour you want by giving it a name, + specifying which colour model, and providing the Red-Green-Blue (RGB)\index{RGB@RGB|textbf}\index{Acronyms@\textbf{Acronyms}, defined!RGB@RGB|textbf} or Cyan-Magenta-Yellow-Black (CMYK)\index{CMYK@CMYK|textbf}\index{Acronyms@\textbf{Acronyms}, defined!CMYK@CMYK|textbf} colour + values expressed as decimals, separated by commas. For + example, an RGB\index{RGB@RGB} shade given as + (37,125,224) in decimal (\#250FE0 in hexadecimal as used + on the Web) can be given as\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\definecolor{midblue}{rgb}{0.145,0.490,0.882} + \end{Verbatim} +\end{sourcecode} + (divide each value by 255, the maximum for + each of the hues in the Red-Green-Blue colour model). You + can then use \command{textcolor} with your new + colour name: {\color{midblue}the midblue looks like + this if you're reading in colour.} + +The \package{color} package also provides + a colour version of \command{fbox} (see \S\thinspace\ref{fbox}) called + \command{colorbox}: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\colorbox{midblue}{\color{magenta}Magenta on midblue} + \end{Verbatim} +\end{sourcecode} + +\colorbox{midblue}{\color{magenta}Magenta + on midblue}: you can + see how careful you need to be with colours! +\section{Installing new fonts} +\label{instfonts} +\index{fonts!installing} +Different fonts come in a variety of packagings: the three + most common used with \TeX{} systems are + PostScript\index{PostScript} fonts, TrueType fonts, and + \mf{} fonts. How you install them and where they go + depends on how you installed \LaTeX{}: all I can deal with here + are the standard locations within the TDS\index{TDS@TDS}. + +Typefaces come supplied as one or more font + `outline' files and a number of + ancillary files: +\begin{description} +\item[\sffamily \mf{} typefaces] +have a number of \url+.mf+ source + (outline) files, possibly also some + \url+.fd+ (font definition) files and a + \url+.sty+ (style) file. The + \url+.tfm+ (\TeX{} font metric) files are + not needed, as they can be generated from the + outlines. +\item[\sffamily PostScript typefaces] +come as a pair of files: a \url+.pfb+ + (PostScript font binary) or \url+.pfa+ + (PostScript font ASCII\index{ASCII@ASCII}) + outline, and an \url+.afm+ (Adobe font + metric) file. There may also be + \url+.inf+ and other files but these are + not needed for use with \TeX{} systems. +\item[\sffamily TrueType typefaces] +are a single \url+.ttf+ file, which + combines outline and metrics in one. +\end{description} + +The instructions here assume the use of the New Font Selection Scheme (NFSS)\index{NFSS@NFSS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!NFSS@NFSS|textbf} used in + \LaTeXe{}. If you are running the obsolete \LaTeX{} 2.09, + upgrade it now. +\subsection{Installing \mf{} fonts} +\label{mffonts} + +This is the simplest installation. When you download + \mf{} fonts from CTAN\index{CTAN@CTAN}, + you'll usually find a large number of Outline files + (\url+.mf+ files) and maybe some other types + as well (see below). +\begin{figure}\small +\caption{\small Creating a new subdirectory for a font} +\label{mkfontdir} +\begin{center} +\includegraphics[width=0.75\textwidth]{public} +\end{center} +\end{figure} +\begin{enumerate} +\item \label{newsub}% +Create a new subdirectory named after the typeface + you're installing in + \url+texmf-local/fonts/source/public/+: +\item +Copy all the \url+.mf+ (outline) + files to this directory. +\item +Copy the \url+.fd+ (Font Definition) + file[s] and the \url+.sty+ (style) file + to your \url+texmf/tex/latex/mfnfss+ + directory. +\item +Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}). +\end{enumerate} + +That's it. Unlike PostScript\index{PostScript} + fonts, \mf{} fonts can be used to generate the font + metric file (\url+.tfm+ files) automatically + on-the-fly the first time the typeface is used, so there + should be nothing else to install. + +Now you can put a \command{usepackage} command + in your preamble with whatever name the + \verb+.sty+ file was called, and read the + documentation to see what commands it gives to use the font + (refer to the last paragraph of \S\thinspace\ref{packinst} and step~\ref{dtxdoc} in the procedure on p.\thinspace\pageref{dtxdoc}). + +If the font came \emph{without}\url+.fd+ or \url+.sty+ files, + you'll need to find someone who can make them for you + (or follow the outline in \S\thinspace\ref{psfonts}, step~\ref{fdfiles} in the procedure on p.\thinspace\pageref{fdfiles}). +\subsubsection{Pre-generated metrics (optional)} + +Some \mf{} fonts come with pre-generated + \url+.tfm+ files which you can install if + your system is slow at generating them itself: +\begin{enumerate} +\addtocounter{enumi}{\thehold}\item +Create a new subdirectory within + \url+texmf-local/fonts/tfm/public/+ + named the same as the one you created for the + \url+.mf+ files above. +\item +Copy all the \url+.tfm+ files into + this subdirectory. +\item +Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}). +\end{enumerate} +\setcounter{hold}{\theenumi}\subsubsection{Pre-generated bitmaps (optional)} + +In some rare cases, pre-generated packed bitmap fonts + (\url+.pk+ files) are also available from + CTAN\index{CTAN@CTAN} (normally your previewer + and print driver creates these automatically, but you can + use the pre-generated ones if you have a very slow + system). If you really want to install these, it's a + similar procedure to the \url+.tfm+ + files: +\begin{enumerate} +\addtocounter{enumi}{\thehold}\item +Create a new subdirectory within + \url+texmf-local/fonts/pk/modeless/+ + named the same as the one you created for the + \url+.mf+ and \url+.tfm+ + files above. +\item +Copy all the \url+.nnnpk+ files + into this subdirectory (\(nnn\) is + a number reflecting the dot-density of the bitmap). On + Microsoft systems the files may just end in + \url+.pk+ and be kept in subdirectories + named after the dot-density, e.g. + \url+dpi360+. +\item +Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}). +\end{enumerate} +\setcounter{hold}{\theenumi}\subsection{Installing PostScript fonts} +\label{psfonts} +\index{fonts!PostScript} +Lots of people will tell you that + PostScript\index{PostScript} fonts and PostScript + output are dead and that TrueType or OpenType fonts and PDF + output are the way to go. While this is true for many cases, + standard \LaTeX{} does not work with TrueType fonts and does + not produce PDF\index{PDF@PDF} directly. Only + \product{pdf\LaTeX{}} does that, and there are + still many printers whose typesetters and platemakers use + PostScript\index{PostScript} rather than PDF\index{PDF@PDF}. In addition, operating system + support for scalable fonts is still very poor on Unix + systems (including Linux), despite the advances in recent + years, so in many cases it still makes sense to use + \TeX{}'s built-in support for PostScript. + +Two files are needed for each font: the + \url+.afm+Adobe Font + Metric (AFM)\index{AFM@AFM|textbf}\index{Acronyms@\textbf{Acronyms}, defined!AFM@AFM|textbf} and the \url+.pfb+PostScript Font Binary (PFB)\index{PFB@PFB|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PFB@PFB|textbf} files. + \emph{You must have both for each font before you + start.} If you only have the near-obsolete + \url+.pfa+PostScript Font + ASCII (PFA)\index{PFA@PFA|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PFA@PFA|textbf} files, it may be possible to generate the + \url+.pfb+ files using the + \product{t1binary} program from the + \product{t1utils} suite (see \url+http://gnuwin32.sourceforge.net/packages/t1utils.htm+) + or the excellent \product{PFAedit} font + editor (from \url+http://pfaedit.sourceforge.net+). There are + unfortunately still some companies distributing Type 1 + fonts in \url+.pfa+ format (Mathematica is + one reported recently). +\begin{warning} + +The installation method I described in earlier + editions has worked perfectly for me for years, but I have + updated it here to use the facilities of the + \product{updmap} program (which comes + with your \TeX{} installation). This removes the need for + one of the steps I gave before, which required editing the + \url+psfonts.map+ file, as this is now + recreated by \product{updmap}. The + procedure below is \emph{not} the official + way (that's \product{fontinst}), but + it is the basis for a script I am working on called + \product{Gutta-Percha}\footnote{Yes, as in rubber.}, which automates the whole process. +\end{warning} + +I'll repeat this: before you start, make sure you + have all the \url+.afm+ and + \url+.pfb+ files for the typeface you want. + In the example below, I'm going to use a single font + from an imaginary typeface called Foo, so I have + \verb+foo.afm+ and + \verb+foo.pfb+ files. +\begin{enumerate} +\item \textbf{Put the files in your temporary directory}\\ +This is \url+/tmp+ on Linux, and + should be \url+C:\tmp+ or + \url+C:\temp+ or even + \url+C:\Windows\temp+ on Microsoft + Windows. +\item \textbf{Decide on the short font name to use + inside \LaTeX{}.}\\ +This is \emph{not} the full + descriptive name (e.g. Baskerville Italic Bold + Extended) but an encoded font name in the format + \verb+fnnsseec+, devised by \person{Karl Berry}, which stores the same information in no + more than eight characters for compatibility with + systems which cannot handle long filenames. The letters + in the format above have the following meanings (see the + \product{fontname} documentation on + your computer for more details): +\begingroup\small \par\medskip\moveleft\itemindent\vbox{\begin{tabular}{@{}lll@{}} +\textbf{\sffamily\upshape Letter}&\textbf{\sffamily\upshape Meaning}&\textbf{\sffamily\upshape Examples}\\[2pt]\hline\\[-1.5\baselineskip] +\verb+f+&foundry&\verb+b+=Bitstream, + \verb+m+=Monotype, + \verb+p+=Adobe\\ +\verb+nn+&typeface&\verb+ba+=Baskerville, + \verb+tm+=Times, + \verb+pl+=Palatino\\ +\verb+ss+&series/shape&\verb+r+=roman, + \verb+bi+=bold italic, etc.\\ +\verb+ee+&encoding&\verb+8a+=default 8-bit ANSI, + \verb+ly+=Y\amp Y's + \TeX{}'n'ANSI\\ +{\fontseries{b}\selectfont{}\verb+c+}&[small]caps&(this is a literal + `c' character, used only + if needed)\\ +\end{tabular} +}\endgroup +The \url+texmf/fontname+ directory in + your installation of \LaTeX{} has files for several + foundries giving fully-formed names like these for + common fonts (e.g. \verb+ptmr8a+ is [Adobe] + \uline{\textbf{P}}ost\-Script + \uline{\textbf{T}}i\uline{\textbf{m}}es + \uline{\textbf{R}}oman in an + \uline{\textbf{8}}\ndash{}bit \uline{\textbf{A}}NSI + encoding; + \verb+bgslly+ is \uline{\textbf{B}}itstream + \uline{\textbf{G}}ill \uline{\textbf{S}}ans + \uline{\textbf{L}}ight in Y\amp Y's + \TeX{}'n'ANSI encoding + [\uline{\textbf{LY}}1]).\footnote{Confusingly, Bitstream fonts (and others from + similar sources) mostly have different names from + the original fonts, so what they call Humanist 521 + is actually Gill Sans. Until recently, US law only + allowed the \emph{names} of typefaces + to be copyrighted, not the font designs themselves, + leading to widespread piracy.} Read the documentation in \titlecite{fontname} to find out how to make up + your own short names if the foundry and font you want is + not shown in the \url+fontname+ + directory. + +In this example we'll call our mythical example + typeface `zork' (standing for + \uline{\textbf{Z}}fonts \uline{\textbf{Or}}dinary + Boo\uline{\textbf{k}}face, because + \verb+k+ is the letter used for Book + fonts, \verb+b+ being already the code + for bold) and we'll assume the font comes in the two + files \url+foo.afm+ and + \url+foo.pfb+ that I mentioned + above. + +While the \product{fontname} + directories have ready-made lists of these names for + popular collections of typefaces, making them up + requires some knowledge of typographic terms and a + careful reading of the + \product{fontname} + documentation. +\item \textbf{Decide on your encoding}\\ +This is what tripped me up the first few times until + someone pointed me at Y\amp Y's\footnote{Sadly, Y\amp Y, Inc has ceased trading and + their \TeX{} distribution is not longer available, + although there is email support at \url+http://lists.ucc.ie/lists/archives/yandytex.html+, + and their encoding files continue to be used.}\TeX{}'n'ANSI encoding which (to me) seems to + be the only one that includes the glyphs I want where I + want them.\footnote{The only one I still have problems with is + `ø', which for some weird + reason isn't catered for in this encoding.}\index{fonts!encoding} Your mileage may vary. This encoding is + referred to as \verb+LY1+ within \LaTeX{} and + the encoding file is in + \url+texmf/dvips/base/texnansi.enc+. + Encoding is needed because Adobe fonts store their + characters in different places to the \TeX{} + standard. + +Copy this encoding file to the temporary directory + where you're doing all this stuff. If you're + using the 8a or 8r encoding (or some other encoding), + then copy that file instead + (\url+8a.enc+, + \url+8r.enc+). +\item \textbf{Convert \url+.afm+ files to + \url+.tfm+}\\\label{idfile}% +The \product{afm2tfm} program is a + standard utility in the \url+bin+ + directory of your \TeX{} installation. If it's not, + update your installation. + +In a command window, type: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\footnotesize] +afm2tfm foo.afm -v zorkly.vpl -p texnansi.enc \ +rzorkly.tfm >zork.id + \end{Verbatim} +\end{sourcecode} + +(Here and elsewhere I have sometimes had to break + the line to fit it on the printed page. It's actually + all typed as one long line if you omit the + backslash.) + +This creates a special `raw'\TeX{} Font Metric file (hence the special + \verb+r+ prefix) that \LaTeX{} can use, with + a list of all its properties encoded with LY1 (the + \url+.vpl+ or Virtual Property List + file). Many people will tell you that virtual fonts are + dead and that this is the wrong way to do it, but no-one + has ever shown me an alternative that works, so I stick + with it. +\item \textbf{Small caps (optional)}\\\label{sc}% +If you want a small caps variant faked up (perhaps + because the typeface family doesn't have a special + small-caps font), repeat the medicine like this: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\footnotesize] +afm2tfm foo.afm -V zorklyc.vpl -p texnansi.enc \ +rzorkly.tfm >>zork.id + \end{Verbatim} +\end{sourcecode} + +Note the capital \verb+V+ option here. + Yes, it \emph{does} overwrite the + \url+rzorkly.tfm+ created in the first + command. Let it. And those are \emph{two} + of the `greater-than' signs + before the \url+zork.id+ filename because + we want to append to it, not overwrite it. +\item \textbf{Create the virtual font}\\ +Turn the \url+.vpl+ files into + \url+.vf+ and \url+.tfm+ + pairs. \LaTeX{} uses these to convert from Adobe's + encoding to its own. +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +vptovf zorkly.vpl zorkly.vf zorkly.tfm +vptovf zorklyc.vpl zorklyc.vf zorklyc.tfm + \end{Verbatim} +\end{sourcecode} + +Again, the \url+vptovf+ program is a + standard part of your \TeX{} distribution. +\item \textbf{Make directories to hold the files}\\\begin{figure}\small +\caption{\small Making subdirectories to hold the files} +\label{mksubdir} +\begin{center} +\includegraphics[width=0.75\textwidth]{fonts} +\end{center} +\end{figure} + +Under your \url+texmf-local+ + directory there should be a \url+fonts+ + directory, and in there there should be + \url+afm+, \url+tfm+, + \url+type1+, and \url+vf+ + directories. Create them if they do not already + exist. + +In each of these four, create a directory for the + foundry, and within them create a directory for the + typeface (using a human-readable typeface name, not the + short \person{Karl Berry} fontname). In our example, this + means: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +cd /usr/TeX/texmf-local/fonts +mkdir -p afm/zfonts/ordinary +mkdir -p tfm/zfonts/ordinary +mkdir -p type1/zfonts/ordinary +mkdir -p vf/zfonts/ordinary +cd /tmp + \end{Verbatim} +\end{sourcecode} + +Or if you're lazy like me: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +(cd /usr/TeX/texmf-local/fonts;\ +for d in afm tfm type1 vf;\ +do mkdir -p $d/zfonts/ordinary;done) + \end{Verbatim} +\end{sourcecode} + +For Microsoft Windows users, the path before + \url+texmf-local+ may look something like + \verb+C:\Program Files\TeXLive\+, depending + on how and where you have installed your \TeX{} + system. + +The \verb+-p+ is a Unix feature: it + automatically creates any missing intervening + subdirectories. If your directory-making command + doesn't do this, you'll have to make the + intervening directories by hand first. +\item \textbf{Copy the files to their rightful places}\\ +Copy the four groups of files to the four new + directories: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +cp *.afm /usr/TeX/texmf/fonts/afm/zfonts/ordinary/ +cp *.tfm /usr/TeX/texmf/fonts/tfm/zfonts/ordinary/ +cp *.pfb /usr/TeX/texmf/fonts/type1/zfonts/ordinary/ +cp *.vf /usr/TeX/texmf/fonts/vf/zfonts/ordinary/ + \end{Verbatim} +\end{sourcecode} + +You can of course do all this with a directory + window and mouse if you find it easier. +\item \textbf{Create a font map}\\ +The font map is what tells + \product{dvips} which PFB\index{PFB@PFB} file to use for which font. The + configuration file for \product{dvips} + is \url+texmf/dvips/config/config.ps+ and + it gets its entries from the program + \product{updmap} which reads map files + for each typeface. The configuration file for + \product{updmap} is + \url+texmf-var/web2c/updmap.cfg+\footnote{There is another one of these at + \url+texmf/web2c/updmap.cfg+, but + that contains the map references for the fonts which + came with your distribution of \TeX{}, so you should + not interfere with it.}, so it needs an entry for our new font, + using the three-letter font family abbreviation (the + first three letters of the Berry fontname (here + `\verb+zor+'): +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +Map zor.map + \end{Verbatim} +\end{sourcecode} + +We also have to create this map file + (\url+zor.map+) in a subdirectory of + \url+texmf-local/dvips/config/+ named + after the foundry, so we need to create + \url+texmf-local/dvips/config/zfonts+ as + well. +\begin{enumerate} +\item +Open + \url+/usr/TeX/texmf-var/web2c/updmap.cfg+ + in your editor. +\item +At the bottom, add the line: + \verb`Map zor.map` +\item +Save and close the file. +\end{enumerate} + +The font entries in our + \verb+zor.map+ will be on a + \emph{single} line each, with no + line-wrapping. Each entry gives the short name of the + font, the long (Adobe) name, the + PostScript\index{PostScript} encoding parameters + (in quotes), and then two filenames prefixed by input + redirects (less-than signs): the encoding file and the + PostScript\index{PostScript} outline file. +\begin{enumerate} +\item +First create the directory if it doesn't already + exist: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +mkdir -p /usr/TeX/texmf-local/dvips/config/zfonts + \end{Verbatim} +\end{sourcecode} +\item +Use your editor to open (create) the file + \url+/usr/TeX/texmf-local/dvips/config/zfonts/zor.map+. +\item \label{fullname}% +Insert the line: +\begin{shiftedsourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\scriptsize] +rzorkly Ordinary-Blackface "TeXnANSIEncoding ReEncodeFont" <texnansi.enc <foo.pfb + \end{Verbatim} +\end{shiftedsourcecode} +\item +Save and close the file. +\end{enumerate} + +You get the full font name (here, + `Ordinary-Blackface') from the + \verb+zork.id+ which was created back in + step~\ref{idfile} in the procedure on p.\thinspace\pageref{idfile} when we ran + \product{afm2tfm}. You must get this + exactly right, because it's the + `official' full name of the font, + and PostScript\index{PostScript} files using this + font need to match it. +\item \textbf{Create a style file}\\ +\LaTeX{} needs a style file to implement the + interface to the font. Call it after the typeface or + something related; in this example we'll call it + \url+foozork.sty+. In it go some details + of the name and date we did this, what version of + \LaTeX{} it needs, and any other command necessary to + operate the font, like the font encoding and whether it + is to supersede the current default Roman font. +\begin{enumerate} +\item +Use your editor to open (create) + \url+foozork.sty+ in your + \url+texmf-local/tex/latex/psnfss+ + directory. +\item +Insert the following lines: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +% foozork - created from foo for Zork +\def\fileversion{1.0} +\def\filedate{2002/12/03} +\def\docdate{2002/12/03} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{foozork} + [\filedate\space\fileversion\space + Zfonts Ordinary PSNFSS2e package] +\RequirePackage[LY1]{fontenc} +\renewcommand{\rmdefault}{zor} +\endinput + \end{Verbatim} +\end{sourcecode} + +Note the following: +\begin{itemize} +\item +The first argument to + \command{ProvidesPackage} + \emph{must} be the same as this + style file name; and that the font family is + referred to as \verb+zor+, being the + foundry letter plus the fontname abbreviation. + This acts as a prefix for any/all font variants + (bold, italic, etc.). + +\item +If you are not using Y\amp Y encoding, + omit the line referring to LY1 font + encoding. + +\item +If this is a typewriter font, make the + renewed command \command{rmdefault} + into \command{ttdefault}. + +\item +If it's a sans-serif font, make it + \command{sfdefault} instead. + +\item +Omit the command completely if you + don't want the style file to supersede the + current defaults but simply to make the font + available. If you do this, you probably want to + write a new command or two to use it, typically + one for grouped use and one for argument + use: + +\end{itemize} +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\footnotesize] +\newcommand{\zorkfamily}{\fontencoding{LY1}% + \fontfamily{zor}\selectfont} +\newcommand{\textzork}[1]{{\zorkfamily#1}} + \end{Verbatim} +\end{sourcecode} +\item +Save and close the file. +\end{enumerate} +\item \textbf{Create the Font Definition file}\\\label{fdfiles}% +The last file to create is the \textbf{\textit{font definition}}\label{fontdef}\index{font definition@\textbf{\textit{font definition}}} + (\url+.fd+) file. This is named + following the pattern \verb+eeefnn.fd+, + using the same conventions as before, by prepending the + (lowercase) encoding abbreviation to the foundry letter + and fontname abbreviation, so our example would be + \verb+ly1zor.fd+ for the LY1 encoding and + the \verb+zor+ short font name. +\begin{enumerate} +\item +Use your editor to open (create) + \url+texmf-local/tex/latex/psnfss/ly1zor.fd+ +\item +Enter the following lines: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +\ProvidesFile{ly1zor.fd}[2002/03/03 v0.1 manual + font definitions for LY1/zor.] + +\DeclareFontFamily{LY1}{zor}{} + +\DeclareFontShape{LY1}{zor}{k}{n}{<-> zorkly}{} +\DeclareFontShape{LY1}{zor}{k}{sc}{<-> zorklyc}{} + \end{Verbatim} +\end{sourcecode} +\item +Save and close the file. +\end{enumerate} + +FD files typically use one + \command{DeclareFontFamily} command which + specifies the encoding and the short font name. Then as + many pairs of \command{DeclareFontShape} + commands as you converted fonts (assuming you did both + normal and small caps for each font: see + step~\ref{sc} in the procedure on p.\thinspace\pageref{sc}; if you didn't, then only one + such command per font is needed here). The arguments to + the \command{DeclareFontShape} command to watch + are the 3rd (weight/width), 4th (shape), and 5th (font + outline name): the rest are static for each + \url+.fd+ file and simply identify the + encoding and the font family. + +The codes to use are given on + pages 414\ndash{}15 of the \titlecite{companion} and should also be in + your copies of + \url+texmf/fontnames/weight.map+ and + \url+texmf/fontnames/width.map+. The + rules for combining weight and width need care: RTFM\index{RTFM@RTFM} for + \package{fontname}. There is no + \url+shape.map+ in + \package{fontname} because it's not + part of font file names, it's purely a \LaTeX{} + creation, so here's what the same book says: +\begingroup\small \begin{center} +\begin{tabular}{ll} +\textbf{\sffamily\upshape Character}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip] +\verb+n+&normal (upright)\\ +\verb+it+&italic\\ +\verb+sl+&slanted\\ +\verb+sc+&small caps\\ +\verb+ui+&upright italic\\ +\verb+ol+&outline\\ +\end{tabular} +\end{center} +\endgroup +Add your own for other oddities, but be consistent: + I use \verb+cu+ for cursive (scripts), for + example, and \verb+k+ for blackletter faces + (not to be confused with \verb+k+ as a + \emph{width} for + `book'). + +The default fontspec + \verb+<->+ in the 5th argument + in the \command{DeclareFontShape} command means + that all sizes are to come from the same font outline + (remember if this was a \mf{} font with different + design sizes like CM\index{CM@CM} it would + be much more complex). + +If the face has only a few variants, you can create + any other entries for bold, italic, slanted, etc. with + the relevant weight and width and shape values pointing + at the relevant outline file. + +If you want one font to substitute for a missing one + (for example italics to substitute for slanted in a + typeface which has no slanted variant of its own) give + the + \verb+ssub+ (`silent + substitution') command in the fontspec: + for example to make all references to + \verb+sl+ (slanted) type use an existing + italic font, make the 5th argument like this: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +{<-> ssub * zor/m/it} + \end{Verbatim} +\end{sourcecode} + +If you find the x-height of a font too big or too + small to sort well with another font you are using, you + can specify an \verb+s+ + (`scale') factor in this argument + instead: this example will shrink the result to + 80\% of normal: +\begin{sourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\small] +{<-> s * [0.8] zorkly} + \end{Verbatim} +\end{sourcecode} +\item \textbf{Update the index and the map files}\\ +Run your \TeX{} indexer program (see step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}) so that + \product{updmap} can find the files it + needs. + +Then run \product{updmap} (just + type \verb+updmap+). This updates the + maps and runs the \TeX{} indexer program again + automatically. +\end{enumerate} + +Now you can \verb+\usepackage{foozork}+ in + your \LaTeX{} file to make it the default font. To use the + font incidentally instead of as the default, you can + say: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +This is {\zorkfamily ZORK} or \textzork{ZORK} + \end{Verbatim} +\end{sourcecode} +\subsection{Installing the Type 1 Computer Modern + fonts} +\label{type1cm} + +Most new distributions of \LaTeX{} use the + PostScript\index{PostScript} Type 1 versions of + the Computer Modern fonts. If your \LaTeX{} installation + uses the \mf{} (bitmap) versions of CM\index{CM@CM}, you may want to switch to the + Type 1 version, especially if you are going to be using + \product{pdf\LaTeX{}} instead of standard + \LaTeX{}, because Acrobat Reader makes such a hames of + displaying Type3 fonts. \product{GSview} + and \product{pdfview} handle them + correctly. + +To do this, install one of the sets of CM\index{CM@CM} PostScript fonts. There are several + available: +\begin{itemize} +\item +The fonts from BlueSky Research at \url+http://www.ctan.org/tex-archive/fonts/cm/ps-type1/bluesky/+ + +\item +\person{Basil K. Malyshev}'s `BaKoMa' + fonts at \url+http://www.ctan.org/tex-archive/fonts/cm/ps-type1/bakoma/+ + +\item +\person{Vladimir Volovich}'s CM-Super at \url+http://www.ctan.org/tex-archive/fonts/ps-type1/cm-super/+ + +\item +\person{Bogus\l{}aw Jackowski}'s Latin Modern at \url+ftp://cam.ctan.org/tex-archive/fonts/ps-type1/lm.tar.gz+ + +\end{itemize} + +The BaKoMa fonts include the American + Mathematical Society (AMS)\index{AMS@AMS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!AMS@AMS|textbf} fonts for extended + mathematics, but are more complex to install because they + come with a special set of TFM files. + +The BlueSky fonts are just PFB\index{PFB@PFB} + and AFM files, and are a drop-in replacement requiring no + further changes, as they use the same TFM files as the + \mf{} version. Follow the \url+README+ + file in the downloadable archive for installation + instructions. + +The Latin Modern and CM-Super fonts are new and I + haven't tested them but they are well spoken of. + Feedback on this is very welcome. + +The \TeX{} Live and \TeX{} Collection distributions use + Type 1 versions of Computer Modern by default. There + are more details in the FAQ at \url+http://www.tex.ac.uk/cgi-bin/texfaq2html?label=uselmfonts+\thinspace{}. +\chapter{Programmability (macros)} +\label{macros} +\index{macros} +We've touched several times on the ability of \LaTeX{} + to be reprogrammed. This is one of its central features, and one + that still, after nearly a quarter of a century, puts it well + above many other typesetting systems, even those with macro + systems of their own. It's also the one that needs most + foreknowledge, which is why this chapter is in this + position. + +\LaTeX{} is in fact itself just a collection of + macros\mdash{}rather a big collection\mdash{}written in + \TeX{}'s internal typesetting language. These \textbf{\textit{macros}}\label{macs}\index{macros@\textbf{\textit{macros}}} are little program-like sets of + instructions with a name which can be used as shorthand for an + operation you wish to perform more than once. + +Macros can be arbitrarily complex. Many of the ones used in + the standard \LaTeX{} packages are several pages long, but as we + will see, even short ones can very simply automate otherwise + tedious chores and allow the author to concentrate on + \emph{writing}. +\section{Simple replacement macros} +\label{replacement} + +In its simplest form, a \LaTeX{} macro can just be a + straightforward text replacement of a phrase to avoid + misspelling something each time you need it, e.g. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\ef}{European Foundation for the + Improvement of Living and Working Conditions} + \end{Verbatim} +\end{sourcecode} + +Put this in your preamble, and you can then use + \command{ef} in your document and it will typeset it + as the full text. Remember that after a command ending in a + letter you need to leave a space to avoid the next word + getting gobbled up as part of the command (see + the first paragraph of \S\thinspace\ref{swallow}). And when you want to force a space + to be printed, use a backslash followed by a space, + e.g. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +The \ef\ is an institution of the Commission of the + European Union. + \end{Verbatim} +\end{sourcecode} + +As you can see from this example, the + \command{newcommand} command takes two arguments: + \begin{inparaenum}[\itshape a\upshape)] \item the name you want to give the new command; and \item the expansion to be performed when you use it\end{inparaenum}, so there are always two sets of curly braces + after \command{newcommand}. +\section{Macros using information gathered previously} +\label{macinf} + +A more complex example is the macro + \command{maketitle} which is used in almost every + formal document to format the title block. In the basic + document classes (book, report, and article) it performs small + variations on the layout of a centred block with the title + followed by the author followed by the date, as we saw in + \S\thinspace\ref{titling}. + +If you inspect one of these document class files, such as + \url+texmf/tex/latex/base/report.cls+ you will + see \command{maketitle} defined (and several variants + called \command{@maketitle} for use in different + circumstances). It uses the values for the title, author, and + date which are assumed already to have been stored in the + internal macros \command{@title}, + \command{@author}, and \command{@date} by + the author using the matching \command{title}, + \command{author}, and \command{date} + commands in the document. + +This use of one command to store the information in + another is a common way of gathering the information from the + user. The use of macros containing the + \verb+@+ character prevents their accidental + misuse by the user: in fact to use them in your preamble we + have to allow the \verb+@+ sign to become a + `letter' so it can be recognised in a + command name, and remember to turn it off again afterwards + (see item~\ref{makeat} below). +\begin{sourcecode}\label{newtitle}\begin{Verbatim}[fontsize=\small] +\makeatletter +\renewcommand{\maketitle}{% + \begin{flushleft}% + \sffamily + {\Large\bfseries\color{red}\@title\par}% + \medskip + {\large\color{blue}\@author\par}% + \medskip + {\itshape\color{green}\@date\par}% + \bigskip\hrule\vspace*{2pc}% + \end{flushleft}% +} +\makeatother + \end{Verbatim} +\end{sourcecode} + +Insert this in the sample file on p.\thinspace\pageref{oldtitle} immediately before the + \verb+\begin{document}+ and remove the + \verb+\color{...}+ commands from the title, + author, and date. Re-run the file through \LaTeX{}, and you + should get something like this: +\begin{center} +\setlength{\fboxsep}{1cm}\includegraphics[width=0.75\textwidth]{newtitle} +\end{center} + +In this redefinition of \command{maketitle}, + we've done the following: +\begin{enumerate}\item\label{makeat} +Enclosed the changes in + \command{makeatletter} and + \command{makeatother} to allow us to use the + \verb+@+ sign in command names;\footnote{If you move all this preamble into a style file of + your own, you don't need these commands: the use + of \url+@+ signs in command names is + allowed in style and class files.} + +\item +Used \command{renewcommand} and put + \command{maketitle} in curly braces after + it; + +\item +Opened a pair of curly braces to hold the new + definition. The closing curly brace is immediately before + the \command{makeatother}; + +\item +Inserted a \env{flushleft} environment + so the whole title block is left-aligned; + +\item +Used \command{sffamily} so the whole title + block is in the defined sans-serif typeface; + +\item +For each of \command{@title}, + \command{@author}, and \command{@date}, + we have used some font variation and colour, and enclosed + each one in curly braces to restrict the changes just to + each command. The closing \command{par} makes + sure that multiline title and authors and dates get + typeset with the relevant line-spacing; + +\item +Added some flexible space between the lines, and + around the \command{hrule} (horizontal rule) at + the end; + +\end{enumerate} + +Note the \verb+%+ signs after any line ending + in a curly brace, to make sure no intrusive white-space find + its way into the output. These aren't needed after simple + commands where there is no curly brace because excess + white-space gets gobbled up there anyway. +\section{Macros with arguments} +\label{macargs} + +But macros are not limited to text expansion. They can + take arguments of their own, so you can define a command to do + something with specific text you give it. This makes them much + more powerful and generic, as you can write a macro to do + something a certain way, and then use it hundreds of times + with a different value each time. + +We looked earlier (\S\thinspace\ref{emph}) at making new + commands to put specific classes of words into certain fonts, + such as product names into italics, keywords into bold, and so + on. Here's an example for a command + \command{product}, which also indexes the product + name and adds a trademark sign: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\product}[1]{% + \textit{#1}\texttrademark% + \index{#1@\textit{#1}}% +} + \end{Verbatim} +\end{sourcecode} + +If I now type \verb+\tmproduct{Velcro}+ then I + get \product{Velcro}\texttrademark{} typeset, and if + you look in the index, you'll find this page referenced + under `{\fontshape{it}\selectfont{}Velcro}'. Let's + examine what this does: +\begin{enumerate}\item +The macro is specified as having one argument + (that's the \verb+[1]+ in the + definition). This will + be the product name you type in curly braces when you use + \command{product}. Macros can have up to nine + arguments. + +\item +The expansion of the macro is contained in the second + set of curly braces, spread over several lines (see item~\ref{macrolines} for why). + +\item +It prints the value of the first argument (that's + the \verb+#1+) in italics, which is + conventional for product names, and adds the + \command{texttrademark} command. + +\item +Finally, it creates an index entry using the same + value (\verb+#1+), making sure that it's + italicised in the index (see the list on p.\thinspace\pageref{indextypo} in \S\thinspace\ref{indextypo} to remind yourself of how indexing + something in a different font works). + +\item\label{macrolines} +Typing this macro over several lines makes it easier + for humans to read. I could just as easily have + typed +\begin{shiftedsourcecode}[-\leftmargin]\begin{Verbatim}[fontsize=\footnotesize] +\newcommand{\product}[1]{\textit{#1}\index{#1@\textit{#1}}} + \end{Verbatim} +\end{shiftedsourcecode} + +but it wouldn't have been as clear what I was + doing. + +One thing to notice is that to prevent unwanted spaces + creeping into the output when \LaTeX{} reads the macro, I + ended each line with a comment character + (\verb+%+). \LaTeX{} normally treats + newlines as spaces when formatting (remember item~\ref{comment}), so this stops the end of line + being turned into an unwanted space when the macro is + used. \LaTeX{} always ignores spaces at the + \emph{start} of macro lines anyway, so + indenting lines for readability is fine. + +\end{enumerate} + +In (\S\thinspace\ref{hyph}) we mentioned the problem + of frequent use of unbreakable text leading to poor + justification or to hyphenation problems. A solution is to + make a macro which puts the argument into an + \command{mbox} with the appropriate font change, but + precedes it all with a conditional + \command{linebreak} which will make it more + attractive to \TeX{} to start a new line. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\var}[1]{\linebreak[3]\mbox{\ttfamily#1}} + \end{Verbatim} +\end{sourcecode} + +This only works effectively if you have a reasonably wide + setting and paragraphs long enough for the differences in + spacing elsewhere to get hidden. If you have to do this in + narrow journal columns, you may have to adjust wording and + spacing by hand occasionally. +\section{Nested macros} +\label{macnest} + +Here's a slightly more complex example, where one + macro calls another. It's common in normal text to refer + to people by their forename and surname (in that order), for + example \person{Don Knuth}, but to have them indexed as \emph{surname, + forename}. This pair of macros, + \command{person} and \command{reindex}, + automates that process to minimize typing and indexing. +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\newcommand{\person}[1]{#1\reindex #1\sentinel} +\def\reindex #1 #2\sentinel{\index{#2, #1}} + \end{Verbatim} +\end{sourcecode} +\begin{enumerate}\item +The digit 1 in square brackets means that + \command{person} has one argument, so you put the + whole name in a single set of curly braces, e.g. + \verb+\person{Don Knuth}+. + +\item +The first thing the macro does is output + \verb+#1+, which is the value of what you typed, + just as it stands, so the whole name gets typeset exactly + as you typed it. + +\item +But then it uses a special feature of Plain \TeX{} + macros (which use \command{def} instead of + \LaTeX{}'s \command{newcommand}\footnote{Don't try this at home alone, children! This + one is safe enough, but you should strictly avoid + \command{def} for a couple of years. Stick to + \command{newcommand} for now.}): they too can have multiple arguments but you + can separate them with other characters (here a space) to + form a pattern which \TeX{} will recognise when reading the + arguments. + +In this example (\command{reindex}) it's + expecting to see a string of characters + (\verb+#1+) followed by a space, followed by + another string of characters (\verb+#2+) + followed by a dummy command (\command{sentinel}). + In effect this makes it a device for splitting a name into + two halves on the space between them, so the two halves + can be handled separately. The \command{reindex} + command can now read the two halves of the name + separately. + +\item +The \command{person} command invokes + \command{reindex} and follows it with the name + you typed plus the dummy command + \command{sentinel} (which is just there to signal + the end of the name). Because \command{reindex} + is expecting two arguments separated by a space and + terminated by a \command{sentinel}, it sees + `\verb+Don+ and + \verb+Knuth+' as two separate + arguments. + +It can therefore output them using + \command{index} in reverse order, which is + exactly what we want. + +\end{enumerate} + +A book or report with a large number of personal names to + print and index could make significant use of this to allow + them to be typed as + \verb+\person{Leslie Lamport}+ and printed as + \person{Leslie Lamport}, but have them indexed as + `Lamport, Leslie' with virtually no effort + on the author's part at all. +\begin{exercise} +\addcontentsline{loe}{section}{\numberline{20}Other names} +\subsubsection*{Other names} +Try to work out how to make this + \command{person} feature work with names + like: +\begin{itemize*} +\item Blanca Maria Bartosova de Paul +\item Patricia Maria Soria de Miguel +\item Arnaud de la Villèsbrunne +\item Prince +\item Pope John Paul II +\end{itemize*} + +Hints: the command \command{space} produces a + normal space, and one way around \LaTeX{}'s requirements + on spaces after command names ending with a letter is to + follow such commands with an empty set of curly braces + \verb+{}+. +\end{exercise} +\section{Macros and environments} +\label{macenv} + +As mentioned in \S\thinspace\ref{fancybox}, it is possible + to define macros to capture text in an environment and reuse + it afterwards. This avoids any features of the subsequent use + affecting the formatting of the text. + +One example of this uses the facilities of the + \package{fancybox} package, which defines a + variety of framed boxes to highlight your text, and a special + environment \env{Sbox} which + `captures' your text for use in these + boxes. +\begin{example} +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\begin{Sbox} +\begin{minipage}{3in} +This text is formatted to the specifications +of the minipage environment in which it +occurs. + +Having been typeset, it is held in the Sbox +until it is needed, which is after the end +of the minipage, where you can (for example) +align it and put it in a special framed box. +\end{minipage} +\end{Sbox} +\begin{flushright} +\shadowbox{\theSbox} +\end{flushright} + \end{Verbatim} +\end{sourcecode}\vspace*{-\baselineskip}\begin{quote}\fontencoding{T1}\fontfamily{cmr}\selectfont\def\sfdefault{cmss}\def\bfdefault{bf}\noindent +\begin{sidebar} +This text is formatted to the specifications of the + minipage environment in which it occurs. + +Having been typeset, it is held in the Sbox until it + is needed, which is after the end of the minipage, where + you can (for example) centre it and put it in a special + framed box. +\end{sidebar}\end{quote}\end{example} + +By putting the text (here in a + \env{minipage} environment because we want to + change the width) inside the \env{Sbox} + environment, it is typeset into memory and stored in the macro + \command{theSbox}. It can then be used afterwards as + the argument of the \command{shadowbox} command (and + in this example it has also been centred). +\section{Reprogramming \LaTeX{}'s internals} +\label{reprog} + +\LaTeX{}'s internal macros can also be reprogrammed or + even rewritten entirely, although doing this can require a + considerable degree of expertise. Simple changes, however, are + easily done. + +Recall that \LaTeX{}'s default document structure for + the Report document class uses Chapters as the main unit of + text, whereas in reality most reports are divided into + Sections, not Chapters (\S\thinspace\ref{repchap}). The result + of this is that if you start off your report with + \verb+\section{Introduction}+, it will print + as + +{\Large{}\fontseries{b}\selectfont{}0.1\quad Introduction\emstrut} + +\noindent which is not at all what you want. The zero is + caused by it not being part of any chapter. But this numbering + is controlled by macros, and you can redefine them. In this + case it's a macro called \verb+\thesection+ + which reproduces the current section number counter (see the last paragraph of \S\thinspace\ref{thecounter}). It's redefined afresh in each + document class file, using the command + \command{renewcommand} (in this case in + \url+texmf/tex/latex/base/report.cls+): +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand \thesection + {\thechapter.\@arabic\c@section} + \end{Verbatim} +\end{sourcecode} + +You can see it invokes \command{thechapter} + (which is defined elsewhere to reproduce the value of the + \counter{chapter} counter), and it + then prints a dot, followed by the Arabic value of the counter + called \counter{section} (that + \verb+\c@+ notation is \LaTeX{}'s internal way + of referring to counters). You can redefine this in your + preamble to simply leave out the reference to chapters: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\renewcommand{\thesection}{\arabic{section}} + \end{Verbatim} +\end{sourcecode} + +I've used the more formal method of enclosing the + command being redefined in curly braces. For largely + irrelevant historical reasons these braces are often omitted + in \LaTeX{}'s internal code (as you may have noticed in + the example earlier). And I've also used the + `public' macro + \command{arabic} to output the value of \counter{section} (\LaTeX{}'s internals + use a `private' set of control + sequences containing \verb+@+-signs, designed to + protect + them against being changed accidentally). + +Now the introduction to your report will start + with: + +{\Large{}\fontseries{b}\selectfont{}1\quad Introduction\emstrut} + +What's important is that you \emph{don't + ever} need to alter the original document class + file \url+report.cls+: you just copy the + command you need to change into your own document preamble, + and modify that instead. It will then override the + default. +\subsection{Changing list item bullets} +\label{bullets} + +As mentioned earlier (\S\thinspace\ref{labelitem}), + here's how to redefine a bullet for an itemized list, + with a slight tweak: +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +\usepackage{bbding} +\renewcommand{\labelitemi}{% + \raisebox{-.25ex}{\PencilRight}} + \end{Verbatim} +\end{sourcecode} + +Here we use the \package{bbding} package + which has a large selection of + `dingbats' or little icons, and we + make the label for top-level itemized lists print a + right-pointing pencil (the names for the icons are in the + package documentation: see \S\thinspace\ref{packagedoc} for + how to get it). + +In this case, we are using the + \command{raisebox} command within the redefinition + because it turns out that the symbols in this font are + positioned slightly too high for the typeface we're + using. The \command{raisebox} command takes two + arguments: the first is a dimension, how much to raise the + object by (and a negative value means + `lower': there is no need for a + \verb+\lowerbox+ command); and the second is + the text you want to affect. Here, we are shifting the + symbol down by ¼ex (see \S\thinspace\ref{dimensions} + for a + list of dimensions \LaTeX{} can use). + +There is a vast number of symbols available: see + \titlecite{symbol-list} for a + comprehensive list. +\chapter{Compatibility with other systems} +\label{compat} + +As we saw in \chaptername~\ref{plaintext}, \LaTeX{} uses + plain-text files, so they can be read and written by any + standard application that can open text files. This helps + preserve your information over time, as the plain-text format + cannot be obsoleted or hijacked by any manufacturer or sectoral + interest, and it will always be readable on any computer, from + your handheld (yes, \LaTeX{} is available for some PDA\index{PDA@PDA}s, see Figure~\ref{zaurus}) to the + biggest supercomputer. +\begin{figure}\small +\caption{\small \LaTeX{} editing and processing on the Sharp Zaurus 5500 + PDA} +\label{zaurus} +\begin{center} +\includegraphics[width=0.3\textwidth]{zedit}\quad\includegraphics[width=0.3\textwidth]{zlatex}\quad\includegraphics[width=0.3\textwidth]{qpdf} +\end{center} +\end{figure} + +However, \LaTeX{} is intended as the last stage of the + editorial process: formatting for print or display. If you have + a requirement to re-use the text in some other + environment\mdash{}a database perhaps, or on the Web or a + CD-ROM\index{CD-ROM@CD-ROM} or DVD\index{DVD@DVD}, or in Braille or voice output\mdash{}then + it should probably be edited, stored, and maintained in + something neutral like the Extensible Markup + Language (XML)\index{XML@XML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!XML@XML|textbf}, and only converted to \LaTeX{} when a + typeset copy is needed. + +Although \LaTeX{} has many structured-document features in + common with SGML\index{SGML@SGML} and XML\index{XML@XML}, it can still only be processed by the + \LaTeX{} and \product{pdf\LaTeX{}} programs. + Because its macro features make it almost infinitely + redefinable, processing it requires a program which can unravel + arbitrarily complex macros, and \LaTeX{} and its siblings are + the only programs which can do that effectively. Like other + typesetters and formatters (Quark + \product{XPress}, + \product{PageMaker}, + \product{FrameMaker}, Microsoft + \product{Publisher}, \product[3]{3B2} etc.), \LaTeX{} is largely a + one-way street leading to typeset printing or display + formatting. + +Converting \LaTeX{} to some other format therefore means you + will unavoidably lose some formatting, as \LaTeX{} has features + that others systems simply don't possess, so they cannot be + translated\mdash{}although there are several ways to minimise + this loss. Similarly, converting other formats into \LaTeX{} + often means editing back the stuff the other formats omit + because they only store appearances, not structure. + +However, there are at least two excellent systems for + converting \LaTeX{} directly to HyperText + Markup Language (HTML)\index{HTML@HTML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!HTML@HTML|textbf} so you can publish it on the web, as + we shall see in \S\thinspace\ref{latexto}. +\section{Converting into \LaTeX{}} +\label{tolatex} + +There are several systems which will save their text in + \LaTeX{} format. The best known is probably the \LyX{} editor + (see Figure~\ref{lyxwin}), which is a wordprocessor-like + interface to \LaTeX{} for Windows and Unix. Both the + \product{AbiWord} and + \product{Kword} wordprocessors on Linux + systems have a very good \textbf{Save As}\dots \LaTeX{} + output, so they can be used to open Microsoft + \product{Word} documents and convert to + \LaTeX{}. Several maths packages like the + \product{EuroMath} editor, and the + \product{Mathematica} and + \product{Maple} analysis packages, can also + save material in \LaTeX{} format. + +In general, most other wordprocessors and DTP systems + either don't have the level of internal markup + sophistication needed to create a \LaTeX{} file, or they lack + a suitable filter to enable them to output what they do have. + Often they are incapable of outputting any kind of structured + document, because they only store what the text looks like, + not why it's there or what role it fulfills. There are + two ways out of this: +\begin{itemize} +\item +Use the \menuitem{File}{Save + As\dots } menu item to save the + wordprocessor file as HTML\index{HTML@HTML}, + rationalise the HTML\index{HTML@HTML} using + \person{Dave Raggett}'s \product{HTML + Tidy}\footnote{\url+http://tidy.sourceforge.net/+}, and convert the resulting + Extensible HyperText Markup + Language (XHTML)\index{XHTML@XHTML|textbf}\index{Acronyms@\textbf{Acronyms}, defined!XHTML@XHTML|textbf} to \LaTeX{} with any + of the standard XML\index{XML@XML} tools (see + below). + +\item +Use a specialist conversion tool like EBT's + \product{DynaTag} (supposedly available + from Enigma, if you can persuade them they have a copy to + sell you; or you may still be able to get it from Red Bridge + Interactive\footnote{\url+http://www.rbii.com/+} in Providence, RI). It's + expensive and they don't advertise it, but for bulk + conversion of consistently-marked + \product{Word} files into XML it beats + everything else hands down. The + \product{Word} files + \emph{must} be consistent, though, and must + use named styles from a stylesheet, otherwise no system on + earth is going to be able to guess what it means. + +\end{itemize} + +There is of course a third way, suitable for large volumes + only: send it off to the Pacific Rim to be retyped into XML or + \LaTeX{}. There are hundreds of companies from India to + Polynesia who do this at high speed and low cost with very + high accuracy. It sounds crazy when the document is already in + electronic form, but it's a good example of the problem + of low quality of wordprocessor markup that this solution + exists at all. + +You will have noticed that most of the solutions lead to + one place: SGML\index{SGML@SGML}\footnote{The Standard Generalized Markup + Language (SGML)\index{SGML@SGML|textbf}\index{Acronyms@\string\textbf{Acronyms}, defined!SGML@SGML|textbf} itself is little used now for new + projects, as the software support for its daughter + XML\index{XML@XML} is far greater, but there + are still hundreds of large document repositories in + SGML\index{SGML@SGML} still growing their collection by + adding documents.} or XML\index{XML@XML}. As explained + above and elsewhere, these formats are the only ones devised + so far capable of storing sufficient information in + machine-processable, publicly-accessible form to enable your + document to be recreated in multiple output formats. Once + your document is in XML\index{XML@XML}, there is a + large range of software available to turn it into other + formats, including \LaTeX{}. Processors in any of the common + SGML\index{SGML@SGML}/XML\index{XML@XML} + processing languages like the Document + Style Semantics and Specification Language (DSSSL)\index{DSSSL@DSSSL|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DSSSL@DSSSL|textbf}, the + Extensible Stylesheet Language + [Transformations] (XSLT)\index{XSLT@XSLT|textbf}\index{Acronyms@\textbf{Acronyms}, defined!XSLT@XSLT|textbf}, + \product{Omnimark}, + \product{Metamorphosis}, + \product{Balise}, etc. can easily be written + to output \LaTeX{}, and this approach is extremely + common. + +Much of this will be simplified when wordprocessors + support native, arbitrary XML\index{XML@XML}/XSLT\index{XSLT@XSLT} as a + standard feature, because \LaTeX{} output will become much + simpler to produce. +\begin{itemize} +\item +Sun's \product{Star Office} and + its Open Source sister, + \product{OpenOffice}, have used XML as + their native file format for several years, and there is a + project at the Organisation for the + Advancement of Structured Information Systems (OASIS)\index{OASIS@OASIS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!OASIS@OASIS|textbf} + for developing a common XML\index{XML@XML} + office file format based on those used by these two + packages, which has been proposed to the International Organization for + Standardization (ISO)\index{ISO@ISO|textbf}\index{Acronyms@\textbf{Acronyms}, defined!ISO@ISO|textbf} in Geneva as a candidate for + an International Standard. + +\item +\product{WordPerfect} has also had a + native SGML\index{SGML@SGML} (and now XML\index{XML@XML}) editor for many years, which will + work with any Document Type + Definition (DTD)\index{DTD@DTD|textbf}\index{Acronyms@\textbf{Acronyms}, defined!DTD@DTD|textbf} (but not a Schema; and at the time + of writing (2005) it still used a proprietary stylesheet + format). + +\item +Microsoft has had a half-hearted `Save + As\dots XML' for a while, using an + internal and formerly largely undocumented Schema (recently + published at last). The + `Professional' versions of + \product{Word} and + \product{Excel} in + \product{Office 11} (Office 2003 for + XP) now have full support for arbitrary Schemas and a real + XML\index{XML@XML} editor, albeit with a rather + primitive interface, but there is no conversion to or from + \product{Word}'s + \url+.doc+ format.\footnote{Which is silly, given that Microsoft used to make + one of the best + \product{Word}-to-SGML\index{SGML@SGML} converters ever, which was + bi-directional (yes, it could round-trip + \product{Word} to SGML\index{SGML@SGML} and back to + \product{Word} and back into SGML\index{SGML@SGML}). But they dropped it on the + floor when XML\index{XML@XML} + arrived.} + +However, help comes in the shape of \person{Ruggero Dambra's + } \product{WordML2\LaTeX{}}, + which is an XSLT\index{XSLT@XSLT} stylesheet to + transform an XML\index{XML@XML} document in + this internal Schema (WordML) into \LaTeXe{} format. + Download it from + any CTAN\index{CTAN@CTAN} server in + \url+/support/WordML2LaTeX+. + +\item\label{rtf2latex2e} +Among the conversion programs on CTAN\index{CTAN@CTAN} is \person{Ujwal Sath\-yam}'s \product{rtf2latex2e}, + which converts Rich Text + Format (RTF)\index{RTF@RTF|textbf}\index{Acronyms@\textbf{Acronyms}, defined!RTF@RTF|textbf} files (output by many wordprocessors) + to \LaTeXe{}. The package + description says it has support for figures and tables, + equations are read as figures, and it can the handle the + latest RTF\index{RTF@RTF} versions from + Microsoft Word 97/98/2000, StarOffice, and other + wordprocessors. It runs on Macs, Linux, other Unix + systems, and Windows. + +\end{itemize} + +When these efforts coalesce into generalised support for + arbitrary DTD\index{DTD@DTD}s and Schemas, it will + mean a wider choice of editing interfaces, and when they + achieve the ability to run XSLT\index{XSLT@XSLT} + conversion into + \LaTeX{} from within these editors, such as is done at the + moment with \product{Emacs} or + \product{XML Spy}, we will have full + convertability. +\subsection{Getting \LaTeX{} out of XML} + +Assuming you can get your document out of its + wordprocessor format into XML\index{XML@XML} by + some method, here is a very brief example of how to turn it + into \LaTeX{}. + +You can of course buy and install a fully-fledged + commercial XML\index{XML@XML} editor with + XSLT\index{XSLT@XSLT} support, and run this + application within it. However, this is beyond the reach of + many users, so to do this unaided you just need to install + three pieces of software: \product{Java}\footnote{\url+http://java.sun.com/j2se/1.4.2/download.html+}, + \product{Saxon}\footnote{\url+http://saxon.sourceforge.net/+} + and the DocBook + 4.2 DTD\footnote{\url+http://www.docbook.org/xml/4.2/index.html+} (URI\index{URI@URI}s are + correct at the time of writing). None of these has a visual + interface: they are run from the command-line in the same + way as is possible with \LaTeX{}. + +As an example, let's take the above paragraph, as typed + or imported into \product{AbiWord} (see + Figure~\ref{abidoc}). This is stored as a single + paragraph with highlighting on the product names (italics), + and the names are also links to their Internet sources, just + as they are in this document. This is a convenient way to + store two pieces of information in the same place. +\begin{figure}\small +\caption{\small Sample paragraph in + \emph{AbiWord} converted to XML\index{XML@XML}} +\label{abidoc} +\begin{center} +\includegraphics[width=1\textwidth]{abiword} +\end{center} +\end{figure} + +\product{AbiWord} can export in DocBook + format, which is an XML\index{XML@XML} vocabulary + for describing technical (computer) documents\ndash{}it's + what I use for this book. \product{AbiWord} + can also export \LaTeX{}, but we're going make our own + version, working from the XML\index{XML@XML} + (Brownie points for the reader who can guess why I'm not + just accepting the \LaTeX{} conversion output). + +Although \product{AbiWord}'s default is + to output an XML\index{XML@XML} \texttt{book} document + type, we'll convert it to a \LaTeX{} article document class. + Notice that \product{AbiWord} has correctly + output the expected section and title markup empty, even + though it's not used. Here's the XML\index{XML@XML} output (I've changed the linebreaks + to keep it within the bounds of this page size): +\begin{sourcecode}\begin{Verbatim}[fontsize=\tiny] +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" + "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> +<book> +<!-- ===================================================================== --> +<!-- This DocBook file was created by AbiWord. --> +<!-- AbiWord is a free, Open Source word processor. --> +<!-- You may obtain more information about AbiWord at www.abisource.com --> +<!-- ===================================================================== --> + <chapter> + <title></title> + <section role="unnumbered"> + <title></title> + <para>You can of course buy and install a fully-fledged commercial XML +editor with XSLT support, and run this application within it. However, this +is beyond the reach of many users, so to do this unaided you just need to +install three pieces of software: <ulink +url="http://java.sun.com/j2se/1.4.2/download.html"><emphasis>Java</emphasis></ulink>, +<ulink +url="http://saxon.sourceforge.net"><emphasis>Saxon</emphasis></ulink>, and +the <ulink url="http://www.docbook.org/xml/4.2/index.html">DocBook 4.2 DTD</ulink> +(URIs are correct at the time of writing). None of these has a visual +interface: they are run from the command-line in the same way as is possible +with L<superscript>A</superscript>T<subscript>E</subscript>X.</para> + </section> + </chapter> +</book> + \end{Verbatim} +\end{sourcecode} + +The XSLT\index{XSLT@XSLT} language lets us + create templates for each type of element in an XML\index{XML@XML} document. In our example, there are + only three which need handling, as we did not create chapter + or section titles (DocBook requires them to be present, but + they don't have to be used). +\begin{itemize} +\item +\texttt{para}, for the + paragraph[s]; + +\item +\texttt{ulink}, for the URIs; + +\item +\texttt{emphasis}, for the + italicisation. + +\end{itemize} + +I'm going to cheat over the superscripting and + subscripting of the letters in the \LaTeX{} logo, and use my + editor to replace the whole thing with the + \command{LaTeX} command. In the other three cases, + we already know how \LaTeX{} deals with these, so we can + write our templates (see Figure~\ref{xslcode}). +\begin{figure}\small +\caption{\small XSLT\index{XSLT@XSLT} script to convert the + paragraph} +\label{xslcode} +\begin{sourcecode}\begin{Verbatim}[fontsize=\footnotesize] +<?xml version="1.0" encoding="utf-8"?> +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0"> + <xsl:output method="text"/> + + <xsl:template match="/"> + <xsl:text>\documentclass{article} +\usepackage{url}</xsl:text> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="book"> + <xsl:text>\begin{document}</xsl:text> + <xsl:apply-templates/> + <xsl:text>\end{document}</xsl:text> + </xsl:template> + + <xsl:template match="para"> + <xsl:apply-templates/> + <xsl:text>
</xsl:text> + </xsl:template> + + <xsl:template match="ulink"> + <xsl:apply-templates/> + <xsl:text>\footnote{\url{</xsl:text> + <xsl:value-of select="@url"/> + <xsl:text>}}</xsl:text> + </xsl:template> + + <xsl:template match="emphasis"> + <xsl:text>\emph{</xsl:text> + <xsl:apply-templates/> + <xsl:text>}</xsl:text> + </xsl:template> + +</xsl:stylesheet> + \end{Verbatim} +\end{sourcecode} +\end{figure} + +If you run this through + \product{Saxon}, which is an XSLT\index{XSLT@XSLT} processor, you can output a \LaTeX{} + file which you can process and view (see Figure~\ref{paraview}). +\begin{sourcecode}\begin{Verbatim}[fontsize=\scriptsize] +$ java -jar /usr/local/saxonb8-0/saxon8.jar -o para.ltx \ +para.dbk para.xsl +$ latex para.ltx +This is TeX, Version 3.14159 (Web2C 7.3.7x) +(./para.ltx +LaTeX2e <2001/06/01> +Loading CZ hyphenation patterns: Pavel Sevecek, v3, 1995 +Loading SK hyphenation patterns: Jana Chlebikova, 1992 +Babel <v3.7h> and hyphenation patterns for english, +dumylang, nohyphenation, czech, slovak, german, ngerman, +danish, spanish, catalan, finnish, french, ukenglish, greek, +croatian, hungarian, italian, latin, mongolian, dutch, +norwegian, polish, portuguese, russian, ukrainian, +serbocroat, swedish, loaded. +(/usr/TeX/texmf/tex/latex/base/article.cls +Document Class: article 2001/04/21 v1.4e Standard LaTeX +document class (/usr/TeX/texmf/tex/latex/base/size10.clo)) +(/usr/TeX/texmf/tex/latex/ltxmisc/url.sty) (./para.aux) +[1] (./para.aux) ) +Output written on para.dvi (1 page, 1252 bytes). +Transcript written on para.log. +$ xdvi para & + \end{Verbatim} +\end{sourcecode} +\begin{figure}\small +\caption{\small Displaying the typeset paragraph} +\label{paraview} +\begin{center} +\includegraphics[width=0.6\textwidth]{para} +\end{center} +\begin{sourcecode}\begin{Verbatim}[fontsize=\scriptsize] +\documentclass{article}\usepackage{url}\begin{document} + + You can of course buy and install a fully-fledged commercial +XML editor with XSLT support, and run this application within it. +However, this is beyond the reach of many users, so to do this +unaided you just need to install three pieces of software: +\emph{Java}\footnote{\url{http://java.sun.com/j2se/1.4.2/download.html}}, +\emph{Saxon}\footnote{\url{http://saxon.sourceforge.net}}, and the +DocBook 4.2 DTD\footnote{\url{http://www.docbook.org/xml/4.2/index.html}} +(URIs are correct at the time of writing). None of these has a visual +interface: they are run from the command-line in the same way as is +possible with \LaTeX. + +\end{document} + \end{Verbatim} +\end{sourcecode} +\end{figure} + +Writing XSLT\index{XSLT@XSLT} is not hard, but + requires a little learning. The output method here is + \verb+text+, which is \LaTeX{}'s file format + (XSLT\index{XSLT@XSLT} can also output HTML\index{HTML@HTML} and other formats of XML). +\begin{enumerate}\item +The first template matches + `\verb+/+', which is + the document root (before the \texttt{book} + start-tag). At this stage we output the text + \verb+\documentclass{article}+ and + \verb+\usepackage{url}+. The + `\verb+apply-templates+' + instructions tells the processor to carry on processing, + looking for more matches. XML\index{XML@XML} + comments get ignored, and any elements which don't match + a template simply have their contents passed through + until the next match occurs. + +\item +The \texttt{book} template outputs the + \verb+\begin{document}+ and the + \verb+\end{document}+ commands, and between + them to carry on processing. + +\item +The \texttt{para} template just outputs + its content, but follows it with a linebreak (using the + hexadecimal character code \verb+x000A+ (see + the ASCII\index{ASCII@ASCII} chart in Table~\ref{asciicodes}). + +\item +The \texttt{ulink} template outputs its + content but follows it with a footnote using the + \command{url} command to output the value of + the \texttt{url} attribute. + +\item +The \texttt{emphasis} template surrounds + its content with \verb+\emph{+ and + \verb+}+. + +\end{enumerate} + +This is a relatively trivial example, but it serves to + show that it's not hard to output \LaTeX{} from XML\index{XML@XML}. In fact there is a set of templates + already written to produce \LaTeX{} from a DocBook file at + \url+http://www.dpawson.co.uk/docbook/tools.html#d4e2905+ +\section{Converting out of \LaTeX{}} +\label{latexto} + +This is much harder to do comprehensively. As noted + earlier, the \LaTeX{} file format really requires the \LaTeX{} + program itself in order to process all the packages and + macros, because there is no telling what complexities authors + have added themselves (what a lot of this book is + about!). + +Many authors and editors rely on custom-designed or + homebrew converters, often written in the standard shell + scripting languages (Unix shells, Perl, Python, Tcl, etc). + Although some of the packages presented here are also written + in the same languages, they have some advantages and + restrictions compared with private conversions: +\begin{itemize} +\item +Conversion done with the standard utilities (eg awk, + tr, sed, grep, detex, etc) can be faster for + \emph{ad hoc} translations, but it + is easier to obtain consistency and a more sophisticated + final product using + \LaTeX{}2HTML\index{HTML@HTML} or + \TeX{}4ht\mdash{}or one of the other systems + available. + +\item +Embedding additional non-standard control sequences in + \LaTeX{} source code may make it harder to edit and + maintain, and will definitely make it harder to port to + another system. + +\item +Both the above methods (and others) provide a fast and + reasonable reliable way to get documents authored in + \LaTeX{} onto the Web in an acceptable\mdash{}if not + optimal\mdash{}format. + +\item +\LaTeX{}2HTML\index{HTML@HTML} was written to + solve the problem of getting \LaTeX{}-with-mathematics + onto the Web, in the + days before MathML and math-capable browsers. + \TeX{}4ht was written to turn \LaTeX{} documents into Web + hypertext\mdash{}mathematics or not. + +\end{itemize} +\subsection{Conversion to \emph{Word}} + +There are several programs on CTAN\index{CTAN@CTAN} to do + \LaTeX{}-to-\product{Word} and similar + conversions, but they do not all handles everything \LaTeX{} + can throw at them, and some only handle a subset of the + built-in commands of default + \LaTeX{}. Two in particular, however, have a good + reputation, although I haven't used either of them (I stay + as far away from \product{Word} as + possible): +\begin{itemize} +\item +\product{latex2rtf} by \person{Wilfried Hennings}, \person{Fernando Dorner}, and \person{Andreas Granzer} translates + \LaTeX{} into RTF\index{RTF@RTF}\mdash{}the + opposite of the \product{rtf2latex2e} + mentioned in item~\ref{rtf2latex2e}the list on p.\thinspace\pageref{rtf2latex2e}. RTF\index{RTF@RTF} can be read by most + wordprocessors, and this program preserves layout and + formatting for most \LaTeX{} documents using standard + built-in commands. + +\item +\person{Kirill Chikrii}'s \product[tex2word]{\TeX{}2Word} for + Microsoft Windows is a converter plug-in for + \product{Word} to let it open \TeX{} + and \LaTeX{} documents. The author's company claims that + `virtually any existing \TeX{}/\LaTeX{} package + can be supported by \product[tex2word]{\TeX{}2Word}' + because it is customisable. + +\end{itemize} + +One easy route into wordprocessing, however, is the + reverse of the procedures suggested in the preceding + section: convert \LaTeX{} to HTML\index{HTML@HTML}, + which many wordprocessors read easily. The following + sections cover two packages for this. +\subsection{\emph{\LaTeX{}2HTML}} + +As its name suggests, \LaTeX{}2HTML\index{HTML@HTML} is a system to convert \LaTeX{} + structured documents to HTML\index{HTML@HTML}. Its main task is to reproduce the + document structure as a set of interconnected HTML\index{HTML@HTML} files. Despite using Perl, + \LaTeX{}2HTML\index{HTML@HTML} relies very heavily + on standard Unix facilities like the + \product{NetPBM} graphics package and the + pipe syntax. Microsoft Windows is not well suited to this + kind of composite processing, although all the required + facilities are available for download in various forms and + should in theory allow the package to run\mdash{}but reports + of problems are common. +\begin{itemize} +\item +The sectional structure is preserved, and + navigational links are generated for the standard Next, + Previous, and Up directions. + +\item +Links are also used for the cross-references, + citations, footnotes, ToC, and lists of figures and + tables. + +\item +Conversion is direct for common elements like lists, + quotes, paragraph-breaks, type-styles, etc, where there + is an obvious HTML\index{HTML@HTML} + equivalent. + +\item +Heavily formatted objects such as math and diagrams + are converted to images. + +\item +There is no support for homebrew macros. + +\end{itemize} + +There is, however, support for arbitrary hypertext + links, symbolic cross-references between `evolving + remote documents', conditional text, and the + inclusion of raw HTML\index{HTML@HTML}. These are + extensions to + \LaTeX{}, implemented as new commands and + environments. + +\LaTeX{}2HTML\index{HTML@HTML} outputs a + directory named after the input filename, and all the output + files are put in that directory, so the output is + self-contained and can be uploaded to a server as it + stands. +\subsection{\emph{\TeX{}4ht}} + +\TeX{}4ht operates differently from + \LaTeX{}2HTML\index{HTML@HTML}: it uses the \TeX{} + program to process the file, and handles conversion in a set + of postprocessors for the common \LaTeX{} packages. It can + also output to XML\index{XML@XML}, including Text Encoding + Initiative (TEI)\index{TEI@TEI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TEI@TEI|textbf} and DocBook, and the OpenOffice and + WordXML formats, and it can create \TeX{}info format + manuals. + +By default, documents retain the single-file structure + implied by the original, but there is again a set of + additional configuration directives to make use of the + features of hypertext and navigation, and to split files for + ease of use. +\subsection{Extraction from PS and PDF} + +If you have the full version of Adobe + \product{Acrobat}, you can open a PDF\index{PDF@PDF} file created by + \product{pdf\LaTeX{}}, select and copy all the + text, and paste it into \product{Word} and + some other wordprocessors, and retain some common formatting + of headings, paragraphs, and lists. Both solutions still + require the wordprocessor text to be edited into shape, but + they preserve enough of the formatting to make it worthwhile + for short documents. Otherwise, use the + \product{pdftotext} program to extract + everything from the PDF\index{PDF@PDF} file as + plain (paragraph-formatted) text. +\subsection{Last resort: strip the markup} + +At worst, the \product{detex} program + on CTAN\index{CTAN@CTAN} will strip a \LaTeX{} file + of all markup and leave just the raw unformatted text, which + can then be re-edited. There are also programs to extract + the raw text from DVI\index{DVI@DVI} and PostScript (PS)\index{PS@PS|textbf}\index{Acronyms@\textbf{Acronyms}, defined!PS@PS|textbf} files. +\appendix +\chapter{Configuring \TeX{} search paths} +\label{cnf} + +\TeX{} systems run on a huge variety of platforms, and are + typically made up of a large number of rather small files. Some + computer operating systems have problems with packages like + this, as their built-in methods for searching for a file when + needed are poor. + +To get around this, \TeX{} uses a technique borrowed from the + Unix world, based on a simple hash index for each directory they + need to look in. This is known as the ls-R database, from the + Unix command (\verb+ls -R+) which creates it. The + program which does this for \TeX{} is actually called after this + command: \product{mktexlsr}, although it may be + renamed \product{texhash} or something else on + your system. This is the program referred to in step~\ref{texindex} in the procedure on p.\thinspace\pageref{texindex}. + +However, to know where to make these indexes, and thus where + to search, \TeX{} needs to be told about them. In a standard + \TeX{} installation this information is in + \url+texmf/web2c/texmf.cnf+. The file is similar + to a Unix shell script, but the only lines of significance for + the search paths are the following (this is how they appear in + the default Unix installation, omitting the comments): +\begin{sourcecode}\begin{Verbatim}[fontsize=\small] +TEXMFMAIN = /usr/TeX/texmf +TEXMFLOCAL = /usr/TeX/texmf-local +HOMETEXMF = $HOME/texmf +TEXMF = {$HOMETEXMF,!!$TEXMFLOCAL,!!$TEXMFMAIN} +SYSTEXMF = $TEXMF +VARTEXFONTS = /var/lib/texmf +TEXMFDBS = $TEXMF;$VARTEXFONTS + \end{Verbatim} +\end{sourcecode} + +As you can see, this defines where the main \TeX{}/\mf{} + directory is, where the local one is, and where the user's + personal (home) one is. It then defines the order in which they + are searched, and makes this the system-wide list. A temporary + directory for bitmap fonts is set up, and added to the list, + defining the places in which \product{texhash} + or \product{mktexlsr} creates its + databases. + +In some installations, the local directory is set up in + \url+/usr/local/share/texmf+ or + \url+/usr/share/texmf.local+ or similar + variations, so you would substitute this name for + \url+/usr/TeX/texmf-local+. Under Microsoft + Windows, the names will be full paths such as + \url+C:\Program Files\TeXLive\texmf+. On an Apple + Mac, it might be \url+Hard + Disk:TeX:texmf+. + +If you edit plain-text configuration files with anything + other than a plain-text editor (e.g. a wordprocessor), or + if you edit them with a plain-text editor which has been set to + word-wrap long lines, make sure you turn line-wrapping + \emph{off} so that any long lines are preserved in + their correct format. +\chapter{\TeX{} Users Group membership} +\label{tugform} + +The \TeX{} Users Group (TUG)\index{TUG@TUG|textbf}\index{Acronyms@\textbf{Acronyms}, defined!TUG@TUG|textbf} was + founded in 1980 for educational and scientific purposes: to + provide an organization for those who have an interest in + typography and font design, and are users of the \TeX{} + typesetting system invented by Donald Knuth. + TUG is run by and for its members and represents the interests + of \TeX{} users worldwide. +\subsection*{TUG membership benefits}\addcontentsline{toc}{subsection}{TUG membership benefits} + +Members of TUG help to support and promote the use of + \TeX{}, \mf{}, and related systems worldwide. All members + receive \titlecite{tugboat}, + the journal of the \TeX{} Users Group, the \TeX{} Live software + distribution (a runnable \TeX{} system), and the CTAN\index{CTAN@CTAN} software distribution (containing most + of the CTAN\index{CTAN@CTAN} archive). + +In addition, TUG members vote in TUG elections, and + receive discounts on annual meeting fees, store purchases, and + TUG-sponsored courses. TUG membership (less benefits) is + tax-deductible, at least in the USA. See the TUG Web site for + details. +\subsection*{Becoming a TUG member}\addcontentsline{toc}{subsection}{Becoming a TUG member} + +Please see the forms and information at \url+http://tug.org/join.html+. You can join + online, or by filling out a paper form. The NTG (Dutch) and + UKTUG (United Kingdom) \TeX{} user groups have joint membership + agreements with TUG whereby you can receive a discount for + joining both user groups. To do this, please join via \url+http://www.ntg.nl/newmember.html+ (the NTG + membership page) or \url+http://uk.tug.org/Membership/+ (the UKTUG + page), respectively, and select the option for joint + membership. + +Each year's membership entitles you to the software and + TUGboat produced for that year (even if it is produced in a + subsequent calendar year, as is currently the case with + TUGboat). You can order older issues of TUGboat and \TeX{} + memorabilia through the TUG store (\url+http://tug.org/store+). + +The current TUG membership fee is \$65 (US) per year + for individuals and \$35 for students and seniors. Add + \$10 to the membership fee after May 31 to cover + additional shipping and processing costs. The current rate for + non-voting subscription memberships (for libraries, for + example) is \$85. The current institutional rate is + \$500, which includes up to seven individual + memberships. +\subsection*{Privacy}\addcontentsline{toc}{subsection}{Privacy} + +TUG uses your personal information only to mail you + products, publications, notices, and (for voting members) + official ballots. Also, if you give explicit agreement, we may + incorporate it into a membership directory which will be made + available only to TUG members. + +TUG neither sells its membership list nor provides it to + anyone outside of its own membership. +\chapter{The ASCII character set} +\label{asciicharset} + +The American Standard Code for Information Interchange was + invented in 1963, and after some redevelopment settled down in + 1984 as standard X3.4 of American National + Standards Institute (ANSI)\index{ANSI@ANSI|textbf}\index{Acronyms@\textbf{Acronyms}, defined!ANSI@ANSI|textbf}. It represents the 95 basic + codes for the unaccented printable characters and punctuation of + the Latin alphabet, plus 33 internal `control + characters' originally intended for the control of + computers, programs, and external devices like printers and + screens. + +Many other character sets (strictly speaking, + `character repertoires') have been standardised for + accented Latin characters and for all other non-Latin writing + systems, but these are intended for representing the symbols + people use when writing text on computers. Most programs and + computers use ASCII\index{ASCII@ASCII} internally for all + their coding, the exceptions being XML\index{XML@XML}-based languages like XSLT\index{XSLT@XSLT}, which are inherently designed to be + usable with any writing system, and a few specialist systems + like APL. + +Although the \TeX{} and \LaTeX{} file formats can easily be + used with many other encoding systems (see the discussion of the + \package{inputenc} in \S\thinspace\ref{accents}), they are based on ASCII\index{ASCII@ASCII}. It is therefore important to know + where to find \emph{all} 95 of the printable + characters, as some of them are not often used in other + text-formatting systems. The following table shows all 128 + characters, with their decimal, octal (base-8), and hexadecimal + (base-16) code numbers. +\begin{table}\small \caption{\small The ASCII characters} +\label{asciicodes} +\begin{center} +\setlength{\tabcolsep}{1mm} +\begin{tabular}{@{}>{$}r<{$\enspace}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\ttfamily}>{\pbs{\centering}}p{1cm}>{\enspace$}l<{$}@{}} +\mbox{\textbf{\sffamily\upshape Oct}}&\textbf{\sffamily\upshape 0}&\textbf{\sffamily\upshape 1}&\textbf{\sffamily\upshape 2}&\textbf{\sffamily\upshape 3}&\textbf{\sffamily\upshape 4}&\textbf{\sffamily\upshape 5}&\textbf{\sffamily\upshape 6}&\textbf{\sffamily\upshape 7}&\mbox{\textbf{\sffamily\upshape Hex}}\\[2pt]\hline\\[-1.5\baselineskip] +'00\UParrow&NUL&SOH&STX&ETX&EOT&ENQ&ACK&BEL&''0\UParrow\\[1mm] +'01\UParrow&BS&HT&LF&VT&FF&CR&SO&SI&''0\DOWNarrow\\[1mm] +'02\UParrow&DLE&DC1&DC2&DC3&DC4&NAK&SYN&ETB&''1\UParrow\\[1mm] +'03\UParrow&CAN&EM&SUB&ESC&FS&GS&RS&US&''1\DOWNarrow\\[1mm] +'04\UParrow&&!&"&\#&\$&\%&\amp &'&''2\UParrow\\[1mm] +'05\UParrow&(&)&*&+&,&-&.&/&''2\DOWNarrow\\[1mm] +'06\UParrow&0&1&2&3&4&5&6&7&''3\UParrow\\[1mm] +'07\UParrow&8&9&:&;&$<$&=&$>$&?&''3\DOWNarrow\\[1mm] +'10\UParrow&@&A&B&C&D&E&F&G&''4\UParrow\\[1mm] +'11\UParrow&H&I&J&K&L&M&N&O&''4\DOWNarrow\\[1mm] +'12\UParrow&P&Q&R&S&T&U&V&W&''5\UParrow\\[1mm] +'13\UParrow&X&Y&Z&[&$\backslash$&]&{\char'136}&{\ttfamily\char'137}&''5\DOWNarrow\\[1mm] +'14\UParrow&\`{}&a&b&c&d&e&f&g&''6\UParrow\\[1mm] +'15\UParrow&h&i&j&k&l&m&n&o&''6\DOWNarrow\\[1mm] +'16\UParrow&p&q&r&s&t&u&v&w&''7\UParrow\\[1mm] +'17\UParrow&x&y&z&{\ttfamily\char'173}&$|$&{\ttfamily\char'175}&{\char'176}&DEL&''7\DOWNarrow\\[1mm] +\\[-1em]\hline\vrule height1.2em width0pt \textbf{}&\textbf{8}&\textbf{9}&\textbf{A}&\textbf{B}&\textbf{C}&\textbf{D}&\textbf{E}&\textbf{F}&\textbf{}\\[1mm] +\end{tabular} +\end{center} +\end{table} + +The index numbers in the first and last columns are for + finding the octal (base-8) and hexadecimal (base-16) values + respectively. Replace the arrow with the number or letter from + the top of the column (if the arrow points up) from the bottom + of the column(if the arrow points down). + +Example: The Escape character (ESC) is octal '033 (03 for + the row, 3 for the number at the top of the column because the + arrow points up) or hexadecimal "1B (1 for the row, B for the + letter at the bottom of the column because the arrow points + down). + +For the decimal value, multiply the Octal row number by + eight and add the column number from the top line (that makes + ESC 27). +\chapter[GNU Free Documentation License]{GNU Free Documentation License\\\LARGE\itshape Version 1.2, November 2002} +\label{gfdl} +\begin{multicols}{2}\small\gfdl +\begin{quotation}\small\begingroup +Copyright (C) 2000,2001,2002 Free Software Foundation, + Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not + allowed. +\par\endgroup\smallskip\footnotesize\noindent \end{quotation} +\setcounter{section}{-1} +\section{PREAMBLE} +\label{gfdl-0} + +The purpose of this License is to make a manual, textbook, + or other functional and useful document `free' in + the sense of freedom: to assure everyone the effective freedom + to copy and redistribute it, with or without modifying it, + either commercially or noncommercially. Secondarily, this + License preserves for the author and publisher a way to get + credit for their work, while not being considered responsible + for modifications made by others. + +This License is a kind of `copyleft', which + means that derivative works of the document must themselves be + free in the same sense. It complements the GNU General Public + License, which is a copyleft license designed for free + software. + +We have designed this License in order to use it for + manuals for free software, because free software needs free + documentation: a free program should come with manuals + providing the same freedoms that the software does. But this + License is not limited to software manuals; it can be used for + any textual work, regardless of subject matter or whether it + is published as a printed book. We recommend this License + principally for works whose purpose is instruction or + reference. +\section{APPLICABILITY AND DEFINITIONS} +\label{gfdl-1} + +\label{gfdl-doc}% +This License applies to any manual or other + work, in any medium, that contains a notice placed by the + copyright holder saying it can be distributed under the terms + of this License. Such a notice grants a world-wide, + royalty-free license, unlimited in duration, to use that work + under the conditions stated herein. The + `Document', below, refers to any such manual or + work. Any member of the public is a licensee, and is + addressed as `you'. You accept the license if + you copy, modify or distribute the work in a way requiring + permission under copyright law. + +\label{gfdl-mod-ver}% +A `Modified Version' of the + Document means any work containing the Document or a portion + of it, either copied verbatim, or with modifications and/or + translated into another language. + +\label{gfdl-secnd-sect}% +A `Secondary Section' is + a named appendix or a front-matter section of the Document + that deals exclusively with the relationship of the publishers + or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that + could fall directly within that overall subject. (Thus, if + the Document is in part a textbook of mathematics, a Secondary + Section may not explain any mathematics.) The relationship + could be a matter of historical connection with the subject or + with related matters, or of legal, commercial, philosophical, + ethical or political position regarding them. + +\label{gfdl-inv-sect}% +The `Invariant Sections' + are certain Secondary Sections whose titles are designated, as + being those of Invariant Sections, in the notice that says + that the Document is released under this License. If a + section does not fit the above definition of Secondary then it + is not allowed to be designated as Invariant. The Document + may contain zero Invariant Sections. If the Document does not + identify any Invariant Sections then there are none. + +\label{gfdl-cov-text}% +The `Cover Texts' are + certain short passages of text that are listed, as Front-Cover + Texts or Back-Cover Texts, in the notice that says that the + Document is released under this License. A Front-Cover Text + may be at most 5 words, and a Back-Cover Text may be at most + 25 words. + +\label{gfdl-transparent}% +A `Transparent' copy of + the Document means a machine-readable copy, represented in a + format whose specification is available to the general public, + that is suitable for revising the document straightforwardly + with generic text editors or (for images composed of pixels) + generic paint programs or (for drawings) some widely available + drawing editor, and that is suitable for input to text + formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in + an otherwise Transparent file format whose markup, or absence + of markup, has been arranged to thwart or discourage + subsequent modification by readers is not Transparent. An + image format is not Transparent if used for any substantial + amount of text. A copy that is not `Transparent' + is called `Opaque'. + +Examples of suitable formats for Transparent copies + include plain ASCII without markup, Texinfo input format, + LaTeX input format, SGML or XML using a publicly available + DTD, and standard-conforming simple HTML\index{HTML@HTML}, + PostScript\index{PostScript} or PDF designed for human + modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats + that can be read and edited only by proprietary word + processors, SGML or XML for which the DTD and/or processing + tools are not generally available, and the machine-generated + HTML\index{HTML@HTML}, PostScript\index{PostScript} or PDF produced by + some word processors for output purposes only. + +\label{gfdl-title-page}% +The `Title Page' means, + for a printed book, the title page itself, plus such following + pages as are needed to hold, legibly, the material this + License requires to appear in the title page. For works in + formats which do not have any title page as such, `Title + Page' means the text near the most prominent + appearance of the work's title, preceding the beginning + of the body of the text. + +\label{gfdl-entitled}% +A section `Entitled XYZ' + means a named subunit of the Document whose title either is + precisely XYZ or contains XYZ in parentheses following text + that translates XYZ in another language. (Here XYZ stands for + a specific section name mentioned below, such as + `Acknowledgements', `Dedications', + `Endorsements', or `History'.) To + `Preserve the Title' of such a section when you + modify the Document means that it remains a section + `Entitled XYZ' according to this + definition. + +The Document may include Warranty Disclaimers next to the + notice which states that this License applies to the Document. + These Warranty Disclaimers are considered to be included by + reference in this License, but only as regards disclaiming + warranties: any other implication that these Warranty + Disclaimers may have is void and has no effect on the meaning + of this License. +\section{VERBATIM COPYING} +\label{gfdl-2} + +You may copy and distribute the Document in any medium, + either commercially or noncommercially, provided that this + License, the copyright notices, and the license notice saying + this License applies to the Document are reproduced in all + copies, and that you add no other conditions whatsoever to + those of this License. You may not use technical measures to + obstruct or control the reading or further copying of the + copies you make or distribute. However, you may accept + compensation in exchange for copies. If you distribute a + large enough number of copies you must also follow the + conditions in section 3. + + +You may also lend copies, under the same conditions stated + above, and you may publicly display copies. +\section{COPYING IN QUANTITY} +\label{gfdl-3} + +If you publish printed copies (or copies in media that + commonly have printed covers) of the Document, numbering more + than 100, and the Document's license notice requires + Cover Texts, you must enclose the copies in covers that carry, + clearly and legibly, all these Cover Texts: Front-Cover Texts + on the front cover, and Back-Cover Texts on the back cover. + Both covers must also clearly and legibly identify you as the + publisher of these copies. The front cover must present the + full title with all words of the title equally prominent and + visible. You may add other material on the covers in + addition. Copying with changes limited to the covers, as long + as they preserve the title of the Document and satisfy these + conditions, can be treated as verbatim copying in other + respects. + +If the required texts for either cover are too voluminous + to fit legibly, you should put the first ones listed (as many + as fit reasonably) on the actual cover, and continue the rest + onto adjacent pages. + +If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, + or state in or with each Opaque copy a computer-network + location from which the general network-using public has + access to download using public-standard network protocols a + complete Transparent copy of the Document, free of added + material. If you use the latter option, you must take + reasonably prudent steps, when you begin distribution of + Opaque copies in quantity, to ensure that this Transparent + copy will remain thus accessible at the stated location until + at least one year after the last time you distribute an Opaque + copy (directly or through your agents or retailers) of that + edition to the public. + +It is requested, but not required, that you contact the + authors of the Document well before redistributing any large + number of copies, to give them a chance to provide you with an + updated version of the Document. +\section{MODIFICATIONS} +\label{gfdl-4} + +You may copy and distribute a Modified Version of the + Document under the conditions of sections 2 and 3 above, + provided that you release the Modified Version under precisely + this License, with the Modified Version filling the role of + the Document, thus licensing distribution and modification of + the Modified Version to whoever possesses a copy of it. In + addition, you must do these things in the Modified + Version: +\begin{enumerate}\renewcommand{\theenumi}{\Alph{enumi}}\item Use in the Title Page (and on the covers, + if any) a title distinct from that of the Document, and + from those of previous versions (which should, if there + were any, be listed in the History section of the + Document). You may use the same title as a previous + version if the original publisher of that version gives + permission. + +\item List on the Title Page, as authors, one or + more persons or entities responsible for authorship of the + modifications in the Modified Version, together with at + least five of the principal authors of the Document (all + of its principal authors, if it has fewer than five), + unless they release you from this requirement. + +\item State on the Title page the name of the + publisher of the Modified Version, as the + publisher. +\item Preserve all the copyright notices of the + Document. + +\item Add an appropriate copyright notice for + your modifications adjacent to the other copyright + notices. + +\item Include, immediately after the copyright + notices, a license notice giving the public permission to + use the Modified Version under the terms of this License, + in the form shown in the Addendum (\S\thinspace\ref{gfdl-addendum}) below. + +\item Preserve in that license notice the full + lists of Invariant Sections and required Cover Texts given + in the Document's license + notice. +\item Include an unaltered copy of this License. + +\item Preserve the section Entitled + `History', Preserve its Title, and add to it + an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title + Page. If there is no section Entitled + `History' in the Document, create one stating + the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the + Modified Version as stated in the previous sentence. + +\item Preserve the network location, if any, + given in the Document for public access to a Transparent + copy of the Document, and likewise the network locations + given in the Document for previous versions it was based + on. These may be placed in the `History' + section. You may omit a network location for a work that + was published at least four years before the Document + itself, or if the original publisher of the version it + refers to gives permission. + +\item For any section Entitled + `Acknowledgements' or + `Dedications', Preserve the Title of the + section, and preserve in the section all the substance and + tone of each of the contributor acknowledgements and/or + dedications given therein. + +\item Preserve all the Invariant Sections of the + Document, unaltered in their text and in their titles. + Section numbers or the equivalent are not considered part + of the section titles. + +\item Delete any section Entitled + `Endorsements'. Such a section may not be + included in the Modified Version. + +\item Do not retitle any existing section to be + Entitled `Endorsements' or to conflict in + title with any Invariant Section. + +\item Preserve any Warranty Disclaimers. + +\end{enumerate} + +If the Modified Version includes new front-matter sections + or appendices that qualify as Secondary Sections and contain + no material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do + this, add their titles to the list of Invariant Sections in + the Modified Version's license notice. These titles must + be distinct from any other section titles. + +You may add a section Entitled + `Endorsements', provided it contains nothing but + endorsements of your Modified Version by various parties--for + example, statements of peer review or that the text has been + approved by an organization as the authoritative definition of + a standard. + +You may add a passage of up to five words as a Front-Cover + Text, and a passage of up to 25 words as a Back-Cover Text, to + the end of the list of Cover Texts in the Modified Version. + Only one passage of Front-Cover Text and one of Back-Cover + Text may be added by (or through arrangements made by) any one + entity. If the Document already includes a cover text for the + same cover, previously added by you or by arrangement made by + the same entity you are acting on behalf of, you may not add + another; but you may replace the old one, on explicit + permission from the previous publisher that added the old + one. + +The author(s) and publisher(s) of the Document do not by + this License give permission to use their names for publicity + for or to assert or imply endorsement of any Modified + Version. +\section{COMBINING DOCUMENTS} +\label{gfdl-5} + +You may combine the Document with other documents released + under this License, under the terms defined in section 4 (\S\thinspace\ref{gfdl-4}) above for modified + versions, provided that you include in the combination all of + the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + +The combined work need only contain one copy of this + License, and multiple identical Invariant Sections may be + replaced with a single copy. If there are multiple Invariant + Sections with the same name but different contents, make the + title of each such section unique by adding at the end of it, + in parentheses, the name of the original author or publisher + of that section if known, or else a unique number. Make the + same adjustment to the section titles in the list of Invariant + Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled + `History' in the various original documents, + forming one section Entitled `History'; likewise + combine any sections Entitled `Acknowledgements', + and any sections Entitled `Dedications'. You + must delete all sections Entitled + `Endorsements'. +\section{COLLECTIONS OF DOCUMENTS} +\label{gfdl-6} + +You may make a collection consisting of the Document and + other documents released under this License, and replace the + individual copies of this License in the various documents + with a single copy that is included in the collection, + provided that you follow the rules of this License for + verbatim copying of each of the documents in all other + respects. + +You may extract a single document from such a collection, + and distribute it individually under this License, provided + you insert a copy of this License into the extracted document, + and follow this License in all other respects regarding + verbatim copying of that document. +\section{AGGREGATION WITH INDEPENDENT + WORKS} +\label{gfdl-7} + +A compilation of the Document or its derivatives with + other separate and independent documents or works, in or on a + volume of a storage or distribution medium, is called an + `aggregate' if the copyright resulting from the + compilation is not used to limit the legal rights of the + compilation's users beyond what the individual works + permit. When the Document is included an aggregate, this + License does not apply to the other works in the aggregate + which are not themselves derivative works of the + Document. + +If the Cover Text requirement of section 3 is applicable + to these copies of the Document, then if the Document is less + than one half of the entire aggregate, the Document's + Cover Texts may be placed on covers that bracket the Document + within the aggregate, or the electronic equivalent of covers + if the Document is in electronic form. Otherwise they must + appear on printed covers that bracket the whole + aggregate. +\section{TRANSLATION} +\label{gfdl-8} + +Translation is considered a kind of modification, so you + may distribute translations of the Document under the terms of + section 4. Replacing Invariant Sections with translations + requires special permission from their copyright holders, but + you may include translations of some or all Invariant Sections + in addition to the original versions of these Invariant + Sections. You may include a translation of this License, and + all the license notices in the Document, and any Warranty + Disclaimers, provided that you also include the original + English version of this License and the original versions of + those notices and disclaimers. In case of a disagreement + between the translation and the original version of this + License or a notice or disclaimer, the original version will + prevail. + +If a section in the Document is Entitled + `Acknowledgements', `Dedications', + or `History', the requirement (section 4) to + Preserve its Title (section 1) will typically require changing + the actual title. +\section{TERMINATION} +\label{gfdl-9} + +You may not copy, modify, sublicense, or distribute the + Document except as expressly provided for under this License. + Any other attempt to copy, modify, sublicense or distribute + the Document is void, and will automatically terminate your + rights under this License. However, parties who have received + copies, or rights, from you under this License will not have + their licenses terminated so long as such parties remain in + full compliance. +\section{FUTURE REVISIONS OF THIS + LICENSE} +\label{gfdl-10} + +The Free Software Foundation may publish new, revised + versions of the GNU Free Documentation License from time to + time. Such new versions will be similar in spirit to the + present version, but may differ in detail to address new + problems or concerns. See + http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing + version number. If the Document specifies that a particular + numbered version of this License `or any later + version' applies to it, you have the option of + following the terms and conditions either of that specified + version or of any later version that has been published (not + as a draft) by the Free Software Foundation. If the Document + does not specify a version number of this License, you may + choose any version ever published (not as a draft) by the Free + Software Foundation. +\section{ADDENDUM: How to use this License + for your documents} +\label{gfdl-addendum} + +To use this License in a document you have written, + include a copy of the License in the document and put the + following copyright and license notices just after the title + page: +\begin{quotation}\small\begingroup + + Copyright (c) YEAR YOUR NAME. Permission is granted to + copy, distribute and/or modify this document under the terms + of the GNU Free Documentation License, Version 1.2 or any + later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no + Back-Cover Texts. A copy of the license is included in the + section entitled `GNU Free Documentation + License'. + +\par\endgroup\smallskip\footnotesize\noindent \end{quotation} + +If you have Invariant Sections, Front-Cover Texts and + Back-Cover Texts, replace the + `with\dots Texts.' line with this: +\begin{quotation}\small\begingroup + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover + Texts being LIST. + +\par\endgroup\smallskip\footnotesize\noindent \end{quotation} + +If you have Invariant Sections without Cover Texts, or + some other combination of the three, merge those two + alternatives to suit the situation. + +If your document contains nontrivial examples of program + code, we recommend releasing these examples in parallel under + your choice of free software license, such as the GNU General + Public License, to permit their use in free software. + +\end{multicols} +\renewcommand{\bibname}{References} +\bibliography{beginlatex} +\bibliographystyle{jurabib} +\begin{VerbatimOut}{beginlatex.bib} +@book{mathguide, + juraauthor = {AMS}, + author = {{}}, + title = {{Short Math Guide for \LaTeX{}}}, + juratitle = {Short Math Guide}, + publisher = {AMS}, + address = {Providence, RI}, + url = {http://www.ams.org/tex/short-math-guide.html}, + year = {2001}, + comment = {Written by XSLT} +} +@techreport{fontname, + author = {Karl Berry}, + title = {{Fontname: Filenames for \TeX{} fonts}}, + url = {http://www.ctan.org/tex-archive/info/fontname/}, + organisation = {\TeX{} Users Group}, + address = {Portland, OR}, + year = {June 2001}, + comment = {Written by XSLT} +} +@book{bull, + author = {RJ Bull}, + title = {{Accounting in Business}}, + publisher = {Butterworths}, + address = {London}, + year = {1972}, + isbn = {0-406-70651-4}, + comment = {Written by XSLT} +} +@techreport{teiguide, + author = {Lou Burnard and Michael Sperberg-McQueen}, + title = {{Guidelines for the Text Encoding Initiative}}, + juratitle = {TEI Guidelines}, + organisation = {OUP}, + address = {Oxford}, + year = {1995}, + comment = {Written by XSLT} +} +@book{davy, + author = {William Davy}, + title = {{A System of Divinity}}, + publisher = {Published by the author}, + address = {Lustleigh, Devon}, + year = {1806}, + comment = {Written by XSLT} +} +@techreport{gentle, + author = {Michael Doob}, + title = {{A Gentle Introduction to \TeX{}: A Manual for Self-Study}}, + juratitle = {Gentle Intro}, + organisation = {\TeX{} Users Group}, + address = {Portland, OR}, + year = {2002}, + url = {http://www.ctan.org/tex-archive/info/gentle/}, + comment = {Written by XSLT} +} +@book{bovary, + author = {Gustave Flaubert}, + title = {{Madame Bovary}}, + address = {Paris}, + year = {1857}, + comment = {Written by XSLT} +} +@book{htmlbook, + author = {Peter Flynn}, + title = {{The HTML Handbook}}, + juratitle = {The HTML Handbook}, + publisher = {International Thompson Computer + Press}, + address = {London}, + isbn = {1-85032-205-8}, + year = {1995}, + comment = {Written by XSLT} +} +@book{sgmltools, + author = {Peter Flynn}, + title = {{Understanding SGML and XML Tools}}, + juratitle = {SGML \amp XML Tools}, + publisher = {Kluwer}, + address = {Boston}, + isbn = {0-7923-8169-6}, + year = {1998}, + comment = {Written by XSLT} +} +@book{fg, + author = {John Fothergill}, + title = {{An Innkeeper's Diary}}, + publisher = {Penguin}, + address = {London}, + edition = {3rd}, + year = {1929}, + comment = {Written by XSLT} +} +@book{companion, + author = {Frank Mittelbach and Michel Goossens and Johannes Braams and David Carlisle and Chris Rowley}, + title = {{The \LaTeX{} Companion}}, + juratitle = {Companion}, + publisher = {Addison-Wesley/Pearson Education}, + address = {Boston, MA}, + edition = {2}, + isbn = {0-201-36299-6}, + year = {2004}, + comment = {Written by XSLT} +} +@book{graphicscomp, + author = {Michel Goossens and Sebastian Rahtz and Frank Mittelbach}, + title = {{The \LaTeX{} Graphics Companion}}, + juratitle = {Graphics Companion}, + publisher = {Addison-Wesley}, + address = {Reading, MA}, + isbn = {0-201-85469-4}, + year = {1997}, + comment = {Written by XSLT} +} +@book{webcomp, + author = {Michel Goossens and Sebastian Rahtz and Ross Moore and Bob Sutor}, + title = {{The \LaTeX{} Web Companion}}, + juratitle = {Web Companion}, + publisher = {Addison-Wesley}, + address = {Reading, MA}, + isbn = {0-201-43311-7}, + year = {1999}, + comment = {Written by XSLT} +} +@article{goreham-ctt, + author = {Anthony Goreham}, + title = {{Re: Installing a new font: PFM, PFB}}, + juratitle = {Installing a new font}, + journal = {\texttt{comp.text.tex}}, + number = {m3r8qj42o3.fsf@micawber.queens.ox.ac.uk}, + pages = {(all pages)}, + year = {28 November 2001}, + comment = {Written by XSLT} +} +@article{heller, + author = {Robert Heller}, + title = {{New To \LaTeX{}\dots Unlearning Bad Habits}}, + juratitle = {Bad habits}, + journal = {\texttt{comp.text.tex}}, + number = {MPG.18d82140d65ddc5898968c@news.earthlink.net}, + pages = {(all pages)}, + year = {11 March 2003}, + comment = {Written by XSLT} +} +@techreport{fontinst, + author = {Alan Jeffrey and Rowland McDonnell}, + title = {{Font installation software for \TeX{}}}, + juratitle = {Fontinst}, + url = {http://www.tex.ac.uk/tex-archive/fonts/utilities/fontinst/}, + organisation = {\TeX{} Users Group}, + year = {30 June 1998}, + comment = {Written by XSLT} +} +@book{aocs, + author = {Donald Ervin Knuth}, + title = {{The Art of Computer Programming}}, + publisher = {Addison-Wesley}, + address = {Reading, MA}, + edition = {2nd}, + volume = {1}, + isbn = {0-201-89685-0}, + year = {1980}, + comment = {Written by XSLT} +} +@book{latexbook, + author = {Leslie Lamport}, + title = {{\LaTeX{}: A Document Preparation System}}, + publisher = {Addison-Wesley}, + address = {Reading, MA}, + isbn = {0-201-52983-1}, + edition = {2nd}, + year = {1994}, + comment = {Written by XSLT} +} +@book{macnamara, + author = {Matthew {Mac Namara}}, + title = {{La Textualisation de \emph{Madame + Bovary}}}, + publisher = {Rodopi}, + address = {Amsterdam}, + year = {2003}, + comment = {Written by XSLT} +} +@techreport{lshort, + author = {Tobias Oetiker and Hubert Partl and Irene Hyna and Elisabeth Schlegl}, + title = {{The (Not So) Short Guide to \LaTeXe{}: \LaTeXe{} in 131 Minutes}}, + juratitle = {Short Guide}, + organisation = {\TeX{} Users Group}, + url = {http://www.ctan.org/tex-archive/info/lshort/}, + year = {2001}, + edition = {3.2}, + comment = {Written by XSLT} +} +@techreport{symbol-list, + author = {Scott Pakin}, + title = {{A comprehensive list of symbols in \TeX{}}}, + juratitle = {Symbol list}, + organisation = {\TeX{} Users Group}, + url = {http://www.ctan.org/tex-archive/info/symbols/comprehensive/}, + year = {2002}, + comment = {Written by XSLT} +} +@techreport{begin, + juraauthor = {TUG}, + author = {{}}, + title = {{Getting Started with \TeX{}, \LaTeX{}, and friends}}, + juratitle = {Getting Started}, + organisation = {\TeX{} Users Group}, + address = {Portland, OR}, + url = {http://www.tug.org/begin.html}, + year = {November 2003}, + comment = {Written by XSLT} +} +@techreport{imported, + author = {Keith Reckdahl}, + title = {{Using imported graphics in \LaTeXe{}}}, + juratitle = {Imported graphics}, + organisation = {\TeX{} Users Group}, + url = {http://www.ctan.org/tex-archive/info/epslatex.pdf/}, + year = {1997}, + edition = {2.0}, + comment = {Written by XSLT} +} +@incollection{tain, + author = {{}}, + title = {{Táin bó Cúailnge}}, + pages = {55}, + booktitle = {Leabhar na h-Uidhri}, + publisher = {Royal Irish Academy}, + address = {Dublin}, + year = {1100}, + comment = {Written by XSLT} +} +@article{varmints, + author = {Marjorie Kinnan Rawlings}, + title = {{Varmints}}, + journal = {Scribner's Magazine}, + year = {1936}, + comment = {Written by XSLT} +} +@book{ryder, + author = {John Ryder}, + title = {{Printing for Pleasure}}, + publisher = {Bodley Head}, + address = {London}, + isbn = {0-370-10443-9}, + year = {1976}, + comment = {Written by XSLT} +} +@techreport{xmlfaq, + author = {Peter Flynn}, + title = {{The XML FAQ}}, + organisation = {University College Cork}, + address = {Cork, Ireland}, + url = {http://www.ucc.ie/xml/}, + year = {January 2005}, + comment = {Written by XSLT} +} +@techreport{gnufdl, + juraauthor = {FSF}, + author = {{}}, + title = {{The GNU Free Documentation License}}, + juratitle = {GNU FDL}, + organisation = {Free Software Foundation}, + address = {Boston, MA}, + url = {http://www.fsf.org/copyleft/fdl.html}, + year = {2003/02/10 + 23:42:49}, + comment = {Written by XSLT} +} +@proceedings{tugboat, + editor = {Barbara Beeton}, + title = {{TUGboat}}, + publisher = {\TeX{} Users Group}, + address = {Portland, OR}, + issn = {0896-3207}, + year = {Since 1980}, + comment = {Written by XSLT} +} +@proceedings{practex, + author = {Lance Carnes and Karl Berry}, + title = {{The Prac\TeX{} Journal}}, + publisher = {\TeX{} Users Group}, + address = {Portland, OR}, + url = {http://www.tug.org/pracjourn/}, + year = {2004}, + comment = {Written by XSLT} +} +@proceedings{wired, + editor = {Chris Anderson}, + title = {{WIRED}}, + publisher = {Cond\'e Nast}, + address = {San Francisco, CA}, + issn = {1059-1028}, + year = {1993--}, + comment = {Written by XSLT} +} +@book{mathwrite, + author = {Donald E Knuth and Tracey Larrabee and Paul M Roberts}, + title = {{Mathematical Writing}}, + publisher = {Mathematical Association of America}, + address = {Washington, DC}, + series = {MAA Notes 14}, + isbn = {0-88385-063-X}, + year = {1989}, + comment = {Written by XSLT} +} +\end{VerbatimOut} +\renewcommand{\indexname}{Index} +\clearpage\section*{\indexname} + +The same fonts are used here as in the text of the book + (see the Introduction on p.\thinspace\pageref{symbols}) to distinguish between different + meanings: +\begingroup\small \begin{center} +\begin{tabular}{@{}ll@{}} +\textbf{\sffamily\upshape Notation}&\textbf{\sffamily\upshape Meaning}\\[2pt]\hline\\[-1.5\baselineskip] +CTAN\index{CTAN@CTAN}&Acronyms (small caps in some typefaces)\\ +\command{command}&\LaTeX{} control sequences (monospace font)\\ +{\fontseries{b}\fontshape{it}\selectfont{}term}&Defining instance of a specialist term (bold + italics)\\ +\product{product}&program or product name (italics)\\ +\env{environment}&\LaTeX{} environment (sans-serif bold)\\ +\package{package}&\LaTeX{} package (sans-serif; all available from + CTAN\index{CTAN@CTAN})\\ +\opt{options}, \counter{variables}&options and variables (oblique)\\ +\end{tabular} +\end{center} +\endgroup +In the online version, the entries below are all hyperlinked to + their source: for clarity the stylesheet recommends retaining + the traditional blue colour but removing the underlining which + most browsers use to indicate a link. + +Page numbers in {\fontseries{b}\selectfont{}bold type} + indicate the defining instance. +\par\parfillskip=0pt plus.5fil +\multicolsep=1.5pc\printindex +\end{document} diff --git a/info/beginlatex/src/old/beginlatex.a4.pdf b/info/beginlatex/src/old/beginlatex.a4.pdf Binary files differnew file mode 100644 index 0000000000..2d219135d5 --- /dev/null +++ b/info/beginlatex/src/old/beginlatex.a4.pdf diff --git a/info/beginlatex/src/old/beginlatex.letter.pdf b/info/beginlatex/src/old/beginlatex.letter.pdf Binary files differnew file mode 100644 index 0000000000..42948ddc97 --- /dev/null +++ b/info/beginlatex/src/old/beginlatex.letter.pdf diff --git a/info/beginlatex/src/old/cmr.jpg b/info/beginlatex/src/old/cmr.jpg Binary files differnew file mode 100644 index 0000000000..7c77167281 --- /dev/null +++ b/info/beginlatex/src/old/cmr.jpg diff --git a/info/beginlatex/src/old/diagram.jpg b/info/beginlatex/src/old/diagram.jpg Binary files differnew file mode 100644 index 0000000000..8c47800944 --- /dev/null +++ b/info/beginlatex/src/old/diagram.jpg diff --git a/info/beginlatex/src/old/fbox.jpg b/info/beginlatex/src/old/fbox.jpg Binary files differnew file mode 100644 index 0000000000..d91cd039dd --- /dev/null +++ b/info/beginlatex/src/old/fbox.jpg diff --git a/info/beginlatex/src/old/fullscreen.jpg b/info/beginlatex/src/old/fullscreen.jpg Binary files differnew file mode 100644 index 0000000000..8a3a5dd6e5 --- /dev/null +++ b/info/beginlatex/src/old/fullscreen.jpg diff --git a/info/beginlatex/src/old/math.jpg b/info/beginlatex/src/old/math.jpg Binary files differnew file mode 100644 index 0000000000..cbe9dfb7c3 --- /dev/null +++ b/info/beginlatex/src/old/math.jpg diff --git a/info/beginlatex/src/old/mirror.jpg b/info/beginlatex/src/old/mirror.jpg Binary files differnew file mode 100644 index 0000000000..90378a0dd1 --- /dev/null +++ b/info/beginlatex/src/old/mirror.jpg diff --git a/info/beginlatex/src/old/p70-01.jpg b/info/beginlatex/src/old/p70-01.jpg Binary files differnew file mode 100644 index 0000000000..cb99a82842 --- /dev/null +++ b/info/beginlatex/src/old/p70-01.jpg diff --git a/info/beginlatex/src/old/p70-02.jpg b/info/beginlatex/src/old/p70-02.jpg Binary files differnew file mode 100644 index 0000000000..e7c626d8f1 --- /dev/null +++ b/info/beginlatex/src/old/p70-02.jpg diff --git a/info/beginlatex/src/old/p70-03.jpg b/info/beginlatex/src/old/p70-03.jpg Binary files differnew file mode 100644 index 0000000000..64c8a030fa --- /dev/null +++ b/info/beginlatex/src/old/p70-03.jpg diff --git a/info/beginlatex/src/old/p70-04.jpg b/info/beginlatex/src/old/p70-04.jpg Binary files differnew file mode 100644 index 0000000000..01f3f0ab67 --- /dev/null +++ b/info/beginlatex/src/old/p70-04.jpg diff --git a/info/beginlatex/src/old/p70-05.jpg b/info/beginlatex/src/old/p70-05.jpg Binary files differnew file mode 100644 index 0000000000..2db786ddc4 --- /dev/null +++ b/info/beginlatex/src/old/p70-05.jpg diff --git a/info/beginlatex/src/old/p70-06.jpg b/info/beginlatex/src/old/p70-06.jpg Binary files differnew file mode 100644 index 0000000000..4a4698d953 --- /dev/null +++ b/info/beginlatex/src/old/p70-06.jpg diff --git a/info/beginlatex/src/old/p70-07.jpg b/info/beginlatex/src/old/p70-07.jpg Binary files differnew file mode 100644 index 0000000000..8d871cb903 --- /dev/null +++ b/info/beginlatex/src/old/p70-07.jpg diff --git a/info/beginlatex/src/old/p70-08.jpg b/info/beginlatex/src/old/p70-08.jpg Binary files differnew file mode 100644 index 0000000000..e455f2f958 --- /dev/null +++ b/info/beginlatex/src/old/p70-08.jpg diff --git a/info/beginlatex/src/old/p70-09.jpg b/info/beginlatex/src/old/p70-09.jpg Binary files differnew file mode 100644 index 0000000000..4e4dc87ee7 --- /dev/null +++ b/info/beginlatex/src/old/p70-09.jpg diff --git a/info/beginlatex/src/old/p70-10.jpg b/info/beginlatex/src/old/p70-10.jpg Binary files differnew file mode 100644 index 0000000000..e7c48a4067 --- /dev/null +++ b/info/beginlatex/src/old/p70-10.jpg diff --git a/info/beginlatex/src/old/p70-11.jpg b/info/beginlatex/src/old/p70-11.jpg Binary files differnew file mode 100644 index 0000000000..614a50ee5e --- /dev/null +++ b/info/beginlatex/src/old/p70-11.jpg diff --git a/info/beginlatex/src/old/p70-12.jpg b/info/beginlatex/src/old/p70-12.jpg Binary files differnew file mode 100644 index 0000000000..84c222fbf0 --- /dev/null +++ b/info/beginlatex/src/old/p70-12.jpg diff --git a/info/beginlatex/src/old/p70-13.jpg b/info/beginlatex/src/old/p70-13.jpg Binary files differnew file mode 100644 index 0000000000..fe353228eb --- /dev/null +++ b/info/beginlatex/src/old/p70-13.jpg diff --git a/info/beginlatex/src/old/p70-14.jpg b/info/beginlatex/src/old/p70-14.jpg Binary files differnew file mode 100644 index 0000000000..38aac20756 --- /dev/null +++ b/info/beginlatex/src/old/p70-14.jpg diff --git a/info/beginlatex/src/old/p70-15.jpg b/info/beginlatex/src/old/p70-15.jpg Binary files differnew file mode 100644 index 0000000000..01aa8b3c57 --- /dev/null +++ b/info/beginlatex/src/old/p70-15.jpg diff --git a/info/beginlatex/src/old/p70-16.jpg b/info/beginlatex/src/old/p70-16.jpg Binary files differnew file mode 100644 index 0000000000..da3a8cb910 --- /dev/null +++ b/info/beginlatex/src/old/p70-16.jpg diff --git a/info/beginlatex/src/old/p70-17.jpg b/info/beginlatex/src/old/p70-17.jpg Binary files differnew file mode 100644 index 0000000000..5995998bce --- /dev/null +++ b/info/beginlatex/src/old/p70-17.jpg diff --git a/info/beginlatex/src/old/p70-18.jpg b/info/beginlatex/src/old/p70-18.jpg Binary files differnew file mode 100644 index 0000000000..209df0e585 --- /dev/null +++ b/info/beginlatex/src/old/p70-18.jpg diff --git a/info/beginlatex/src/old/p70-19.jpg b/info/beginlatex/src/old/p70-19.jpg Binary files differnew file mode 100644 index 0000000000..74b93f7f10 --- /dev/null +++ b/info/beginlatex/src/old/p70-19.jpg diff --git a/info/beginlatex/src/old/p70-20.jpg b/info/beginlatex/src/old/p70-20.jpg Binary files differnew file mode 100644 index 0000000000..3c16c85341 --- /dev/null +++ b/info/beginlatex/src/old/p70-20.jpg diff --git a/info/beginlatex/src/old/p70-21.jpg b/info/beginlatex/src/old/p70-21.jpg Binary files differnew file mode 100644 index 0000000000..ef1c35fdbf --- /dev/null +++ b/info/beginlatex/src/old/p70-21.jpg diff --git a/info/beginlatex/src/old/p70-22.jpg b/info/beginlatex/src/old/p70-22.jpg Binary files differnew file mode 100644 index 0000000000..6df5cf75f5 --- /dev/null +++ b/info/beginlatex/src/old/p70-22.jpg diff --git a/info/beginlatex/src/old/p70-23.jpg b/info/beginlatex/src/old/p70-23.jpg Binary files differnew file mode 100644 index 0000000000..a81be080b6 --- /dev/null +++ b/info/beginlatex/src/old/p70-23.jpg diff --git a/info/beginlatex/src/old/p70-24.jpg b/info/beginlatex/src/old/p70-24.jpg Binary files differnew file mode 100644 index 0000000000..6234de9670 --- /dev/null +++ b/info/beginlatex/src/old/p70-24.jpg diff --git a/info/beginlatex/src/old/p70-25.jpg b/info/beginlatex/src/old/p70-25.jpg Binary files differnew file mode 100644 index 0000000000..a737ff474e --- /dev/null +++ b/info/beginlatex/src/old/p70-25.jpg diff --git a/info/beginlatex/src/old/p70-26.jpg b/info/beginlatex/src/old/p70-26.jpg Binary files differnew file mode 100644 index 0000000000..060d36a386 --- /dev/null +++ b/info/beginlatex/src/old/p70-26.jpg diff --git a/info/beginlatex/src/old/p70-27.jpg b/info/beginlatex/src/old/p70-27.jpg Binary files differnew file mode 100644 index 0000000000..efbb3daad7 --- /dev/null +++ b/info/beginlatex/src/old/p70-27.jpg diff --git a/info/beginlatex/src/old/p70-28.jpg b/info/beginlatex/src/old/p70-28.jpg Binary files differnew file mode 100644 index 0000000000..b6cd0c882f --- /dev/null +++ b/info/beginlatex/src/old/p70-28.jpg diff --git a/info/beginlatex/src/old/p70-29.jpg b/info/beginlatex/src/old/p70-29.jpg Binary files differnew file mode 100644 index 0000000000..701e04b13f --- /dev/null +++ b/info/beginlatex/src/old/p70-29.jpg diff --git a/info/beginlatex/src/old/p70-30.jpg b/info/beginlatex/src/old/p70-30.jpg Binary files differnew file mode 100644 index 0000000000..4b5233cf50 --- /dev/null +++ b/info/beginlatex/src/old/p70-30.jpg diff --git a/info/beginlatex/src/old/p70-31.jpg b/info/beginlatex/src/old/p70-31.jpg Binary files differnew file mode 100644 index 0000000000..a3c3fdcff3 --- /dev/null +++ b/info/beginlatex/src/old/p70-31.jpg diff --git a/info/beginlatex/src/old/p70-32.jpg b/info/beginlatex/src/old/p70-32.jpg Binary files differnew file mode 100644 index 0000000000..b67bb929bb --- /dev/null +++ b/info/beginlatex/src/old/p70-32.jpg diff --git a/info/beginlatex/src/old/p70-33.jpg b/info/beginlatex/src/old/p70-33.jpg Binary files differnew file mode 100644 index 0000000000..f934a9aa68 --- /dev/null +++ b/info/beginlatex/src/old/p70-33.jpg diff --git a/info/beginlatex/src/old/p70-34.jpg b/info/beginlatex/src/old/p70-34.jpg Binary files differnew file mode 100644 index 0000000000..37790bd223 --- /dev/null +++ b/info/beginlatex/src/old/p70-34.jpg diff --git a/info/beginlatex/src/old/p70-35.jpg b/info/beginlatex/src/old/p70-35.jpg Binary files differnew file mode 100644 index 0000000000..1397ecf9ba --- /dev/null +++ b/info/beginlatex/src/old/p70-35.jpg diff --git a/info/beginlatex/src/old/p70-36.jpg b/info/beginlatex/src/old/p70-36.jpg Binary files differnew file mode 100644 index 0000000000..0ac769713a --- /dev/null +++ b/info/beginlatex/src/old/p70-36.jpg diff --git a/info/beginlatex/src/old/p70-37.jpg b/info/beginlatex/src/old/p70-37.jpg Binary files differnew file mode 100644 index 0000000000..6dadd38b79 --- /dev/null +++ b/info/beginlatex/src/old/p70-37.jpg diff --git a/info/beginlatex/src/old/p71-01.jpg b/info/beginlatex/src/old/p71-01.jpg Binary files differnew file mode 100644 index 0000000000..de5b4f1da6 --- /dev/null +++ b/info/beginlatex/src/old/p71-01.jpg diff --git a/info/beginlatex/src/old/p71-02.jpg b/info/beginlatex/src/old/p71-02.jpg Binary files differnew file mode 100644 index 0000000000..c75277af3a --- /dev/null +++ b/info/beginlatex/src/old/p71-02.jpg diff --git a/info/beginlatex/src/old/p71-03.jpg b/info/beginlatex/src/old/p71-03.jpg Binary files differnew file mode 100644 index 0000000000..48cdac9f85 --- /dev/null +++ b/info/beginlatex/src/old/p71-03.jpg diff --git a/info/beginlatex/src/old/p71-04.jpg b/info/beginlatex/src/old/p71-04.jpg Binary files differnew file mode 100644 index 0000000000..19426d4d65 --- /dev/null +++ b/info/beginlatex/src/old/p71-04.jpg diff --git a/info/beginlatex/src/old/p71-05.jpg b/info/beginlatex/src/old/p71-05.jpg Binary files differnew file mode 100644 index 0000000000..e757f2c4e6 --- /dev/null +++ b/info/beginlatex/src/old/p71-05.jpg diff --git a/info/beginlatex/src/old/p71-06.jpg b/info/beginlatex/src/old/p71-06.jpg Binary files differnew file mode 100644 index 0000000000..abc5611af5 --- /dev/null +++ b/info/beginlatex/src/old/p71-06.jpg diff --git a/info/beginlatex/src/old/p71-07.jpg b/info/beginlatex/src/old/p71-07.jpg Binary files differnew file mode 100644 index 0000000000..e574897244 --- /dev/null +++ b/info/beginlatex/src/old/p71-07.jpg diff --git a/info/beginlatex/src/old/p71-08.jpg b/info/beginlatex/src/old/p71-08.jpg Binary files differnew file mode 100644 index 0000000000..aa9ad44fee --- /dev/null +++ b/info/beginlatex/src/old/p71-08.jpg diff --git a/info/beginlatex/src/old/rotate.jpg b/info/beginlatex/src/old/rotate.jpg Binary files differnew file mode 100644 index 0000000000..2685570965 --- /dev/null +++ b/info/beginlatex/src/old/rotate.jpg diff --git a/info/beginlatex/src/old/scale.jpg b/info/beginlatex/src/old/scale.jpg Binary files differnew file mode 100644 index 0000000000..48b7b32fb1 --- /dev/null +++ b/info/beginlatex/src/old/scale.jpg diff --git a/info/beginlatex/src/old/tkbibtex.jpg b/info/beginlatex/src/old/tkbibtex.jpg Binary files differnew file mode 100644 index 0000000000..62a263a43a --- /dev/null +++ b/info/beginlatex/src/old/tkbibtex.jpg diff --git a/info/beginlatex/src/old/y2klogo.jpg b/info/beginlatex/src/old/y2klogo.jpg Binary files differnew file mode 100644 index 0000000000..a1d58ddd04 --- /dev/null +++ b/info/beginlatex/src/old/y2klogo.jpg |