I'm typesetting identifier documentation by generating them from a database. These identifiers that are very free-format, i.e. using a mixture of camel-Case and underscores etc. I want to print them in typewriter font, hyphenated.
I have managed the printing of the underscores identifiers with the help of TeX.SX, thanks very much.
However... hyphenation. I want to allow a linebreak between a lowercase
character and an uppercase character, and after _ and -, and replace
the normal hyphen with another character (\cdot would be nice, but that's not a character in T1) to prevent ambiguity for the latter case.
I think I'd want keep the original hyphenation points (useful for the string "modification" in my example). I guess breaking before or after a number does not need special treatment.
Here is an example of my current \identifier command that does not add extra hyphenation points. I'm not understanding it well enough to mix in the code from e.g. Automatic camel case breaking though - could someone have a go at it for me please?
\documentclass{article}
\usepackage[T1]{fontenc} % better underscore
\usepackage[htt]{hyphenat}
\makeatletter%
\DeclareRobustCommand*{\identifier}[1]{%
\begingroup\@activeus\scantokens{%
\ifmmode%
\expandafter\texttt%
\else%
\expandafter\textnhtt%
\fi{#1}%
\endinput}\endgroup}%
\begingroup\lccode`\~=`\_\relax
\lowercase{\endgroup\def\@activeus{\catcode`\_=\active \let~\_}}
\makeatother
\begin{document}
\parbox{0pt}{\hspace{0pt}%
\identifier{SmartModificationSense}
\identifier{SmartModification_Sense}
\identifier{Smart_Modification_Sense2}
\identifier{smartModification_Sense2}
\identifier{smartModi-fication_Sense2}
\identifier{adj_Iref3_5percent}
\identifier{enable_SPI_1}
}
\end{document}
