Overloading the Machine



LaTeX cheat sheet (PDF)


(Notes before they get sorted)


If chapter titles are too long, so that they overrun the space allocated to them in the page headings, you can assign a short title to them, with \section[short title]{full title}. To not affect the entry in the table of contents, \chaptermark{A Portrait of the Hacker} can be used.

Internal crossreferences can be handled with \label{} and then \ref{} to refer to them. To get names instead of numbers, use the hyperref package, and then the \autoref{} or \nameref{} commands.

\setcounter{errorcontextlines}{999} provides more context for error messages.

pdflatex doesn't deal with eps files. To include graphics in a way that both pdflatex and latex will work with, just leave off the extension in the \includegraphics command, and then keep both a .eps and a .png version in the graphics path.

Padding in boxes

\setlength{\fboxsep}{12pt} will put 12pts of space between the text and the box boundary. Works for colorboxes too.

Widows and Orphans

The last line on any page must not be the first line of a paragraph, and the first line on any page must not be the last line of a paragraph. (In typesetting jargon, your pages may contain no orphans or widows. Knuth calls a widow a "club line".)

Try \clubpenalty=300 and \widowpenalty=300 to fix these.

Actually, I usually have to bump those way up — like to 10000 — to have any effect.

Table of Contents

\addcontentsline{toc}{chapter}{Introduction} will add an unnumbered section to the TOC. This should be placed next to the section or chapter entry that is being added, to make sure that the page number comes out right.

toc is the file extension for the table of contents that should be added to. chapter should be whatever the section level is. Introduction is the name of the node.


\hyphenation{fortran, er-go-no-mic} lists acceptable hyphenation points.

This goes in the preamble.

\- also indicates acceptable hyphenation points.


Thousands of TeX fonts at your fingertips


\usepackage{} goes after \documentclass{}.


\ps{} does a P.S. in a letter.


  • \usepackage{url}
  • \url{http://www.fsf.org}

It seems that you can't use \url{} inside {\small} inside \caption{}. Get an error that says "url used in a moving argument." Should probably learn what that means, really.

Changing the font

You can change the font with \urlstyle{}. So, \urlstyle{tt} is the default. The predefined styles are rm, sf and same.

The \UrlFont command changes the font. So, \def\UrlFont{\tt} would select the default font. You can get bold URLs by doing \def\UrlFont{\bfseries}. These are not monotype, though.


  • \usepackage{graphicx}
  • \includegraphics[scale=0.5]{foo.eps}

What does \includegraphics*{} do again?

You can use the [scale=0.5] argument to \includegraphics command to scale the image to 50% of its size. So \includegraphics[scale=0.5]{image.eps}.

You can also specify width= and height=. If you specify only one of them, the image will be scaled to that size keeping the ratio.


h Place the float here, i.e., at the same point it occurs in the source text.
t Position at the top of the page.
b Position at the bottom of the page.
p Put on a special page for floats only.
! Override internal parameters Latex uses for determining good float positions.

Wrapped Figures

  • \usepackage{wrapfig}
  \caption{The Toucan}
 \begin{wrapfigure}[12]{r}[34pt]{5cm} <figure> \end{wrapfigure}

[number of narrow lines] {placement} [overhang] {width of figure}

Placement is one of r, l, i, o, R, L, I, O, for right, left, inside, outside, (here / FLOAT). The figure sticks into the margin by `overhang', if given, or by the length \wrapoverhang, which is normally zero. The number of wrapped text lines is normally calculated from the height of the figure, but may be specified manually ("12" above).

Converting LaTeX to HTML


HTML Tidy Home Page

HTML Tidy Web Interface

HTML Tidy Quick Reference

Useful command-line options
--output-xhtml t Output xhtml.
--logical-emphasis y Turn i into em, b into strong
--char-encoding "utf8" Use UTF-8.

Good sample command-line I used to convert latex2html output to xhtml:

tidy --clean y --doctype "transitional" --output-xhtml y --indent "auto" --wrap "90" --char-encoding "utf8" --logical-emphasis y

After tidy, you probably want to remove the doctype, the head, and class= attributes.


I think this may not be free software. I need to check that before using it again.

latex2html Home Page


navigation options


Linux Gazette article

latex2html will read from ~/.latex2html-init.

Useful command-line options
-split 0 will put the document all in one HTML file.
-no_subdir will put the document(s) in the current directory instead of a subdirectory.
-show_section_numbers will include section numbers. By default they are not included.
-html_version=4.0 will use HTML version 4.0
-no_auto_link Don't include a link to the document's index.html (I don't use this)
-link 0 No links to other nodes (I don't use this)
-no_footnode Put footnotes at the bottom of the pages.
-address 0 Don't sign the pages with the author address. The default is to sign it.
-info 0 Don't include an About this Document section at the end. The default is to include it.
-no_navigation Don't include navigation buttons on each page
-iso_lang "EN.US" Use that language.

To write code that will not be used in the HTML version of the document, surround it with %begin{latexonly}...%end{latexonly}.

It doesn't understand \setcounter{chapter}{0}, but you can get the Introduction to be unnumbered by using \chapter*{Introduction} for it. However, this means that it won't show up in the TOC in the HTML version?

Things to figure out

  • How to skip numbering of the Introduction and start with the first Chapter
  • Where are the garbage characters coming from?

Left off messing with ~/.latex2html-init

As per http://tug.org/mailman/htdig/latex2html/2002-July/001936.html.


This page was last modified on 2011 December 20. "NotesLaTeX" by John Sullivan is Copyright ©2003 - 2011, and licensed under the Creative Commons Attribution-Share Alike 3.0 United States License.