6

I have a large document with narrower paragraph width than regular (approx 5 average words long), and I want to disable hyphenation short of having the opportunity to allow hyphenation of chosen words (usually where TeX produces horribly overflowing boxes as a result of not being allowed hyphenation and not having enough tolerance).

I know I can disable hyphenation with \hyphenpenalty=10000 but then I cannot even get TeX to hyphenate anything, even explicitly (or do I?)

Essentially, I want a white-list hyphenation strategy. No hyphenation of anything, except words of my choosing, in places of my choosing, in hyphenation pattern of my choosing.

I have tried \hyphenpenalty=9999 but that still allows TeX to occasionally hyphenate some words.

I am on MikTex, and use Xetex and polyglossia, but I am not sure if it matters all that much.

Thank you.

0

1 Answer 1

6

This is a possible way to do what you want:

\RequirePackage[english=nohyphenation]{hyphsubst}
\documentclass[twocolumn]{article}
\usepackage[english]{babel}

\hyphenation{adip-is-cing}

\usepackage{lipsum}

\begin{document}
\lipsum
\end{document}

enter image description here

As you see, only adipiscing is hyphenated, because an exception for it has been defined.

In the text body you can still use \- for marking an allowed hyphenation point.


If the nohyphenation “language” is not defined, add some magic:

\makeatletter
\@ifundefined{l@nohyphenation}{\chardef\l@nohyphenation=\@cclv}{}
\makeatother
\RequirePackage[english=nohyphenation]{hyphsubst}
\documentclass[twocolumn]{article}
\usepackage[english]{babel}

\hyphenation{adip-is-cing}

\usepackage{lipsum}

\begin{document}
\lipsum
\end{document}

In my opinion, also MiKTeX should provide by default a language with no hyphenation patterns like TeX Live does; maybe it's possible to enable it from its control panel. The above code assigns nohyphenation to language 255, which is most likely still undefined.

6
  • THanks. However, MikTex tells me it does not know such pattern, 'nohyphenation'. Not sure how to proceed from there... Jun 9, 2014 at 0:00
  • @amn I added a workaround; I guess, however, that enabling nohyphenation is possible from MiKTeX's control panel.
    – egreg
    Jun 9, 2014 at 6:17
  • "Some magic" \makeatletter...\RequirePackage...{hypsubst} can be replaced by simple command \language=255 given after \begin{document}. The \hyphenation{words-exce-ption} have to be set after \language=255.
    – wipet
    Jun 9, 2014 at 6:57
  • @wipet Yes, that's a possibility, but maybe something else involving babel could be needed.
    – egreg
    Jun 9, 2014 at 7:20
  • Thanks for the edit. Are there any drawbacks to typeset in "language 255"? I mean does TeX not use the language as a hint for controlling some of its functions? I use Norwegian as a language, and I specify it for a reason. I hope the ligatures and other things related to localisation (displayed date and time, perhaps) do not break because of this? Jun 13, 2014 at 13:17

You must log in to answer this question.

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