6

Is there a (simple) way to allow hypheation a-n-y-w-h-e-r-e in any word?

Toothrot
  • 3,346
  • I guess you could set \lefthyphenmin=1 and \righthyphenmin=1 in the preamble. Be forewarned: The typographic results are likely to be awful. – Mico Oct 27 '15 at 08:45
  • @Mico Setting \lefthyphenmin=1 and \righthyphenmin=1 wouldn't be enough, because the hyphenation patterns still wouldn't allow hyphenations like anyw-here or anywh-ere AFAIK (which are consistent even with the TeX defaults of \lefthyphenmin=2 and \righthyphenmin=3). – ShreevatsaR Jan 25 '17 at 21:14
  • @ShreevatsaR - You are right. In fact, according to the comment the OP left below @Jfbu's answer, he/she does not want to change the default values of \lefthyphenmin and \righthyphenmin; put differently, hyphenation should in fact not literally be allowed a-n-y-w-h-e-r-e in any word. I must confess that since the use case for the query was never particularly clear to me, I hadn't given it much additional thought. Do you think I should delete my comment? – Mico Jan 26 '17 at 00:16
  • @Mico No please don't delete it; it's fine. Also, the comment below the answer was left not by the OP but by me, earlier today. :-) – ShreevatsaR Jan 26 '17 at 00:29

1 Answers1

12

With xelatex this is easily done.

\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{kantlipsum}
\usepackage{multicol}
\begin{document}\thispagestyle{empty}
% "texdoc xetex" for Xe(La)TeX reference manual
\XeTeXinterchartokenstate 1
\XeTeXinterchartoks 0 0 = {\-}
\begin{multicols}{5}
  \kant[42]
\end{multicols}

\end{document}

hyphenation everywhere

In contrast the output without the use of \XeTeXinterchartoks:

standard hyphenation

Perhaps you even don't want the -'s. Then the following can be used:

\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{kantlipsum}
\usepackage{multicol}
\begin{document}\thispagestyle{empty}
% "texdoc xetex" for Xe(La)TeX reference manual
{% temporarily enable hyphenation everywhere at no cost
\XeTeXinterchartokenstate 1
\XeTeXinterchartoks 0 0 = {\discretionary{}{}{}}
\exhyphenpenalty 0
\begin{multicols}{5}
  \kant[42]
\end{multicols}
}

% back to normal
\end{document}

no hyphens

Or possibly you prefer the - to stick into the right margins:

\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{kantlipsum}
\usepackage{multicol}
\begin{document}\thispagestyle{empty}
% "texdoc xetex" for Xe(La)TeX reference manual
{% temporarily enable breaking everywhere
\XeTeXinterchartokenstate 1
\XeTeXinterchartoks 0 0 = {\discretionary{\rlap{-}}{}{}}
\exhyphenpenalty 0
\hyphenpenalty   0
\begin{multicols}{5}
  \kant[42]
\end{multicols}
}

% back to normal
\end{document}

with hyphens in margin

  • Is it possible to do this while still respecting \lefthyphenmin=2 and \righthyphenmin=3? That is, an-ywhere, any-where, anyw-here, anywh-ere would all be allowed, but not a-nywhere or anywhe-re or anywher-e (In particular, words shorter than 5 characters wouldn't be hyphenated)? – ShreevatsaR Jan 25 '17 at 21:12
  • @user4686 Your answer is very helpful. If I use it, but replace \kant[42] with a string of characters in scriptio continua (for example, ``ΑΜΕΝΑΡΤΑΣΤΟΥΒΑΣΙΛΙΚΟΥΓΕΝΟΥΣΤΟΥΑΙΓΥΠΤΙΟΥΗΤΟΥΚΑΛΛΙΚΡΑΤΟΥΣΙΣΙΔΟ...''), then the characters tend to be somewhat lax about obeying the right margin of each column. Do you know a fix? – Noah J Jun 26 '23 at 20:59