\sectiontitle{Producing Simple Documents using \LaTeX} \label{la-text} \subsectiontitle{Producing a \LaTeX\ Input File} We describe the structure of a typical \LaTeX\ input file. The first line of the input file should consist of a \verb?\documentstyle? command. The recommended such \verb?\documentstyle? command for mathematical articles and similar documents has the form \begin{quote} \begin{verbatim} \documentstyle[tcda,12pt]{article} \end{verbatim} \end{quote} (You do not have to worry about what this command means when first learning to use \LaTeX: its effect is to ensure that the final document is correctly positioned on A4 size paper and that the text is of a size that is easy to read.) There are variants of this \verb?\documentstyle? command which are appropriate for letters or for books. The \verb?documentstyle? command may be followed by certain other optional commands, such as the \verb?\pagestyle? command. It is not necessary to find out about these commands when first learning to use \LaTeX. After the \verb?\documentstyle? command and these other optional commands, we place the command \begin{quote} \begin{verbatim} \begin{document} \end{verbatim} \end{quote} This command is then followed by the main body of the text, in the format prescribed by the rules of \LaTeX. Finally, we end the input file with a line containing the command \begin{quote} \begin{verbatim} \end{document} \end{verbatim} \end{quote} \subsectiontitle{Producing Ordinary Text using \LaTeX} To produce a simple document using \LaTeX\ one should create a \LaTeX\ input file, beginning with a \verb?\documentstyle? command and the \verb?begin{document}? command, as described above. The input file should end with the \verb?\end{document}? command, and the text of the document should be sandwiched between the \verb?\begin{document}? and \verb?\end{document}? commands in the manner described below. If one merely wishes to type in ordinary text, without complicated mathematical formulae or special effects such as font changes, then one merely has to type it in as it is, leaving a completely blank line between successive paragraphs. You do not have to worry about paragraph indentation: \TeX\ will automatically indent all paragraphs with the exception of the first paragraph of a new section (unless you take special action to override the conventions adopted by \TeX) For example, suppose that we wish to create a document containing the following paragraphs: \begin{quotation} \small \noindent If one merely wishes to type in ordinary text, without complicated mathematical formulae or special effects such as font changes, then one merely has to type it in as it is, leaving a completely blank line between successive paragraphs. You do not have to worry about paragraph indentation: all paragraphs will be indented with the exception of the first paragraph of a new section. One must take care to distinguish between the `left quote' and the `right quote' on the computer terminal. Also, one should use two `single quote' characters in succession if one requires ``double quotes''. One should never use the (undirected) `double quote' character on the computer terminal, since the computer is unable to tell whether it is a `left quote' or a `right quote'. One also has to take care with dashes: a single dash is used for hyphenation, whereas three dashes in succession are required to produce a dash of the sort used for punctuation---such as the one used in this sentence. \end{quotation} To create this document using \LaTeX\ we use the following input file: \begin{quote} \begin{verbatim} \documentstyle[tcda,12pt]{article} \begin{document} If one merely wishes to type in ordinary text, without complicated mathematical formulae or special effects such as font changes, then one merely has to type it in as it is, leaving a completely blank line between successive paragraphs. You do not have to worry about paragraph indentation: all paragraphs will be indented with the exception of the first paragraph of a new section. One must take care to distinguish between the `left quote' and the `right quote' on the computer terminal. Also, one should use two `single quote' characters in succession if one requires ``double quotes''. One should never use the (undirected) `double quote' character on the computer terminal, since the computer is unable to tell whether it is a `left quote' or a `right quote'. One also has to take care with dashes: a single dash is used for hyphenation, whereas three dashes in succession are required to produce a dash of the sort used for punctuation---such as the one used in this sentence. \end{document} \end{verbatim} \end{quote} Having created the input file, one then has to run it through the \LaTeX\ program and then print it out the resulting output file (known as a `DVI' file). \subsectiontitle{Blank Spaces and Carriage Returns in the Input File} \TeX\ treats the carriage return at the end of a line as though it were a blank space. Similarly \TeX\ treats tab characters as blank spaces. Moreover, \TeX\ regards a sequence of blank spaces as though it were a single space, and similarly it will ignore blank spaces at the beginning or end of a line in the input file. Thus, for example, if we type \begin{quote} \begin{verbatim} This is a silly example of a file with many spaces. This is the beginning of a new paragraph. \end{verbatim} \end{quote} then we obtain \begin{quotation} \small This is a silly example of a file with many spaces. This is the beginning of a new paragraph. \end{quotation} It follows immediately from this that one will obtain the same results whether one types one space or two spaces after a full stop: \TeX\ does not distinguish between the two cases. Any spaces which follow a control sequence will be ignored by \TeX. \begin{quotation} \footnotesize If you really need a blank space in the final document following whatever is produced by the control sequence, then you must precede this blank by a {\it backslash} \verb?\?. Thus in order to obtain the sentence \begin{quotation} \TeX\ is a very powerful computer typesetting program. \end{quotation} we must type \begin{quote} \begin{verbatim} \TeX\ is a very powerful computer typesetting program. \end{verbatim} \end{quote} (Here the control sequence \verb?\TeX? is used to produce the \TeX\ logo.) In general, preceding a blank space by a backslash forces \TeX\ to include the blank space in the final document. \end{quotation} As a general rule, you should never put a blank space after a left parenthesis or before a right parenthesis. If you were to put a blank space in these places, then you run the risk that \TeX\ might start a new line immediately after the left parenthesis or before the right parenthesis, leaving the parenthesis marooned at the beginning or end of a line. \subsectiontitle{Quotation Marks} Single left and right quotation marks are produced by \verb?`? and \verb?'? respectively. Double left and right quotation marks are produced by \verb?``? and \verb?''? respectively. Thus \begin{quotation} \small ``What did you do yesterday?'' he asked. \end{quotation} is produced by typing \begin{quote} \begin{verbatim} ``What did you do yesterday?'' he asked. \end{verbatim} \end{quote} You should never use the character \verb?"? to produce quotation marks. This is because \TeX\ has no way of knowing whether you want a left quote or a right quote if you do this. \begin{quotation} \footnotesize You can use the control sequences \verb?\lq? and \verb?\rq? in place of \verb?`? and \verb?'?. This is useful if your keyboard does not have a \verb?`? character. \end{quotation} \begin{quotation} \footnotesize Sometimes you need two quotation marks following one another, as in \begin{quotation} ``I regard computer typesetting as being reasonably `straightforward'\,'' he said. \end{quotation} The way to do this is to use the control sequence \verb?\,? between the quotation marks. Thus one would type \begin{quote} \begin{verbatim} ``I regard computer typesetting as being reasonably `straightforward'\,'' he said. \end{verbatim} \end{quote} However this problem arises very rarely. \end{quotation} \subsectiontitle{Dashes} \TeX\ allows you to produce dashes of various length. Typing \verb?-? by itself produces a hyphen, as in `double-quote'. Typing \verb?--? produces a dash suitable for denoting a range of numbers, as in the phrase `on pages 155--159', produced by typing \begin{quote} \begin{verbatim} on pages 155--159. \end{verbatim} \end{quote} Finally, typing \verb?---? produces a punctuation dash---this is a dash such as the one in this sentence. \subsectiontitle{Section Headings in \LaTeX} Section headings of various sizes are produced (in the {\it article\/} document style) using the commands \verb?\section?,\verb?\subsection? and \verb?\subsubsection? commands. \LaTeX\ will number the sections and subsections automatically. The title of the section should be surrounded by curly brackets and placed immediately after the relevant command. Thus if we type \begin{quote} \begin{verbatim} \section{Section Headings} We explain in this section how to obtain headings for the various sections and subsections of our document. \subsection{Headings in the `article' Document Style} In the `article' style, the document may be divided up into sections, subsections and subsubsections, and each can be given a title, printed in a boldface font, simply by issuing the appropriate command. \end{verbatim} \end{quote} then the title of the section and that of the subsection will be printed in a large boldface font, and will be numbered accordingly. Other document styles (such as the {\it book\/} and {\it letter\/} styles) have other `sectioning' commands available (for example, the {\it book\/} style has a \verb?\chapter? command for beginning a new chapter). \begin{quotation} \footnotesize Sometimes one wishes to suppress the automatic numbering provided by \LaTeX. This can be done by placing an asterisk before the title of the section or subsection. Thus, for example, the section numbers in the above example could be suppressed by typing \begin{quote} \begin{verbatim} \section*{Section Headings} We explain in this section how to obtain headings for the various sections and subsections of our document. \subsection*{Headings in the `article' Document Style} In the `article' style, the document may be divided up into sections, subsections and subsubsections, and each can be given a title, printed in a boldface font, simply by issuing the appropriate command. \end{verbatim} \end{quote} \end{quotation} \subsectiontitle{Changing Fonts} Fonts are changed using the control sequences \verb?\rm?, \verb?\sl?, \verb?\it?, \verb?\tt? and \verb?\bf?. \begin{quote} \begin{tabular}{ll} \verb?\rm? changes to the normal ``roman'' font: & \rm Roman\\ \verb?\sl? changes to a slanted roman font: & \sl Slanted\\ \verb?\it? changes to an italic font: & \it Italic\\ \verb?\tt? changes to an ``typewriter'' font: & \tt Typewriter\\ \verb?\bf? changes to a boldface font: & \bf Boldface \end{tabular} \end{quote} It is best to use the special characters \verb?{? and \verb?}? when changing fonts. One encloses the text whose font is to be changed within these curly brackets and places the font-changing control sequence immediately after the opening bracket~\verb?{?. Thus the text \begin{quotation} \small In this sentence we have {\it italicized\/} a few words, set others in {\sl slanting type\/} or {\bf boldface type}, and typeset others using a {\tt `typewriter' font in which all the letters have a fixed width}. \end{quotation} is produced by typing \begin{quote} \begin{verbatim} In this sentence we have {\it italicized\/} a few words, set others in {\sl slanting type\/} or {\bf boldface type}, and typeset others using a {\tt `typewriter' font in which all the letters have a fixed width}. \end{verbatim} \end{quote} \begin{quotation} \footnotesize The control sequence \verb?\/? produces the so-called {\it italic correction}. The use of this is recommended when changing back from an {\it italic\/} or {\sl slanted\/} font into a {\rm roman} or {\bf boldface} font, in order to produce extra space to compensate for the way in which some {\it italic\/} and {\sl slanted\/} letters lean into the following blank space. However this italic correction should not be used before a comma or a full stop. \end{quotation} \LaTeX\ provides the control sequence \verb?\em? for {\em emphasizing\/} text. This will set the emphasized text in italic, unless the surrounding text is already in italic, in which case the text will be set in ordinary roman font. Thus \begin{quote} \begin{verbatim} Here is some {\em emphasized text with {\em emphasized} words embedded in the {\em emphasized} text} too. \end{verbatim} \end{quote} produces \begin{quotation} \small Here is some {\em emphasized text with {\em emphasized} words embedded in the {\em emphasized} text} too. \end{quotation} \subsectiontitle{Accents and other Symbols used in Text} There are a variety of control sequences for producing accents. For example, the control sequence \verb?\'{o}? produces an acute accent on the letter~\verb?o?. Thus typing \begin{quote} \begin{verbatim} Se\'{a}n \'{O} Cinn\'{e}ide. \end{verbatim} \end{quote} produces \begin{quotation} \small Se\'{a}n \'{O} Cinn\'{e}ide. \end{quotation} Similarly we use the control sequence \verb?\`? to produce the grave accent in `alg\`{e}bre' and we use \verb?\"? to produce the umlaut in `Universit\"{a}t'. A list of the accents provided by \TeX\ is given in Appendix~\ref{la-txtcs}. The control sequences \verb?\i? and \verb?\j? produce dotless $i$ and $j$. These are required when placing an accent on the letter. Thus \={\i} is produced by typing \verb?\={\i}?. There are also control sequences for ligatures and other special symbols used within text. These are listed in Appendix~\ref{la-txtcs}. \subsectiontitle{Special Characters} The characters \begin{quote} \begin{verbatim} # $ % & \ ^ _ { } ~ \end{verbatim} \end{quote} have special purposes within \TeX. Thus they cannot be produced in the final document simply by typing them directly. On the rare occasions when one needs to use the special characters \begin{quote} \#\ \$\ \%\ \&\ \_\ \{\ \} \end{quote} in the final document, they can be produced by typing the control sequences \begin{quote} \begin{verbatim} \# \$ \% \& \_ \{ \} \end{verbatim} \end{quote} respectively. However, somewhat more ingenuity is required to produce \verb?\?, \verb?^? and \verb?~?.