LaTeX formatting tips and tricks
This is a place to record the accumulated wisdom and experience gained as LaTeX projects go through the formatting rounds and post-processing.
Formatting Greek text
In order to format polytonic Greek text, with accents, aspirates, etc., the following can be added to the preamble:
\usepackage[polutonikogreek,english]{babel}
(the last language listed is the document default) and the appropriate language needs to be switched on with either \selectlanguage{english}
, or \selectlanguage{greek}
within the page code. Alternatively, for short phrases there is \textgreek{...}
.
The standard documentation for the babel package gives some useful information. To learn how to code the accents etc consult the document by Apostolos Syropoulos available from Using Latex to type Greek (as a PostScript file 'usage-a4.ps').
There can be problems with accessing the necessary Greek fonts, depending on your TeX installation. The original implementation of Greek with babel assumed METAFONT bitmaps (which don't always work "out of the box" with pdfTeX), but more recently the cbgreek Type 1 fonts have been made available, but only at one design size. Adding \usepackage[10pt]{type1ec}
immediately following the \documentclass
declaration is reputed to make the cbgreek fonts coöperate smoothly.
There are other LaTeX packages (and fontsets) for dealing with polytonic Greek, and these can use different conventions for coding the accents etc (such as the ibycus4 package, which adapts the beta-code of the Thesaurus Linguae Graecae).
Upright math variables
In some old mathematical books the convention was for uppercase variables to be set upright, rather than italic as is the modern convention. The consensus is that, unless the project comments decree otherwise, nothing special should be done with these upright variables in the formatting rounds—pretend the upright variables are italic and format as usual: $F(x)$
inline and \[ F(x) \]
displayed, with no \mathrm
or similar being applied. It is then left to the PPer to either switch to the modern convention and produce an etext with italic uppercase variables, or use something like the following (proposed by blaise) in the preamble—basically changing the font from which uppercase variables are drawn.
\input {t1cmr.fd} \DeclareSymbolFont{upletters} {T1}{cmr} {m}{n} \SetSymbolFont{upletters} {bold}{T1}{cmr} {b}{n} \DeclareSymbolFontAlphabet{\mathnormal}{upletters} \DeclareMathSymbol{A}{\mathalpha}{upletters}{`A} \DeclareMathSymbol{B}{\mathalpha}{upletters}{`B} etc
Another option (not syntactically accurate though) is
\DeclareMathSymbol{A}{\mathalpha}{operators}{`A} \DeclareMathSymbol{B}{\mathalpha}{operators}{`B} etc
Enormous surds
The standard TeX \sqrt
includes a bar indicating the scope of the root. Some old books just use the surd sign, but TeX's standard \surd
doesn't size automatically. Two variations on coding enormous surds are
\DeclareMathDelimiter{\Surd}{\mathopen}{symbols}{"70}{largesymbols}{"70} \left\Surd...\right.
suggested by iarnell, and
\newcommand\Surd[1]{\left\delimiter"4270370 #1\right.} \Surd{...}
suggested by dcwilson.
Surds of other orders
In normal LaTeX you get a cube root via \sqrt[3]{...}
, but the normal \surd
command doesn't have this additional argument for the order of the root.
The following code added to the document preamble should redefine \surd
to act just like \sqrt
in having an optional order argument and in sizing itself to its contents (that is, \surd[7]{\dfrac{x^2-3}{42}}
should work as expected).
\makeatletter \newcommand\Surd[1]{\left\delimiter"4270370 #1\right.} \let\surdsign\Surd \DeclareRobustCommand\surd{\@ifnextchar[\@surd\surdsign} \def\@surd[#1]{\setbox\rootbox\hbox{$\m@th\scriptscriptstyle{#1}$}% \mathpalette\s@rd} \def\s@rd#1#2{% \setbox\z@\hbox{$\m@th#1\surdsign{#2}$}% \dimen@\ht\z@ \advance\dimen@-\dp\z@ \mkern5mu\raise.6\dimen@\copy\rootbox \mkern-10mu\box\z@} \makeatother
Hardcoded theorem numbers
During the formatting rounds the tendency is to preserve in some hardcoded form any numbering etc, for equations, chapters, sections, theorems, exercises, whatever. The PPer may revert to using LaTeX's autonumbering features, but at least the original numbers are still present for reference. For equations this is covered by the guidelines (using \tag
); for chapters and sections the guidelines suggest retaining any numbers in a comment. For theorems, the guidelines refer cryptically to needing additional preamble code: one possibility (due to dcwilson) is as follows (with font stuff modified to suit the particular project).
\usepackage{amsthm} \newtheoremstyle{foo}% name {}% Space above, empty = `usual value' {}% Space below {\upshape}% Body font {\parindent}% Indent amount (empty = no indent, \parindent = para indent) {\bfseries}% Thm head font {.}% Punctuation after thm head {.5em}% Space after thm head: " " = normal interword space; % \newline = linebreak {#1\if!#3!\else\ \fi\thmnote{#3}}% Thm head spec (optional number etc) \theoremstyle{foo} \newtheorem*{theorem}{THEOREM} \newtheorem*{proposition}{PROPOSITION} \newtheorem*{lemma}{LEMMA} \newtheorem*{corollary}{COROLLARY} \newtheorem*{exercise}{EXERCISE}
The intended use is
\begin{theorem}[12]...\end{theorem}
will produce "THEOREM 12. ..."
\begin{lemma}...\end{lemma}
will give just "LEMMA. ..."
\begin{corollary}[TO THEOREM 12]...\end{corollary}
produces "COROLLARY TO THEOREM 12. ...".
Condensed intertext
Often math text will have intertext on the same lines as the math, e.g.
... So, without actually doing the sum of numbers from one to one hundred, Gauss reasoned thusly: | ||
Let | 1 + 2 + ... + 99 + 100 | = S; |
which is | = (1 + 100) + (2 + 99) + ... + (50 + 51), | |
= 101 × 50. | ||
Therefore— | S | = 5,050. |
While
... So, without actually doing the sum of numbers from one to one hundred, Gauss reasoned thusly: Let \begin{align*} 1 + 2 + \ldots + 99 + 100 &= S; \\ \intertext{which is } &= (1+100) + (2+99) + \ldots + (50+51), \\ &= 101 \times 50. \\ \intertext{Therefore--- } S &= 5,050. \end{align*}
is sufficient to represent the information on the page, the appearance can be maintained fairly easily, using flalign
:
... So, without actually doing the sum of numbers from one to one hundred, Gauss reasoned thusly: \begin{flalign*} &\text{\indent Let }& 1 + 2 + \ldots + 99 + 100 &= S; &&\phantom{Therefore--- }\\ &\text{which is }& &= (1+100) + (2+99) + \ldots + (50+51), &&\\ && &= 101 \times 50. &&\\ &\text{Therefore--- }& S &= 5,050. && \end{flalign*}
All the align
environments produce arrays with pairs of columns, alternately right- and left-justified, with proper spacing inside the pairs, and various amounts around them. (In the code above, the blue-colored &
s separate the pairs of columns.) In flalign
, the left- and right-most columns are FLush with the margins, so we can use it to get these bits of intertext to match the image. We want the text to be left-justified, so we want it in the second column, after a zero-width, right-justified column. Then the math and then a third pair, which is flush with the right margin. Normally the third pair needs a \phantom
with width equal to the longest text on the left, so the math will be properly centered.
This technique is not currently recommended for use in F1 or F2. See here for an experimental alternative.