blob: 648271186e534a240933df79c2fe6e091487bdc2 [file]
<!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>Inserting Math (GNU Texinfo 6.8dev)</title>
<meta name="description" content="Inserting Math (GNU Texinfo 6.8dev)">
<meta name="keywords" content="Inserting Math (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="Insertions.html" rel="up" title="Insertions">
<link href="Glyphs-for-Text.html" rel="next" title="Glyphs for Text">
<link href="Inserting-Subscripts-and-Superscripts.html" rel="prev" title="Inserting Subscripts and Superscripts">
<style type="text/css">
<!--
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
pre.display-preformatted {font-family: inherit}
-->
</style>
</head>
<body lang="en">
<div class="section-level-extent" id="Inserting-Math">
<div class="nav-panel">
<p>
Next: <a href="Glyphs-for-Text.html" accesskey="n" rel="next">Glyphs for Text</a>, Previous: <a href="Inserting-Subscripts-and-Superscripts.html" accesskey="p" rel="prev"><code class="code">@sub</code> and <code class="code">@sup</code>: Inserting Subscripts and Superscripts</a>, Up: <a href="Insertions.html" accesskey="u" rel="up">Special Insertions</a> &nbsp; [<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>
<h3 class="section" id="g_t_0040math-and-_0040displaymath_003a-Formatting-Mathematics">11.7 <code class="code">@math</code> and <code class="code">@displaymath</code>: Formatting Mathematics</h3>
<a class="anchor" id="math"></a><a class="index-entry-id" id="index-math"></a>
<a class="index-entry-id" id="index-Mathematical-expressions_002c-inserting"></a>
<a class="index-entry-id" id="index-Formulas_002c-mathematical"></a>
<p>You can write a short mathematical expression with the <code class="code">@math</code>
command. Write the mathematical expression between braces, like this:
</p>
<div class="example">
<pre class="example-preformatted">@math{\sin 2\pi \equiv \cos 3\pi}
</pre></div>
<p>which looks like this:
</p><div class="display">
<pre class="display-preformatted"><em class="math">\sin 2\pi \equiv \cos 3\pi</em>
</pre></div>
<p>The <code class="code">@math</code> command has no special effect on the Info
output or (by default) the HTML output, merely outputting
the contents verbatim.
</p>
<p>For the TeX output, <code class="code">@math</code> switches into math mode.
This allows you to use all the
plain TeX math control sequences for symbols, functions, and so on,
starting with &lsquo;<samp class="samp">\</samp>&rsquo;. It&rsquo;s best to use &lsquo;<samp class="samp">\</samp>&rsquo; instead of &lsquo;<samp class="samp">@</samp>&rsquo;
for any such mathematical commands; otherwise, <code class="command">texi2any</code>
will complain.
</p>
<a class="index-entry-id" id="index-Math-output-for-HTML"></a>
<p>By default, the HTML output is only enclosed by <code class="code">&lt;em&gt;</code>.
<code class="command">texi2any</code> provides three options for displaying properly
formatted mathematics for HTML. You can select these with the
<code class="code">HTML_MATH</code> variable (see <a class="pxref" href="HTML-Customization-Variables.html">HTML Customization Variables</a>).
With <code class="code">HTML_MATH</code> set to &lsquo;<samp class="samp">l2h</samp>&rsquo;, <code class="command">texi2any</code> attempts
to use the <code class="command">latex2html</code> program to produce image files for
mathematical material. With the &lsquo;<samp class="samp">t4h</samp>&rsquo; setting, <code class="command">texi2any</code>
attempts to use the <code class="command">tex4ht</code> program. With the &lsquo;<samp class="samp">mathjax</samp>&rsquo;
setting, <code class="command">texi2any</code> inserts references in the output files
to MathJax scripts to format the material. The MathJax option
requires JavaScript to be enabled in the browser to work. See also
<a class="ref" href="MathJax-Customization-Variables.html">MathJax Customization Variables</a> and <a class="ref" href="latex2html-Customization-Variables.html"><code class="command">latex2html</code> Customization Variables</a>.
</p>
<a class="index-entry-id" id="index-Displayed-equations"></a>
<a class="index-entry-id" id="index-Equations_002c-displayed"></a>
<a class="index-entry-id" id="index-displaymath"></a>
<p>For displayed equations, you can use the <code class="code">@displaymath</code>
command. Example:
</p>
<div class="example">
<pre class="example-preformatted">@displaymath
f(x) = {1\over\sigma\sqrt{2\pi}}
e^{-{1\over2}\left({x-\mu\over\sigma}\right)^2}
@end displaymath
</pre></div>
<p>which produces:
</p>
<div class="displaymath"><em>f(x) = {1\over\sigma\sqrt{2\pi}}
e^{-{1\over2}\left({x-\mu\over\sigma}\right)^2}
</em></div>
<p>Although <code class="code">@sub</code> and <code class="code">@sup</code> may work inside math mode in
some contexts, it is better to use TeX&rsquo;s &lsquo;<samp class="samp">_</samp>&rsquo; and &lsquo;<samp class="samp">^</samp>&rsquo;
characters to denote subscripts and superscripts within mathematical
expressions. In general, the contents of <code class="code">@math</code> or
<code class="code">@displaymath</code> should be plain TeX only, with no
interspersed Texinfo commands.
</p>
<a class="index-entry-id" id="index-_005cmathopsup"></a>
<p>Due to the conflict with Texinfo&rsquo;s <code class="code">@sup</code> command, you can access
the plain TeX command <code class="code">\sup</code> as <code class="code">\mathopsup</code> instead,
in the unlikely occurrence that you want to do this (but only when
processing with TeX, not with any of the <code class="code">HTML_MATH</code> options).
</p>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Glyphs-for-Text.html">Glyphs for Text</a>, Previous: <a href="Inserting-Subscripts-and-Superscripts.html"><code class="code">@sub</code> and <code class="code">@sup</code>: Inserting Subscripts and Superscripts</a>, Up: <a href="Insertions.html">Special Insertions</a> &nbsp; [<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>