manpagez: man pages & more
info texinfo
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.2 @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 lowercase, you should rearrange the sentence.

In the Info output, @code results in single quotation marks around the text. In other formats, @code argument is typeset in a typewriter (monospace) font. For example,

The function returns @code{nil}.

produces this:

The function returns nil.

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

By default, TeX will consider breaking lines at ‘-’ and ‘_’ characters within @code and related commands. This can be controlled with @allowcodebreaks (see section @allowcodebreaks: Control Line Breaks in @code). The HTML output attempts to respect this for ‘-’, but ultimately it is up to the browser’s behavior. For Info, it seems better never to make such breaks.

For Info, the quotes are omitted in the output of the @code command and related commands (e.g., @kbd, @command), in typewriter-like contexts such as the @example environment (see section @example: Example Text) and @code itself, etc.

To control which quoting characters are implicitly inserted by Texinfo processors in the output of ‘@code’, etc., see the OPEN_QUOTE_SYMBOL and CLOSE_QUOTE_SYMBOL customization variables (see section Other Customization Variables). This is separate from how actual quotation characters in the input document are handled (see section Inserting Quote Characters).

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on October 2, 2013 using texi2html 5.0.

© 2000-2017
Individual documents may contain additional copyright information.