Node: code, Next: , Previous: Useful Highlighting, Up: Indicating



@code{sample-code}

Use the @code command to indicate text that is a piece of a program and which consists of entire syntactic tokens. Enclose the text in braces.

Thus, you should use @code for an expression in a program, for the name of a variable or function used in a program, or for a keyword in a programming language.

Use @code for command names in languages that resemble programming languages, such as Texinfo. For example, @code and @samp are produced by writing @code{@@code} and @code{@@samp} in the Texinfo source, respectively.

It is incorrect to alter the case of a word inside an @code command when it appears at the beginning of a sentence. Most computer languages are case sensitive. In C, for example, Printf is different from the identifier printf, and most likely is a misspelling of it. Even in languages which are not case sensitive, it is confusing to a human reader to see identifiers spelled in different ways. Pick one spelling and always use that. If you do not want to start a sentence with a command name written all in lower case, you should rearrange the sentence.

In the printed manual, @code causes TeX to typeset the argument in a typewriter face. In the Info file, it causes the Info formatting commands to use single quotation marks around the text.

For example,

     The function returns @code{nil}.
     

produces this in the printed manual:

The function returns nil.

Here are some cases for which it is preferable not to use @code:

Since @command, @option, and @env were introduced relatively recently, it is acceptable to use @code or @samp for command names, options, and environment variables. The new commands allow you to express the markup more precisely, but there is no real harm in using the older commands, and of course the long-standing manuals do so.