%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Contents: Things you need to know % $Id: things.tex,v 1.2 1996/01/25 14:01:06 oetiker Exp oetiker $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Things You Need to Know} \begin{intro} In the first part of this chapter you will get a short overview about the philosophy and history of \LaTeXe. The second part of the chapter focuses on the basic structures of a \LaTeX{} document. After reading this chapter you should have a rough knowledge of how \LaTeX{} works. When reading on, this will help you to integrate all the new information into the big picture. \end{intro} \section{The Name of the Game} \subsection{\TeX} \TeX{} is a computer program by \index{Knuth, Donald E.}Donald E.~Knuth~\cite{texbook}. It is aimed at typesetting text and mathematical formulae. \TeX{} is pronounced ``Tech,'' with a ``ch'' as in the German word ``Ach'' or in Scottish ``Loch.'' In an \texttt{ASCII} environment \TeX{} becomes \texttt{TeX}. \subsection{\LaTeX} \LaTeX{} is a macro package which enables authors to typeset and print their work at the highest typographical quality, using a predefined, professional layout. \LaTeX{} was originally written by \index{Lamport, Leslie}Leslie Lamport~\cite{manual}. It uses the \TeX{} formatter as its typesetting engine. Recently the \LaTeX{} package has been updated by the \index{LaTeX3@\LaTeX 3}\LaTeX 3 team, led by \index{Mittelbach, Frank}Frank Mittelbach, to include some long-requested improvements and to re\-unify all the patched versions which have cropped up since the release of \index{LaTeX 2.09@\LaTeX{} 2.09}\LaTeX{} 2.09 some years ago. To distinguish the new version from the old, it is called \index{LaTeX 2e@\LaTeXe}\LaTeXe. This documentation deals with \LaTeXe. \LaTeX{} is pronounced ``Lay-tech'' or ``Lah-tech.'' If you refer to \LaTeX{} in an \texttt{ASCII} environment you type \texttt{LaTeX}. \LaTeXe{} is pronounced ``Lay-tech two e'' and typed \texttt{LaTeX2e}. \section{Basics} \subsection{Author, Book Designer, and Typesetter} To publish something, authors give their typed manuscript to a publishing company. A book designer of the publishing company then decides the layout of the document (column width, fonts, space before and after headings,~\ldots). The book designer writes his instructions into the manuscript and then gives it to a typesetter, who typesets the book according to these instructions. A human book designer tries to find out what the author had in mind while writing the manuscript. He decides on chapter headings, citations, examples, formulae, etc.\ based on his professional knowledge and from the contents of the manuscript. In a \LaTeX{} environment, \LaTeX{} takes the role of the book designer and uses \TeX{} as its typesetter. But \LaTeX{} is ``only'' a program and therefore needs more guidance. The author has to provide additional information which describes the logical structure of his work. This information is written into the text as ``\LaTeX{} commands.'' This is quite different from the \wi{WYSIWYG}\footnote{What you see is what you get.} approach which most modern word processors such as \emph{Word for Windows} or \emph{WordPerfect} take. With these applications, authors specify the document layout interactively while typing text into the computer. All along the way, they can see on the screen how the final work will look when it is printed. When using \LaTeX{} it is normally not possible to see the final output while typing the text. But the final output can be previewed on the screen after processing the file with \LaTeX. Then corrections can be made before actually sending the document to the printer. \subsection{Layout Design} Typographical design is a craft. Unskilled authors often commit serious formatting errors by assuming that book design is mostly a question of aesthetics---``If a document looks good artistically it is well designed.'' But as a document has to be read and not hung up in a picture gallery, the readability and understandability is of much greater importance than the beautiful look of it. Examples: \begin{itemize} \item The font size and numbering of headings have to be chosen to make the structure of chapters and sections clear to the reader. \item The line length has to be short enough that it does not strain the eyes of the reader, while long enough to fill the page beautifully. \end{itemize} With \wi{WYSIWYG} systems, authors often generate aesthetically pleasing documents with very little or inconsistent structure. \LaTeX{} prevents such formatting errors by forcing the author to declare the \emph{logical} structure of his document. \LaTeX{} then chooses the most suitable layout. \subsection{Advantages and Disadvantages} A topic often discussed when people from the \wi{WYSIWYG} world meet \LaTeX{} people, is ``the \wi{advantages of \LaTeX{}} over a normal word processor'' or the opposite. The best thing you can do when such a discussion starts, is to keep a low profile, as it often gets out of hand. But sometimes you cannot escape \ldots \medskip\noindent The main advantages of \LaTeX{} over normal word processors are the following: \begin{itemize} \item Professionally crafted layouts are available which make a document really look as if ``printed.'' \item The typesetting of mathematical formulae is supported in a convenient way. \item The user only needs to learn a few easy to understand commands, which specify the logical structure of a document. They almost never need to tinker with the actual layout of the document. \item Even complex structures such as footnotes, references, table of contents, and bibliographies can be generated easily. \item For many typographical tasks not directly supported by basic \LaTeX, there exist free add-on packages. For example, packages are available to include \textsc{PostScript} graphics or to typeset bibliographies conforming to exact standards. Many of these add-on packages are described in \companion. \item \LaTeX{} encourages authors to write well structured texts because this is how \LaTeX{} works---by specifying structure. \item \TeX, the formatting engine of \LaTeXe, is highly portable and free. Therefore the system runs on almost any hardware platform available. % % Add examples ... % \end{itemize} \medskip \noindent\LaTeX{} also has some disadvantages: \begin{itemize} \item More resources (memory, disk-space, computing power) are required to run a \LaTeX{} system than a simple word processor. But things are getting better, as Word for Windows 6.0 needs even more disk space than a normal \LaTeX{} system. When it comes down to processor usage, \LaTeX{} beats any WYSIWYG system, as it only needs a lot of CPU time when a document is actually processed, while WYSIWYG packages hog the CPU all the time. \item Although within a predefined document layout some parameters can be adjusted, the design of a whole new layout is difficult and takes a lot of time.\footnote{Rumour says, that this is one of the key elements which will be addressed in the upcoming \LaTeX 3 system}\index{LaTeX3@\LaTeX 3} \end{itemize} \section{\LaTeX{} Input Files} The input for \LaTeX{} is a plain \texttt{ASCII} text file. You can create it with any text editor. It contains the text of the document as well as the commands which tell \LaTeX{} how to typeset the text. \subsection{Spaces} ``Whitespace'' characters such as blank or tab are treated uniformly as ``\wi{space}'' by \LaTeX{}. \emph{Several consecutive} \wi{whitespace} characters are treated as \emph{one} ``space''. Whitespace at the start of a line is generally ignored and a single linebreak is treated like a ``space''. \index{whitespace!at the start of a line} An empty line between two lines of text defines the end of a paragraph. \emph{Several} empty lines are treated the same as \emph{one} empty line. The text below is an example. On the right hand side is the text from the input file and on the left hand side is the formatted output. \begin{example} It does not matter whether you enter one or several spaces after a word. An empty line starts a new paragraph. \end{example} \subsection{Special Characters} The following symbols are \wi{reserved characters}, that either have a special meaning under \LaTeX{} or are not available in all the fonts. If you enter them in your text directly, they will normally not print, but rather coerce \LaTeX{} to do things you did not intend. \begin{code} \verb.$ & % # _ { } ~ ^ \ . \end{code} As you will see, these characters can be used in your documents all the same by adding a prefix backslash: \begin{example} \$ \& \% \# \_ \{ \} \end{example} The other symbols and many more can be printed with special commands in mathematical formulae or as accents. \subsection{\LaTeX{} Commands} \LaTeX{} \wi{commands} are case sensitive and take one of the following two formats: \begin{itemize} \item They start with a \wi{backslash} \verb|\| and then have a name consisting only of letters. Command names are terminated by a space, a number or any other `non-letter'. \item They consist of a backslash and exactly one % numerical or special character. \end{itemize} % % \\* doesn't comply ! % % % Can \3 be a valid command ? (jacoboni) % \LaTeX{} ignores whitespace after commands. If you want to get a \index{whitespace!after commands}space after a command, you have to put either \verb|{}| and a blank or a special spacing command after the command name. The \verb|{}| stops \LaTeX{} from eating up all the space after the command name. \begin{example} I read that Knuth divides the people working with \TeX{} into \TeX{}nicians and \TeX perts.\\ Today is \today. \end{example} Some commands need a \wi{parameter} which has to be given between \wi{curly braces} \verb|{ }| after the command name. Some commands support \wi{optional parameters} which are added after the command name in \wi{square brackets}~\verb|[ ]|. The next example uses some \LaTeX{} commands. Don't worry about them, they will be explained later. \begin{example} You can \textsl{lean} on me! \end{example} \begin{example} Please, start a new line right here!\linebreak[3] Thank you! \end{example} \subsection{Comments} \index{comments} When \LaTeX{} encounters a \verb|%| character while processing an input file, it ignores the rest of the present line. This is useful for adding notes to the input file, which will not show up in the printed version. \begin{example} This is an % stupid % Better: instructive <---- example. \end{example} \section{Input File Structure} When \LaTeXe{} processes an input file it expects it to follow a certain \wi{structure}. Thus every input file must start with the command \begin{code} \verb|\documentclass{...}| \end{code} This specifies what sort of document you intend to write. After that, you can include commands which influence the style of the whole document or you can load \wi{package}s which add new features to the \LaTeX{} system. To load such a package you use the command \begin{code} \verb|\usepackage{...}| \end{code} When all the setup work is done\footnote{The area between \texttt{\bs documentclass} and \texttt{\bs begin$\mathtt{\{}$document$\mathtt{\}}$} is called \emph{\wi{preamble}}.}, you start the body of the text with the command \begin{code} \verb|\begin{document}| \end{code} Now you enter the text mixed with some useful \LaTeX{} commands. At the end of the document you add the \begin{code} \verb|\end{document}| \end{code} command, which tells \LaTeX{} to call it a day. Anything which follows this command will be ignored by \LaTeX. Figure~\ref{mini} shows the contents of a minimal \LaTeXe{} file. A slightly more complicated \wi{input file} is given in Figure~\ref{document}. \begin{figure}[!bp] \begin{lined}{6cm} \begin{verbatim} \documentclass{article} \begin{document} Small is beautiful. \end{document} \end{verbatim} \end{lined} \caption{A Minimal \LaTeX{} File} \label{mini} \end{figure} \begin{figure}[!bp] \begin{lined}{10cm} \begin{verbatim} \documentclass[a4paper,11pt]{article} \usepackage{latexsym} \author{H.~Partl} \title{Minimalism} \frenchspacing \begin{document} \maketitle \tableofcontents \section{Start} Well and here begins my lovely article. \section{End} \ldots{} and here it ends. \end{document} \end{verbatim} \end{lined} \caption{Example of a Realistic Journal Article} \label{document} \end{figure} \section{The Layout of the Document} \subsection {Document Classes}\label{sec:documentclass} The first information \LaTeX{} needs to know when processing an input file is the type of document the author wants to create. This is specified with the \ci{documentclass} command. \begin{command} \ci{documentclass}\verb|[|\emph{options}\verb|]{|\emph{class}\verb|}| \end{command} \noindent Here \emph{class} specifies the type of document to be created. Table~\ref{documentclasses} lists the document classes explained in this introduction. The \LaTeXe{} distribution provides additional classes for other documents including letters and slides. The \emph{\wi{option}s} parameter customises the behaviour of the document class. The options have to be separated by commas. In Table~\ref{options} the most common options for the standard document classes are listed. \begin{table}[!bp] \caption{Document Classes} \label{documentclasses} \begin{lined}{12cm} \begin{description} \item [\normalfont\texttt{article}] for articles in scientific journals, presentations, short reports, program documentation, invitations, \ldots \index{article class} \item [\normalfont\texttt{report}] for longer reports containing several chapters, small books, PhD theses, \ldots \index{report class} \item [\normalfont\texttt{book}] for real books \index{book class} \item [\normalfont\texttt{slide}] for slides. The class uses big sans serif letters. \index{slide class} \end{description} \end{lined} \end{table} \begin{table}[!bp] \caption{Document Class Options} \label{options} \begin{lined}{12cm} \begin{flushleft} \begin{description} \item[\normalfont\texttt{10pt}, \texttt{11pt}, \texttt{12pt}] \quad Sets the size of the main font for the document. If no option is specified, \texttt{10pt} is assumed. \index{document font size}\index{base font size} \item[\normalfont\texttt{a4paper}, \texttt{letterpaper}, \ldots] \quad Defines the paper size. The default size is \texttt{letterpaper}. Besides that, \texttt{a5paper}, \texttt{b5paper}, \texttt{executivepaper}, and \texttt{legalpaper} can be specified. \index{legal paper} \index{paper size}\index{A4 paper}\index{letter paper} \index{A5 paper}\index{B5 paper}\index{executive paper} \item[\normalfont\texttt{fleqn}] \quad Typesets displayed formulae left-aligned instead of centred. \item[\normalfont\texttt{leqno}] \quad Places the numbering of formulae on the left hand side instead of the right. \item[\normalfont\texttt{titlepage}, \texttt{notitlepage}] \quad Specifies whether a new page should be started after the \wi{document title} or not. The \texttt{article} class does not start a new page by default, while \texttt{report} and \texttt{book} do. \index{title} \item[\normalfont\texttt{twocolumn}] \quad Instructs \LaTeX{} to typeset the document in \wi{two column}s. \item[\normalfont\texttt{twoside, oneside}] \quad Specifies whether double or single sided output should be generated. The classes \texttt{article} and \texttt{report} are \wi{single sided} and the \texttt{book} class is \wi{double sided} by default. \item[\normalfont\texttt{openright, openany}] \quad Makes chapters begin either only on right hand pages or on the next page available. This does not work with the \texttt{article} class, as it does not know about chapters. The \texttt{report} class by default starts chapters on the next page available and the \texttt{book} class starts them on right hand pages. \end{description} \end{flushleft} \end{lined} \end{table} Example: An input file for a \LaTeX{} document could start with the line \begin{code} \ci{documentclass}\verb|[11pt,twoside,a4paper]{article}| \end{code} it instructs \LaTeX{} to typeset the document as an \emph{article} with a base font size of \emph{eleven points} and to produce a layout suitable for \emph{double sided} printing on \emph{a4 paper}. \pagebreak[2] \subsection{Packages} \index{package} While writing your document, you will probably find that there are some areas where basic \LaTeX{} cannot solve your problem. If you want to include \wi{graphics}, \wi{coloured text} or source code from a file into your document, you need to enhance the capabilities of \LaTeX. Such enhancements are called packages. Packages are activated with the \begin{command} \ci{usepackage}\verb|[|\emph{options}\verb|]{|\emph{package}\verb|}| \end{command} \noindent command. Where \emph{package} is the name of the package and \emph{options} is a list of keywords which trigger special features in the package. Some packages come with the \LaTeXe{} base distribution (See Table~\ref{packages}). Others are provided separately. You may find more information on the packages installed at your site in your \guide. The prime source for information about \LaTeX{} is \companion. It contains descriptions of hundreds of packages along with information of how to write your own extensions to \LaTeXe. \begin{table}[!hbp] \caption{Some of the Packages Distributed with \LaTeX} \label{packages} \begin{lined}{11cm} \begin{description} \item[\normalfont\texttt{doc}] Allows the documentation of \LaTeX{} programs.\\ Described in \texttt{doc.dtx}\footnote{This file should be installed on your system, and you should be able to get a \texttt{dvi} file by typing \texttt{latex doc.dtx}. The same is true for all the other files mentioned in this table.} and in \companion. \item[\normalfont\texttt{exscale}] Provides scaled versions of the maths extension font.\\ Described in \texttt{ltexscale.dtx}. \item[\normalfont\texttt{fontenc}] Specifies which \wi{font encoding} \LaTeX{} should use.\\ Described in \texttt{ltoutenc.dtx}. \item[\normalfont\texttt{ifthen}] Provides commands of the form\\ `if\ldots then do\ldots otherwise do\ldots.'\\ Described in \texttt{ifthen.dtx} and \companion. \item[\normalfont\texttt{latexsym}] To access the \LaTeX{} symbol font, you should use the \texttt{latexsym} package. Described in \texttt{latexsym.dtx} and in \companion \item[\normalfont\texttt{makeidx}] Provides commands for producing indexes. Described in section~\ref{sec:indexing} and in \companion. \item[\normalfont\texttt{syntonly}] Processes a document without typesetting it.\\ Described in \texttt{syntonly.dtx} and in \companion. This is useful for quick error checking. \item[\normalfont\texttt{inputenc}] Allows the specification of an input encoding such as ASCII, ISO Latin-1, ISO Latin-2, 437/850 IBM code pages, Apple Macintosh, Next, ANSI-Windows or user-defined one. Described in \texttt{inputenc.dtx}. \end{description} \end{lined} \end{table} \clearpage % % Package Info pointer % % \subsection{Page Styles} \LaTeX{} supports three predefined \wi{header}/\wi{footer} combinations---so-called \wi{page style}s. The \emph{style} parameter of the \index{page style!plain@\texttt{plain}}\index{plain@\texttt{plain}} \index{page style!headings@\texttt{headings}}\index{headings@texttt{headings}} \index{page style!empty@\texttt{empty}}\index{empty@\texttt{empty}} \begin{command} \ci{pagestyle}\verb|{|\emph{style}\verb|}| \end{command} \noindent command defines which one to use. Table~\ref{pagestyle} lists the predefined page styles. \begin{table}[!hbp] \caption{The Predefined Page Styles of \LaTeX} \label{pagestyle} \begin{lined}{12cm} \begin{description} \item[\normalfont\texttt{plain}] prints the page numbers on the bottom of the page in the middle of the footer. This is the default page style. \item[\normalfont\texttt{headings}] prints the current chapter heading and the page number in the header on each page while the footer remains empty. (This is the style used in this document) \item[\normalfont\texttt{empty}] sets both the header and the footer to be empty. \end{description} \end{lined} \end{table} It is possible to change the page style of the current page with the command \begin{command} \ci{thispagestyle}\verb|{|\emph{style}\verb|}| \end{command} In \companion{} there is a description how to create your own headers and footers. % % Pointer to the Fancy headings Package description ! % % % Add Info on page-numbering, ... % \pagenumbering \section{Big Projects} When working on big documents, you might want to split the input file into several parts. \LaTeX{} has two commands which help you to do that. \begin{command} \ci{include}\verb|{|\emph{filename}\verb|}| \end{command} \noindent you can use this command in the document body, to insert the contents of another file. Note that \LaTeX{} will start a new page before processing the material input from \emph{filename}. The second command can be used in the preamble. It allows you to instruct \LaTeX{} to only input some of the \verb|\include|d files. \begin{command} \ci{includeonly}\verb|{|\emph{filename}\verb|,|\emph{filename}% \verb|,|\ldots\verb|}| \end{command} After this command is executed in the preamble of the document. Only \ci{include} commands for the filenames which are listed in the argument of the \ci{includeonly} command will be executed. Note that there must be no space between the filename and the comma. The \ci{include} command starts typesetting the included text on a new page. This is helpful when you use \ci{includeonly}, because the pagebreaks will not move, even when some included files at ommited. Sometimes this might not be desirable. In this case, you can use the \begin{command} \ci{input}\verb|{|\emph{filename}\verb|}| \end{command} command. It simply includes the file specified. No flashy suits, no strings attached. \endinput %%% Local Variables: %%% mode: latex %%% TeX-master: "lshort2e" %%% End: