## General Tips

### Focus on the content and the logical format of a document. Let TeX take care of the visual formatting

A main design goal behind TeX and LaTeX is to relieve an author of the burden of having to be concerned with the visual appearance of a document. Given the basic structural elements of a document, TeX is very good at creating a professionally looking typeset output. All TeX needs to know is the logical function of a particular chunk of text, e.g., whether it is a title (indicated by "\title{...}"), a section heading ("\section{...}"), a list item (\item{...}), a theorem (\begin{thm}...\end{thm}), an inline math expression ($...$), a displayed math expression ($...$), or ordinary text.

Given such information about the logical structure of a document, TeX will take care of all the rest, e.g., what fonts to use, how much space to insert, where to insert linebreaks within text, whether to center a header, or whether to indent a line. TeX is very good at this, it (or rather its author, Don Knuth) knows more about typesetting conventions than almost any author, and it has very sophisticated algorithms to optimize such things as line and page breaks.

Below are some examples of visual formatting that you should avoid. [There are situations where some manual formatting may be appropriate, in e.g., non-standard (i.e., not "article/book type") documents such as exams, announcements, posters, etc., bibliographies, etc. However, for normal papers, books, and theses, such commands should be used very sparingly, if at all.]

• Manual coding of titles and headings. \begin{center} \LARGE Introduction \end{center}, etc. Instead use appropriate logical constructs: \section{...}, etc.
• Explicit font and sizing commands. \textbf, \Large, \small, etc. (To "highlight" a term (e.g. in a definition) use \emph{...} ("emphasis"), a logical highlighting instruction, rather than an explicit font instruction.)
• Forced line breaks or page breaks within ordinary text. \linebreak, \break, \pagebreak, \\, etc. (Occasionally, a \linebreak or \pagebreak may be appropriate to fix a bad line or page break; but this should only be a last resort.)
• Spacing commands. \hspace, \vspace, \bigskip, etc. These are almost never appropriate. If the proper logical structures (\begin{proof} .... \end{proof}, \section{...}, etc.) are used, the appropriate amount of vertical spacing is automatically inserted.
• Forced indentations. \indent, \noindent (Unwanted indentations are often caused by blank lines, which TeX interprets as paragraph breaks. To get rid of the indentations, just delete or comment out the blank line.)
• Forced displaystyle. \displaystyle. (In displays with the displayed math construct $...$ displaystyle is the default, so no explicit \displaystyle is needed. In inline math, if displaystyle is forced with an explicit \displaystyle command, the result usually looks very poor. Either don't use displaystyle, or code the expression as a display, enclosed by $...$. )
• Spacing commands in math mode. Spacing in math mode can be adjusted/finetuned with commands like \, \!, \ . However, in most cases such adjustments are unnecessary and make for poorer looking output since TeX automatically inserts the appropriate amount of spacing. Refer to the Gratzer book for the (very few) situations where TeX doesn't get the spacing quite right, and manual adjustments may be made. In case of doubt, just leave the spacing up to TeX. Even if there are occasional imperfections, not fiddling with the spacing at all is far better (and takes a lot less work!) than overcorrecting by inserting lots of manual spacing.

Bottomline: If you let TeX do its job, the result will almost always look better than if you were to try to use manual formatting commands to force a particular look. On top of that, you'll save yourself quite a bit of time by not having to insert manual formatting commands and fiddling with these until the look is right.

### Respect the modes of TeX: Use ordinary (text) mode for text, math mode for inline math material, and display math mode for displayed equations

The basic "modes" of TeX are text mode, inline math mode, and display math mode. The default is text mode, intended for ordinary (English) text; this is what TeX uses without any special instructions. A pair of dollar signs indicates to TeX that the enclosed chunck is a mathematical expression and is to be typeset in math mode. Similarly, a backslash-bracket pair, or an equation environment such as \begin{align} ... \end{align}, tells TeX that the enclosed material is a formula to be displayed.

There are significant differences in the typesetting of a given chunk of text depending on the mode TeX is in (e.g., the spacing rules are completely different in math mode than in text mode), and if an inappropriate mode is used, the output can look very poor. Thus, it is important to ensure that TeX is in the correct mode, e.g., by enclosing all (inline) math material in a pair of dollar signs, while leaving nonmath material outside dollar sign pairs. This might seem like an obvious rule, but it is commonly violated. Here are some examples:

• Don't italicize words by placing them inside $...$. The letters do come out italicized, but the spacing looks awful since it is optimized for mathmode and the letters will be typeset as if they were mathematical variables, multiplied together.
• Enclose variables and numbers embedded in regular text within dollar signs. For example, in the phrase "Let F be a field", "F" represents a variable and thus should be enclosed in dollar signs: "Let $F$ be a field." The same goes for numbers, though there the differences between text and math mode are more subtle: Instead of "In dimension 3 we have ..." use "In dimension $3$ we have ..."
• Enclose text material inside displays in \text{...}. \text{...} causes the expression enclosed in braces to be typeset in text mode. This is useful in displayed formulas that involve some textual material. For example, in the expression "f(x)= \sin x and g(x)=\cos x ", the word "and" is ordinary text and thus should be typeset in text mode: "$f(x)=\sin x \quad \text{and}\quad g(x)=\cos x$".
• Leave punctuation signs outside (inline) mathematical expressions. A surprisingly common mistake is to include punctuation signs within the dollar signs delimiting a math formula. Punctuation signs are not part of the formula (they belong to the surrounding text), and therefore should not be enclosed within the dollar signs. For example, in the phrase "let $f(x)= cx,$ where c is a constant", the comma is not part of the math expression and therefore should be outside the dollar sign pair: "let $f(x)= cx$, where c is a constant".
• Use mode-specific font commands. Most font changing commands come in two versions, one for ordinary text (e.g., \textbf{...}), and the other for mathematical material (e.g. \mathbf{...}). Use the version appropriate for the mode, e.g.: "A \textbf{field} is ..."; Let $\mathbf{v}$ be a vector...".

### Go by the book (i.e., Gratzer's book). Don't try to improvise

You probably know enough TeX that you could get by (sort of) without further consulting books and references, and it is tempting to do just that. This, however, would be a mistake that will cost you in the long run.

If you come across something you have never encountered before (say, how to put an asterisk on a summation symbol to create a "starred" sum, or how to typeset binomial coefficients), do not try to find a "solution" on your own, but instead check Gratzer's book to see if the situation is covered there. Any fixes you might come up with on your own are likely inferior to the "book solution", and while they may not cause immediate problems when compiling the code, they will probably result in poorly looking output. Moreover, by continuing to do things your own way, you will acquire bad coding habits that are hard to shed and which, aside from leading to inferior looking TeX output, will end up costing you time from using inefficient and wasteful coding techniques.

Note on other Latex books. By "the book" I mean Gratzer's "Math into Latex". This is the authoritative reference on mathematical Latex. The majority of Latex books (and online materials) don't focus on mathematical typesetting, and while they may be useful for nonmathematical Latex, many offer bad, or out-dated, advice on mathematical Latex. As an example, almost all Latex guides recommend the "eqnarray" environment for multiline equations, which has been rendered obsolete by the "align" environment provided by the amsmath package. The "align" environment produces better looking output, is more robust, easier to use, and much more flexible. Gratzer's book is the only one that fully covers this and similar environments.

### Don't blindly copy other people's TeX code

Another very common mistake is to copy somebody else's TeX code. Not everybody is an expert in TeX and produces code that is worth imitating. In fact, the vast majority of papers that I have come across are deficient in some respects, and would make poor examples. If you want to write a paper in LaTeX, start from scratch, or use one of the models in Gratzer's book as a template, rather that using someone else's paper.