some common (la)tex errors author Martin J. Osborne introduction TeX (and LaTeX, a set of TeX macros) can produce extremely high-quality output. It is particularly strong in typesetting mathematical expressions. Its interpretation of most plain text is consistent with the expectations of an old-fashioned typist. Some differences, however, lead many writers into errors. Further, in order to take care of fine points, it incorporates distinctions that a typist never needed to contemplate. All the following points are discussed in Donald E. Knuth's TeXbook (Addison-Wesley, Reading, Mass., 1984) and other books on TeX, but are overlooked more often than not by the authors of material typeset using TeX that crosses my desk. Most of them are, in a sense, pretty minor. But once you begin to notice the "errors" they will stick out like a sore thumb. The following discussion applies to the conventions for typesetting English in Canada and the US. As far as I know, British conventions are the same. Conventions for typesetting other languages differ. For example, French conventions for spacing are entirely different. periods TeX usually assumes that a period (the character ".") ends a sentence if it is followed by a space, or by a right parenthesis and then a space, or by other similar strings. Consequently it puts more space between a period (or the immediately following right parenthesis or similar character) and the following word than it does between one word and the next. (You can control exactly how much more—see pp. 75–76 of the TeXbook.) A consequence is that if you type "i.e. a word", TeX thinks the period after the "e" ends a sentence, and thus puts too much space after it. The solution is to type "i.e.\ a word". The backslash followed by the space tells TeX that you want a normal interword space, not a sentence-separating space, after the "i.e.". There is one exception in TeX's interpretation of a period (hence the earlier "usually"). If the preceding character is an uppercase letter, TeX assumes that the period does not end a sentence. The idea is that "most likely" (in Knuth's words (p. 74)) the uppercase letter is someone's initial, and thus the period is not sentence-ending. Unfortunately, for anyone who ends sentences with acronyms more often than she types people's initials, Knuth's assumption is not correct. If you write, for example, "... like the axiom PAR. Now consider ...", TeX will treat the period after "PAR" as not sentence-ending. You tell TeX that it is sentence-ending by typing "\@." instead of simply the period. It's a bit tricky to remember to do this. Summary: Type a period alone if the period ends a sentence and does not follow an uppercase letter. Type ".\ " [period, backslash, space] if the period does not end a sentence. Type "\@. " [backslash, at-sign, period, space] if the period ends a sentence and follows an uppercase letter. The same rules apply to exclamation marks and question marks, so if you type one of these that doesn't end a sentence, put "\ " after it. (In my opinion these complicated rules are one of the very few examples of poor design in TeX. If every period that followed an uppercase letter did not end a sentence, the rules would be fine. But in my experience many such periods do end sentences, and I would much prefer all periods followed by spaces to be interpreted as sentence-ending. Probably TeX macros can be written to change TeX's default, but I hesitate to try my hand.) Note to users of Scientific Word: TeX treats n spaces, for n ≥ 1, as equivalent to 1 space. So if you're used to typing two spaces after a period at the end of a sentence, no problem. But if you type a period followed by two spaces in Scientific Word you get ". \ " in the file, which causes TeX to add an extra space after its sentence-separating space after the period. So don't! (Given the extreme rareness with which one wants extra space between sentences, Scientific Word's action doesn't seem sensible. Note that if you type two spaces between words in Scientific Word you also get two spaces, while in TeX you get only one no matter how many you type.) ellipses Three periods in a row make an ellipsis (used to indicate omitted material), but to get an ellipsis, do not type three periods in a row! If you do, the periods will be too tightly spaced (TeX treats them as three periods, one after the other). Instead, type "\ldots", which produces three nicely spaced dots. (According to Matt Swift, the behavior of \ldots is not perfect. His style file, lips.sty (available on CTAN), defines \lips, which he says is better-behaved. I haven't tried it, though I have noticed some unfortunate line breaks after \ldots.) If your ellipsis is in some mathematics, then in some cases you want the three dots centered vertically on the line, rather than sitting on the baseline. To do so, use \cdots. (If you're using the AMSTeX package, \dots will decide where to put the dots. I haven't tried it.) hyphens, en-dashes, em-dashes, and minus signs Hyphens A hyphen separates the parts of a compound word, like "daughter-in-law". To get one, type "-". En-dashes An en-dash is a bit longer than a hyphen, and is used to separate the elements of a range ("see pages 5–7"). To get one, type "--" (two hyphens in a row). (If you really want two hyphens in a row, type "{-}{-}".) Don't use an en-dash to separate compound words, but remember to use en-dashes, not hyphens, for the page ranges in references. Em-dashes An em-dash is a punctuation mark. (As in: "A specter is haunting Europe—the specter of Communism.") To get one, type "---" (three hyphens in a row); the typographical convention is that there is no space between an em-dash and the surrounding text. Minus signs To get a minus sign, which is longer than a hyphen, you need to go into math mode. If you type "-5" in text, the "-" is typeset as a hyphen; you need to type $-5$ (or, if you're using Scientific Word, put the "-5" in math mode). quotation marks If you type " (or '') you get closing quotes. To get opening ones, type . switching from sloping font to upright one When switching from a sloping (italic, or slanted) font to an upright one you need to insert an "italic correction" after any character that hangs over into space needed for the next character. For example, if you type "{\em If} I ...", the top part of the "f" in "If" will be too close to the "I". You need to type "{\em If\/} I ...". But if the character following the sloping font is a period or a comma, you don't need the correction. Further, if you use the LaTeX2e commands \textit{...} or \textsl{...} the correction is handled automatically for you. (At least, that's what The LaTeX Companion (Goossens, Mittelbach, and Samarain; Addison-Wesley, Reading, Mass., 1994, p. 171) says, though my experiments suggest that the correction isn't handled properly if the text is within math. (Try $(\textit{f})$ and you'll find that the "f" bumps into the right parenthesis; you need $(\textit{f\/})$.)) However, here's a tricky point: you do need the correction when switching from a sloping font (e.g. italic) to math italic! And worse still, you may be using an environment (like a theorem) in which the fact that the text will be in a sloping font is not explicit. Suppose, for example, that your theorem environment puts the text of a theorem in an italic font, and you type \begin{theorem}If $f$ is ... \end{theorem} Then the "f" of the "If" will be too close to the math "f". What you need is \begin{theorem}If\/ $f$ is ... \end{theorem} This point may seem to be even more minor than the others, but without the italic correction the spacing can be really poor, especially if the spacing on the line is tight. (You can see many examples in my book Bargaining and markets---I was not aware of the problem until after the book was published.) math and nonmath The spacing rules within math mode are different from those within text. So to get the spacing exactly right, you need to put math in math mode and nonmath in text mode. For example, if you type "Let $x, y \in X$", thinking that a comma is a comma is a comma, so whether it's in math or not doesn't matter, the spacing is not correct. TeX will put the space required after a comma in math after your comma, while you want the space appropriate for text. You need to type "Let $x$, $y \in X$". (Actually, I argue that to be precise you should write "Let $x \in X$ and $y \in X".) You're also in trouble if you type "... is$x.$Thus ...", where the period following the "x" is supposed to be sentence-ending. Because it's in math mode, TeX treats it as a period in math, not as sentence-ending. In a few cases, the math-status of a character may be unclear. For example, are digits math or not? In some Roman fonts, there is no difference between "1" and "$1$", so you may not need to answer the question. But if your digits are in italic text you need to make a decision; "1" creates an italic digit, whereas "$0$" creates a Roman one. Probably you want to type "in the year 2007", but "the value of$f$is$1$." (You definitely need to use math mode if the number is negative (to get the minus sign).) The general rule is simple: if it's math, put it in math mode; if it's not math, don't put it in math mode. text within math All text within math must be in a text box, because TeX's rules for spaces between characters are different in math mode and text mode. TeX treats "$The$" as "T" times "h" times "e", and spaces the characters accordingly. So don't type "the action pair$(Top, Left)$"; you need "the action pair$(\textit{Top},\textit{Left\/})$". (Don't be tempted to type "the action pair$($\textit{Top, Left}$)\$"---the spacing and possibility of a linebreak after the comma should be determined by the rules for math, not for text.) Again the rule is simple: if it's text within math, put it in a text box within the math. Page last modified 2010/10/19 All material copyright © Martin J. Osborne 1996-2010