rhl18.htm

来自「linux的初学电子书」· HTM 代码 · 共 1,395 行 · 第 1/3 页

HTM
1,395
字号
<HTML>

<HEAD>

<TITLE>Red Hat Linux Unleashed rhl18.htm </TITLE>

<LINK REL="ToC" HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm">

<LINK REL="Index" HREF="htindex.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/htindex.htm">

<LINK REL="Next" HREF="rhl19.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl19.htm">

<LINK REL="Previous" HREF="rhl17.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl17.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">

<A NAME="I0"></A>

<H2>Red Hat Linux Unleashed rhl18.htm</H2>

<P ALIGN=LEFT>

<A HREF="rhl17.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl17.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="rhl19.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl19.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E124" >geqn</A>

<UL>

<LI>

<A HREF="#E69E242" >Executing geqn</A>

<LI>

<A HREF="#E69E243" >Equations</A>

<LI>

<A HREF="#E69E244" >Subscripts and Superscripts</A>

<LI>

<A HREF="#E69E245" >Fractions</A>

<LI>

<A HREF="#E69E246" >Square Roots</A>

<LI>

<A HREF="#E69E247" >Summations, Set Theory, and Integrals</A>

<LI>

<A HREF="#E69E248" >Brackets, Bars, and Piles</A>

<LI>

<A HREF="#E69E249" >Matrices</A>

<LI>

<A HREF="#E69E250" >Quoted Text</A>

<LI>

<A HREF="#E69E251" >Character Changes</A>

<LI>

<A HREF="#E69E252" >Using geqn</A></UL>

<LI>

<A HREF="#E68E125" >gtbl</A>

<UL>

<LI>

<A HREF="#E69E253" >Executing gtbl</A>

<LI>

<A HREF="#E69E254" >Options</A>

<LI>

<A HREF="#E69E255" >Format</A>

<LI>

<A HREF="#E69E256" >Data</A>

<LI>

<A HREF="#E69E257" >Examples</A></UL>

<LI>

<A HREF="#E68E126" >Summary</A></UL></UL></UL>

<HR ALIGN=CENTER>

<A NAME="E66E18"></A>

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>18</B></FONT></CENTER></H1>

<BR>

<A NAME="E67E18"></A>

<H2 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>geqn</B><B> and </B><B>gtbl</B></FONT></CENTER></H2>

<BR>

<P>Now that you are comfortable with groff, you can look at two useful add-ons for groff: geqn and gtbl. In this chapter, you learn the following:

<BR>

<UL>

<LI>What are geqn and gtbl?

<BR>

<BR>

<LI>How to create complex equations easily

<BR>

<BR>

<LI>How to format tables for groff documents

<BR>

<BR>

</UL>

<P>In the last chapter, you saw how groff can be used to produce formatted documents to both screen and printer. Unfortunately, groff is not the easiest package to work with for complex problems such as tables and equations, so a set of macros for these 
tasks was developed.

<BR>

<P>The utilities gtbl and geqn are preprocessors, which means that you write the source code as usual, but then the gtbl and geqn programs scan through and replace their specific commands with groff commands. Except for the specific commands changed, no 
other changes to the text or groff commands are performed.

<BR>

<BR>

<A NAME="E68E124"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>geqn</B></FONT></CENTER></H3>

<BR>

<P>The geqn preprocessor is designed for formatting complex equations and printing special symbols. You need only use geqn if you are using groff to create a document with these kinds of characters embedded within them.

<BR>

<P>Although groff has enough power to provide simple equations, it is not particularly friendly, or powerful enough for more than single-line material. On the other hand, geqn is quite easy to work with. Most aspects of geqn are designed to look like 
equivalent English commands or words.

<BR>

<P>You can quickly move through a set of the important parts of geqn. As you will see, it is remarkably easy to work with.

<BR>

<BR>

<A NAME="E69E242"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Executing </B><B>geqn</B></FONT></CENTER></H4>

<BR>

<P>The geqn preprocessor is invoked before the groff formatter. Usually, this is accomplished with a simple pipe command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">geqn filename | groff</FONT></PRE>

<P>This processes filename through geqn, which converts geqn commands to equivalent groff commands and then sends the result to groff for processing.

<BR>

<P>The command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">geqn file1 file2 file3 | groff</FONT></PRE>

<P>processes three files and sends them all to groff.

<BR>

<P>Remember that many consoles can't display equations properly because they are not bitmapped and don't have the character set available. You may have to output the results to a printer to see any exercises you try.

<BR>

<BR>

<A NAME="E69E243"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Equations</B></FONT></CENTER></H4>

<BR>

<P>You must tell geqn where equations begin and end by using the commands .EQ (equation start) and .EN (equation end). Within the two commands, anything typed is treated as an equation. For example, the command

<BR>

<PRE>

<FONT COLOR="#000080">.EQ

b=c*(d+x)

.EN</FONT></PRE>

<P>is formatted to the equation

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">b=c*(d+x)</FONT></PRE>

<P>If you try that line without the equation indicators, feeding it straight to groff, you don't receive the same output because groff can't interpret the characters properly.

<BR>

<P>You can number equations, as is often required in technical documents, by placing a number after the .EQ command. For example, the command

<BR>

<PRE>

<FONT COLOR="#000080">.EQ 15

b=c*(d+x)

.EN</FONT></PRE>

<P>places the number 15 in the left margin next to the equation.

<BR>

<BR>

<A NAME="E69E244"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Subscripts and Superscripts</B></FONT></CENTER></H4>

<BR>

<P>To place superscripts and subscripts in an equation, use the commands sup and sub. The words sup and sub must be surrounded by spaces. For example, the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">E=mc sup 2</FONT></PRE>

<P>produces Einstein's most famous equation.

<BR>

<P>To indicate the end of a subscript or superscript and continue with normal characters, use a space or a tilde (~) character. For example, the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">x=(z sup 2)+1</FONT></PRE>

<P>gives you the finished output

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">x=(z2)+1</FONT></PRE>

<P>which is probably not what you wanted. Instead, use one of the following commands:

<BR>

<PRE>

<FONT COLOR="#000080">x=(z sup 2 )+1

x=(z sup 2~)+1</FONT></PRE>

<P>In these commands, the space or the tilde indicates the end of the superscript. This gives you the following output:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">x=(z<SUP>2</SUP>)+1</FONT></PRE>

<P>You can subscript subscripts, and superscript superscripts, simply by combining the formats:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">y sub x sub 3</FONT></PRE>

<P>You can also produce both subscript and superscript on the same character using the two commands together:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">x sub y sup 3</FONT></PRE>

<P>Because a space is used to indicate the end of a subscript or superscript, this can cause a problem when you want spaces either as part of the equation, or to separate words to be converted. To get around this problem, use braces to enclose the 
subscript or superscript:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">w sup {x alpha y}</FONT></PRE>

<P>This shows that the Greek letters are also available, as they are within groff. You can have braces within braces, as well:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">omega sub { 2 pi r sup { 2 + rho }}</FONT></PRE>

<P>Try these commands for yourself, and experiment to see the output.

<BR>

<BR>

<A NAME="E69E245"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Fractions</B></FONT></CENTER></H4>

<BR>

<P>To create a proper-looking fraction, use the keyword over. The geqn preprocessor automatically adjusts the length of the line separating the parts. For example, the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">a = 2b over {3c alpha}</FONT></PRE>

<P>produces an equation with a horizontal line separating the two components, just as if you were writing the equation out on paper.

<BR>

<P>You can, of course, combine all the other elements of geqn to create more complex-looking equations:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">{alpha + beta * gamma sup 3} over {3 sub {4 + alpha}}</FONT></PRE>

<P>When you are combining sup and sub with over, geqn processes sup and sub first, and then it does over, much as you would when writing the equation.

<BR>

<BR>

<A NAME="E69E246"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Square Roots</B></FONT></CENTER></H4>

<BR>

<P>To draw a square root symbol, use the keyword sqrt, and geqn ensures that the square root symbol is properly drawn to enclose all parts of the equation that are indicated as belonging to the square root. Very large square root signs that cover a lot of 
material on many lines, for example, do not look particularly good when printed. You should consider using the superscript 0.5 instead.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?