⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch18.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 3 页
字号:


<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->






 











 

















<center><H1>geqn and gtbl</H1></center>







<UL>



	<LI><A HREF="#Heading1">- 18 -</A>



	<UL>



		<LI><A HREF="#Heading2">geqn and gtbl</A>



		<UL>



			<LI><A HREF="#Heading3">geqn</A>



			<UL>



				<LI><A HREF="#Heading4">Executing geqn</A>



				<LI><A HREF="#Heading5">Equations</A>



				<LI><A HREF="#Heading6">Subscripts and Superscripts</A>



				<LI><A HREF="#Heading7">Fractions</A>



				<LI><A HREF="#Heading8">Square Roots</A>



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



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



				<LI><A HREF="#Heading11">Matrices</A>



				<LI><A HREF="#Heading12">Quoted Text</A>



				<LI><A HREF="#Heading13">Character Changes</A>



				<LI><A HREF="#Heading14">Using geqn</A>



			</UL>



			<LI><A HREF="#Heading15">gtbl</A>



			<UL>



				<LI><A HREF="#Heading16">Executing gtbl</A>



				<LI><A HREF="#Heading17">Options</A>



				<LI><A HREF="#Heading18">Format</A>



				<LI><A HREF="#Heading19">Data</A>



				<LI><A HREF="#Heading20">Examples</A>



			</UL>



			<LI><A HREF="#Heading21">Summary</A>



		</UL>



	</UL>



</UL>







<P>



<HR SIZE="4">







<H2 ALIGN="CENTER"><A NAME="Heading1<FONT COLOR="#000077">- 18 -</FONT></H2>



<H2 ALIGN="CENTER"><A NAME="Heading2<FONT COLOR="#000077">geqn and gtbl</FONT></H2>



<P><I>by Tim Parker</I></P>







<P>IN THIS CHAPTER</P>







<UL>



	<LI>geqn 



	<P>



	<LI>gtbl 



</UL>







<P>Now that you are comfortable with <TT>groff</TT>, you can look at two useful add-ons



for <TT>groff</TT>: <TT>geqn</TT> and <TT>gtbl</TT>. In this chapter, you learn the



following:







<UL>



	<LI>What are <TT>geqn</TT> and <TT>gtbl</TT>?



	<P>



	<LI>How to create complex equations easily



	<P>



	<LI>How to format tables for <TT>groff</TT> documents



</UL>







<P>In the last chapter, you saw how <TT>groff</TT> can be used to produce formatted



documents to both screen and printer. Unfortunately, <TT>groff</TT> 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.</P>



<P>The utilities <TT>gtbl</TT> and <TT>geqn</TT> are preprocessors, which means that



you write the source code as usual, but then the <TT>gtbl</TT> and <TT>geqn</TT>



programs scan through and replace their specific commands with <TT>groff</TT> commands.



Except for the specific commands changed, no other changes to the text or <TT>groff</TT>



commands are performed.



<H3 ALIGN="CENTER"><A NAME="Heading3<FONT COLOR="#000077">geqn</FONT></H3>



<P>The <TT>geqn</TT> preprocessor is designed for formatting complex equations and



printing special symbols. You need only use <TT>geqn</TT> if you are using <TT>groff</TT>



to create a document with these kinds of characters embedded within them.</P>



<P>Although <TT>groff</TT> 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, <TT>geqn</TT> is quite easy to work with. Most aspects of <TT>geqn</TT>



are designed to look like equivalent English commands or words.</P>



<P>You can quickly move through a set of the important parts of <TT>geqn</TT>. As



you will see, it is remarkably easy to work with.



<H4 ALIGN="CENTER"><A NAME="Heading4<FONT COLOR="#000077">Executing geqn</FONT></H4>



<P>The <TT>geqn</TT> preprocessor is invoked before the <TT>groff</TT> formatter.



Usually, this is accomplished with a simple pipe command:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">geqn filename | groff



</FONT></PRE>



<P>This processes filename through <TT>geqn</TT>, which converts <TT>geqn</TT> commands



to equivalent <TT>groff</TT> commands and then sends the result to <TT>groff</TT>



for processing.</P>



<P>The command<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">geqn file1 file2 file3 | groff



</FONT></PRE>



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



<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. Or if you are running X Window,



you can have <TT>groff</TT> output Postscript and view it on-screen with Ghostscript.



<H4 ALIGN="CENTER"><A NAME="Heading5<FONT COLOR="#000077">Equations</FONT></H4>



<P>You must tell <TT>geqn</TT> where equations begin and end by using the commands



<TT>.EQ</TT> (equation start) and <TT>.EN</TT> (equation end). Within the two commands,



anything typed is treated as an equation. For example, the command<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">.EQ



b=c*(d+x)



.EN



</FONT></PRE>



<P>is formatted to the equation<FONT COLOR="#0066FF"></FONT>



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



</FONT></PRE>



<P>If you try that line without the equation indicators, feeding it straight to <TT>groff</TT>,



you don't receive the same output because <TT>groff</TT> can't interpret the characters



properly.</P>



<P>You can number equations, as is often required in technical documents, by placing



a number after the <TT>.EQ</TT> command. For example, the command<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">.EQ 15



b=c*(d+x)



.EN



</FONT></PRE>



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



<H4 ALIGN="CENTER"><A NAME="Heading6<FONT COLOR="#000077">Subscripts and Superscripts</FONT></H4>



<P>To place superscripts and subscripts in an equation, use the commands <TT>sup</TT>



and <TT>sub</TT>. The words <TT>sup</TT> and <TT>sub</TT> must be surrounded by spaces.



For example, the command<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">E=mc sup 2



</FONT></PRE>



<P>produces Einstein's most famous equation.</P>



<P>To indicate the end of a subscript or superscript and continue with normal characters,



use a space or a tilde (<TT>~</TT>) character. For example, the command<FONT COLOR="#0066FF"></FONT>



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



</FONT></PRE>



<P>gives you the finished output<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">x=(z2)+1



</FONT></PRE>



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



COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">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:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">x=(z2)+1



</FONT></PRE>



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



the formats:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">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:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">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:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">w sup {x alpha y}



</FONT></PRE>



<P>This shows that the Greek letters are also available, as they are within <TT>groff</TT>.



You can have braces within braces, as well:<FONT COLOR="#0066FF"></FONT>



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



</FONT></PRE>



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



<H4 ALIGN="CENTER"><A NAME="Heading7<FONT COLOR="#000077">Fractions</FONT></H4>



<P>To create a proper-looking fraction, use the keyword <TT>over</TT>. The <TT>geqn</TT>



preprocessor automatically adjusts the length of the line separating the parts. For



example, the command<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">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.</P>



<P>You can, of course, combine all the other elements of <TT>geqn</TT> to create



more complex-looking equations:<FONT COLOR="#0066FF"></FONT>



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



</FONT></PRE>



<P>When you are combining <TT>sup</TT> and <TT>sub</TT> with <TT>over</TT>, <TT>geqn</TT>



processes <TT>sup</TT> and <TT>sub</TT> first, and then it does <TT>over</TT>, much



as you would when writing the equation.



<H4 ALIGN="CENTER"><A NAME="Heading8<FONT COLOR="#000077">Square Roots</FONT></H4>



<P>To draw a square root symbol, use the keyword <TT>sqrt</TT>, and <TT>geqn</TT>



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.</P>



<P>You can use <TT>sqrt</TT> quite easily. For example, the command<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">sqrt a+c - 1 over sqrt {alpha + beta}



</FONT></PRE>



<P>has the first square root sign over <TT>a+c</TT>, and the second over the part



in braces.



<H4 ALIGN="CENTER"><A NAME="Heading9<FONT COLOR="#000077">Summations, Set Theory,



and Integrals</FONT></H4>



<P>To produce a summation, use the keyword <TT>sum</TT> and the keywords <TT>from</TT>



and <TT>to</TT> to show the upper and lower parts of the command. For example, use



the command<FONT COLOR="#0066FF"></FONT>

⌨️ 快捷键说明

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