Microtypography (microtype)

microtype is the package that makes justified paragraphs noticeably more beautiful. It was written by R. Schlicht. What it does is undramatic — nudging punctuation a hair past the margin, stretching or shrinking glyph widths by a fraction of a percent — adjustments invisible at a glance, yet across a page they line up the right edge, even out interword spacing, and reduce both rivers of white space and overflowing lines. Adding it is usually a one-line affair, \usepackage{microtype}. This page walks through protrusion, expansion, tracking, and the other features — and the crucial point that which features you get depends on the engine.

What microtype is

TeX already typesets well, but microtype adds a layer of micro-typography on top — refinements that act at the level of individual characters and gaps between them. These features were originally introduced by pdfTeX and later propagated, in part, to LuaTeX and XeTeX. microtype is the unified LaTeX interface to them, lifting the appearance of Western (Latin-script) text.

The main features it provides are below. The first two — protrusion and font expansion — are the centerpiece, and are enabled by default when they can safely be assumed to work. The rest you switch on with options as needed.

  • Character protrusion (margin kerning): push punctuation and some letters slightly past the margin so the text edge looks optically straight.
  • Font expansion: stretch or shrink each line’s glyph widths by a tiny amount, reducing interword stretch and evening out the paragraph’s “color.”
  • **Tracking / letterspacing (\textls):** space out the letters of a word or run evenly — suited to capitals and small caps.
  • **Disabling ligatures (\DisableLigatures):** turn off ligatures per font; useful for typewriter faces and the like.
  • Interword-spacing and extra-kerning adjustment: the spacing / kerning options (pdfTeX only).

Note that these are refinements for Western (Latin) text. Japanese has its own typesetting model — line-breaking restrictions, spacing between Japanese and Western characters, and so on — distinct from protrusion and expansion, and handled by tools such as luatexja. The more basic automatic Western processing, like ligatures and kerning, is covered on the sibling page “Writing Western text.”

Character protrusion

A protrusion (also called margin kerning) lets characters at the start or end of a line hang a hair past the margin. The reason is an optical illusion. When you align a period, comma, or hyphen — or a letter with a round or slanted contour like o, A, or v — flush to the text edge, the sidebearing of that glyph makes the edge look as if it caves inward. Letting such characters protrude slightly makes the edge of the text block look optically straight.

Pushing line-ending punctuation fully into the margin is the well-known idea of hanging punctuation, and it helps to think of microtype’s protrusion as doing this per character, by the right amount, and more subtly. The effect is clearest for punctuation and for letters of small area or non-flat contour. Protrusion works on all three major engines — pdfTeX, LuaTeX, and XeTeX alike.

Protrusion takes effect naturally in running paragraphs, but not where TeX sees no margin — such as inside itemize or tabular. To make the first or last glyph protrude in those places, microtype provides \leftprotrusion and \rightprotrusion (this finer control requires the e-TeX extensions).

Font expansion

A font expansion stretches each line’s glyphs horizontally by a tiny amount (typically a fraction of a percent up to a few percent), or squeezes them, to make the lines fit the measure. In justification, line width is normally reached by stretching and shrinking the interword glue; if a slight adjustment of the glyph widths takes over part of that job, the interword spaces need to vary less. The upshot is less line-to-line variation in spacing and a more uniform paragraph “color.”

A practical benefit is fewer overfull and underfull boxes (the overrun and gappy-line warnings) — the setting comes out a notch smoother. You can tune the limits with the stretch and shrink options and the granularity with step, but the defaults are fine to start with.

Crucially, expansion is available on pdfTeX and LuaTeX only — not on XeTeX. Load microtype under XeTeX and you still get protrusion and tracking, but expansion is switched off automatically (no error, because the package only enables what can safely run). If you want the full treatment including expansion on XeTeX, the right move is to switch to LuaTeX.

Tracking and letterspacing

Tracking (letterspacing) opens up the space between letters evenly. microtype’s tracking is realized by expanding the font’s own glyph spacing rather than inserting space between characters, so it does not break hyphenation — avoiding the weakness of the classic “scatter your own \kerns” approach (which stops the word from breaking).

For ad-hoc letterspacing, use \textls{...}. It works whether or not the tracking option is on, and even in math mode. The amount is in thousandths (the default is about 100/1000) and can be given in the optional argument, as in \textls[200]{...}. To apply it to a run of following characters, \lsstyle switches letterspacing on until the end of the group. For headings, where you do not want extra kerning added before and after, the starred \textls*{...} is handy.

To set it for a whole font set, write something like \SetTracking{encoding=*, shape=sc}{40} in the preamble (this example tracks small caps by 40/1000). A caution: letterspacing lowercase is traditionally held to be ugly. The microtype manual itself says you should, as a rule, only letterspace capitals or small capitals. Tracking works on pdfTeX, LuaTeX, and XeTeX.

document.tex
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{microtype}
% space out small caps by 40/1000 wherever they appear
\SetTracking{encoding = *, shape = sc}{40}
\begin{document}
\textsc{Small Caps}, and ad-hoc \textls[200]{LETTERSPACED} capitals.
\end{document}

Other features and configuration

Beyond these, microtype can control ligatures, extra kerning, and interword spacing. To disable ligatures, use \DisableLigatures. For example, \DisableLigatures{encoding = T1, family = tt*} turns off ligatures for the typewriter family in T1 encoding — useful when, say, showing code where you do not want -- fused into an en dash. Note, though, that disabling all of a font’s ligatures also switches off its kerning. Listing the ligature-initial characters in the optional argument, as in [?,!], disables only the selected ligatures. The command may be used only in the preamble, and only once.

The kerning and spacing options enable extra kerning and interword-spacing adjustment respectively, but these are pdfTeX-only (they do nothing on LuaTeX or XeTeX). Both are off by default; enable them explicitly only when needed, as in \usepackage[kerning=true,spacing=true]{microtype}.

To change settings after loading, use \microtypesetup{...}. For instance, to switch protrusion off only while the table of contents is built, bracket it with \microtypesetup{protrusion=false} and \microtypesetup{protrusion=true}. To give one part of the document a different setup, switch the context with \microtypecontext{...} (or the microtypecontext environment). Passing the draft option disables the micro-typography wholesale, handy for before/after comparisons.

Engine support

Which features you get depends on the TeX engine. microtype automatically enables only what runs safely on your engine, so loading it with no options never errors — but it helps to know what does and does not take effect. The two things to remember: expansion is not available on XeTeX, and interword spacing and extra kerning are pdfTeX-only.

FeaturepdfTeXLuaTeXXeTeX
protrusionProtrusionYesYesYes
expansionFont expansionYesYesNo
trackingTracking (letterspacing)YesYesYes
ligaturesDisabling ligaturesYesYesNo
kerningExtra kerningYesNoNo
spacingInterword spacingYesNoNo

In sum, the most capable is pdfTeX (protrusion + expansion + tracking + kerning + spacing); next is LuaTeX (protrusion + expansion + tracking, but no kerning or spacing); and XeTeX offers protrusion and tracking only (no expansion).

Using it

The basic case is **just the one line, \usepackage{microtype}.** That enables protrusion and expansion (where the engine supports them) by default, and most documents are meaningfully better for it. microtype is stable and almost free of side effects — there is rarely any harm in adding it. For serious Western typesetting it is effectively a standard move, a near-mandatory quality upgrade. It is commonly paired with fontenc ([T1] on the pdfTeX engines).

Here is a slightly more involved preamble. It explicitly activates protrusion and expansion (activate), tracks small caps lightly with \SetTracking, and disables ligatures only for the typewriter family used to show code. Follow the comments to see what each option does.

document.tex
\documentclass{article}
\usepackage[T1]{fontenc}
% protrusion + expansion explicitly on; "final" forces them in draft mode too
\usepackage[activate={true,nocompatibility},final]{microtype}
% letterspace small caps a little (40/1000)
\SetTracking{encoding = *, shape = sc}{40}
% in code, keep "--" as two hyphens (also turns off kerning for this font)
\DisableLigatures{encoding = T1, family = tt*}
\begin{document}
Justified paragraphs look more even, \textsc{small caps} are gently
letterspaced, and \texttt{a--b} stays as two hyphens in code.
\end{document}

The adjustments are subtle and may not be obvious at first glance. But turn the page and you will notice the right edge settling into line, the interword spacing calming down, and less hyphenation and overrun. As a finishing touch, microtype is well worth keeping in your toolkit.