Hyphen, en dash and em dash in LaTeX

One hyphen - prints a hyphen, two -- an en dash and three --- an em dash. A minus sign is a hyphen in math mode: $-5$.

The three dashes

The hyphen joins words. The en dash stands between numbers in a range. The em dash marks an aside in English text and is set without spaces.

A well-known rule, pages 10--20, and an aside---like this one---in a sentence.
Result
The compiled example

Open in the editor

Minus sign

A hyphen in text is too short for a minus sign. In math mode the same key prints a minus that is as wide as a plus sign.

Wrong: -5 degrees. Right: $-5$ degrees and $a - b$.
Result
The compiled example

Open in the editor

The dash in German text

German uses the en dash with a space on both sides for an aside, and without spaces for a range. A ~ in front of the dash keeps it from starting a new line.

Der Gedankenstrich~-- so wie hier~-- steht mit Leerzeichen,
der Bis-Strich ohne: S.~10--20, 2020--2024.
Result
The compiled example

Open in the editor

Commands and typed characters

\textendash and \textemdash print the two dashes as commands. The characters themselves can also be typed or pasted into the source.

10\textendash 20, yes\textemdash no, 10–20, yes—no
Result
The compiled example

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages