unwanted space after a command

Gray, Gary L. euler at psu.edu
Mon Oct 25 15:41:53 CEST 2021


Hi,

I have defined several commands that look like:

\providecommand{\fn}[1]{\textcolor{DarkOrange3}{\texttt{\detokenize{#1}}}}

to use when entering computer code in documents for the classes I teach. I like the command because it allows me to put underscores or anything else I need in it. The command works nicely if I do something like:

\fn{legendreP(n,x)}

but if I have a backslash in the command, an extra space is added after the command. For example, with

\fn{w = A\b}.

there is a space between the "b" and the period. How can I define a command like this that doesn't add that extra space?

Thank you!

-- Gary L. Gray (he/him/his)


More information about the texhax mailing list.