home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / text / tex / 15528 < prev    next >
Encoding:
Text File  |  1993-01-28  |  36.1 KB  |  1,028 lines

  1. Path: sparky!uunet!UB.com!pacbell.com!ames!olivea!charnel!psgrain!ee.und.ac.za!tplinfm
  2. From: gmaltby@unpcs1.cs.unp.ac.za (Gavin Maltby)
  3. Newsgroups: comp.text.tex
  4. Subject: latex notes: 2 of 4
  5. Summary: part 2 of 4
  6. Keywords: latex notes
  7. Message-ID: <gmaltby.119.728117588@unpcs1.cs.unp.ac.za>
  8. Date: 27 Jan 93 06:53:09 GMT
  9. Organization: University of Natal, Pietermaritzburg, South Africa
  10. Lines: 1015
  11. NNTP-Posting-Host: pc038.cc.unp.ac.za
  12.  
  13. % part 2 of 4
  14. \begin{table}[ht]
  15. \centering
  16. \begin{tabular}{l|r|r|r|}
  17. \multicolumn{1}{l}{size} &
  18. \multicolumn{1}{c}{default (10pt)} &
  19.         \multicolumn{1}{c}{11pt option}  &
  20.         \multicolumn{1}{c}{12pt option}\\
  21. \cline{2-4}
  22. \verb|\tiny|       & 5pt  & 6pt & 6pt\\
  23. \cline{2-4}
  24. \verb|\scriptsize| & 7pt  & 8pt & 8pt\\
  25. \cline{2-4}
  26. \verb|\footnotesize| & 8pt & 9pt & 10pt \\
  27. \cline{2-4}
  28. \verb|\small|        & 9pt & 10pt & 11pt \\
  29. \cline{2-4}
  30. \verb|\normalsize| & 10pt & 11pt & 12pt \\
  31. \cline{2-4}
  32. \verb|\large|      & 12pt & 12pt & 14pt \\
  33. \cline{2-4}
  34. \verb|\Large|      & 14pt & 14pt & 17pt \\
  35. \cline{2-4}
  36. \verb|\LARGE|      & 17pt & 17pt & 20pt\\
  37. \cline{2-4}
  38. \verb|\huge|       & 20pt & 20pt & 25pt\\
  39. \cline{2-4}
  40. \verb|\Huge|       & 25pt & 25pt & 25pt\\
  41. \cline{2-4}
  42. \end{tabular}
  43. \caption{\LaTeX\ size-changing commands.}\label{tab:styles}
  44. \label{tab:sizes}
  45. \end{table}
  46.  
  47. The point-size option referred to in table~\ref{tab:sizes} is that
  48. specified in the \verb@\documentstyle@ command issued at the
  49. beginning of the input file.  Through it you select that base
  50. (or default) font for your document to be 10, 11, or~12 point Roman.
  51. If no options are specified, the default is 10-point Roman.  The
  52. table shows, for instance, that if I issue a \verb@\large@ in
  53. this document for which I chose the {\tt 12pt} document style
  54. option the result will be a {\large 14-point Roman typeface}.
  55.  
  56. We mentioned that to restrict the scope of a type-changing
  57. command we will set the text to be affected off in a group.
  58. Let's look at an example of this.
  59.  
  60. \moveright0.1\textwidth\vbox{%
  61. \footnotesize\begin{verbatim}
  62. When we want to {\em emphasise\/} some text we
  63. use the {\tt em} command, and use grouping to
  64. restrict the scope.  We can change font {\large sizes}
  65. in much the same way.  We can also obtain {\it italicised},
  66. {\bf emboldened}, {\sc Capitals} and {\sf sans serif} styles.
  67. \end{verbatim}
  68. }
  69.  
  70. \result{%
  71. When we want to {\em emphasise\/} some text we
  72. use the {\tt em} command, and use grouping to
  73. restrict the scope.  We can change font {\large sizes}
  74. in much the same way.  We can also obtain {\it italicised},
  75. {\bf emboldened}, {\sc Capitals} and {\sf sans serif} styles.
  76. }
  77.  
  78. Notice how clever grouping allows us to do all that without
  79. once having to use \verb@\rm@ or \verb@\normalsize@.
  80.  
  81. One more thing slipped into that example---and {italic correction\/}
  82. \verb@\/@.  This is a very small amount of additional space that
  83. we asked to be inserted to allow for the change from sloping
  84. {\em emphasised} text to upright text, because the interword
  85. space has been made to look less substantial from the terminal
  86. sloping character.  One has to keep an eye open for circumstances
  87. where this is necessary.  See the effect of omitting an italic correction
  88. after the emphasised text earlier in this paragraph.
  89.  
  90. One might expect, by now, that \LaTeX\ would insert an italic correction
  91. for us.  But there are enough occasions when it is not wanted, and there
  92. is no good rule for \LaTeX\ to use to decide just when to do it for us.
  93. So the italic correction is always left up to the typist.
  94.  
  95. \subsection{Accents}
  96. \LaTeX\ provides accents for just about all occasions.  They are
  97. accessed through a variety of control symbols and single-letter
  98. control worlds which accept a single argument---the letter to be
  99. accented.  These control sequences are detailed in table~\ref{tab:accents}.
  100.  
  101. \begin{table}[ht]
  102. \centering
  103. \begin{tabular}{lll}
  104. \verb@\`{o}@ & \`{o} & (grave accent)\\
  105. \verb@\'{o}@ & \'{o} &(acute accent)\\
  106. \verb@\^{o}@ & \^{o} & (circumflex or ``hat'')\\
  107. \verb@\"{o}@ & \"{o} & (umlaut or dieresis)\\
  108. \verb@\~{o}@ & \~{o} & (tilde or ``squiggle'')\\
  109. \verb@\={o}@ & \={o} & (macron or ``bar'')\\
  110. \verb@\.{o}@ & \.{o} & (dot accent)\\
  111. \verb@\u{o}@ & \u{o} & (breve accent)\\
  112. \verb@\v{o}@ & \v{o} & (h\'{a}\v{c}ek or ``check'')\\
  113. \verb@\H{o}@ & \H{o} & (long Hungarian umlaut)\\
  114. \verb@\t{oo}@ & \t{oo} & (tie-after accent)\\
  115. \verb@\c{o}@ & \c{o} & (cedilla accent)\\
  116. \verb@\d{o}@ & \d{o} & (dot-under accent)\\
  117. \verb@\b{o}@ & \b{o} & (bar-under accent)
  118. \end{tabular}
  119. \caption{Control sequences for accents}
  120. \label{tab:accents}
  121. \end{table}
  122.  
  123. Thus we can produce \'{o} by typing \verb@\'{o}@,
  124. \v{a} by typing \verb@\v{a}@, and P\'{a}l Erd\"{o}s
  125. by typing \verb@P\'{a}l Erd\"{o}s@.  Take special
  126. care when accenting an $i$ or a $j$, for they should
  127. lose their dots when accented.  Use the control
  128. words \verb@\i@ and \verb@\j@ to produce dotless
  129. versions of these letters.  Thus the best way to type
  130. to type \u{e}x\u{\i}gent is \verb"\u{e}x\u{\i}gent".
  131.  
  132. \subsection{Over-ruling some of \TeX's choices}
  133. We've seen that ties can be used to stop linebreaks
  134. occurring between words.  But how can we stop
  135. \LaTeX\ from hyphenating a particular word?
  136. More generally, how can we stop it from splitting
  137. any given group of characters across two lines.
  138. The answer is to make that group of characters
  139. appears as one solid {\em box\/}, through
  140. use of an \verb@\mbox@ command.
  141.  
  142. \moveright0.1\textwidth\vbox{%
  143. \footnotesize\begin{verbatim}
  144. For instance, if we wanted to be sure that the word
  145. {\em currentitem\/} is not split across lines
  146. then we should type it as \mbox{\em currentitem}.
  147. \end{verbatim}
  148. }
  149.  
  150. If for some reason we wish to break a line\\
  151. in the middle of nowhere, preventing \LaTeX\
  152. from justifying that line to the prevailing right
  153. margin, the we use the \verb@\newline@
  154. command.  One can also use the abbreviated
  155. form \verb@\\@.
  156.  
  157. \moveright0.1\textwidth\vbox{%
  158. \footnotesize\begin{verbatim}
  159. We start with a short line.\newline
  160. And  now we continue with the normal
  161. text, remembering that where we press
  162. Return in the input file probably won't
  163. correspond to a line break in the final
  164. document.  More short lines\\
  165. are easy, too.
  166. \end{verbatim}
  167. }
  168. \noindent will produce the line breaks we want
  169.  
  170. \result{%
  171. We start with a short line.\newline
  172. And  now we continue with the normal
  173. text, remembering that where we press
  174. Return in the input file probably won't
  175. correspond to a line break in the final
  176. document.  More short lines\\
  177. are easy, too.
  178. }
  179.  
  180. A warning is in order:  \verb@\newline@
  181. must only end part of a line that is ``already
  182. set''.  It cannot be used to add additional
  183. space between paragraphs, nor to leave
  184. space for a picture you want to paste in.
  185. This is not to be awkward, but is just part
  186. of \LaTeX\ holding up its end of the deal
  187. by making you have to specially request
  188. additional vertical space.  This prevents
  189. unwanted extra space from entering
  190. your document.
  191.  
  192. Later we shall see how to impose our own choice
  193. of page size, paragraph indentation, etc.  For now
  194. we will continue to accept those declared for
  195. us in the document style.
  196.  
  197. \subsection{Commenting your document}
  198. It is handy to be able to make comments
  199. to yourself in the source file for a document.
  200. Things like ``I must rewrite this section'' and
  201. ``This is version 3 of the document'' are likely.
  202. It would also be useful to be able to make
  203. the compiler ignore certain parts of the
  204. document at times.  For this purpose
  205. we can use the \verb@%@ character, for
  206. all text on an input line that is
  207. after a \verb@%@  which is not part of
  208. an occurrence of the control symbol
  209. \verb@\%@ is discarded by the compiler.
  210. Here is an example:
  211.  
  212. \moveright0.1\textwidth\vbox{%
  213. \footnotesize\begin{verbatim}
  214. There was a 100\% turnout today,
  215. an all-time record.  %perhaps I should check this claim!
  216. %Indeed, there are lots of unsubstantiated claims here!
  217. This made for an extremely productive session.
  218. \end{verbatim}
  219. }
  220. \noindent will yields
  221.  
  222. \result{%
  223. There was a 100\% turnout today,
  224. an all-time record.  %perhaps I should check this claim!
  225. %Indeed, there are lots of unsubstantiated claims here!
  226. This made for an extremely productive session.
  227. }
  228.  
  229. \subsection{Footnotes}
  230. Inserting footnotes is easy---\LaTeX\ will position and
  231. number them for you.  You just indicate {\em exactly\/}
  232. where the footnote marker should go, and provide the
  233. text of the footnote.  The footnote text will be
  234. placed at the bottom of the present page in a somewhat
  235. smaller font, and be separated from the main text by
  236. a short horizontal rule\footnote{See for yourself!  It's
  237. easy when you don't have to do any work.} to conform with
  238. convention.  The footnote in the last line was typed
  239. like this:
  240.  
  241. \moveright0.1\textwidth\vbox{%
  242. \footnotesize\begin{verbatim}
  243. ...rule\footnote{See for yourself! It's easy ...work.} to conform
  244. \end{verbatim}
  245. }
  246. No space was typed between the {\tt rule} and the
  247. \verb@\footnote@, because we want the footnote
  248. marker to appear right next to the last letter of the word.
  249.  
  250. Multiple footnotes\footnote{Here is another footnote} are
  251. obtained just by using the \verb@\footnote@ command
  252. again and again.
  253.  
  254. \subsection{Topmatter}
  255. We declare the title and author information using the
  256. \verb@\title@ and \verb@\author@ commands, each of
  257. which accept a single argument.  Multiple authors
  258. are all listed in the argument of \verb@\title@,
  259. separated by \verb@\and@'s.  The \verb@\date@
  260. command can be used to date a document.  After
  261. we have declared each of these, we issue a
  262. \verb@\maketitle@ command to have them typeset for
  263. us.  In the \verb@book@ and \verb@article@ document
  264. styles this will result in a separate page; in
  265. the \verb@article@ style the ``top matter'' will
  266. be placed at the top of the first page.  The style
  267. files determine the placement and the choice of font.
  268.  
  269. \moveright0.1\textwidth\vbox{%
  270. \footnotesize\begin{verbatim}
  271. \title{A Thought for the Day}
  272. \author{Fred Basset \and Horace Hosepipe}
  273. \date{November 1992}
  274. \maketitle
  275. \end{verbatim}
  276. }
  277. \noindent will produce something along the lines of
  278.  
  279. \result{%
  280. \begin{center}
  281. {\Large A Thought for the Day}\\
  282. \smallskip Fred Basset\quad Horace Hosepipe\\
  283. \smallskip November 1992
  284. \end{center}
  285. }
  286.  
  287. This topmatter must appear {\em after\/} the 
  288. \verb"\begin{document}" and before any other printing material.
  289.  
  290. \subsection{Sectioning commands}
  291. As part of our task of describing the logical structure of
  292. the document, we must indicate to \LaTeX\ where to start sectional
  293. units.  To do this we make use of the sectioning commands shown
  294. in table~\ref{tab:sectioning}.
  295.  
  296. \begin{table}[ht]
  297. \centering
  298. {\tt
  299. \begin{tabular}{lll}
  300. \bs part & \bs subsection & \bs paragraph\\
  301. \bs chapter & \bs subsubsection & \bs subparagraph\\
  302. \bs section & & \\
  303. \end{tabular}
  304. }
  305. \caption{\LaTeX\ sectioning commands}
  306. \label{tab:sectioning}
  307. \end{table}
  308.  
  309. Each sectioning command accepts a single argument---the section
  310. heading that is to be used.  \LaTeX\ will provide the section
  311. numbering (and numbering of subsections within sections, etc.)\
  312. so there is no need to include any number in the argument.
  313. \LaTeX\ will also take care of whatever spacing is required to
  314. set the new logical unit off from the others, perhaps through
  315. a little extra space and using a larger font.  It will
  316. also start a new page in the case that a new chapter is
  317. begun.
  318.  
  319. The \verb@\part@ command is used for major subdivisions of
  320. substantial documents.  The \verb@\paragraph@ and
  321. \verb@\subparagraph@ commands are, unfortunately
  322. confusing.  They are used to section off a modest number of
  323. paragraphs of text---they don't start new paragraphs (remember that
  324. that was done by leaving a blank line in our input file).
  325. The names were retained for historical reasons.
  326.  
  327. It is always a good idea to {\em plan\/} the overall
  328. sectional structure of a document in advance, or at least
  329. give it a little thought.  Not that it would be difficult to
  330. change your mind later (you could use the global replace
  331. feature of an editor, for instance), but so that you have
  332. a good idea of the structure that you have to describe to
  333. \LaTeX.
  334.  
  335. The sectioning command that began the present sectional unit
  336. of this document was
  337.  
  338. \moveright0.1\textwidth\vbox{%
  339. \begin{verbatim}
  340. \subsection{Sectioning commands}
  341. \end{verbatim}
  342. }
  343. \noindent and that was all that was required to get the numbered
  344. section name and the table of contents entry.
  345.  
  346. There are occasions when you want a heading to have all the
  347. appearance of a particular sectioning command, but shouldn't
  348. be numbered as a section in its own right or produce a table
  349. of contents entry.  This can be achieved through using the
  350. {\em *-form\/} of the command, as in \verb@\section*{...}@.
  351. We'll see that many \LaTeX\ commands have such a *-form
  352. which modify their behaviour slightly.
  353.  
  354. Not only will \LaTeX\ number your sectional units for you,
  355. it will compile a table of contents too.  Just include the
  356. command \verb@\tableofcontents@ after the 
  357. \verb@\begin{document}@ command and after the topmatter that
  358. should precede it.
  359.  
  360.  
  361. \subsection{\LaTeX\ environments}
  362. Perhaps the most powerful and convenient concept in the \LaTeX\
  363. syntax is that of an {\em environment}.  We will see most of
  364. the ``heavy'' typesetting problems we will encounter can be best
  365. tackled by one or other of the \LaTeX\ environments.
  366.  
  367. Some environments are used to {\em display\/} a portion of text,
  368. i.e.\ to set it off from the surrounding text by indenting it.
  369. The {\tt quote} and {\tt verse} environments are examples of
  370. these.  The {\tt center} environment allows us to centre
  371. portions of text, while the {\tt flushright} environment
  372. sets small portions of text flush against the right margin.
  373.  
  374. But the true power of \LaTeX\ begins to show itself when
  375. we look at environments such as those that provide facilities
  376. for itemised or enumerated lists, complex tabular arrangements,
  377. and for taking care of figure and table positioning and captioning.
  378. What we learn here will also be applicable in typesetting some
  379. complicated mathematical arrangements in the next chapter.
  380.  
  381. All the environments are begun by a {\tt \bs begin{\{{\em name}\}}}
  382. command and ended by an {\tt \bs end{\em \{name\}}}, where
  383. {\em name\/} is the environment name.  These commands also
  384. serve as begin-group and end-group\footnote{See section \ref{sec:groups}}
  385. markers, so that all commands are local to the present environment---they
  386. cannot affect text outside the environment.
  387.  
  388. We can also have environment embedded within environment within
  389. environment and so on, limited only by memory available on the
  390. computer.  We must, however, be careful to check that each of
  391. these {\em nested\/} environments is indeed contained within
  392. the one just outside of it.
  393.  
  394. \nsubsubsection{{\tt em} environment}
  395. We start with a very simple environment, one which provides
  396. an alternative to the \verb@\em@ command.  Remember that
  397. \verb@\em@ does not accept an argument; it applies to
  398. everything within its scope as dictated by the group
  399. within which it is used.  This can be tricky if we wish
  400. to emphasise a large amount of text, for we may forget
  401. a group-delimiting brace and so upset the entire grouping
  402. structure of our document.  In cases where we fear this might
  403. happen, we can proceed as follows.
  404.  
  405. \moveright0.1\textwidth\vbox{%
  406. \footnotesize\begin{verbatim}
  407. \begin{em}
  408. We must always be careful to match our group-delimiting
  409. braces correctly.  If the braces in a document are unevenly
  410. matched then \LaTeX\ will become confused because we will
  411. have, in effect, indicated different scopes than we
  412. intended for commands.
  413. \end{em}
  414. \end{verbatim}
  415. }
  416. \noindent which will give
  417.  
  418. \result{%
  419. \begin{em}
  420. We must always be careful to match our group-delimiting
  421. braces correctly.  If the braces in a document are unevenly
  422. matched then \LaTeX\ will become confused because we will
  423. have, in effect, indicated different scopes than we
  424. intended for commands.
  425. \end{em}
  426. }
  427.  
  428. Although \LaTeX\ doesn't care too much for how we format
  429. our source file, it is obviously a good idea to lay it
  430. out logically and readably anyway.  This helps minimise
  431. errors as well as aids in finding them.  For this reason
  432. I have adopted the convention of always placing the
  433. environment \verb@\begin@ and \verb@\end@ commands on
  434. lines by themselves.
  435.  
  436. \nsubsubsection{{\tt quote} and {\tt quotation} environments}
  437. This environment can be used to display a part
  438. of a sentence or paragraph, or even several
  439. paragraphs, in such a manner that the material
  440. stands out from the rest of the text.  This can
  441. be used to enhance readability, or to simply
  442. emphasise something.  Its syntax is simple:
  443.  
  444. \moveright0.05\textwidth\vbox{%
  445. \footnotesize\begin{verbatim}
  446. Horace smiled and retaliated:
  447. \begin{quote}
  448. \em You can mock the non-WYSIWYG nature of \TeX\
  449. all you like.  You don't understand that that is
  450. precisely what makes \TeX\ enormously more powerful
  451. than that lame excuse for a typesetter you use.
  452. And I'll bet that from start to finish of preparing
  453. a document I'm quicker than you are, even if you
  454. do type at twice the speed and have the so-called
  455. advantage of WYSIWYG.  In your case, what you see
  456. is {\em all\/} you get!
  457. \end{quote}
  458. and then continued with composing his masterpiece of the
  459. typesetting art.
  460. \end{verbatim}
  461. }
  462. \noindent produces the following typeset material:
  463.  
  464. \moveleft0.05\textwidth\vbox{\result{%
  465. \noindent Horace smiled and retaliated:
  466. \begin{quote}
  467. \noindent\em You can mock the non-WYSIWYG nature of \TeX\
  468. all you like.  You don't understand that that is
  469. precisely what makes \TeX\ enormously more powerful
  470. than that lame excuse for a typesetter you use.
  471. And I'll bet that from start to finish of preparing
  472. a document I'm quicker than you are, even if you
  473. do type at twice the speed and have the so-called
  474. advantage of WYSIWYG.  In your case, what you see
  475. is {\em all\/} you get!
  476. \end{quote}
  477. and then continued with composing his masterpiece of the
  478. typesetting art.
  479. }
  480. }
  481.  
  482. That is a much more readable manner of presenting Horace's
  483. piece of mind than embedding it within a regular paragraph.
  484. The {\tt quote} environment was responsible for the margins
  485. being indented on both sides during the quote.  This example
  486. has also been used to show how the commands that begin and
  487. end an environment restrict the scope of commands issued within
  488. that environment: The \verb@\em@ at the beginning of the
  489. quote did not affect the text following the quote.  We have
  490. also learned here that if we use \verb@\em@ within already
  491. emphasised text, the result is roman type---and we don't
  492. require an italic correction here because the final letter
  493. of `all' was not sloping to the right.
  494.  
  495. The {\tt quotation} environment is used in just the same way
  496. as the {\tt quote} environment above, but it is intended
  497. for setting long quotations of several paragraphs.  It would
  498. be suitable for quoting a few paragraphs from the text of
  499. some speech, for instance.  \LaTeX\ treats the given
  500. text just like normal text that it has to set into paragraphs,
  501. except that it indents the margins a little.
  502.  
  503. \nsubsubsection{{\tt verse} environment}
  504. This is provided to facilitate the setting of poetry.
  505. When within the {\tt verse} environment, we use
  506. \verb@\newline@ (or \verb@\\@) to end a line; and
  507. what would normally signify a new paragraph
  508. serves to indicate the start of a new stanza.
  509. Let's have a shot at some cheap poetry.
  510.  
  511. \moveright0.1\textwidth\vbox{%
  512. \footnotesize\begin{verbatim}
  513. \begin{verse}
  514. Roses are red\\
  515. Violets are blue\\
  516. I think \TeX\ is great\\
  517. And so will you!
  518.  
  519. Roses are still red\\
  520. Violets are still blue\\
  521. I'm schizophrenic\\
  522. And so am I.
  523. \end{verse}
  524. \end{verbatim}
  525. }
  526. \noindent will produce the following stunningly-creative ``poem'':
  527.  
  528. \result{%
  529. \begin{verse}
  530. Roses are red\\
  531. Violets are blue\\
  532. I think \TeX\ is great\\
  533. And so will you!
  534.  
  535. Roses are still red\\
  536. Violets are still blue\\
  537. I'm schizophrenic\\
  538. And so am I.
  539. \end{verse}
  540. }
  541.  
  542.  
  543.  
  544. \nsubsubsection{{\tt center} environment}
  545. This environment allows the centring of consecutive lines
  546. of text, new lines being indicated by a \verb@\\@.  If you
  547. don't separate lines with the \verb@\\@ command then you'll
  548. get a centred paragraph the width of the page,
  549. which won't look any different to normal.  If only one
  550. line is to be centred, then no \verb@\\@ is necessary.
  551.  
  552. \moveright0.1\textwidth\vbox{%
  553. \footnotesize\begin{verbatim}
  554. The {\tt center} environment takes care of the vertical
  555. spacing before and after it, so we don't need to leave any.
  556. \begin{center}
  557. If we leave no blank line after the\\
  558. {\tt center} environment\\
  559. then the ensuing text will not\\
  560. be regarded as part of a new\\
  561. paragraph, and so will not be indented.\\
  562. \end{center}
  563.  
  564. In this case we left a blank line after the environment,
  565. so the new text was regarded as starting a new paragraph.
  566. \end{verbatim}
  567. }
  568. \noindent gives the following text
  569.  
  570. \result{%
  571. The {\tt center} environment takes care of the vertical
  572. spacing before and after it, so we don't need to leave any.
  573. \begin{center}
  574. If we leave no blank line after the\\
  575. {\tt center} environment\\
  576. then the ensuing text will not\\
  577. be regarded as part of a new\\
  578. paragraph, and so will not be indented.\\
  579. \end{center}
  580.  
  581. In this case we left a blank line after the environment,
  582. so the new text was regarded as starting a new paragraph.
  583. }
  584.  
  585. \nsubsubsection{{\tt flushright} and {\tt flushleft} environments}
  586. The {\tt flushright} environment causes each line to be set
  587. with its last character against the right margin, without trying
  588. to stretch the line to to current text width.  The {\tt flushleft}
  589. environment is similar.
  590.  
  591. \moveright0.1\textwidth\vbox{%
  592. \footnotesize\begin{verbatim}
  593. We can stop \LaTeX\ from justifying each line to both the
  594. left and the right margins.
  595. \begin{flushright}
  596. The {\tt flushright} environment is\\
  597. used for text with an even right margin\\
  598. and a ragged left margin.
  599. \end{flushright}
  600. \begin{flushleft}
  601. and the {\tt flushleft} environment is\\
  602. used for text with an even left margin\\
  603. and a ragged right margin.
  604. \end{flushleft}
  605. \end{verbatim}
  606. }
  607. \noindent gives the desired display
  608.  
  609. \result{%
  610. We can stop \LaTeX\ from justifying each line to both the
  611. left and the right margins.
  612. \begin{flushright}
  613. The {\tt flushright} environment is\\
  614. used for text with an even right margin\\
  615. and a ragged left margin.
  616. \end{flushright}
  617. \begin{flushleft}
  618. and the {\tt flushleft} environment is\\
  619. used for text with an even left margin\\
  620. and a ragged right margin.
  621. \end{flushleft}
  622. }
  623.  
  624. One must be wary not to lapse into ``word-processing'' mode
  625. when using these environments.  Remember that pressing return
  626. at the end of a line in the input file does not serve to end
  627. the current line there, but just to indicate the end of another word.
  628. We have to use the \verb@\\@ command to end a line.
  629.  
  630. \nsubsubsection{{\tt verbatim} environment}
  631. We can simulate typed text using the {\tt verbatim} environment.
  632. The \verb@\tt@ (typewriter text) type style can be used for
  633. simulating typed words, but runs into trouble if one of the
  634. characters in the simulated typed text is a specially reserved
  635. \LaTeX\ character.  For instance, \verb@{\tt type \newline}@
  636. would not have the desired effect because \LaTeX\ would
  637. interpret the \verb@\newline@ is an instruction to start
  638. a new line.
  639.  
  640. The {\tt verbatim} environment allows the simulation of multiple
  641. typed lines.  {\em Everything\/} within the environment is
  642. typeset in typewriter font exactly as it appears in our source
  643. file---obeying spaces and line breaks as in the source file and
  644. not recognising the existence of any special symbols.
  645.  
  646. % this is going to be ugly, because we can't demonstrate an
  647. % \end{verbatim} using the verbatim environment
  648. \moveright0.1\textwidth\vbox{%
  649. \footnotesize\begin{flushleft}
  650. \tt\bs begin\{verbatim\}\\
  651. In the verbatim environment we can type anything\\
  652. we like.\\
  653. So we don't  need to look out for uses of \%, \$, \& etc,\\
  654. nor will control sequences like \bs newline have any\\
  655. effect.\\
  656. \bs end\{verbatim\}
  657. \end{flushleft}
  658. }
  659. \noindent will produce the simulated input text
  660.  
  661. \moveright0.1\textwidth\vbox{%
  662. \footnotesize\begin{verbatim}
  663. In the verbatim environment we can type anything
  664. we like.
  665. So we don't  need to look out for uses of %, $, & etc,
  666. nor will control sequences like \newline have any 
  667. effect.
  668. \end{verbatim}
  669. }
  670.  
  671. The only thing that cannot be typed in the {\tt verbatim}
  672. environment is the sequence \verb@\end{verbatim}@.  You
  673. might notice that I still managed to simulate that
  674. control sequence above.  One can always get what you want
  675. in \TeX, perhaps with a little creativity.
  676.  
  677. If we want only to simulate a few typed words, such as when
  678. I say to use \verb@\newline@ to start a new line, then the
  679. \verb@\verb@ command is used.  This command has a slightly
  680. odd syntax, pressed upon it by the use for which it was
  681. intended. It cannot accept an argument, because we may 
  682. want to simulate typed text that is enclosed by
  683. \verb@{braces}@.  What one does is to choose any character
  684. that is {\em not\/} in the text to be simulated, and use
  685. a pair of these characters as ``argument delimiters''.  I usually use the 
  686. \verb"@" or \verb@"@ charachters, as I rarely have any other uses for them.
  687. Thus
  688.  
  689. \result{%
  690. \noindent use \verb"\%" to obtain a \% sign
  691. }
  692. \noindent is typed as
  693.  
  694. \moveright0.1\textwidth\vbox{
  695. \footnotesize\begin{verbatim}
  696. use \verb"\%" to obtain a \% sign
  697. \end{verbatim}
  698. }
  699.  
  700. \nsubsubsection{{\tt itemize}, {\tt enumerate}, {\tt description} environments}
  701. \LaTeX\ provides three predefined list-making environment, and a 
  702. ``primitive'' list environment for designing new list environments
  703. of your own.  We shall just describe the predefined ones here.
  704.  
  705. There is delightfully little to learn in order to be able to create
  706. lists.  The only new command is \verb@\item@ which indicates the
  707. beginning of a new list item (and the end of the last one if this is
  708. not the first item).  This command accepts an optional argument
  709. (which means you'd enclose it in square brackets) that can be
  710. used to provide an item label.  If no optional argument is given, then
  711. \LaTeX\ will provide the item label for you;  in an
  712. {\tt itemize} list it will bullet the items, in an
  713. {\tt enumerate} list it will number the items, and in a list
  714. of {\tt description}s the default is to have no label (which would look
  715. a bit odd, so you're expected to use the optional argument there).
  716.  
  717. Remember that \verb@\item@ is used to separate list items; it
  718. does not accept the list item as an argument.  
  719.  
  720. \moveright0.1\textwidth\vbox{%
  721. \footnotesize\begin{verbatim}
  722. \begin{itemize}
  723. \item an item is begun with \verb@\item@
  724. \item if we don't specify labels, then
  725.       \LaTeX\ will bullet the items for us
  726. \item I indent lines after the first in the
  727.       input file, but that is just to keep things
  728.       readable.  As always, \LaTeX\ ignores additional
  729.       spaces.
  730.  
  731. \item a blank line between items is ignored, for
  732.       \LaTeX\ is responsible for spacing items.
  733. \item \LaTeX\ is in paragraph-setting mode when
  734.       it reads the text of an item, and so will
  735.       perform all the usual functions
  736. \end{itemize}
  737. \end{verbatim}
  738. }
  739. \noindent produces the following itemised list:
  740.  
  741. \result{
  742. \begin{itemize}
  743. \item an item is begun with {\tt\bs item}%\verb blew up here!
  744. \item if we don't specify labels, then
  745.       \LaTeX\ will bullet the items for us
  746. \item I indent lines after the first in the
  747.       input file, but that is just to keep things
  748.       readable.  As always, \LaTeX\ ignores additional
  749.       spaces.
  750.  
  751. \item a blank line between items is ignored, for
  752.       \LaTeX\ is responsible for spacing items.
  753. \item \LaTeX\ is in paragraph-setting mode when
  754.       it reads the text of an item, and so will
  755.       perform all the usual functions
  756. \end{itemize}
  757. }
  758.  
  759. Lists can also be embedded within one another,
  760. for they are just environments and we said that
  761. environments have this property.  Remember that
  762. we must nest them in the correct order.  We
  763. demonstrate with the following list, which also
  764. shows how to use the {\tt enumerate} environment.
  765.  
  766. \moveright0.1\textwidth\vbox{%
  767. \footnotesize\begin{verbatim}
  768. \noindent I still have to do the following things:
  769. \begin{enumerate}
  770. \item Sort out LAN accounts for people on the course
  771.    \begin{itemize}
  772.    \item Have new accounts created for those not already
  773.          registered on the LAN
  774.    \item Make sure all users have a personal directory
  775.         on the data drive
  776.    \item Give read and scan rights to users in the \TeX\
  777.          directories
  778.    \item Add users to the appropriate LAN print queues
  779.    \end{itemize}
  780. \item Have a \TeX\ batch file added to a directory that
  781.       is on a public search path
  782. \item Finish typing these course notes and proof-read them
  783. \item Photocopy and bind the finished notes
  784. \end{enumerate}
  785. \end{verbatim}
  786. }
  787. \noindent will give the following list
  788.  
  789. \result{
  790. I still have to do the following things:
  791. \begin{enumerate}
  792. \item Sort out LAN accounts for people on the course
  793.    \begin{itemize}
  794.    \item Have new accounts created for those not already
  795.          registered on the LAN
  796.    \item Make sure all users have a personal directory
  797.         on the data drive
  798.    \item Give read and scan rights to users in the \TeX\
  799.          directories
  800.    \item Add users to the appropriate LAN print queues
  801.    \end{itemize}
  802. \item Have a \TeX\ batch file added to a directory that
  803.       is on a public search path
  804. \item Finish typing these course notes and proof-read them
  805. \item Photocopy and bind the finished notes
  806. \end{enumerate}
  807. }
  808.  
  809. See how I lay the source file out in a readable fashion.
  810. This is to assist myself, not \LaTeX.
  811.  
  812. The {\tt description} environment is, unsurprisingly, 
  813. for making lists of descriptions.
  814.  
  815. \moveright0.1\textwidth\vbox{%
  816. \footnotesize\begin{verbatim}
  817. \begin{description}
  818. \item[\tt itemize] an environment for setting itemised lists.
  819. \item[\tt enumerate] an environment for setting numbered lists.
  820. \item[\tt description] an environment for listing descriptions.
  821. \end{description}
  822. \end{verbatim}
  823. }
  824. \noindent will typeset the following descriptions:
  825.  
  826. \result{%
  827. \begin{description}
  828. \item[\tt itemize] an environment for setting itemised lists.
  829. \item[\tt enumerate] an environment for setting numbered lists.
  830. \item[\tt description] an environment for listing descriptions.
  831. \end{description}
  832. }
  833.  
  834. Note that the scope of the \verb@\tt@ commands used in the
  835. item labels was restricted to the labels.
  836.  
  837. \nsubsubsection{{\tt tabbing} environment}
  838. This environment simulates tabbing on typewriters.
  839. There one chose the tab stops in advance (analysing
  840. the material to be typed for the longest item in
  841. each column) and typed entries consecutively,
  842. hitting the tab key to move to the next tab stop
  843. and return to move to the next line.
  844.  
  845. In the {\tt tabbing} environment, we proceed similarly.
  846. We look for the worst-case line (that which will 
  847. determine the desired tab stops) and use it to
  848. set the tabs by inserting \verb@\=@ control symbols
  849. at the points where we want tab stops. We then discard
  850. that line using \verb@\kill@, since the worst-case line
  851. might not be the first line in the material we have to
  852. type.  We then type each line, using \verb@\>@ to move
  853. to the next tab stop and \verb@\\@ to end a line.
  854.  
  855. \moveright0.1\textwidth\vbox{%
  856. \footnotesize\begin{verbatim}
  857. \begin{tabbing}
  858. Cheddar cheese \= Recommended \= \$2.00 \kill
  859. Green Ham \> Recommended \> \$2.00
  860. Eggs \> 1 a week \> \$1.50
  861. Cheddar cheese \> Hmmm \> \$0.80
  862. Yak cheese \> Avoid \> \$0.05
  863. \end{tabbing}
  864. \end{verbatim}
  865. }
  866. \noindent gives the following uniformly-tabbed table
  867.  
  868. \result{%
  869. \begin{tabbing}
  870. Cheddar cheese \= Recommended \= \$2.00 \kill
  871. Green Ham      \> Recommended \> \$2.00\\
  872. Eggs           \> 1 a week    \> \$1.50\\
  873. Cheddar cheese \> Hmmm   \> \$0.80\\
  874. Yak cheese     \> Avoid  \> \$0.05
  875. \end{tabbing}
  876. }
  877.  
  878. In the format line I chose the longest entry
  879. from each of the prospective columns.  I lined
  880. some of the \verb@\>@ commands up in the source
  881. just to keep things readable.
  882.  
  883. Remember that excess spaces are ignored.  \LaTeX\
  884. sets the \verb@\kill@ed line normally and sees where the
  885. tab stops requested will be needed in the typeset text.
  886. Note also that commands given within the {\tt tabbing}
  887. environment are local to {\em the current item}. 
  888.  
  889. Actually, we use the above approach in the case that
  890. we require uniformly tabbed columns.  The format line
  891. is not compulsory, and we can define tab stops dynamically.
  892. See if you can make sense of the following.
  893.  
  894. \moveright0.1\textwidth\vbox{%
  895. \footnotesize\begin{verbatim}
  896. \begin{tabbing}
  897. Entry in position 1,1 \= Entry 1,2 \= Entry 1,3\\
  898. Entry in position 2,1 \> Entry 2,2 \> Entry 2,3\\
  899. Entry 3,1 \= Entry 3,2 \> Entry 3,3\\
  900. Entry 4,1 \> Entry 4,2 \> Entry 4,3
  901. \end{tabbing}
  902. \end{verbatim}
  903. }
  904. \noindent which produces
  905.  
  906. \result{%
  907. \begin{tabbing}
  908. Entry in position 1,1 \= Entry 1,2 \= Entry 1,3\\
  909. Entry in position 2,1 \> Entry 2,2 \> Entry 2,3\\
  910. Entry 3,1 \= Entry 3,2 \> Entry 3,3\\
  911. Entry 4,1 \> Entry 4,2 \> Entry 4,3
  912. \end{tabbing}
  913. }
  914.  
  915. The are additional commands that can be used within
  916. the tabbing environment to achieve special effects,
  917. but we won't be discussing them here.
  918.  
  919. \nsubsubsection{{\tt tabular} environment}
  920. The {\tt tabular} environment is used to produce
  921. tables of items, particularly when the table
  922. is predominantly rectangular and when line drawing
  923. is required.  \LaTeX\ will make most decisions for
  924. us;  for instance it will align everything for us
  925. without having to be told which are the longest
  926. entries in each column.
  927.  
  928. This environment is the first of many that use the
  929. \TeX\ ``tabbing character'' {\tt \&}.  This character
  930. is used to separate consecutive entries in a row
  931. of a table, array, etc.  The end of a row is indicated
  932. in the usual manner, by using \verb@\\@.
  933. In this way the individual cells of the table, or array,
  934. are clearly described to \LaTeX, and it can analyse
  935. them to make typesetting decisions.  Commands issued
  936. within a cell so defined are, again, local to that
  937. cell.
  938.  
  939. The {\tt tabular} environment is also our first example
  940. of an {\em environment with arguments}.  The arguments
  941. are given, in braces as usual, just after the closing
  942. brace after the environments name.  In the case of
  943. {\tt tabular} there is a single mandatory argument
  944. giving the justification of the entries in each column:
  945. {\tt l} for left justified, {\tt r} for right justified,
  946. and {\tt c} for centred.  There must be an entry for each
  947. column of the table, and there is no default.  Let's start
  948. with a simple table.
  949.  
  950. \moveright0.1\textwidth\vbox{%
  951. \footnotesize\begin{verbatim}
  952. \begin{tabular}{llrrl}
  953. \bf Student name & \bf Number & \bf Test 1 & \bf Test 2 & \bf Comment\\
  954. F. Basset    & 865432 & 78     & 85     & Pleasing\\
  955. H. Hosepipe  & 829134 & 5      & 10     & Improving\\
  956. I.N. Middle  & 853931 & 48     & 47     & Can make it
  957. \end{tabular}
  958. \end{verbatim}
  959. }
  960. \noindent will produce the following no-frills table
  961.  
  962. \result{%
  963. \begin{tabular}{llrrl}
  964. \bf Student name & \bf Number & \bf Test 1 & \bf Test 2 & \bf Comment\\
  965. F. Basset        & 865432     & 78         & 85         & Pleasing\\
  966. H. Hosepipe      & 829134     & 5          & 10         & Improving\\
  967. I.N. Middle      & 853931     & 48         & 47         & Can make it
  968. \end{tabular}
  969. }
  970. Note that a \verb@\\@ was not necessary at the end
  971. of the last row.  Also note that, once again, the alignment
  972. of the \verb@&@ characters was for human readability.
  973. It is conventional to set columns of numbers with right
  974. justification.  The \verb@\bf@ directives apply only the
  975. entries in which they are given.
  976.  
  977. A {\tt |} typed in the {\tt tabular} environment's argument
  978. causes a vertical line to be drawn at the indicated position
  979. and extending for the height of the entire table.  An
  980. \verb@\hline@ given in the environment draws a horizontal
  981. line extending the width of the table to be drawn at the
  982. vertical position at which the command is given.
  983. A \verb@\cline@$\{i$-$j\}$ draws a line spanning columns
  984. $i$ to $j$, at the vertical position at which the
  985. command is given.  A repeated line-drawing command
  986. causes a double line to be drawn.  We illustrate line
  987. drawing in tables by putting some lines into our first
  988. table.  We will type this example in a somewhat expanded
  989. form, trying to make it clear why the lines appear where they
  990. do.
  991.  
  992. \moveright0.1\textwidth\vbox{%
  993. \footnotesize\begin{verbatim}
  994. \begin{tabular}{|l|l|r|r|l|}
  995. \hline
  996. \bf Student name & \bf Number & \bf Test 1 & \bf Test 2 & \bf Comment\\
  997. \hline
  998. F. Basset        & 865432     & 78         & 85         & Pleasing\\
  999. \hline
  1000. H. Hosepipe      & 829134     & 5          & 10         & Improving\\
  1001. \hline
  1002. I.N. Middle      & 853931     & 48         & 47         & Can make it\\
  1003. \hline
  1004. \end{tabular}
  1005. \end{verbatim}
  1006. }
  1007. \noindent which will give
  1008.  
  1009. \result{%
  1010. \begin{tabular}{|l|l|r|r|l|}
  1011. \hline
  1012. \bf Student name & \bf Number & \bf Test 1 & \bf Test 2 & \bf Comment\\
  1013. \hline
  1014. F. Basset        & 865432     & 78         & 85         & Pleasing\\
  1015. \hline
  1016. H. Hosepipe      & 829134     & 5          & 10         & Improving\\
  1017. \hline
  1018. I.N. Middle      & 853931     & 48         & 47         & Can make it\\
  1019. \hline
  1020. \end{tabular}
  1021. }
  1022.  
  1023. --
  1024. Gavin Maltby, University of Natal, Pietermaritzburg, South Africa
  1025. gmaltby@unpcs1.cs.unp.ac.za, maltby@unpsun1.cc.unp.ac.za
  1026. Any opinion expressed is mine and mine alone.
  1027. ------------------------------------------------------------------
  1028.