# [Tex/LaTex] Automatic camel case breaking

hyphenationline-breaking

Based on my old question Push long words in a new line, I search for a possibility to allow linebreak before a capital character in camel case terms.

For example the term createUnspecifiedNodeErrorMarker can be break into create-Unspecified-Node-Error-Marker.

\documentclass{scrartcl}

\begin{document}
\section{Test}
And another example the show must go on, but we have too less text (\textbf{createUnspecifiedNodeWarningMarker} and
\end{document}


TeX would linebreak (hyphenate) the camel case words, but perhaps not where you wish eg

cre-a-te-Un-spec-i-fiedNodeEr-ror-Marker


shows the default hyphenation points (using the default US English hyphenation)

It wasn't clear if you wanted hyphens at the break points. I have assumed not. If you do then change \penalty2 to \-.

This boxes the parts between capital letters so they don't break, and puts a small penalty before capitals so they can break.

As with anything using catcode changes (like \verb it will not work in the argument to another command)

\documentclass{scrartcl}

\showhyphens{createUnspecifiedNodeErrorMarker}

\makeatletter
\def\zzz{\leavevmode\begingroup
\let\ifcase\iftrue
\def\or##1{%
\catcode##1\active\uccode\~##1\uppercase{%
\def~{\egroup\penalty2\hbox\bgroup\string##1}}}%
\@Alph{}%
\@zzz}

\def\@zzz#1{\textbf{\hbox\bgroup#1\egroup}\endgroup}
\makeatother

\begin{document}
\section{Test}

And another example the show must go on, but we have too less text (\zzz{createUnspecifiedNodeWarningMarker} and
`