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

📄 unx24.htm

📁 Linux Unix揭密.高质量电子书籍.对学习Linux有大帮助,欢迎下载学习.
💻 HTM
📖 第 1 页 / 共 3 页
字号:

<BR></P>

<PRE>matrix {

lcol { 0 above {x over y} }

rcol { 1 above {x sup 2} }

}</PRE>

<P>This code produces

<BR></P>

<P><B><IMG SRC="24unx12.gif"></B></P>

<P>You could use ccol to center columns. The main advantage of using the matrix keyword, though, is that the elements align themselves horizontally better.

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I15" NAME="I15">

<FONT SIZE=4><B>Defines</B>

<BR></FONT></A></CENTER></H3>

<P>If you use a complex term over and over again, you can define it as something short. A good choice, for example, is &amp;. Then, instead of typing

<BR></P>

<PRE>x= sqrt {SIGMA {x sup 2}} over N</PRE>

<P>you can type

<BR></P>

<PRE>x= &amp;</PRE>

<P>define works like this:

<BR></P>

<PRE>.EQ

define &amp;  'sqrt {SIGMA {x sup 2}} over N'

x = &amp;

.EN</PRE>

<P>You can select any characters you want&#151;fg, xy, and so on&#151;but be sensible. Don't choose ^ or ~. Don't choose your eqn delimiters. And don't choose an eqn keyword, even though it is permitted.

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I16" NAME="I16">

<FONT SIZE=4><B>Precedence</B>

<BR></FONT></A></CENTER></H3>

<P>Without braces to force it to look at terms as groups, eqn recognizes the following orders of precedence:

<BR></P>

<PRE>

<BR>dyad vec under bar tilde hat dot dotdot



<BR>left right



<BR>fwd back down up



<BR>fat roman italic bold size



<BR>sub sup



<BR>sqrt over



<BR>from to</PRE>

<P>All operations group to the right, except for sqrt, left, and right, which group to the left.

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I17" NAME="I17">

<FONT SIZE=4><B>Finishing Touches</B>

<BR></FONT></A></CENTER></H3>

<P>eqn offers several ways for you to beautify your output. You can line up several equations, change fonts and point sizes, and insert vertical and horizontal movement.

<BR></P>

<P>To line up several equations, use mark and lineup. mark, which can be used only once in an equation, marks the horizontal position where lineup aligns the other equations. For example,

<BR></P>

<PRE>.EQ

a mark = b

.EN

.EQ

lineup = b+1

.EN

.EQ

lineup = b+c+1

.EN</PRE>

<P>produces

<BR></P>

<P><B><IMG SRC="24unx13.gif"></B></P>

<P>You can also change fonts and point sizes in an equation. Table 24.5 describes the keywords used.

<BR></P>

<UL>

<LH><B>Table 24.5. Keywords used to change fonts and point sizes.</B>

<BR></LH></UL>

<TABLE BORDER>

<TR>

<TD>

<PRE><I>Keyword</I>

<BR></PRE>

<TD>

<PRE><I>Description</I>

<BR></PRE>

<TR>

<TD>

<P>bold</P>

<TD>

<P>Prints the next character or term in bold type</P>

<TR>

<TD>

<P>fat</P>

<TD>

<P>Prints the next character or term in pseudo-bold, by overstriking</P>

<TR>

<TD>

<P>font <I>f</I></P>

<TD>

<P>Changes to font f any font that troff recognizes (such as R, B, I, CW, and HB)</P>

<TR>

<TD>

<P>italic</P>

<TD>

<P>Prints the next character or term in italic type</P>

<TR>

<TD>

<P>roman</P>

<TD>

<P>Prints the next character or term in roman type</P>

<TR>

<TD>

<P>size <I>n</I></P>

<TD>

<P>Changes to point size n, which can be specified as a number or as a relative quantity (such as size -2 or size +3)</P></TABLE>

<P>There is a gsize option for setting a global point size. Similarly, there is a gfont. You should put these options near the top of your file; otherwise, eqn uses the default point size (usually 10).

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I18" NAME="I18">

<FONT SIZE=4><B>Unconventional Uses for </B><B><I>eqn</I></B>

<BR></FONT></A></CENTER></H3>

<P>You can use eqn to put diacritical marks on foreign words. Just remember that eqn prints words in italics. So you need to specify roman. Consider the following code:

<BR></P>

<PRE>No# roman e dotdot #l Coward

Georg H# roman a dotdot #ndel

malague# roman n tilde #a</PRE>

<P>It produces

<BR></P>

<P><B>No&#235;l Coward<BR>

Georg H&#228;ndel<BR>

malague&#241;a</B></P>

<P>You can also use eqn to produce the service mark symbol if it isn't available as a troff special character. The service mark is like the trademark except that it reads SM. For example,

<BR></P>

<PRE>XYZZY-Box# sup roman SM #</PRE>

<P>produces

<BR></P>

<P><B>XYZZY-Box<SUP>SM</SUP></B></P>

<P>Okay, it's not as neat as XYZZY-BOX\(SM, but it's a whole lot better than XYZZY-Box\v' -3p'\s-3SM\s+3\v' +3p'!

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I19" NAME="I19">

<FONT SIZE=4><B>Troubleshooting</B>

<BR></FONT></A></CENTER></H3>

<P>Sometimes, despite your best efforts, your equations just don't come out right. Here are some suggestions for detecting and correcting faulty code, and for dealing with some of eqn's more arcane characteristics.

<BR></P>

<H4 ALIGN="CENTER">

<CENTER><A ID="I20" NAME="I20">

<FONT SIZE=3><B>Using checkeq</B>

<BR></FONT></A></CENTER></H4>

<P>At its best, eqn is quirky. So, before you print a 50-page chapter containing 70 equations, check your equations. This pinpoints syntax errors such as unmatched delimiters. The checkeq program is a good place to start. Use checkeq like this:

<BR></P>

<PRE>checkeq myeqnfile</PRE>

<P>If checkeq finds no errors, it displays the following:

<BR></P>

<PRE>myeqnfile</PRE>

<P>or

<BR></P>

<PRE>myeqnfile:

     New delims: ##, line 2</PRE>

<P>If you have an odd number of delimiters, you'll see something like this:

<BR></P>

<PRE>myeqnfile:

myeqnfile:

     New delims: ##, line 2

     3 line ##, lines 7-9

     3 line ##, lines 9-11

     3 line ##, lines 11-13

     3 line ##, lines 13-15

     3 line ##, lines 15-17

     Unfinished ##</PRE>

<P>If, for some reason, you've specified bad delimiters (#$, for example, or #), checkeq announces:

<BR></P>

<PRE>myeqnfile

     Strange delims at Line 2</PRE>

<P>or

<BR></P>

<PRE>myeqnfile

     Unfinished</PRE>

<P>checkeq isn't good for much more than this.

<BR></P>

<H4 ALIGN="CENTER">

<CENTER><A ID="I21" NAME="I21">

<FONT SIZE=3><B>Processing to </B><B><I>/dev/null</I></B>

<BR></FONT></A></CENTER></H4>

<P>Because checkeq lets a lot of mistakes slip by, you can also process your equation and send output to /dev/null (so you don't clutter your directory with a lot of troff output).

<BR></P>

<P>To do this:

<BR></P>

<PRE>eqn myeqnfile &gt; /dev/null</PRE>

<P>When errors are found, you see a message like the following:

<BR></P>

<PRE>eqn: syntax error near line 19, file nyeqnfile

    context is

    !a = (x &gt;&gt;&gt; {sup &lt;&lt;&lt;&lt; 2}) + 1!</PRE>

<P>The line number is not guaranteed, but it should be close.

<BR></P>

<P>Again, this is not foolproof because, if eqn can process your code, it will. You'll get no error message, even if your output is garbled or nonexistent.

<BR></P>

<H4 ALIGN="CENTER">

<CENTER><A ID="I22" NAME="I22">

<FONT SIZE=3><B>Additional Suggestions</B>

<BR></FONT></A></CENTER></H4>

<P><B>If you get no output at all:</B>

<BR></P>

<P>If your file contains nothing but an equation, try inserting a line of text before the equation. If you don't want text, use translated tildes:

<BR></P>

<PRE>.tr ~

~ ~ ~

.EQ

x sup 2 + y sup 2 = z sup 2

.EN</PRE>

<P>Oddly enough, this does not seem to affect eqn code&#151;even code with tildes in it.

<BR></P>

<P><B>If the vertical spacing is wrong:</B> Try printing your file with a different macro package&#151;or with no macro package. (If you're using a home-grown package, you may have to pipe your file through eqn before you send it through troff.) Try 
processing the eqn code and replacing the code with the processed code in your file. Try using space 0 as the first line of your eqn code:

<BR></P>

<PRE>.EQ

space 0

code

.

.

.

.EN</PRE>

<P>If you're using the .EQ/.EN macros to delimit your equation, try using delimiters (## or !!)&#151;and, of course, vice versa.

<BR></P>

<P><B>If your equation is garbled:</B> Check for omitted spaces and braces. (Use them, even if you don't really need them.) Count braces and parentheses to make sure you have an even number of each. checkeq&#151;and eqn itself&#151;doesn't always find this 

problem. If your equation contains a sup, make sure you use spaces around its argument, even if there's a brace. Make sure you have keywords in the right order. For example, #x highbar tilde# produces no error message, but it prints the bar right on the 
tilde. (The correct order is #x tilde highbar#.) If your equation is long or complicated, use lots of spaces and newlines to make it easy to read.

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I23" NAME="I23">

<FONT SIZE=4><B><I>eqn</I></B><B> and the Preprocessors</B>

<BR></FONT></A></CENTER></H3>

<P>You can use eqn with any of the other preprocessors (pic, grap, and tbl), but only with delimiters&#151;not with .EQ/.EN macros. Before you do this, however, ask yourself if it's really necessary. You could always get another job, or move to a tiny 
island with no electricity and no telephone lines.

<BR></P>

<P>The sections that follow provide some help if you can't face life without grap.

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I24" NAME="I24">

<FONT SIZE=4><B>eqn and pic</B>

<BR></FONT></A></CENTER></H3>

<P>You cannot use ## as eqn delimiters with pic code. You can use $$ and !! and %%. I wouldn't experiment with anything else.

<BR></P>

<P>Complicated equations inside pic pictures will come out wrong if eqn has to provide extra vertical space&#151;for example, for an integral sign. Use space 0 to (try to) prevent this, as follows:

<BR></P>

<PRE>.EQ

delim !!

.

.

.

pic code &quot;!space 0 eqn code!&quot;</PRE>

<P>You need the quotation marks for pic.

<BR></P>

<P>A simple example of pic and eqn is

<BR></P>

<P><B><IMG SRC="24unx14.gif"></B></P>

<P>The code is as follows:

<BR></P>

<PRE>.EQ

delim !!

.EN

.PS

box ht .75i wid i.5i &quot;!a sup 2 + b sup 2 = c sup 2!&quot;

.PE</PRE>

<H3 ALIGN="CENTER">

<CENTER><A ID="I25" NAME="I25">

<FONT SIZE=4><B>eqn and grap</B>

<BR></FONT></A></CENTER></H3>

<P>Because grap is built on pic, you can expect similar problems if you use eqn with grap. You can use the same delimiters, and you can expect to have to use space 0 to correct vertical spacing problems. eqn tries to override grap's spacing unless you do. 

Do just as you did for pic; here's an example:

<BR></P>

<PRE>.EQ

delim !!

.EN

.G1

label left &quot;!y= sqrt { (2x sup 3 + 1)/3}!&quot;

.G2</PRE>

<P>You must use quotation marks, as with pic.

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I26" NAME="I26">

<FONT SIZE=4><B>eqn and tbl</B>

<BR></FONT></A></CENTER></H3>

<P>There are a few simple rules for using eqn in tables. (tbl is discussed in detail in Chapter 23.)

<BR></P>

<UL>

<LI>If you have equations and tables in your file, run the file through tbl first.

<BR>

<BR></LI>

<LI>Do not use pound signs (##) as delimiters. (I tried it and got several indignant screenfulls of complaints. I'm not sure what the conflict is.)

<BR>

<BR></LI>

<LI>Do not use the same characters for eqn delimiters and tbl tab characters.

<BR>

<BR></LI>

<LI>Avoid using T braces with equations.

<BR>

<BR></LI>

<LI>Don't put an equation in an n-style column. tbl cannot process the equation properly.

<BR>

<BR></LI></UL>

<P>To put an equation in a table, do the following:

<BR></P>

<OL>

<LI>Define your eqn delimiters (use exclamation points).

<BR>

<BR></LI>

<LI>Start your table.

<BR>

<BR></LI>

<LI>Insert your eqn code between exclamations points.

<BR>

<BR></LI></OL>

<P>With me and ms, you can use arguments to the .EQ macro to position your equation horizontally. Both packages accept the following:

<BR></P>

<PRE>.EQ C     \centers the equation

.EQ I     \indents the equation

.EQ L     \left justifies the equation</PRE>

<H3 ALIGN="CENTER">

<CENTER><A ID="I27" NAME="I27">

<FONT SIZE=4><B>Summary</B>

<BR></FONT></A></CENTER></H3>

<P>eqn is a limited use program, but a very useful one. It's easy to learn, easy to use (except for the spaces), and it does an excellent job of setting mathematical expressions.

<BR></P>

<P><A HREF="unx23.htm"><IMG SRC="bluprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index.htm"><IMG SRC="blutoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="unx25.htm"><IMG SRC="blunext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>

<A HREF="index.htm"><IMG SRC="bluprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Home"></A>

</P></BODY></HTML>

⌨️ 快捷键说明

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