John's Small Collection of LaTeX Tips

General Advice

The third edition of A Guide to LaTeX by Kopka and Daly is the best LaTeX book. It's also a good idea to have copies of The LaTeX Companion and The LaTeX Web Companion around. When doing serious LaTeXing, The TeXbook is useful surprisingly often.

Dave Coppit and I have collaborated to create a skeleton LaTeX dissertation that meets UVA formatting requirements; it should be useful to potential dissertation authors. It includes a makefile and produces nice-looking postscript, PDF, and HTML. Also see Dave's LaTeX tips.

I frequently spent time fighting a problem that had already been solved and in fact, often a LaTeX package implementing the solution was available. CTAN and the LaTeX books are essential resources for avoiding reinventing wheels. These are the packages that I found to be useful for typesetting my dissertation:

Jgraph is a powerful and versatile (but low-level) tool for creating postscript figures. It can be used to generate much more customized graphs than either Gnuplot or Excel is capable of producing.

This page contains good advice about what to do in the case where you need to reduce the page count of a document and you can't be bothered to rewrite it.

Putting these two commands into the preamble


helps suppress widows and orphans. Setting the values to 10000 will completely eliminate them, but sometimes at the expense of typesetting quality elsewhere on a page.

Use a small space (\,) to typeset units attractively. For example, the microsecond macro \newcommand{\us}{\,$\mu$s\xspace} would be used as 42\us.

The command \raggedbottom prevents LaTeX from adding vertical white space in strange places on pages that it cannot fill properly.

LaTeX and HTML

TtH is a simple, easy-to-use LaTeX to HTML converter. It runs quickly but is easily confused by macros. It is useful, for example, for converting a LaTeX doc to HTML that can be directly loaded into MS Word in order to use its handy grammar checker.

Tex4ht is another LaTeX to HTML converter. It isn't straightforward to build, install, or configure Tex4ht, but it's superior to TtH in every other way I can think of. Rather than attempting to parse and interpret LaTeX, it adds hooks using a style file and then post-processes the DVI file to generate HTML.

Tex4ht seems to strain TeX somewhat. To keep from getting messages that say "TeX capacity exceeded, sorry" it may be necessary to increase TeX's capacity by placing a configuration file texmf.cnf in the document directory and setting the environment variable TEXMFCNF to "dir::" where dir is the path to the document directory. This only works for TeXs that use kpathsea.

Putting these lines:

Gdvips -mode ibmvga -D 110 -f %%1 -pp %%2  >
Gconvert -crop 0x0 -density 500x500 -geometry 25% -transparency  '#FFFFFF' %%3

into the file tex4ht.env is useful for convincing tex4ht to produce reasonably sized, antialiased bitmap versions of postscript figures.

Like all automatic HTML generators, Tex4ht does not always produce clean (or even correct) HTML. HTML Tidy is an incredibly useful tool for finding (and often, automatically fixing) problems in HTML files. WWWis is a useful utility for making image size annotations in web pages agree with actual image sizes (it's surprising how easy it is to get these annotations wrong or to let them get out of date). Finally, always look over your web pages using several different browsers -- HTML generators seem to have a knack for emitting constructs that render differently in different browsers.

Avoiding Common LaTeX Mistakes

Because TeX usually assumes that periods are used to end sentences, by default it puts extra whitespace after each period that is followed by a space character in the input. To defeat this heuristic, when a non-sentence-ending period is to be followed by a space, the space must be an explicit blank. For example "Smith et al.\ claim that...".

The converse of the previous problem happens when a capital letter precedes a sentence-ending period in the input. For example "...using the Pentium III. This means that...". In this case LaTeX assumes that the period terminates an abbreviation and follows it with inter-word space rather than inter-sentence space. Fix this by writing "...Pentium III\@. This...". A handy way to find this error is:

  grep '[A-Z]\.' *.tex

Punctuation stranded on the far side of a footnote marker is unsightly -- footnotes are supposed to be put outside of punctuation, like this "...has no effect on performance.\footnote{According to Smith and Jenkins.}".

Don't italicize familiar foreign language phrases and scholarly use of Latin such as "a priori", "et al.", "i.e.", "etc.", etc. It needlessly draws attention to unimportant text. Also, "et al." is an abbreviation for "et alia," and needs to be punctuated as such.

It is important to avoid naively using this toolchain: latex -> dvips -> distill because the resulting PDF can contain poorly antialiased versions of bitmapped fonts. This PDF prints slowly and looks bad on the screen. Help stamp out this ugliness by using one of the following workarounds:

Putting a tilde before references and citations (e.g. Blorple~\cite{Blorp88}) prevents LaTeX from putting a line break in an inopportune location.

Creating esthetically pleasing documents is hard, especially using a swiss-army sledgehammer like LaTeX. For those who are interested in why one might want to pay attention to the details and which details matter, The Elements of Typographic Style by Robert Bringhurst is a great resource (and an inspiring example of artful typesetting).

Back to...

John's Homepage

Last modified: Wed Sep 19 17:20:25 2001