JezK
Edit File: _0040code.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- Created by GNU Texinfo 6.8, https://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.8, 8 June 2021), 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-2021 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.8)</title> <meta name="description" content="@code (GNU Texinfo 6.8)"> <meta name="keywords" content="@code (GNU Texinfo 6.8)"> <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"> <!-- a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em} a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} span:hover a.copiable-anchor {visibility: visible} ul.no-bullet {list-style: none} --> </style> </head> <body lang="en"> <div class="subsection" id="g_t_0040code"> <div class="header"> <p> Next: <a href="_0040kbd.html" accesskey="n" rel="next"><code>@kbd</code>{<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> <span id="g_t_0040code_007bsample_002dcode_007d"></span><h4 class="subsection">6.1.2 <code>@code</code>{<var>sample-code</var>}</h4> <span id="code"></span><span id="index-code"></span> <span id="index-Syntactic-tokens_002c-indicating"></span> <p>Use the <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> <span id="index-Expressions-in-a-program_002c-indicating"></span> <span id="index-Keywords_002c-indicating"></span> <span id="index-Reserved-words_002c-indicating"></span> <p>Thus, you should use <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>@code</code> for command names in languages that resemble programming languages, such as Texinfo. For example, <code>@code</code> and <code>@samp</code> are produced by writing ‘<samp>@code{@@code}</samp>’ and ‘<samp>@code{@@samp}</samp>’ in the Texinfo source, respectively. </p> <span id="index-Case_002c-not-altering-in-_0040code"></span> <p>It is incorrect to alter the case of a word inside a <code>@code</code> command when it appears at the beginning of a sentence. Most computer languages are case sensitive. In C, for example, <code>Printf</code> is different from the identifier <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>@code</code> results in single quotation marks around the text. In other formats, <code>@code</code> argument is typeset in a typewriter (monospace) font. For example, </p> <div class="example"> <pre class="example">The function returns @code{nil}. </pre></div> <p>produces this: </p> <blockquote> <p>The function returns <code>nil</code>. </p></blockquote> <p>Here are some cases for which it is preferable <em>not</em> to use <code>@code</code>: </p> <ul> <li> For shell command names, such as <code>ls</code> (use <code>@command</code>). </li><li> For environment variables, such as <code>TEXINPUTS</code> (use <code>@env</code>). </li><li> For shell options, such as ‘<samp>-c</samp>’, when such options stand alone (use <code>@option</code>). </li><li> An entire shell command often looks better if written using <code>@samp</code> rather than <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>goto-ch</samp>’, which is just a part of the name for the <code>goto-char</code> Emacs Lisp function, you should use <code>@samp</code>. </li><li> In general, when writing about the characters used in a token; for example, do not use <code>@code</code> when you are explaining what letters or printable symbols can be used in the names of functions. (Use <code>@samp</code>.) Also, you should not use <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>@code</code> for the keystroke commands of GNU Emacs (use <code>@kbd</code> instead) although you may use <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>-</samp>’ and ‘<samp>_</samp>’ characters within <code>@code</code> and related commands. This can be controlled with <code>@allowcodebreaks</code> (see <a href="_0040allowcodebreaks.html"><code>@allowcodebreaks</code>: Control Line Breaks in <code>@code</code></a>). The HTML output attempts to respect this for ‘<samp>-</samp>’, but ultimately it 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>@code</code> command and related commands (e.g., <code>@kbd</code>, <code>@command</code>), in typewriter-like contexts such as the <code>@example</code> environment (see <a href="_0040example.html"><code>@example</code>: Example Text</a>) and <code>@code</code> itself, etc. </p> <p>To control which quoting characters are implicitly inserted by Texinfo processors in the output of ‘<samp>@code</samp>’, etc., see the <code>OPEN_QUOTE_SYMBOL</code> and <code>CLOSE_QUOTE_SYMBOL</code> customization variables (see <a 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 href="Inserting-Quote-Characters.html">Inserting Quote Characters</a>). </p> </div> <hr> <div class="header"> <p> Next: <a href="_0040kbd.html"><code>@kbd</code>{<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>