Text Formatting\kern ruins hyphenation

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

\kern ruins hyphenation

Post by Laurentius »

The example is self-explanatory. A solution would be wonderful!

Code: Select all

\documentclass{article}
\usepackage{ucharclasses}

\newXeTeXintercharclass \QuotationMarkClass
\XeTeXcharclass `` = \QuotationMarkClass
\XeTeXcharclass `' = \QuotationMarkClass

\XeTeXinterchartoks \QuotationMarkClass \BasicLatinClass {\kern 1pt}
\XeTeXinterchartoks \BasicLatinClass \QuotationMarkClass {\kern 1pt}

\hyphenation{hair-space}

\begin{document}

\XeTeXinterchartokenstate=0

Between quotation marks and the quoted text there must needs be a `hairspace'.
But using character classes to insert one ruins hyphenation.

\XeTeXinterchartokenstate=1

Between quotation marks and the quoted text there must needs be a `hairspace'.
But using character classes to insert one ruins hyphenation.

\end{document}

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

\kern ruins hyphenation

Post by cgnieder »

the same happens when you add the kern manually:

Code: Select all

\documentclass{article}
\hyphenation{hair-space}

\begin{document}

Between quotation marks and the quoted text there must needs be a `hairspace'.
But using character classes to insert one ruins hyphenation.

Between quotation marks and the quoted text there must needs be a `\kern1pt
hairspace\kern1pt'\kern1pt.  But using character classes to insert one ruins
hyphenation.

\end{document}
If you use \hspace or \hskip instead hyphenation is allowed again:

Code: Select all

% arara: xelatex
\documentclass{article}
\usepackage{ucharclasses}

\newXeTeXintercharclass \QuotationMarkClass
\XeTeXcharclass `` = \QuotationMarkClass
\XeTeXcharclass `' = \QuotationMarkClass

\XeTeXinterchartoks \QuotationMarkClass \BasicLatinClass {\hskip1pt\relax}
\XeTeXinterchartoks \BasicLatinClass \QuotationMarkClass {\hskip1pt\relax}

\hyphenation{hair-space}

\begin{document}

\XeTeXinterchartokenstate=0

Between quotation marks and the quoted text there must needs be a `hairspace'.
But using character classes to insert one ruins hyphenation.

\XeTeXinterchartokenstate=1

Between quotation marks and the quoted text there must needs be a `hairspace'.
But using character classes to insert one ruins hyphenation.

\end{document}
Regards
site moderator & package author
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

\kern ruins hyphenation

Post by cgnieder »

Better:

Code: Select all

\XeTeXinterchartoks \QuotationMarkClass \BasicLatinClass {\nobreak\hskip1pt\relax}
\XeTeXinterchartoks \BasicLatinClass \QuotationMarkClass {\nobreak\hskip1pt\relax}
While \kern does not insert a valid break point \hskip does. So you need to disallow breaking there manually.

Regards
site moderator & package author
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

\kern ruins hyphenation

Post by Laurentius »

Thanks. (I eventually did the unnecessarily clever {{\spaceskip=1pt~}}.)

Out of curiosity, do you know why `normal' quotation marks cause no hyphenation problems?
Last edited by cgnieder on Fri Jul 10, 2015 7:35 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

\kern ruins hyphenation

Post by cgnieder »

Laurentius wrote:Out of curiosity, do you know why `normal' quotation marks cause no hyphenation problems?
I don't understand: why should they? Other punctuation doesn't cause problems either. The problem was the explicit kern.

Regards
site moderator & package author
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

Re: \kern ruins hyphenation

Post by Laurentius »

I meant to ask the cause not the reason. But it's not important.
Post Reply