Go to the previous, next section.
There are two separate ways to specify special characters to
SM, by using a syntax
very similar to TeX (the type-setting system created by Donald Knuth
that we used for this manual), or the traditional Mongo way. You might
ask what are the advantages
of TeX? One is that sub- and super- scripts are handled much more naturally,
making it much harder to type
when you meant
Another is that you no longer have to remember that
is hidden
in the Greek font as `q', you can simply type \theta
. A
third would be that you may well know TeX already.
If you want to make SM understand TeX strings
you should define the variable
TeX_strings
(if you put a line
TeX_strings 1
in your `.sm' file this will be done automatically).
You can, of course, undefine it at any time to revert to the old-fashioned
strings described below.
Using TeX-style
strings is strongly recommended by the authors; all future and most
recent improvements to SM's labels are only supported in TeX mode.
If you want to change the default font used for labels, define the variable
default_font
, either interactively (DEFINE default_font
oe
), or by putting a line in your `.sm file': default_font oe
.
This affects axis as well as regular labels and
only works if you use TeX_strings
(of course).
For some devices with hardware fonts (for example, postscript printers
or a Tektronix 4010 terminal), if expand
is exactly 1, and
angle
is exactly 0, the hard fonts will be used for speed.
Various strategies to defeat this are discussed below.
label \pi^{\-21/22 = {\3\int2e^{-x^22\,dxwill print a well-known result (You'll have to
RELOCATE
somewhere
where the label will be visible first, of course).
(If
you want to try it now, you should be careful typing those ^'s, as
they are special to the history editor, dealing with this is
discussed below.) In
this example the characters \
, {
, 2
, and ^
are special (and so is _
which wasn't used). Postponing \
for the moment, ^
means `make the next group a superscript',
_
means `make the next group a subscript', where a group is
either a single character, a single control sequence (wait a moment!), or a
string enclosed in braces. So A_a^{SM2B
would appear as
A \
can serve one of two functions, either
turning off the special meaning of the next character (so \_
is simply a _
with no special significance), or to introduce a
named `control sequence'. These fall into three groups, those that
change fonts, those that serve as abbreviations for single
characters (e.g. \pi
in the example), and those that are macros.
The font changes persist
until the end of the string, or the current group, whichever comes
first.
The available fonts are
`greek', `old english', `private', `roman', `script', and `tiny'. They
may be referred to either by a
two-character control sequences (\gr
, \oe
, \pr
,
\rm
, \sc
, or \ti
) or simply by the first character
(e.g. \r
for the roman font).
In addition \i
or \it
can be used to make the current font italic (italics are turned off
again either by a second \it
or by grouping the first \it
within {2
). The `bold' font \b
or \bf
is similar,
in that it makes the current font bold, and can be toggled off with a second
\bf
if you didn't simply group it. I'd strongly recommend
treating \bf
and \it
like any other font change, and
group them rather than relying on this toggling action.
You can alter the size of the letters
by using an escape such as \6
which scales the current group
(any font change is local to a group).
\6
corresponds to multiplying the size by @tex
$1.2^6$
or
about 3, \-4
scales by @tex
$1/1.2^4$
or 0.48. This is similar to
the `magstep' used in scaling fonts in TeX.
These scale factors
are in addition to the expansion produced by going
up or down (^
or _
), or setting EXPAND
.
Other control sequences either consist of one non-alphabetic
character, or else a name consisting only of letters, so \,
or
\palmtree
is valid but \one2three
is not. If a
alphabetic name is followed by a space, the space is treated as simply
delimiting the name and is discarded. For example,
AB^{\alpha_\beta CD2
will appear as
(note that the space after beta
disappeared). How do you make
just a few characters italic (script, old english, etc.)? Try
ABC{\it DEF2GHI
. You can't read a subscript, and want it in
`tiny' font? Try \Lambda_{\ti ab2
. All of the Greek letters are
defined, as \alpha
-\omega
,\Alpha
-\Omega
,
there are various mathematical symbols (e.g. \int
, \infty
,
or \sqrt
), some astronomical (e.g. \AA
for
and some
miscellaneous characters (e.g. \snow
to draw a snowflake).
You can generate
a complete list of definitions by saying load fonts TeX_defs
.
Some of these definitions are more complex than just special characters, if you know TeX most of them should be familiar.
\bar str
str
.
\over str1 str2
str1
over str2
, separated by a horizontal line.
\phantom str
str
, but take up as much space as str
would have if you had drawn it.
\smash str
str
but pretend that it took up no space.
\strut
You can also define your own TeX definitions by using the special
command \def\name{value2
inside a label. It produces no output,
but defines name
to expand to value
. For example, I could define
\TeX
to produce TeX by saying
LABEL \def\TeX{T\raise-200\kern-20E\raise200X2.Once a definition has been made it is remembered forever (well, until you leave SM actually) whatever devices you plot on. You must make sure that all curly brackets are properly paired inside your definition. You can have arguments just like real TeX, referred to as
#1
,
#2
, #3
and so forth, for example
\def\sub#1{_{#122
Your SM guru can compile TeX-definitions into the binary fonts file, instructions are given in the fonts appendix.
We have made a number of extensions to TeX that are useful in a plotting package, but wouldn't be especially valuable in a printed document. We have also distorted the meanings of some of TeX's control words; sorry.
\point n s
\apoint angle n s
DOT
) into a label. The
string \point43
(or \point 4 3
) will draw a point at the
current position in the string, of ptype
`4 3'. This sequence,
from the \
to the 3
, is treated as a single character as regards
things like subscripts. If you want to specify an angle, use something like
\apoint 45 4 0
.
\hrule width
width
in screen units. It will be multiplied by the current
expansion.
\kern dx
\kern #
moves the current plot position by #
horizontally, where the distance
#
is specified in screen units (the whole screen is 32768
across). It is multiplied by the expansion currently in effect, and may be
postive or negative. See also \raise
.
\line type length
\line
inserts a line into a label, at about the level of the
middle of a lower-case character.
e.g. \line 1 1000
will draw a line of length 1000 (in screen
units, so the screen is 32768 across), of ltype 1.
See also \hrule
.
\move dx dy
(dx,dy)
, but don't disturb SM's current idea of where
it is. This means that we can draw a line over a character with a string
such as \move 0 300{\line 0 4002A
. It is possible to use the
commands such as \width
to take the guesswork out of such commands,
for example the definition of \bar
is
\def\bar#1{\move0\advance\height{#12by100{\rule\width{#122#12
\raise dy
\raise #
moves the current plot position by #
vertically, where the distance
#
is specified in screen units (the whole screen is 32768
across). It is multiplied by the expansion currently in effect, and may be
postive or negative. See also \kern
.
\vrule depth height
d
and
height h
(and width 0) in screen units. Dimensions are multiplied by
the current expansion.
There are also a number of control sequences that can be used whenever
a number is expected (by \kern
, \line
, \move
,
or \raise
);
for an example of their use see \move
in the preceding table.
\advance num1 [ by ] num
\width{...2
)
by the second. The by
is optional.
\depth{...2
\divide num1 [ by ] num2
num1
by num2
/1000. As for \advance
,
num1
and num2
need not be `simple' numbers but can be
combinations of widths, advances, and so on. The by
is optional.
\height{...2
\multiply num1 [ by ] num2
num1
by num2
/1000. See \divide
for the
lack of restrictions on num1 and num2. The by
is optional.
\width{...2
If you want to know the dimensions of the string that you have just drawn (or just not drawn, q.v. PUTLABEL 0) you can look at the internal variables $sdepth, $sheight, and $slength.
Now for a few caveats: Firstly, because \n
is a newline, you must type
\\nu
or "\nu"
to get a
Secondly, the superscript
character
^
is special to the history editor, so to type it interactively
you must quote
it with the quote_next
key (usually ^Q or ESC-q, i.e.
type ^Q^
). Alternatively, you could change your history
character to some under-used character such as % or ' (which is the
solution that I use: you can choose a new character such as ' by
simply putting a line
history_char '
in your `.sm' file).
Thirdly, TeX (and our pseudoTeX) are
rather verbose and labels may not fit on one line. The solution is to
continue the line by ending it with a \. This is probably best done
within a macro, as the continuation line won't appear on your history
list if typed at the prompt. You can currently have about 25
continuation lines (2000 characters).
A final point will only worry
TeXies, namely that the emulation isn't perfect: for example
\sum_i
won't put the i
beneath the summation symbol.
Some of the other discrepancies were listed in the previous section.
If EXPAND is set to exactly 1, and ANGLE is exactly 0, then SM will use hardware fonts, when available, in writing labels. This is faster, but can lead to two styles of labels in one plot which is ugly.
There are various ways to trick SM into always using its own fonts: you can say say "ANGLE 360", or use a \0 to select a font with (explicitly) no expansion. To affect the axis tick labels too, using the AXIS or BOX commands, you'll have to say "EXPAND 1.0001" or somesuch.
Rather than always expanding your plots, you could ask your SM Guru to edit the `graphcap' file to prevent a given device (usually a printer) from ever using hardware fonts. Tell her to see section The Stdgraph Graphics Kernel. If she won't oblige, you can define your own device in your own graphcap file, and put yours first in the `.sm' file. For example, my `.sm' file includes the line
+graphcap /d/rhl/graphcapand the file `/d/rhl/graphcap' looks like:
# Private overrides for RHL: # postscript|postscript + no hardware fonts:\ :TB@:TE@:TC=postscript:Then I set
$printer
to postscript
(also in `.sm')
and all is well.
An alternative is to specify the device as
DEVICE postscript :TB@:TE@:tc=postscript:which is perhaps simpler (you'd just define your value of
printer
properly).
If you insist on using old-style labels (which are still the default),
here's a quick summary.
Type \a
or \\a
to change to font
a
for one character (first form) or permanently (second
form). The possible fonts are g, o, p, r, s,
and t
for
`greek', `old english', `private', `roman', `script', and `tiny'
respectively. In addition, the pseudo-fonts u
and d
move text `up' and `down' respectively, and i
produces
`italic' (actually just slanted) characters.
Size changes are just like any other font change, so
\6
and \-4
will affect one character and the rest of
the string respectively.
This is really somewhat simpler than it sounds - try
label \gp\u\-21/2\2\d = \3\g:e\u-x\u2\d\s dxNote that `tiny' is a misnomer, it is (nowadays) just a font that look better if you need small letters (
\t\-6
will produce a shrunken `tiny' font, just like the
old days).
Spaces are treated differently in different fonts, as a greek space is
a negative space (i.e. a backspace), and a script space is only half as
wide as a normal space.
Go to the previous, next section.