📄 ch18.htm
字号:
<PRE><FONT COLOR="#0066FF">sum from x=1 to x=100 x sup 2
</FONT></PRE>
<P>to create the formula for summing <TT>x</TT> squared over the range 1 to 100.
If you want to use a special word, use braces:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">sum from x=1 to {x= inf} x sup 2
</FONT></PRE>
<P>This is the same command, except summing from 1 to infinity. The braces ensure
that the <TT>to</TT> component is properly interpreted. If no <TT>from</TT> or <TT>to</TT>
component is specified, they are not printed.</P>
<P>To use integrals, the keyword <TT>int</TT> is used, and can again take a <TT>from</TT>
argument:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">lim from n=1 xy sup 3 = 9
</FONT></PRE>
<P>Other reserved words for <TT>geqn</TT> are used with set theory. You can use the
keywords <TT>union</TT> and <TT>inter</TT> for the union and intersect of sets.
<H4 ALIGN="CENTER"><A NAME="Heading10<FONT COLOR="#000077">Brackets, Bars,
and Piles</FONT></H4>
<P>As equations get more complicated, you need to use more brackets and braces. You
can generate brackets (<TT>[]</TT>), braces (<TT>{}</TT>), and parentheses (<TT>()</TT>)
as needed by using the <TT>left</TT> and <TT>right</TT> commands:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">left { b over d+1} = left ( alpha over {beta + gamma} )
</FONT></PRE>
<P>This produces large braces, and parentheses are required to surround the terms.
You can nest these, of course, with <TT>geqn</TT> adjusting the sizes properly. Braces
are usually bigger than brackets and parentheses.</P>
<P>For floor and ceiling characters, use the <TT>left floor</TT>, <TT>right</TT>
<TT>floor</TT>, <TT>left ceiling</TT>, and <TT>right ceiling</TT> commands. For example,<FONT
COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">left ceiling x over alpha right ceiling > left floor beta over 2 right floor
</FONT></PRE>
<P>draws the equation with the proper vertical bars and ceiling and floor markers.</P>
<P>To create a pile of elements, use the reserved word <TT>pile</TT>. The following
example shows the usage best:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">X = left [ pile { a above b above c } right ]
</FONT></PRE>
<P>This produces output with the three elements <TT>a</TT>, <TT>b</TT>, and <TT>c</TT>
stacked vertically within big braces.
<H4 ALIGN="CENTER"><A NAME="Heading11<FONT COLOR="#000077">Matrices</FONT></H4>
<P>To make a matrix requires a little more work. You could probably make a matrix
using the <TT>pile</TT> command, but if the elements are not of equal height, they
will not line up. For that reason, use the keyword <TT>matrix</TT>. The general format
is<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">matrix {
ccol { elements }
ccol { elements }
</FONT></PRE>
<P>in which <TT>ccol</TT> produces centered columns. For left-adjusted columns, use
<TT>lcol</TT>; <TT>rcol</TT> produces right-adjusted columns. The elements are specified
individually. For example, the command<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">matrix {
ccol { x sub 1 above y sub 1 }
ccol { x sub 2 above y sub 2 }
</FONT></PRE>
<P>produces the matrix</P>
<PRE><FONT COLOR="#0066FF">x1 x2
</FONT></PRE>
<PRE><FONT COLOR="#0066FF">y1 y2
</FONT></PRE>
<P>All matrices must have the same number of elements in each column or <TT>geqn</TT>
can't process the matrix properly.
<H4 ALIGN="CENTER"><A NAME="Heading12<FONT COLOR="#000077">Quoted Text</FONT></H4>
<P>Any characters placed within quotation marks are not interpreted by <TT>geqn</TT>.
This is useful for text strings that may contain reserved words, such as the following:<FONT
COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">italic "beta" = beta + gamma
</FONT></PRE>
<P>Here, the word <TT>beta</TT> will appear in italic without being converted to
the beta character.
<H4 ALIGN="CENTER"><A NAME="Heading13<FONT COLOR="#000077">Character Changes</FONT></H4>
<P>You can change font and point size with <TT>geqn</TT> in much the same way as
with <TT>groff</TT>. The default setting is usually Roman 10 point. If you want to
set bold characters, use the keyword <TT>bold</TT>; <TT>italic</TT> sets italic font.<FONT
COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">x=y bold alpha
</FONT></PRE>
<P>You can also use the keyword <TT>fat</TT>, which widens the character (useful
for things such as grad characters). These reserved words affect only what immediately
follows, so you must use braces if the area to be changed is more than a single block
of characters.<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">x=y*2 bold {alpha + gamma}
</FONT></PRE>
<P>To change the size of characters, use the <TT>size</TT> keyword:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">size 16 {alpha + beta}
</FONT></PRE>
<P>This sets the enclosed text in 16 point size. Incremental changes are acceptable.</P>
<P>To affect the entire equation, you can use the <TT>gsize</TT> (global size) and
<TT>gfont</TT> (global font) commands at the start of the <TT>geqn</TT> block:<FONT
COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">.EQ
gsize 14
gfont H
....
</FONT></PRE>
<P>This makes it easy to format the equations however you wish.
<H4 ALIGN="CENTER"><A NAME="Heading14<FONT COLOR="#000077">Using geqn</FONT></H4>
<P>As you have seen, <TT>geqn</TT> is quite friendly and easy to use, especially
if you are used to writing out equations longhand. You should play around with the
system and learn the different features. There are more commands available within
<TT>geqn</TT>, but the main ones have been shown to you. For more information, check
the man pages or a good <TT>troff</TT> book that includes <TT>eqn</TT>.
<H3 ALIGN="CENTER"><A NAME="Heading15<FONT COLOR="#000077">gtbl</FONT></H3>
<P>The <TT>gtbl</TT> routine is designed to help in the preparation of charts, multicolumn
lists, and any other material presented in a tabular format. The <TT>gtbl</TT> commands
are not difficult to work with, but can be awkward to learn, so studying examples
is the best method.</P>
<P>To use <TT>gtbl</TT>, two special commands are used to indicate to <TT>groff</TT>
that the area between the two commands is to be processed as <TT>gtbl</TT> instructions.
These two key commands are <TT>.TS</TT> (table start) and <TT>.TE</TT> (table end).
Commands between these two are processed by <TT>gtbl</TT> first, which converts the
<TT>gtbl</TT> commands to <TT>groff</TT> commands; then, the source is passed to
<TT>groff</TT>.</P>
<P>Tables are independent of each other with <TT>gtbl</TT>, meaning that each must
contain all the information for formatting the data within the table and can't rely
on a previous format. Tables contain three types of information: text for the table
itself, options that control the behavior of <TT>gtbl</TT>, and formatting commands
to lay out the table itself. The general format of a <TT>gtbl</TT> source code section
is as follows:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">.TS
options;
format.
data
.TE
</FONT></PRE>
<P>Let's look at the important parts of the <TT>gtbl</TT> layout first, and then
see how they are combined to produce finished tables.
<H4 ALIGN="CENTER"><A NAME="Heading16<FONT COLOR="#000077">Executing gtbl</FONT></H4>
<P>Because <TT>gtbl</TT> is a preprocessor, it is invoked on the source file, and
then the results are passed to <TT>groff</TT>. The simplest way to do this is with
the command<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">gtbl filename | groff
</FONT></PRE>
<P>in which the <TT>gtbl</TT> preprocessor runs against the source in filename and
then sends the output to <TT>groff</TT>. If you are processing more than one file
at a time, or you need to send the output of <TT>gtbl</TT> to another preprocessor,
such as <TT>geqn</TT>, you use piping slightly differently. The command<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">gtbl filename | geqn | groff
</FONT></PRE>
<P>sends the output to <TT>geqn</TT> and then to <TT>groff</TT>.
<H4 ALIGN="CENTER"><A NAME="Heading17<FONT COLOR="#000077">Options</FONT></H4>
<P>There can be a single line of options after a <TT>.TS</TT> command that affects
the entire table. Any options must follow the <TT>.TS</TT> command. If more than
one option is specified, they must be separated by spaces, commas, or tabs, and terminate
in a semicolon. <TT>gtbl</TT> accepts the following options:
<TABLE BORDER="0">
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="143" ALIGN="LEFT"><TT>center</TT> </TD>
<TD ALIGN="LEFT">Centers the table (default is left-justified). </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="143" ALIGN="LEFT"><TT>expand</TT> </TD>
<TD ALIGN="LEFT">Makes tables as wide as current line length. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="143" ALIGN="LEFT"><TT>box</TT> </TD>
<TD ALIGN="LEFT">Encloses the table in a box. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="143" ALIGN="LEFT"><TT>allbox</TT> </TD>
<TD ALIGN="LEFT">Encloses each element of the table in a box. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="143" ALIGN="LEFT"><TT>doublebox</TT> </TD>
<TD ALIGN="LEFT">Encloses the table in two boxes. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="143" ALIGN="LEFT"><TT>tab (</TT>n<TT>)</TT> </TD>
<TD ALIGN="LEFT">Uses n instead of a tab to separate data. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="143" ALIGN="LEFT"><TT>linesize (</TT>n<TT>)</TT> </TD>
<TD ALIGN="LEFT">Uses point size n for lines or rules. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="143" ALIGN="LEFT"><TT>delim (</TT>mn<TT>)<BR>
</TT></TD>
<TD ALIGN="LEFT">Uses m and n as equation delimiters.<BR>
</TD>
</TR>
</TABLE>
When <TT>gtbl</TT> tries to lay out a table, it tries to keep the entire table on
one page if possible, even if it has to eject the previous page only partially completed.
This can sometimes cause problems because <TT>gtbl</TT> can make mistakes estimating
the size of the table prior to generating it, especially if there are embedded line
commands that affect spacing or point size. To avoid this problem, some users surround
the entire table with the display macros <TT>.DS</TT> (display start) and <TT>.DE</TT>
(display end). You can ignore this for most tables, unless you start embedding commands
within the data.
<CENTER>
<H4><A NAME="Heading18<FONT COLOR="#000077">Format</FONT></H4>
</CENTER>
<P>The format section of the table structure indicates how the columns are to be
laid out. Each line in the format section corresponds to one line of data in the
finished table. If not enough format lines are specified to match all the lines of
data, the last format line specified is used for the remainder of the table. This
lets you use a specific format for headers and a single format line for the rest
of the table. The format section ends with a period.</P>
<P>Each line in the format section contains a keyletter for each column in the table.
Keyletters should be separated by spaces or tabs for each column to enhance readability.
Keyletters are case-independent (so you can use upper- or lowercase for the keyletters,
or a mixture of the two, without affecting the layout). Supported <TT>gtbl</TT> keyletters
are as follows:
<TABLE BORDER="0">
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="105" ALIGN="LEFT"><TT>l</TT> </TD>
<TD ALIGN="LEFT">Left-justified entry </TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -