\documentclass[11pt]{article} \usepackage[mtbold]{mathtime} \usepackage{graphics} \input{page} \input{thcmac2e} \flushbottom \begin{document} \title{Final Formatting} \author{} \date{} \maketitle \noindent Now we consider some issues that arise in the final formatting of a document: line breaks, page breaks, figure placement, and shrinking the number of pages without rewriting. \section*{Line breaks} We have already seen some rules for when you should disallow line breaks: \begin{itemize} \item Before the last item in a list of two or more short items. Do not type \verb`x and y`. Instead, type \verb`x and~y`. Don't worry about this rule if the items are not short; it's OK to omit the tilde when typing \verb`Dukakis and Bentsen`. \item Between the noun phrase that gives the type of a math symbol and the math symbol itself. Do not type \verb`vertex $v$`. Instead, type \verb`vertex~$v$`. But the two-or-more-item rule supersedes this rule, so you should type \verb`vertices $u$ and~$v$`. \end{itemize} \subheading{Bad math breaks} Sometimes, you just happen to get a bad break within a math expression. For example, try $X = x_1 + x_2 + \cdots + x_n$. I don't like the break before the ellipsis. You can always rewrite to change where the line breaks are. Here's the previous paragraph, rewritten. You can get a bad breaks within a math expression. Consider $X = x_1 + x_2 + \cdots + x_n$. I don't like the break before the ellipsis. There is another way: inhibit the line break by putting the math expression in an \verb`\mbox`. The longer the paragraph, and the shorter the words, the more flexibility \TeX{} will have in how to compensate for the box. Here's that paragraph again, but with an \verb`\mbox`. Sometimes, you just happen to get a bad break within a math expression. For example, try \mbox{$X = x_1 + x_2 + \cdots + x_n$}. I don't like the break before the ellipsis. As you can see, that created an overfull line. We'll see how to deal with overfull lines in a moment, but we have another option here. A math expression can have some natural break points. In the above example, a break after the equals sign wouldn't be so bad. Let's put only the right-hand side in an \verb`\mbox`. Sometimes, you just happen to get a bad break within a math expression. For example, try $X = \mbox{$x_1 + x_2 + \cdots + x_n$}$. I don't like the break before the ellipsis. That's not too bad. Note how the \verb`\mbox` is treated like any other part of the math expression. There are two pairs of dollar signs: one for the entire expression, and one within the \verb`\mbox` to get it back into math mode. Remember that \verb`\mbox` puts you back into the default font and out of math mode. \subheading{Avoiding overfull lines} Your final copy should have no lines that are truly overfull. An overfull line is often due to a lengthy, hyphenated word near the end of a line, for example, commander-in-chief, along with a short paragraph that gives \TeX{} little leeway for line breaking. Why a hyphenated word? Because \TeX{} will hyphenate a hyphenated word only where there is already a hyphen. In other words it's OK with breaking commander-in-chief as commander-/in-chief or commander-in-/chief, but it won't break it as com-/mander-in-chief. Although you can use the \verb`\hyphenation` command to tell \TeX{} how to hyphenate a single word, it doesn't seem to do much with words that are already hyphenated. Instead, use the \verb`\-` command to tell \TeX{} where it is allowed to put a hyphen. Here's the previous paragraph with more relaxed hyphenation. An overfull line is often due to a lengthy, hyphenated word near the end of a line, for example, com\-mander-in-chief, along with a short paragraph that gives \TeX{} little leeway for line breaking. There are other sources of overfull lines. One is boxes, which are never breakable. The \verb`\mbox` command, which we used to prevent a bad line break in math mode, is the most common source of boxes that run into the right margin. Another source is text produced by the \verb`\verb` command, which \TeX{} will never break. In fact, you're not even allowed to have a newline within the argument to a \verb`\verb` command in your .tex file! When you have an overfull box, you'll see a line in the log file and in the console output that tells you about it: {\small \begin{verbatim} Overfull \hbox (6.69226pt too wide) in paragraph at lines 81--84 []\OT1/ptm/m/n/10.95 An over-full line is of-ten due to a lengthy, hy-phen-ated word near the end of a line, for ex-am-ple, commander- \end{verbatim} } The easiest way to avoid overfull lines is to put \verb`\sloppy` and \verb`\fussy` around the paragraph with the overfull line. Leave a blank line before and after each, like so: \sloppy An overfull line is often due to a lengthy, hyphenated word near the end of a line, for example, commander-in-chief, along with a short paragraph that gives \TeX{} little leeway for line breaking. \fussy What's happening here is that \TeX{} has a notion of ``badness'' when it breaks paragraphs into lines. Badness ranges from 0 to~10000, and think of 10000 as infinitely bad. To avoid lines with badness over a certain tolerance (I think it's 1000, but I'm not sure), \TeX{} will make overfull lines, tell you about it in the console and log file, and let \emph{you} deal with it. The \verb`\sloppy` command says to avoid overfull lines, even at the expense of high badness. With \verb`\sloppy`, \TeX{} is even free to produce lines with badness~10000. The \verb`\fussy` command directs \TeX{} to act like its usual fussy self. In the above example, the badness from using \verb`\sloppy` was so little that \TeX{} did not even report on it in the log file. In other cases, the log file will contain a report of an underfull line along with the amount of badness. You usually can see too much whitespace in underfull lines. Here's a contrived example: \sloppy An overfull line is often due to a lengthy, hyphenated word near the end of a line, \mbox{and I'm talking about a word like} commander-in-chief, along with a short paragraph that gives \TeX{} little leeway for line breaking. \fussy If you check the log file, you'll see that in the above example, we got an underfull line with badness~4792. It has too much space between words. For text, if \verb`\sloppy` and \verb`\fussy` don't fix your problem, then you may have to rewrite. The advantage of rewriting is that half the time, your sentence comes out better than before. The disadvantage is that half the time, it doesn't. If you're using the verbatim environment, you can shrink it in both dimensions by using a smaller font. Here's what I would have gotten above if I hadn't used \verb`\small`: \begin{verbatim} Overfull \hbox (20.16559pt too wide) in paragraph at lines 79--82 \OT1/ptm/m/n/10.95 The usual causes of an over-full line in a para-graph are (1 ) a short para-graph and/or (2) [] \end{verbatim} Note that when you use a size-changing command like \verb`\small`, \verb`\footnotesize`, or even \verb`\large`, you need to put it within an environment. That's why there are curly braces around it. Also, I find that the baseline skip---the spacing between consecutve baselines---is sometimes not what I'd expect when I use a size-changing command. \subheading{Math displays} If a displayed equation, whether a single line or an eqnarray, is too wide, you have a few alternatives. If it's a single-line equation, then break it into multiple lines and turn it into an eqnarray. For example, you can turn \[ \prob{A_1 \cap A_2 \cap \cdots \cap A_n} = \prob{A_1} \cdot \prob{A_2 \mid A_1} \cdot \prob{A_3 \mid A_1 \cap A_2} \cdot \prob{A_4 \mid A_1 \cap A_2 \cap A_3} \cdots \prob{A_n \mid A_1 \cap A_2 \cap \cdots \cap A_{n-1}} \] into \begin{eqnarray*} \prob{A_1 \cap A_2 \cap \cdots \cap A_n} & = & \prob{A_1} \cdot \prob{A_2 \mid A_1} \cdot \prob{A_3 \mid A_1 \cap A_2} \cdot \prob{A_4 \mid A_1 \cap A_2 \cap A_3} \cdots \\ & & \prob{A_n \mid A_1 \cap A_2 \cap \cdots \cap A_{n-1}} \ . \end{eqnarray*} If you have an eqnarray that is just a touch too wide, you can use the commands \verb`\narrowarray` and \verb`\normalarray` that you saw previously. For example, here's an array that's too wide: \begin{eqnarray*} m[2,5] & = & \min\left\{\begin{array}{lclclcl} m[2,2] + m[3,5] + p_1 p_2 p_5 & = & 0 + 2500 + 35 \cdot 15 \cdot 20 & = & 0 + 2500 + 10500 & = & 13000\ ,\\ m[2,3] + m[4,5] + p_1 p_3 p_5 & = & 2625 + 1000 + 35 \cdot 5 \cdot 20 & = & 2625 + 100 + 3500 & = & 7125\ ,\\ m[2,4] + m[5,5] + p_1 p_4 p_5 & = & 4375 + 0 + 35 \cdot 10 \cdot 20 & = & 4375 + 0 + 7000 & = & 11375 \end{array}\right.\\ & = & 7125\ . \end{eqnarray*} Reducing the space between all those columns helps: \narrowarray{.15} \begin{eqnarray*} m[2,5] & = & \min\left\{\begin{array}{lclclcl} m[2,2] + m[3,5] + p_1 p_2 p_5 & = & 0 + 2500 + 35 \cdot 15 \cdot 20 & = & 0 + 2500 + 10500 & = & 13000\ ,\\ m[2,3] + m[4,5] + p_1 p_3 p_5 & = & 2625 + 1000 + 35 \cdot 5 \cdot 20 & = & 2625 + 100 + 3500 & = & 7125\ ,\\ m[2,4] + m[5,5] + p_1 p_4 p_5 & = & 4375 + 0 + 35 \cdot 10 \cdot 20 & = & 4375 + 0 + 7000 & = & 11375 \end{array}\right.\\ & = & 7125\ . \end{eqnarray*} \normalarray This equation is quite a bit more squished than I would have liked. The best solution would have been to just use more lines. \section*{Page breaks} As with line breaks, there are two sides to bad page breaks: how to force one where there was not one, and how to inhibit one that occurred. First, a note about widows, orphans, and headings. A \defn{widow line} is a single line from a multiline paragraph that appears at the top of a page. An \defn{orphan line} is the opposite of a widow line: a single line from a multiline paragraph that appears at the bottom of a page. \TeX{} inserts page breaks so as to avoid widow and orphan lines. (By the way, there is also the notion of a \defn{widow word}, which is a single word that appears on a line by itself. \TeX{} will try to avoid widow words as well.) \LaTeX{} will also avoid having a heading appear at the bottom of a page without at least one line of text below it. It is because \TeX{} and \LaTeX{} avoid widow lines, orphan lines, and headings at the bottom of a page that you might see a page break occur earlier than you think is necessary. \subheading{Forcing a page break} That's easy. Use the \verb`\newpage` command. If you're using twocolumn mode, \verb`\newpage` actually starts a new column. Here's a forced page break. \newpage The \verb`\newpage` command will not cause any remaining figures or tables to print. Use \verb`\clearpage` to force a new page and spit out any remaining figures or tables. You can also use the \verb`\pagebreak` command. One difference between \verb`\newpage` and \verb`\pagebreak` is that with \verb`\pagebreak`, you may get the vertical equivalent of an underfull line. \TeX{} normally tries to make each page the same height, and so you might get an abnormal amount of space between paragraphs. If that happens, consider inserting the \verb`\raggedbottom` declaration (rather than the default \verb`\flushbottom`). To show you what I mean, here's a \verb`\pagebreak` command. \pagebreak I generally use \verb`\newpage` so that I don't have to think about \verb`\raggedbottom`. \subheading{Inhibiting a page break} Inhibiting a page break is really the same thing as squeezing more text onto a page. In old \LaTeX{}, there was a \verb`\samepage` command, but it didn't work very well. Actually, there's a \verb`\nopagebreak` command in \LaTeX2e{}, but it doesn't work very well, either. The best way by far to inhibit a page break by squeezing in more text is the \verb`\enlargethispage` command. You give it a length that says by how much you want the vertical size of this particular page to increase. I generally put the \verb`\enlargethispage` command before the last paragraph on the page. I specify the amount as some number of exes, and I always use an integer amount: \verb`\enlargethispage{2ex}`. \sloppy Actually, I always use the starred form: \verb`\enlargethispage*{2ex}`. The starred form also tells \LaTeX{} to shrink the open vertical space on the page as much as possible. For example, it will shrink space before and after math displays, items in a list, and headings. I have even used the command \verb`\enlargethispage*{0ex}` just to shrink vertical space without enlarging the page! \fussy The next two pages show the effect of \verb`\enlargethispage*`. \newpage \begin{enumerate} \item Apples. \item Bananas. \item Coconuts. \item Dates. \item Emeril. \item Figs. \item Grapefruit. \item Ho-ho-kus, New Jersey. \item Irvington, New Jersey. \item Jujubees. \item Kale. \item Lactose-intolerance. \item Mangos. \item Nomar Garciaparra. \item Ortiz, David. \item Plantains. \item Quince. \item Radishes. \item Skeletons from the Closet. \item Terrapin Station. \item Ugueth Urbina. \item Vona Knuckles. \item Wish I had a monkey. \item Xacto knife. \item Yellowknife. \item Zither. \item Zircon-encrusted tweezers. \item Zarley Zalapski. \item ZZ Top. \item Zarathustra. \end{enumerate} \newpage \enlargethispage*{1ex} \begin{enumerate} \item Apples. \item Bananas. \item Coconuts. \item Dates. \item Emeril. \item Figs. \item Grapefruit. \item Ho-ho-kus, New Jersey. \item Irvington, New Jersey. \item Jujubees. \item Kale. \item Lactose-intolerance. \item Mangos. \item Nomar Garciaparra. \item Ortiz, David. \item Plantains. \item Quince. \item Radishes. \item Skeletons from the Closet. \item Terrapin Station. \item Ugueth Urbina. \item Vona Knuckles. \item Wish I had a monkey. \item Xacto knife. \item Yellowknife. \item Zither. \item Zircon-encrusted tweezers. \item Zarley Zalapski. \item ZZ Top. \item Zarathustra. \end{enumerate} \end{document}