Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Prevent hyphenation of a word in LaTeX

📅 2012-Nov-05 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ hyphenation, latex ⬩ 📚 Archive

Problem

As it goes about placing words along a line, LaTeX might automatically break a word across two lines by adding a hyphen between the two pieces of the word. This is called hyphenation. It might not be desirable to hyphenate certain words, like a name for example.

Solution

Hyphenation of a particular word can be prevented by enclosing that word in a \mbox command. This command creates an invisible box around its parameter. Since a box cannot be broken across lines, this forces LaTeX to place that word on a single line.

For example, if LaTeX is breaking the word abracadabra across two lines, replace it with \mbox{abracadabra}.

Reference: Preventing line breaks from Section 2.2.1 of LaTeX by Leslie Lamport


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧