[Tex/LaTex] How to display the possible hyphenation points for words in a language other than US English

hyphenationlanguagestex-core

This is a follow-up to tohecz's question, which I'm asking at the suggestion of Mico.

The original question asks how to discover the hyphenation points for particular words, and the answers explain how to do this in various ways and for various engines.

For example, user9588's answer introduces \showhyphens and Mico's comment explains how to use the command interactively.

So, here's a sample session:

$ tex
This is TeX, Version 3.14159265 (TeX Live 2014) (preloaded format=tex)
**\relax

*\showhyphens{un casgliad credadwy traddodiadau athroniaeth mathemateg canolfan hapusrwydd blwyddyn deuddeg llongyfarchiadau cyfeiriadau}

Underfull \hbox (badness 10000) detected at line 0
[] \tenrm un cas-gliad credadwy trad-do-di-adau athro-ni-aeth math-e-mateg cano
l-fan ha-pus-r-wydd blwyd-dyn deud-deg llongy-farchi-adau cyfeiri-adau

*\bye
(see the transcript file for additional information)
No pages of output.
Transcript written on texput.log.

Now, there is clearly a problem because these are not necessarily the correct hyphenation points. For example, dd is a single letter, yet TeX is splitting traddodiadau, blwyddyn and deuddeg in the middle of that letter.

The problem is not that the correct hyphenation patterns are unavailable:

Welsh hyphenation patterns

As can be seen, traddodiadau and deuddeg are split correctly in this output and, in general, the words are split at points which are not predicted by the sample session with \showhyphens.

The problem is that TeX needs to load the correct hyphenation patterns and to apply the correct set for the active language:

\documentclass[welsh,a6paper,twocolumn]{article}
\usepackage{babel}
\usepackage[hscale=.25]{geometry}
\begin{document}
    un casgliad credadwy traddodiadau athroniaeth mathemateg canolfan hapusrwydd blwyddyn deuddeg llongyfarchiadau cyfeiriadau
\end{document}

How can I display the possible hyphenation points for words in a language other than US English?

I've used a non-English example above, but the same question will also apply to other variants of English. For example, British hyphenation patterns differ from the American ones. (Compare the results of \showhyphens{favourite} and \showhyphens{favorite}, for example.)

Best Answer

You can use the testhyphens package.

\documentclass{article}
\usepackage[british,welsh]{babel}
\usepackage{testhyphens}

\begin{document}

\begin{checkhyphens}{}
un casgliad credadwy traddodiadau athroniaeth mathemateg canolfan
hapusrwydd blwyddyn deuddeg llongyfarchiadau cyfeiriadau
\end{checkhyphens}

\selectlanguage{british}

\begin{checkhyphens}{}
un casgliad credadwy traddodiadau athroniaeth mathemateg canolfan
hapusrwydd blwyddyn deuddeg llongyfarchiadau cyfeiriadau
\end{checkhyphens}

\end{document}

enter image description here