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

📄 323-325.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:groff</TITLE>

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

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=17//-->

<!--PAGES=323-325//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="319-322.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="326-330.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">Fonts</FONT></H4>

<P>Changing fonts requires the command <TT>.ft</TT> (font type). In the early days of <TT>troff</TT>, only four fonts were supported: Roman, Roman bold, Roman italic, and a set of special characters. Other fonts had to be specially loaded in the phototypesetter. For this reason, <TT>groff</TT> defaults to Roman.</P>

<P>To switch to Roman bold, use the command <TT>.ft B</TT>, while <TT>.ft I</TT> switches, not surprisingly, to Roman italic. To return to the normal Roman font, the command <TT>.ft R</TT> is used, although on most systems, <TT>.ft</TT> by itself will suffice:</P>

<!-- CODE SNIP //-->

<PRE>

This is in normal Roman font.

.ft B

This is bold.

.ft I

This is italic.

.ft

This is back to normal Roman font.

</PRE>

<!-- END CODE SNIP //-->

<P>You can switch fonts with a line-embedded command, too, using <TT>\f</TT> followed by either <TT>I</TT> or <TT>B</TT>, switching back to the normal font with <TT>R</TT>:</P>

<!-- CODE SNIP //-->

<PRE>

This is normal, \fBbold\fR and \fIitalics\fR.

</PRE>

<!-- END CODE SNIP //-->

<P>Since underline wasn&#146;t supported on most system printers, underlined text was converted to italic. The underline command <TT>.ux</TT> would italicize the next <I>x</I> lines of text.</P>

<P>Because we now have many more fonts to work with than Roman, we must be able to change fonts within <TT>groff</TT>. The command to change fonts is <TT>.fp</TT> (font physically mounted), which also requires a number to indicate the position the font was mounted in the phototypesetter (old stuff, isn&#146;t it?). For example, if Helvetica was mounted in font position three and we referred to it by the font letter <TT>H</TT>, the command</P>

<!-- CODE SNIP //-->

<PRE>

.fp 3 H

</PRE>

<!-- END CODE SNIP //-->

<P>would instruct the phototypesetter to switch to Helvetica in font position three. <TT>groff</TT> still retains these old-style commands.</P>

<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Indenting and Line Length</FONT></H4>

<P>The line length is set to default to 6.5 inches within <TT>groff</TT>. To override this value, the <TT>.ll</TT> (line length) command is used with an argument indicating the units. For example, the command</P>

<!-- CODE SNIP //-->

<PRE>

.ll 7i

</PRE>

<!-- END CODE SNIP //-->

<P>switches <TT>groff</TT> to use a seven-inch line length. The maximum length accepted is usually about 7.5 inches, so to use wider paper than that you have to move the left margin over to compensate with the <TT>.po</TT> (page offset) command. The value <TT>.po 0</TT> sets the left margin as far over as possible.</P>

<P>To indent text, you use the <TT>.in</TT> (indent) command. It takes a number and an indicator of the units as arguments, as the following example shows:</P>

<!-- CODE SNIP //-->

<PRE>

This is normal stuff.

.in 0.75I

This is indented three-quarters of an inch.

</PRE>

<!-- END CODE SNIP //-->

<P>To move the right margin to the left so that you can make a distinctive block of text within a normal chunk, use the <TT>.ll</TT> (line length) command shown earlier:</P>

<!-- CODE //-->

<PRE>

This is normal text, and goes on and on.

Even more text that continues the transition.

.in 1i

.ll -1i

This is now indented one inch to the left, and the

right margin is indented one inch from the normal right

margin. This makes the text stand out a little.

.in -1i

.ll &#43;1i

And this is back to normal. The block will stand out nicely

amongst all this normal text.

</PRE>

<!-- END CODE //-->

<P>Notice that in this example relative movements of plus and minus a value are used to make it easier. This way, we don&#146;t have to measure the page. To revert to original values, use the commands <TT>.in</TT> and <TT>.ll</TT> with no arguments, as well.</P>

<P>An indent and line-length change is effective until the next command changes it. Sometimes you want to affect only a single line, though. If you want to indent only a single line, use the <TT>.ti</TT> (temporary indent) command:</P>

<!-- CODE SNIP //-->

<PRE>

This is really fine stuff. You can tell, &#146;cause I&#146;m

still awake.

.ti 3i

This line is temporarily indented by three inches, but the

next line will be back to normal.

</PRE>

<!-- END CODE SNIP //-->

<P>Tabs are used to set column output. Usually, tabs are used with <TT>groff</TT> only for unfilled text, which is material that displays in columns. Tab stops are set, by default, every half inch. To override these values, use the <TT>.ta</TT> (tab) command. The command</P>

<!-- CODE SNIP //-->

<PRE>

.ta 1i 2i 3i 4i 5i 6i

</PRE>

<!-- END CODE SNIP //-->

<P>sets the tabs at every inch instead. You can think of the setting of tabs within <TT>groff</TT> much as they are done on a typewriter, from left to right. Tabs are usually set for columns of numbers or tables, but the <TT>groff</TT> macro <TT>gtbl</TT> is much better at this. (You get a look at <TT>gtbl</TT> in the next chapter.)</P>

<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">Other Character Controls</FONT></H4>

<P>The <TT>groff</TT> system has special instructions for controlling the size of individual letters, as well as formulas and special characters such as Greek letters. However, because it is unlikely <TT>groff</TT> is used for this type of output these days, we&#146;ll ignore those capabilities. If you want more information on how to provide these special features, check the <TT>groff</TT> man pages or consult a good <TT>troff</TT> book.</P>

<H3><A NAME="Heading8"></A><FONT COLOR="#000077">Macros</FONT></H3>

<P>A <I>macro</I> is a shorthand notation for a set of commands or strings. Many commands used to write man pages are macros. To give a practical example of a <TT>groff</TT> macro, suppose we want every paragraph to start with a blank line and a temporary indent of half an inch. The <TT>groff</TT> commands to do this are</P>

<!-- CODE SNIP //-->

<PRE>

.sp

.ti &#43;.5i

</PRE>

<!-- END CODE SNIP //-->

<P>Instead of typing these two lines every paragraph, we can define a macro of one character (or more) that does it for us.

</P>

<P>To define the macro, we use the <TT>.de</TT> (define) command followed by the name of the macro and the commands. It looks like this, placed somewhere at the top of the source code:</P>

<!-- CODE SNIP //-->

<PRE>

.de PP

.sp

.ti &#43;.5I

..

</PRE>

<!-- END CODE SNIP //-->

<P>The last line with two periods indicates the end of the definition. Now, whenever we use the command <TT>.PP</TT>, it will be executed as the lines in the macro.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>Note:&nbsp;&nbsp;</B><BR>Make sure that you don&#146;t define a macro with the name of a reserved <TT>groff</TT> command, or the macro will not be executed.

<HR></FONT>

</BLOCKQUOTE>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="319-322.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="326-330.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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