Responding to this question, David Carlisle provided source code that automatically breaks or hyphenates camelCase words so that they may span multiple lines. Breaking or hyphenation occurs before capitals, e.g. camel-Case.

I have successfully used the code and altered it slightly to match my needs (used typewriter font as well as bold text):


However, I cannot colour the text. I have tried various things such as

  • \textcolor inside David Carlisle's implementation, i.e. \def\@zzz#1{\textbf{\texttt{\hbox\bgroup\textcolor{mycustomcolor}{#1}\egroup}}\endgroup}
    I also tried this with \textcolor outside \textbf
  • creating a new command that uses \zzz (David Carlisle wrote this won't work, but I got desperate):
  • and a few other variants. For example, I tried the above with both the color package and the xcolor package. I also tried the \color command.

mycustomcolor was defined using \definecolor{mycustomcolor}{RGB}{201, 20, 15}

Is it somehow possible to colour text in David Carlisle's implementation? Thanks in advance for any help provided.

  • I added color in an answer to the previous question.
    – egreg
    Commented Mar 27, 2018 at 21:34
  • Thank you @egreg! I upvoted you on the other question, but stuck with the solution posted here (never change a running system =) ) Commented Mar 28, 2018 at 10:11

1 Answer 1


You need to use \color not \textcolor also the redefinition of \ifcase to \iftrue was a cheap trick to re-use \Alph to get a list of uppercase letters. It is only safe if no command uses \ifcase in the scope of the envrionment, which is apparently not the case for xcolor so this just defines a new list of uppercase rather than patchng `\@alph, but is otherwise identical code.


   \zzelt A\zzelt B\zzelt C\zzelt D\zzelt E\zzelt F\zzelt G\zzelt H\zzelt I\zzelt J\zzelt
   K\zzelt L\zzelt M\zzelt N\zzelt O\zzelt P\zzelt Q\zzelt R\zzelt S\zzelt T\zzelt U\zzelt V\zzelt W\zzelt X\zzelt
    Y\zzelt Z}



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

enter image description here

  • Thank you very, very much for your reply. Is it possible to use the xcolor package instead? I tried replacing \usepackage[color] with \usepackage[xcolor] but that causes errors when compiling. I tried to debug or replace \color with \textcolor but my latex knowledge is nowhere near good enough for the kind of "low-level" code in your MWE. Sorry I wasn't clear about my need for xcolor ... I only just realised myself that tikz loads xcolor. Commented Mar 27, 2018 at 8:18
  • I tried using xcolor with \color (i.e. only alteration to your MWE was \usepackage[xcolor]) but got several error messages, such as: "Undefined control sequence...", "Missing = inserted...", "Improper alphabetic constant...", "Missing number, treated as zero...", "Improper alphabetic constant..." Commented Mar 27, 2018 at 8:34
  • @Jay_At_Play oh yes so you do, sorry! can only require a minor change (xcolor is a compatible extension of color in almost all cases) but out of time now, I'll fix that later and ping you here Commented Mar 27, 2018 at 8:38
  • Thank you so much, you are amazing =) I'll try to pass on the favour and contribute to tex.StackExchange Commented Mar 27, 2018 at 8:41
  • @Jay_At_Play xcolor Commented Mar 27, 2018 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .