| <!DOCTYPE html> |
| <html> |
| <!-- Created by Texinfo 6.8dev+dev, http://www.gnu.org/software/texinfo/ --> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| <!-- This manual is for GNU Texinfo (version 6.8dev, 23 February 2022), |
| a documentation system that can produce both online information and a |
| printed manual from a single source using semantic markup. |
| |
| Copyright (C) 1988, 1990-1993, 1995-1999, 2001-2022 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with no |
| Invariant Sections, with no Front-Cover Texts, and with no Back-Cover |
| Texts. A copy of the license is included in the section entitled |
| "GNU Free Documentation License". --> |
| <title>@code (GNU Texinfo 6.8dev)</title> |
| |
| <meta name="description" content="@code (GNU Texinfo 6.8dev)"> |
| <meta name="keywords" content="@code (GNU Texinfo 6.8dev)"> |
| <meta name="resource-type" content="document"> |
| <meta name="distribution" content="global"> |
| <meta name="Generator" content="texi2any"> |
| <meta name="viewport" content="width=device-width,initial-scale=1"> |
| |
| <link href="index.html" rel="start" title="Top"> |
| <link href="Command-and-Variable-Index.html" rel="index" title="Command and Variable Index"> |
| <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> |
| <link href="Indicating.html" rel="up" title="Indicating"> |
| <link href="_0040kbd.html" rel="next" title="@kbd"> |
| <link href="Useful-Highlighting.html" rel="prev" title="Useful Highlighting"> |
| <style type="text/css"> |
| <!-- |
| div.example {margin-left: 3.2em} |
| ul.mark-bullet {list-style-type: disc} |
| --> |
| </style> |
| |
| |
| </head> |
| |
| <body lang="en"> |
| <div class="subsection-level-extent" id="g_t_0040code"> |
| <div class="nav-panel"> |
| <p> |
| Next: <a href="_0040kbd.html" accesskey="n" rel="next"><code class="code">@kbd</code>{<var class="var">keyboard-characters</var>}</a>, Previous: <a href="Useful-Highlighting.html" accesskey="p" rel="prev">Highlighting Commands are Useful</a>, Up: <a href="Indicating.html" accesskey="u" rel="up">Indicating Definitions, Commands, etc.</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Variable-Index.html" title="Index" rel="index">Index</a>]</p> |
| </div> |
| <hr> |
| <h4 class="subsection" id="g_t_0040code_007bsample_002dcode_007d">6.1.2 <code class="code">@code</code>{<var class="var">sample-code</var>}</h4> |
| |
| <a class="anchor" id="code"></a><a class="index-entry-id" id="index-code"></a> |
| |
| <a class="index-entry-id" id="index-Syntactic-tokens_002c-indicating"></a> |
| <p>Use the <code class="code">@code</code> command to indicate text that is a piece of a |
| program and which consists of entire syntactic tokens. Enclose the |
| text in braces. |
| </p> |
| <a class="index-entry-id" id="index-Expressions-in-a-program_002c-indicating"></a> |
| <a class="index-entry-id" id="index-Keywords_002c-indicating"></a> |
| <a class="index-entry-id" id="index-Reserved-words_002c-indicating"></a> |
| <p>Thus, you should use <code class="code">@code</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. |
| </p> |
| <p>Use <code class="code">@code</code> for command names in languages that resemble |
| programming languages, such as Texinfo. For example, <code class="code">@code</code> and |
| <code class="code">@samp</code> are produced by writing ‘<samp class="samp">@code{@@code}</samp>’ and |
| ‘<samp class="samp">@code{@@samp}</samp>’ in the Texinfo source, respectively. |
| </p> |
| <a class="index-entry-id" id="index-Case_002c-not-altering-in-_0040code"></a> |
| <p>It is incorrect to alter the case of a word inside a <code class="code">@code</code> |
| command when it appears at the beginning of a sentence. Most computer |
| languages are case sensitive. In C, for example, <code class="code">Printf</code> is |
| different from the identifier <code class="code">printf</code>, 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. |
| </p> |
| <p>In the Info output, <code class="code">@code</code> results in single quotation marks |
| around the text. In other formats, <code class="code">@code</code> argument is typeset |
| in a typewriter (monospace) font. For example, |
| </p> |
| <div class="example"> |
| <pre class="example-preformatted">The function returns @code{nil}. |
| </pre></div> |
| |
| <p>produces this: |
| </p> |
| <blockquote class="quotation"> |
| <p>The function returns <code class="code">nil</code>. |
| </p></blockquote> |
| |
| <p>Here are some cases for which it is preferable <em class="emph">not</em> to use <code class="code">@code</code>: |
| </p> |
| <ul class="itemize mark-bullet"> |
| <li>For shell command names, such as <code class="command">ls</code> (use <code class="code">@command</code>). |
| |
| </li><li>For environment variables, such as <code class="env">TEXINPUTS</code> (use <code class="code">@env</code>). |
| |
| </li><li>For shell options, such as ‘<samp class="samp">-c</samp>’, when such options stand alone (use |
| <code class="code">@option</code>). |
| |
| </li><li>An entire shell command often looks better if written using |
| <code class="code">@samp</code> rather than <code class="code">@code</code>. In this case, the rule is to |
| choose the more pleasing format. |
| |
| </li><li>For a string of characters shorter than a syntactic token. For example, |
| if you are writing about ‘<samp class="samp">goto-ch</samp>’, which is just a part of the |
| name for the <code class="code">goto-char</code> Emacs Lisp function, you should use |
| <code class="code">@samp</code>. |
| |
| </li><li>In general, when writing about the characters used in a token; for |
| example, do not use <code class="code">@code</code> when you are explaining what letters |
| or printable symbols can be used in the names of functions. (Use |
| <code class="code">@samp</code>.) Also, you should not use <code class="code">@code</code> to mark text |
| that is considered input to programs unless the input is written in a |
| language that is like a programming language. For example, you should |
| not use <code class="code">@code</code> for the keystroke commands of GNU Emacs (use |
| <code class="code">@kbd</code> instead) although you may use <code class="code">@code</code> for the names |
| of the Emacs Lisp functions that the keystroke commands invoke. |
| |
| </li></ul> |
| |
| <p>By default, TeX will consider breaking lines at ‘<samp class="samp">-</samp>’ and |
| ‘<samp class="samp">_</samp>’ characters within <code class="code">@code</code> and related commands. This |
| can be controlled with <code class="code">@allowcodebreaks</code> |
| (see <a class="pxref" href="_0040allowcodebreaks.html"><code class="code">@allowcodebreaks</code>: Control Line Breaks in <code class="code">@code</code></a>). In the HTML output breaking |
| lines is up to the browser’s behavior. For Info, it seems better |
| never to make such breaks. |
| </p> |
| <p>For Info, the quotes are omitted in the output of the <code class="code">@code</code> |
| command and related commands (e.g., <code class="code">@kbd</code>, <code class="code">@command</code>), |
| in typewriter-like contexts such as the <code class="code">@example</code> environment |
| (see <a class="pxref" href="_0040example.html"><code class="code">@example</code>: Example Text</a>) and <code class="code">@code</code> itself, etc. |
| </p> |
| <p>To control which quoting characters are implicitly inserted by Texinfo |
| processors in the output of ‘<samp class="samp">@code</samp>’, etc., see the |
| <code class="code">OPEN_QUOTE_SYMBOL</code> and <code class="code">CLOSE_QUOTE_SYMBOL</code> customization |
| variables (see <a class="pxref" href="Other-Customization-Variables.html">Other Customization Variables</a>). This is separate |
| from how actual quotation characters in the input document are handled |
| (see <a class="pxref" href="Inserting-Quote-Characters.html">Inserting Quote Characters</a>). |
| </p> |
| |
| </div> |
| <hr> |
| <div class="nav-panel"> |
| <p> |
| Next: <a href="_0040kbd.html"><code class="code">@kbd</code>{<var class="var">keyboard-characters</var>}</a>, Previous: <a href="Useful-Highlighting.html">Highlighting Commands are Useful</a>, Up: <a href="Indicating.html">Indicating Definitions, Commands, etc.</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Variable-Index.html" title="Index" rel="index">Index</a>]</p> |
| </div> |
| |
| |
| |
| </body> |
| </html> |