TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


And another example the show must go on, but we have too less text (\textbf{createUnspecifiedNodeWarningMarker} and
\textbf{createUnspecifiedNodeErrorMarker}, sdjklashjksa \textbf{createUnspecifiedLinkWarningMarker} and
share|improve this question
Be (but only slightly) careful what you wish for. Compare: "StringRenderingEngine" with "String[space]RenderingEngine". If it splits in the wrong place you have ambiguity. – Brent.Longborough Aug 10 '12 at 8:18
You are right, I only want to use it in an seperate environment, not for the whole document. – CSchulz Aug 10 '12 at 8:48
up vote 7 down vote accepted

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


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 \-.

enter image description here

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)






And another example the show must go on, but we have too less text (\zzz{createUnspecifiedNodeWarningMarker} and
\zzz{createUnspecifiedNodeErrorMarker}, sdjklashjksa \zzz{createUnspecifiedLinkWarningMarker} and
share|improve this answer
Thanks, I will write an environment with that. :) – CSchulz Aug 14 '12 at 14:04
Is there any possibility to use it within captions? – CSchulz Oct 17 '12 at 14:25
it's a fragile command so \protect\zzz should do the right thing, oh apart from the catcode change part :( – David Carlisle Oct 17 '12 at 14:32
I don't understand what you mean with "oh apart from the catcode change part :(" – CSchulz Oct 20 '12 at 13:42
But protect doesn't work with sections and so on, correct? – CSchulz Oct 20 '12 at 14:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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