Text FormattingHyphenation for Words with a Slash

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
heavytull
Posts: 16
Joined: Wed Feb 08, 2012 9:38 pm

Hyphenation for Words with a Slash

Post by heavytull »

It seems that \hyphenation is not working when the word defined with the macro is next to a slash in the text. For example:

Code: Select all

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}  
\usepackage[english]{babel}
\setlength{\parindent}{0pt}
\usepackage{hyphenat}
\hyphenation{de-mo-du-la-tion}

\begin{document}
Some text Some text Some text 
Some text Some text Some modulation/demodulation''.\par\addvspace{6pt}
\end{document}
When compiling, a warning appears in the log showing that the word is not known with the hyphenation rule defined with \hyphenation{}. But when the rule is given in the text body with \- it works.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Hyphenation for Words with a Slash

Post by localghost »

The hyphenat manual suggests to use the \fshyp command for this purpose.

Code: Select all

\documentclass[11pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{hyphenat}

\begin{document}
  The quick brown fox jumps over the lazy dog. The quick brown modulation\fshyp{}demodulation
\end{document}
Note that under certain circumstances the word might be hyphenated as "modulation/-demodulation". Here is an example.

Code: Select all

\documentclass[11pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{hyphenat}

\begin{document}
  The quick brown fox jumps over the lazy dog. The quick modulation\fshyp{}demodulation
\end{document}

Thorsten
Post Reply