wspr / herries-press

A collection of LaTeX packages by Peter Wilson
http://wspr.github.com/herries-press/
29 stars 5 forks source link

[hyphenat] Only underscores work #25

Open wspr opened 6 years ago

wspr commented 6 years ago

From a user:

While trying to break text at underscores in typewriter fonts I stumbled over hyphenat, which offers a great solution for my problem (although I redeclared \BreakableUnderscore to not use a hyphen).

During my search on how to break the text, I eventually found a stack exchange answer recommending hyphenat with a disappointing comment it wouldn't work: https://tex.stackexchange.com/a/290801/51583 .

Because I also found a nice example sentence with some other solutions (https://tex.stackexchange.com/q/219445/51583), I tested hyphenat more thoroughly as follows:

\documentclass[a4paper]{article}
\usepackage[htt]{hyphenat}
\begin{document}
If an unrecoverable error occurs during the transformation, then a
\texttt{javax.xml.transform.TransformerException} is thrown.

If an unrecoverable error occurs during the transformation, then a
\texttt{javax\_xml\_transform\_TransformerException} is thrown.

If an unrecoverable error occurs during the transformation, then a
\texttt{javax\textbackslash{}xml\textbackslash{}transform\textbackslash{}TransformerException}
is thrown.

If an unrecoverable error occurs during the transformation, then a
\texttt{javax/xml/transform/TransformerException} is thrown.
\end{document}

Interestingly, hyphenat only breaks the second version with the underscores, contrary to the expectation.