# 367 Latex Typography 46c89dfd

> LaTeX Typography and Line Breaking Reference

- Skill: `tools-only/367-latex-typography-46c89dfd` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/367-latex-typography-46c89dfd`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/367-latex-typography-46c89dfd/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Design & Media
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/tools-only/367-latex-typography-46c89dfd

---

# LaTeX Typography and Line Breaking Reference

## Understanding Overfull Hbox Warnings

An "overfull hbox" warning indicates that LaTeX could not fit the content within the specified margins. The warning format is:

```
Overfull \hbox (Xpt too wide) in paragraph at lines Y--Z
```

Where:
- `Xpt` - The amount by which the line exceeds the margin (in points)
- `Y--Z` - The line range in the source file where the problem occurs

## LaTeX Line Breaking Algorithm

LaTeX uses the Knuth-Plass algorithm for line breaking, which considers:

### 1. Badness

A measure of how much inter-word spacing deviates from ideal:
- 0 = perfect spacing
- 100+ = very stretched or compressed
- 10000 = infinitely bad (forces line break)

### 2. Penalties

Costs assigned to various line-breaking decisions:
- Hyphenation penalty (default 50)
- Explicit hyphen penalty
- Line penalty
- Club/widow penalties

### 3. Demerits

Total cost combining badness and penalties. LaTeX minimizes total demerits across the paragraph.

## Why Character Count Is Misleading

### Letter Width Variation

In most fonts, letters have different widths:

```
Narrow:  i, l, t, f, j, r
Medium:  a, c, e, n, o, s, u, v, x, z
Wide:    m, w, M, W
```

Example: "illicit" (7 chars) may be narrower than "mammaw" (6 chars).

### Kerning

Space between letter pairs is adjusted:
- "AV" - letters move closer (negative kern)
- "AT" - letters move closer
- "oo" - slight adjustment

### Ligatures

Some letter combinations merge:
- fi -> fi
- fl -> fl
- ff -> ff

This can affect word width unpredictably.

## Hyphenation Considerations

LaTeX hyphenates words according to language-specific patterns. Key points:

### Hyphenation Points

Words break at specific syllable boundaries:
- "hy-phen-ation" has 3 break points
- "through" has 0 break points (single syllable)

### Hyphenation Quality

Some hyphenation points are better than others:
- Breaking after prefixes: "un-happy" (good)
- Breaking before suffixes: "happi-ness" (good)
- Breaking in middle: "hap-piness" (acceptable)

### \hyphenation Command

Custom hyphenation can be specified:
```latex
\hyphenation{awk-ward an-oma-ly}
```

## Strategies for Fixing Overfull Hbox

### Strategy 1: Shorter Synonyms

Replace words with shorter synonyms. Prioritize:
1. Words directly at the line break point
2. Words with significantly shorter alternatives
3. Words that appear multiple times

### Strategy 2: Better Hyphenation

Sometimes a word with better hyphenation points works better than a shorter word:
- "community" (9 chars, com-mu-ni-ty) may flow better than
- "group" (5 chars, no hyphenation)

### Strategy 3: Reflow Entire Paragraph

Sometimes changing an earlier word causes the paragraph to reflow favorably, even if the direct cause isn't changed.

### Strategy 4: Allow Slight Overflow

If changes aren't possible, `\sloppy` or `\emergencystretch` can help:
```latex
\emergencystretch=1em
```

## Diagnostic Commands

### Check Hyphenation

```latex
\showhyphens{problematic}
```

### Show Box Details

```latex
\showboxbreadth=100
\showboxdepth=100
\showbox0
```

### Trace Line Breaking

```latex
\tracingparagraphs=1
```

## Common Word Length Comparisons

When substituting synonyms, consider these common patterns:

| Long Word | Chars | Short Synonym | Chars | Savings |
|-----------|-------|---------------|-------|---------|
| demonstrate | 11 | show | 4 | 7 |
| approximately | 13 | about | 5 | 8 |
| nevertheless | 12 | still | 5 | 7 |
| comprehensive | 13 | full | 4 | 9 |
| consequently | 12 | so | 2 | 10 |
| significantly | 13 | greatly | 7 | 6 |
| immediately | 11 | now | 3 | 8 |
| unfortunately | 13 | sadly | 5 | 8 |

## Testing Changes

Always verify changes by:

1. Recompiling the document
2. Checking for the specific warning
3. Confirming no new warnings appeared
4. Visually inspecting the output

Use this grep pattern to find all warnings:
```bash
pdflatex document.tex 2>&1 | grep -E "Overfull|Underfull|hbox|vbox"
```

