1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
<head>
<title>UK TeX FAQ -- question label mathstext</title>
</head><body>
<h3>Text inside maths</h3>
<p>When we type maths in (La)TeX, the letters from which we make up
ordinary text assume a special significance: they all become
single-letter variable names. The letters appear in italics, but it's
not the same sort of italics that you see when you're typing ordinary
text: a run of maths letters (for example "here") looks oddly
"lumpy" when compared with the word written in italic text. The
difference is that the italic text is kerned to make the letters fit
well together, whereas the maths is set to look as if you're
multiplying <em>h</em> by <em>e</em> by <em>r</em> by <em>e</em>. The other
way things are odd in TeX maths typing is that spaces are ignored:
at best we can write single words in this oddly lumpy font.
<p>So, if we're going to have good-looking text in amongst maths we're
writing, we have to take special precautions. If you're using
LaTeX, the following should help.
<p>The simplest is to use <code>\</code><code>mbox</code> or <code>\</code><code>textrm</code>:
<blockquote>
<pre>
$e = mc^2 \mbox{here we go again}$
</pre>
</blockquote>
The problem is that, with either, the size of the text remains firmly
at the surrounding text size, so that
<blockquote>
<pre>
$z = a_{\mbox{other end}}$
</pre>
</blockquote>
looks quite painfully wrong.
<p>The other simple technique, <code>\</code><code>textrm</code>, is more promising:
<blockquote>
<pre>
$z = a_{\textrm{other end}}$
</pre>
</blockquote>
is definitely right. However, the surrounding text may not be in your
roman font; if you care about matching text, you need to choose
between <code>\</code><code>textrm</code>, <code>\</code><code>textsf</code>, and so on.
<p>(The maths-mode instance of your roman font (<code>\</code><code>mathrm</code>) gets the
size right, but since it's intended for use in maths, its spaces get
ignored - use <code>\</code><code>mathrm</code> for upright roman alphabetic variable
names, but not otherwise.)
<p>You can correct these problems with size selectors in the text, as:
<blockquote>
<pre>
$z = a_{\mbox{\scriptsize other end}}$
</pre>
</blockquote>
which works if your surrounding text is at default document size, but
gives you the wrong size otherwise.
<p>These short cuts are (just about) OK for the "occasional"
mathematician, but serious mathematics calls for a technique that
relieves the typist of the sort of thought required. As usual, the
AMSLaTeX system provides what's necessary - the <code>\</code><code>text</code>
command. The command is actually provided by the <i>amstext</i>
package, but the "global" <i>amsmath</i> package loads it, so
anyone using AMSLaTeX proper has the command available, so even
joke mathematicians can write:
<blockquote>
<pre>
\usepackage{amsmath}
...
$z = a_{\text{other end}}$
</pre>
</blockquote>
and the text will be at the right size, and in the same font as
surrounding text.
<p>AMSLaTeX also makes provision for interpolated comments in the
middle of one of its multi-line display structures, through the
<code>\</code><code>intertext</code> command. For example:
<blockquote>
<pre>
\begin{align}
A_1&=N_0(\lambda;\Omega')-\phi(\lambda;\Omega'),\\
A_2&=\phi(\lambda;\Omega')-\phi(\lambda;\Omega),\\
\intertext{and} A_3&=\mathcal{N}(\lambda;\omega).
\end{align}
</pre>
</blockquote>
places the text "and" on a separate line before the last line of the
display. If the interjected text is short, or the equations
themselves are light-weight, you may find that <code>\</code><code>intertext</code> leaves
too much space. Slightly more modest is the <code>\</code><code>shortintertext</code>
command from the <i>mathtools</i> package:
<blockquote>
<pre>
\begin{align}
a =& b
\shortintertext{or}
c =& b
\end{align}
</pre>
</blockquote>
To have the text on the same line as the second equation, one can use
the the <code>flalign</code> environment (from <i>amsmath</i>)
with lots of dummy equations (represented by the double <code>&</code>
signs):
<blockquote>
<pre>
\begin{flalign}
&& a =& b && \\
\text{or} && c =& b &&
\end{flalign}
</pre>
</blockquote>
<p>Comprehensive documentation of AMSLaTeX is to be found in
<i>amsldoc</i>, in the distribution; it is also available on the web
at <a href="ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf">ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf</a>
<dl>
<dt><tt><i>amsldoc.tex</i></tt><dd>Distributed as part of AMSLaTeX
<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/amslatex.tar.gz">macros/latex/required/amslatex</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/amslatex.zip">zip</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/amslatex/">browse</a>)
<dt><tt><i>amsmath.sty</i></tt><dd>Distributed as part of AMSLaTeX
<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/amslatex.tar.gz">macros/latex/required/amslatex</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/amslatex.zip">zip</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/amslatex/">browse</a>)
<dt><tt><i>amstext.sty</i></tt><dd>Distributed as part of AMSLaTeX
<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/amslatex.tar.gz">macros/latex/required/amslatex</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/amslatex.zip">zip</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/amslatex/">browse</a>)
<dt><tt><i>mathtools.sty</i></tt><dd>Distributed as part of the <i>mh</i> bundle
<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/mh.tar.gz">macros/latex/contrib/mh</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/mh.zip">zip</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/mh/">browse</a>)
</dl>
<p><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=mathstext">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=mathstext</a>
</body>
|