Is there a (simple) way to allow hypheation a-n-y-w-h-e-r-e in any word?
Asked
Active
Viewed 782 times
6
1 Answers
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}
In contrast the output without the use of \XeTeXinterchartoks:
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}
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}
-
Is it possible to do this while still respecting
\lefthyphenmin=2and\righthyphenmin=3? That is,an-ywhere,any-where,anyw-here,anywh-erewould all be allowed, but nota-nywhereoranywhe-reoranywher-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




\lefthyphenmin=1and\righthyphenmin=1in the preamble. Be forewarned: The typographic results are likely to be awful. – Mico Oct 27 '15 at 08:45\lefthyphenmin=1and\righthyphenmin=1wouldn't be enough, because the hyphenation patterns still wouldn't allow hyphenations likeanyw-hereoranywh-ereAFAIK (which are consistent even with the TeX defaults of\lefthyphenmin=2and\righthyphenmin=3). – ShreevatsaR Jan 25 '17 at 21:14\lefthyphenminand\righthyphenmin; put differently, hyphenation should in fact not literally be alloweda-n-y-w-h-e-r-ein 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