# How to make a single word look as some code?

I would like to be able to make a single word in a text look like a coded word. Is there any command such as \code{...} which allows me to do so?

(basically, I want to produce something like above for the "\code{...}" part)

-
Do you want it to change the background to grey too? –  N.N. Nov 24 '11 at 11:15
@N.N : it could have been even better yeah, but it's not extremely important. –  SRKX Nov 24 '11 at 12:46

Normally a monospaced font is used for this. This is accomplished with \texttt{...}. If you want to use code, you can use \def\code#1{\texttt{#1}}. From that point on you can write \code{...} to get monospaced output.

-
Yes, that's the way to go. Put it semantically correct (by calling it code) and use texttt inside this until you come across a better formatting. –  wal-o-mat Nov 24 '11 at 11:15
@egreg I'm not so sure about the last approach (yes, I know why you're doing it, but from an interface POV I prefer macros where the arguments required are clear). –  Joseph Wright Nov 24 '11 at 11:41
@JosephWright That's why I wrote that it's advanced. :) –  egreg Nov 24 '11 at 11:50
I would also wrap a \mbox around the \texttt, to avoid the word being hyphenated if it happens to fall near the end of a line. –  Karl Ove Hufthammer Nov 24 '11 at 11:51
\verb|code| or \verb#code# also works. It creates characters in monospace, although its primary utility to enter commands that the compiler wont confuse as tex commands.