Prev Up Next
Go backward to 4.13 Text processing - HTML
Go up to 4 Labs
Go forward to 4.15 bc - Extended Precision Calculator

4.14 Text processing nroff - manual pages

nroff text processing
CSC137    Louis Taber    October 10, 1999

nroff and troff are used to produce the online
documentation or man pages.  There are several
macro sets that can be used with nroff and troff.
Without them both are difficult to use. You can
think of the macro sets as being analogous to a
style sheet in Microsoft Word.

1.      Use a text editor to produce a file for
        processing with nroff, a text processing
        program.  This document will need to have
        centered text:

                     Like this line.

        And, underlined text like this word.

        Also print out the day, month, and year:
        3/26/96

        Also:

                  Center and underline.

2.      Use the spell-check program to check for
        misspelled words.

3.      Turn in three items: your formatted docu-
        ment, your original source file, and your
        spelling list from spell.
The following example is the input file for the assignment sheet:
.ad l
.ll 50
.nf
nroff text processing
.br
CSC137    Louis Taber    October 10, 1999                      
.fi
.sp
nroff and troff are used to produce the online 
documentation or man pages.  There are several 
macro sets that can be used with nroff and troff.  
Without them both are difficult to use. You can 
think of the macro sets as being analogous to a style 
sheet in Microsoft Word.
.sp
.in .8i
.ti -.8i
1.      Use a text editor to produce a file for 
processing with nroff, a text processing program.  This
document will need to have centered text:
.sp
.ce
Like this line.
.sp
And, underlined text like this
.ul 1
word.
.sp
Also print out the day, month, and year:   
\n(mo/\n(dy/\n(yr 
.sp 
Also: 
.sp
.ce 1
.ul 1
Center and underline.
.sp
.ad l
.ti -.8i
2.      Use the spell-check program to check for misspelled
words.
.sp
.ti -.8i
3.      Turn in three items: your formatted document, your
original source file, and your spelling list from spell.
.ex
Summary information about nroff
  1. Compatibility: Text can also be used with troff.
  2. Macros: Necessary for nroff to be useful. To invoke with standard macro files use options:
     
    -man for manual pages 
    -ms for (Scientific papers - e.g. .AB for Abstract) 
    -me for (Books - e.g. .+c for Begin chapter) 
    
    On gort these load the macro file
    /usr/lib/groff/tmac/tmac.X
    where X is replaces by an, s, or e. (There are additional macro options.)
  3. Various commands:
    FONT CONTROL 
    .bd               bold font 
    .ft font 
     
    CHARACTER SIZE 
    .ps n             point size 
     
    PAGE CONTROL 
    .bp               begin page 
    .pl               set page length 
    .pn               set page number 
    .rt               return - vertical - for columns
     
    TEXT FILLING / ADJUSTING / CENTERING 
    .ad x             (l,r,c,b,n)adjust
    .br               break
    .ce               center 
    .fi               fill 
    .na               no adjust 
    .nf               no fill 
     
    VERTICAL SPACING 
    .ls               line spacing 
    .sp               space 
    <blank line>      break and space
     
    LINE LENGTH and INDENTING
    .in               indent
    .ll               line length 
    .ti               temporary indent
    
  4. PRE-DEFINED Variables:
     
    %                 page number
    dw                day of week (1-7)
    dy                day of month 
    ln                current line
    mo                month 
    yr                year 
    .c                current line from input 
    .f                current font
    .i                current indent
    .j                current adjustment mode 
    .l                line length
    
  5. Using number variables (registers):
    .nr R v [i]       define numeric variable R with 
                      value v with optional increment i
    .af R c           set format to numeric variable 
                      (1,01,i,I,a,A) 
    \nx               use register x 
    \n(xy             use register xy - two letters 
    \n+x              add increment and then use 
    \n-(xy            subtract increment and then use 
    
  6. Using string variables (registers):
    .ds R str         define variable R to contain str 
    .as R str         append str to string variable R 
    \*x               use register x 
    \*(xy             use register xy - two letters 
    \w'string'        width of string
    
  7. COMMENTS:
    \" comment
    
  8. MACROS:
    .de xx            \"begin macro definition 
    Today is \\$1 the \\$2. 
    ..                \"end of macro definition 
    
    Macro usage:
     
    .xx Monday 14th 
    
    Produces:
     
    Today is Monday the 14th.
    

Instructor: ltaber@pima.edu** Red's Home page** The Pima College Site

Prev Up Next