10

Polyglossia systematically ignores my custom \hyphenation, and generates overfull hboxes all over the place as a consequence.

Here’s an example:

\documentclass{article}

\usepackage{polyglossia}

\setmainlanguage[variant=uk]{english}

\hyphenation{a-bun-dance}

\begin{document}
A
abundance abundance abundance abundance abundance abundance abundance abundance
abundance abundance abundance abundance abundance abundance abundance abundance
\end{document}

Renders as (via xelatex example):

screenshot

This seems to happen for many/all words. The documentation doesn’t contain any hint at how to fix this. Is it a bug or am I doing something wrong?

This is using an up-to-date TeX Live 2014 with XeTeX 3.14159265-2.6-0.99991.

2
  • english has \lefthyphenmin=2 so the break after the first a will never be taken automatically. Feb 24, 2015 at 16:13
  • @David Okay, good to know (and actually reassuring, I don’t actually want that break, I was just trying to be extra permissive here). But in any case the relevant break would be the other, so this doesn’t solve my problem. Feb 24, 2015 at 16:14

2 Answers 2

9

It appears the main language is set up at begin document, it is still US English in the preamble, it works if you delay the setting:

\documentclass{article}

\usepackage{polyglossia}

\setmainlanguage[variant=uk]{english}



\begin{document}
\hyphenation{a-bun-dance}

A
abundance abundance abundance abundance abundance abundance abundance abundance
abundance abundance abundance abundance abundance abundance abundance abundance
\end{document}
5

This is a problem similar to Set hyphenation with polyglossia but it requires a different approach, because English is treated differently: only one set of patterns for English is used by Polyglossia and it's set at begin document.

\documentclass{article}

\usepackage{polyglossia}

\setmainlanguage[variant=uk]{english}

\newcommand{\sethyphenation}[2]{%
  \AtBeginDocument{%
    \begin{otherlanguage*}{#1}\hyphenation{#2}\end{otherlanguage*}%
  }%
}

\sethyphenation{english}{a-bun-dance}

\begin{document}
\parbox{0pt}{A abundance}
\end{document}

enter image description here

1
  • 1
    For me, AtBeginDocument wasn't sufficient, but etoolbox's AfterEndPreamble was.
    – Teepeemm
    Jun 19, 2020 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .