In my Verbatim I need to specify colour for my code.

In this answer (fancyvrb alternate commandchars and \textcolor) the solution is to put this code in the preamble:


and then use


My problem is the commandchars. \textcolor needs a pair of braces, but in my code I use all the pair of braces that is: () [] {}.

So is it possible to specify another pair of commandchars? Something like &fvtextcolor'blue''function' or &fvtextcolor"blue""function"?

  • Yes, but you need two different characters: [commandchars=\&\`\'] would use the backtick for the opening brace and the apostrophe for the closing brace. Any unused character is good.
    – egreg
    May 19, 2014 at 12:06
  • So this should work &fvtextcolorred'test' ? May 19, 2014 at 12:08
  • Sorry, almost any unused character. :(; I tried with " and ! and it seems to work.
    – egreg
    May 19, 2014 at 12:15
  • Thank you so much, it worked! Can you post it as an answer, so I can mark the question as solved? May 19, 2014 at 12:17

1 Answer 1


In theory, any unused characters would do, but unfortunately for certain characters this conflicts with other parts of verbatim typesetting.

I've found out that


gives the expected result.

The characters that are likely not to work are

` < > , ' -

If you really need some of them, a workaround can be devised.

You must log in to answer this question.

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