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

📄 unx21.htm

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

<P>Another method to grab a block of vertical space is the .sv request. It takes the same arguments as .sp but has some different behaviors. You cannot request space at the top of a page with .sp, for example. Also, if a space request exceeds the size of 
the page, it is truncated at the bottom of the page with .sp. With .sv, the space is not generated unless there is room on the page for the space. In this case, the space requested is remembered and can be released on a new page with .os. Normally, .os 
appears only in complicated macro definitions, which are discussed later.

<BR></P>

<P>For the sample letter, save a half inch of space at the top of the page. The source is Listing 21.5, and the output is Figure 21.10.

<BR></P>

<P>

<BR><B><A HREF="21unx10.gif">Figure 21.10. </B><B><I>troff</I></B><B> output with requested space </B><B>using .sv.</A></B>

<BR></P>

<UL>

<LH><B>Listing 21.5. </B><B>troff</B><B> source using .sv.</B></LH></UL>

<PRE>.sv 0.5i

.nf

101 Main Street

Morristown, NJ  07960

15 March, 1994

.sp 1i

Dear Sir,

.fi

I just wanted to drop you a note to thank you for spending the

time to give me a tour of your facilities. I found the experience

both educational and enjoyable. I hope that we can work together

to produce a product we can sell.</PRE>

<P>Two other spacing controls are also available. The request .ns turns off spacing mode, effectively disabling the .sp command. To restore spacing, .rs is used. These commands are more likely to be found in macros.

<BR></P>

<H3 ALIGN="CENTER">

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

<FONT SIZE=4><B>Line Controls</B>

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

<P>So far, I have examined troff requests to fill and adjust lines of text and to move your location on a page. I will now examine how to alter the line itself.

<BR></P>

<P>By default, the length of a line of text is 6.5 inches in nroff, and 7.54 inches in troff. This can be changed with the .ll request. The default space measurement is in ems, but I find using inches a bit easier. Listing 21.6 shows the source, changing 
the line length to 4 inches; its effect on the output is shown in Figure 21.11.

<BR></P>

<P>

<BR><B><A HREF="21unx11.gif">Figure 21.11. </B><B><I>troff</I></B><B> output with line indents and </B><B>lengths.</A></B>

<BR></P>

<P>Lines of text can also be indented, both for a single line and for all text. The .in request indents all lines of text a common distance. This is illustrated by indenting the return address in Listing 21.6. A temporary indent can be requested with .ti, 

such as might lead a paragraph. This is also illustrated in Listing 21.6 and Figure 21.11.

<BR></P>

<UL>

<LH><B>Listing 21.6. </B><B>troff</B><B> source illustrating line indents and lengths.</B></LH></UL>

<PRE>.nf

.ll 4.0i

.in 2.0i

101 Main Street

Morristown, NJ  07960

15 March, 1994

.sp 1i

.in 0

Dear Sir,

.fi

.ti 0.25i

I just wanted to drop you a note to thank you for spending the

time to give me a tour of your facilities. I found the experience

both educational and enjoyable. I hope that we can work together

to produce a product we can sell.</PRE>

<P>Using text indents can help organize a document.

<BR></P>

<H3 ALIGN="CENTER">

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

<FONT SIZE=4><B>Page Control</B>

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

<P>So far, this chapter has examined how to format text independent of the page, but for most documents, page controls are necessary. Both nroff and troff default to an 11-inch page. troff has a one-inch left margin, and nroff has no left margin. Pages 
start at page one and are sequentially numbered. Each of these details can be changed by the document writer.

<BR></P>

<P>The .pl request sets the length of a page; the default space measurement is in vertical spaces. Again, inches can be better used here. For the sample letter, assume a page length of 8 inches. (Some other normal page lengths are 12 inches for A4 paper 
and 14 inches for legal-sized paper. troff can support pages up to 75 inches in length, and nroff up to 136 inches.)

<BR></P>

<P>You can force new pages with the .bp request. An argument can affect the number of pages output. The .ns request, mentioned earlier, disables the .bp request, unless a specific number of pages is requested.

<BR></P>

<P>The .pn request assigns a page number to the next page printed. This does not affect the present page, only subsequent pages. These three requests are illustrated in Listing 21.7 and Figure 21.12, an extended form of the letter.

<BR></P>

<P>

<BR><B><A HREF="21unx17.gif">Figure 21.12. </B><B><I>troff</I></B><B> output with page controls.</A></B>

<BR></P>

<UL>

<LH><B>Listing 21.7. </B><B>troff</B><B> source illustrating page controls.</B></LH></UL>

<PRE>.nf

.ll 5.0i

.pl 8.0i

.in 2.5i

101 Main Street

Morristown, NJ  07960

15 March, 1994

.in 0

.sp 1i

Dear Sir,

.fi

.ti 0.5i

I just wanted to drop you a note to thank you for spending the

time to give me a tour of your facilities. I found the experience

both educational and enjoyable. I hope that we can work together

to produce a product we can sell.

.pn 4

I am sending a copy of our proposal on the next page. I look forward

to hearing from you.

.sp 2

.in 2.5i

Yours,

.sp 0.5i

Joe Smith, President Any Corp.

.bp

.in 0

We propose to build our widget tools with your widget makers.</PRE>

<P>Note that the page number is not printed. Page numbers are printed only if explicitly requested by the programmer. These techniques are discussed later in this chapter in Section 21.19 &quot;Flotsam and Jetsam,&quot; where I discuss page titling.

<BR></P>

<P>The text can be offset on the page using the .po request. This is different from the .in request. .po sets the 0 value for indents and temporary indents. This is illustrated in Figure 21.13, which has a page offset of two inches to the preamble of the 
Constitution.

<BR></P>

<P>

<BR><B><A HREF="21unx13.gif">Figure 21.13. </B><B><I>troff</I></B><B> output with a two-inch page </B><B>offset.</A></B>

<BR></P>

<P>Two very powerful page controls are the .mk and the .rt requests. The .mk request saves the current vertical location in an internal register (which can be specified in the argument). This sets a flag at the current location. The .rt request returns to 

that previous location. One good use for these requests is to establish multiple column output. The programmer can set the mark at the top of the page, and at the bottom of the page return to the mark. This is illustrated in Listing 21.8 and Figure 21.14. 

Note that the simple multiple column approach also requires the use of the .ll and .po requests.

<BR></P>

<P>

<BR><B><A HREF="21unx14.gif">Figure 21.14. </B><B><I>troff</I></B><B> output showing the work of .mk </B><B>and .rt.</A></B>

<BR></P>

<UL>

<LH><B>Listing 21.8. </B><B>troff</B><B> source using </B><B>.mk</B><B> and </B><B>.rt</B><B> requests.</B></LH></UL>

<PRE>.ll 3i

.mk a

.ce

Preamble

.sp

We, the people of the United States, in order

to form a more perfect Union, establish justice, insure

domestic tranquility, provide for the common defense, promote

the general welfare,

and secure the blessing of liberty to ourselves and our posterity do

ordain and establish this Constitution for the United States of

America.

.sp

.ce

Article I

.sp

Section 1  Legislative powers; in whom vested:

.sp

All legislative powers herein granted shall be vested in a

Congress of the United States, which shall consist of a Senate

and a House of Representatives.

.sp

Section 2  House of Representatives, how and by whom chosen,

Qualifications of a Representative. Representatives and direct

taxes, how apportioned. Enumeration. Vacancies to be filled.

Power of choosing officers and of impeachment.

.sp

1. The House of Representatives shall be composed of members

chosen every second year by the people of the several states,

and the electors in each State shall have the qualifications

requisite for electors of the most numerous branch of the

State Legislature.

.sp

2. No person shall be a Representative who shall not have

attained to the age of twenty-five years, and been seven years

a citizen of the United States, and who shall not, when elected,

be an inhabitant of that State in which he shall be chosen.

.sp

.rt

.po 4.5i

3. Representatives and direct taxes shall be apportioned among

the several States which maybe included within this Union,

according to their respective numbers, which shall be determined

by adding to the whole number of free persons, including those

bound for service for a term of years, and excluding Indians not

taxed, three-fifths of all other persons. The actual enumeration

shall be made within three years after the first meeting of the

Congress of the United States, and within every subsequent term

of ten years, in such manner as they shall by law direct. The

number of Representatives shall not exceed one for every thirty

thousand, but each State shall have at least one Representative;

and until such enumeration shall be made, the State of New

Hampshire shall be entitled to choose three, Massachusetts eight,

Rhode Island and Providence Plantations one, Connecticut five,

New York six, New Jersey four, Pennsylvania eight, Delaware one,

Maryland six, Virginia ten, North Carolina five, South Carolina

five, and Georgia three.

.sp

4. When vacancies happen in the representation from any State,

the Executive Authority thereof shall issue writs of election

to fill such vacancies.

.sp

5. The House of Representatives shall choose their Speaker and

other officers; and shall have the sole power of impeachment.</PRE>

<P>The last page control is .ne. This is used to indicate that a certain amount of space is needed before the end of a page. Using this request, you can avoid starting paragraphs at the bottom of a page. Normally, .ne would be included in a macro. If the 
space requested is available, nothing happens. If the space is not available, the end of page processing is triggered.

<BR></P>

<H3 ALIGN="CENTER">

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

<FONT SIZE=4><B>Fonts and Style Controls</B>

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

<P>The previous sections have dealt with the positioning of text on the page and have ignored the actual modification of the text itself. This section handles different fonts and point sizes.

<BR></P>

<P>The standard font is a Times Roman font. Italic, Bold, and Special fonts are also available on all systems. Some sites may also include Helvetica, Bold-Helvetica, Italic-Helvetica, and Constant-Width fonts. Check your local system for which fonts are 
available.

<BR></P>

<P>The request .ft sets the appropriate font. Mounting and unmounting fonts is performed automatically with this request. The requested font must be specified in the argument; if no argument is present, the previous font is restored. The arguments are 
shown in Table 21.2.

<BR></P>

<UL>

<LH><B>Table 21.2. Standard </B><B>troff</B><B> and </B><B>nroff</B><B> fonts.</B>

<BR></LH></UL>

<TABLE BORDER>

<TR>

<TD>

<PRE><I>Identifier</I>

<BR></PRE>

<TD>

<PRE><I>Font</I>

<BR></PRE>

<TR>

<TD>

<P>B</P>

<TD>

<P>Bold</P>

<TR>

<TD>

<P>I</P>

<TD>

<P>Italic</P>

<TR>

<TD>

<P>R</P>

<TD>

<P>Roman</P>

<TR>

<TD>

<P>P</P>

<TD>

<P>Previous</P>

<TR>

<TD>

<P>H</P>

<TD>

<P>Helvetica</P>

<TR>

<TD>

<P>CW</P>

<TD>

<P>Constant Width</P>

<TR>

<TD>

<P>HB</P>

<TD>

<P>Helvetica Bold</P>

<TR>

<TD>

<P>HI</P>

<TD>

<P>Helvetica Italic</P></TABLE>

<P>Fonts have limited meaning in nroff. The font used is a constant-width font. By specifying bold, characters are overstruck in printing. Italic is interpreted as an underline. Other fonts have no meaning.

<BR></P>

<P>By setting fonts, you can italicize the preamble to the Constitution and print each section header in bold. The source is in Listing 21.9, and the output is in Figure 21.15.

<BR></P>

<P>

<BR><B><A HREF="21unx15.gif">Figure 21.15. </B><B><I>troff</I></B><B> output using multiple </B><B>fonts.</A></B>

<BR></P>

<UL>

<LH><B>Listing 21.9. Font selection in </B><B>troff</B><B>.</B></LH></UL>

<PRE>.ce

.ft B

Preamble

.sp

.ft I

We, the people of the United States, in order

to form a more perfect Union, establish justice, insure

domestic tranquility, provide for the common defense, promote

the general welfare,

and secure the blessing of liberty to ourselves and our

posterity do ordain and establish this Constitution for the

United States of America.

.sp

.ce

.ft B

Article I

.sp

.ft R

Section 1  Legislative powers; in whom vested:

.sp

All legislative powers herein granted shall be vested in a

Congress of the United States, which shall consist of a Senate

and a House of Representatives.</PRE>

<P>The .bd request sets an artificial bold capability by offsetting a second printing of the character by a number of points. This can be used to make the italic font appear to be bold, with .bd I 3. There is no effect in nroff.

<BR></P>

<P>Different sizes of text can be created using the .ps request. You can specify either a relative change or an absolute point size. Closely related is the .ss request, which sets the width of the space character. Similarly, when the point size is changed, 

the vertical spacing may also need to be changed, or parts of consecutive lines may overlap. Using these requests, you can increase the size of the section headers in the Constitution and increase the size of the words &quot;We the people.&quot; This is 
illustrated in Listing 21.10 and Figure 21.16.

<BR></P>

<P>

<BR><B><A HREF="21unx16.gif">Figure 21.16. Multiple point sizes in </B><B><I>troff</I></B><B> </B><B>output.</A></B>

<BR></P>

⌨️ 快捷键说明

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