5

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

  • not exactly what you've asked for, but maybe helpful: How to break long words after n chars (long genomic sequences) – barbara beeton Oct 26 '15 at 21:57
  • 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 8: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 0: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 0:29
9

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.