I've just registered. This is my first question to this site.

I am trying to make a verbatim command for inline code. This has been asked and answered many times before, but I never found a direct answer that actually works for me. I am using MikTeX 2.9, completely updated.

In my text - a technical manual - I am using fancyvrb. I have plain text and code snippets. These are handled by \DefineVerbatimEnvironment. It is working fine.

Inline code, on the other hand, has been posing the usual problem of passing a parameter into the \Verb. I mean to have an inline environment suitable for code, but allowing for text formatting AND immune to backslashes and so, so that I can format inline code or Windows file paths without the need to encode every single backslash as \textbackslash.

I can use \CustomVerbatimCommand, but this uses a single character for enclosing the target text, instead of curly brackets. I came up with this definition:


With this I can use the \inCodeStub¡text¡ - which I did not wish to - but the attempt at the bracketed version is not working. Could anyone tell me why/offer a solution?

Here is a MWE:

% New command/environment for code snippets
% Inline code fragments
% Code blocks
% Code blocks, no left margin

% Complex code blocks, where too many encodings would be necessary
% Inline code fragments
% The inverted exclamation mark -- ¡ -- never occurs in code, so it is a good candidate to use as bracket

% This is a stub for the fancyvrb starred environments below
% NOTE: Inside this environment, intead of
% \command{object}, write
% ¬command¦object^
% as these characters -- ¬, ¦ and ^ -- are very rare in code


Text outside. \inCode{Text inside. Works with plain text.} Text outside.

Now with backslashes it doesn't work: \inCode{\something and ¬textbf¦\something^}

But the same using the stub code works fine: \inCodeStub¡\something and ¬textbf¦\something^¡
  • What encoding are you using for the TeX file? If it's UTF-8, then you can't use ¬ as a command char, because it's two-byte.
    – egreg
    Commented May 2, 2014 at 14:16
  • In any case, a verbatim command such as \inCodeStub can't go in the argument to another command.
    – egreg
    Commented May 2, 2014 at 14:36
  • Hi egreg. Thank you for your feedback. In fact, in my main document, I use \usepackage[utf8]{inputenc} and I still manage to have this working with \inCodeStub¡\something and ¬textbf¦\something^¡. The only part not working is wrapping this in a functional command, with {}s. I checked the \CustomVerbatimCommand definition in fancyvrb.pdf hoping I could hack it, but I'm not a \TeXpert... yet.
    – Ricardo
    Commented May 2, 2014 at 16:02
  • If I add \usepackage[utf8]{inputenc} and save the example as UTF-8, I get errors at \CustomVerbatimCommand (which I expected).
    – egreg
    Commented May 2, 2014 at 16:13

1 Answer 1


You can't use ¬ and ¦ as “command chars” if you have \usepackage[utf8]{inputenc}. Only one byte characters can be used for the purpose (and not all of them, actually).

If you are willing to switch to XeLaTeX or LuaLaTeX, then it's possible.

You must log in to answer this question.

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