home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula
/
nebula.bin
/
Documents
/
Others
/
viCourse+
/
WriteAbook.txt
< prev
Wrap
Text File
|
1993-01-25
|
14KB
|
465 lines
Table of Contents
1. What is Unix? ............................................. 1
2. Writing A Book ............................................ 3
3. Format And Commands For Writing A Book .................... 5
4. What To Do After The Writing .............................. 7
i
HOW TO WRITE A BOOK IN UNIX
Adrian Carter
Copyright 1992 by Adrian Carter
Put in the public domain.
1.
What is Unix?
Unix is an operating system that was developed at Bell Labs
in the 70's. An operating system is what makes a computer
useful. It runs programs, it tells programs what section of
memory they can use, it allocates time for each program run, it
allows you to use disks to store programs. In Dos a program
uses all the memory and all the time. This only allows one
program to run at a time. In Unix a program has it's own memory
and it's own slice of time to run. This means that unlike Dos
Unix can run more programs at the same time.
With Unix on your computer you can read into your documents
from your database like this with out having to exit your pro-
gram at all. And with Unix there is usually 3 ways or more to
do anything.
225 Dorthy Smith Smith (555)555-5555
227 Mr.& Mrs. Dorsey P. Smith (555)555-5555
228 Mr.& Mrs. Warren Smith (555)555-5555
229 Mrs. Claude Smith (555)555-5555
230 Ms. Carla Smith (555)555-5555
232 Al & Elane Smith (555)555-5555
233 Fred & Bessie Smith (555)555-5555
234 Paul & Sandy Smith (555)555-5555
Because Unix is a file system with only a few compiled
programs this allows you to read any file you have permission
to. You may use any part of any file in any document you are
working on. This is if you have permission. Therefore when
your boss wants a report it is usually easy to get it for
him/her simply using what is available. No other system that
will run on a PC is as good. There are many flavors of Unix but
1
they all work the same.
In Dos if you are writing a book you can use any editor or
word processing program to write with. Some have spell checkers
built in. In Unix spell is a shell file (like a bat file in
Dos) in newer versions spell is a "c" program it uses a dic-
tionary file that is a straight ascii file that can be updated
with any editor. This means that the editor program does not
have to be humongous therefore your disk can hold more.
In Dos each program you use is like a black box ie. you
must learn a lot of new commands for the program to be of use.
Even in windows each program has different commands. In Unix
there are over 150 small programs to learn as needed. After you
learn these then you can do anything you want. You will have
programs to sort your data, to remove duplicates, to change from
lower to upper case, to do math on rows or columns, to print
what you to printer or typesetter, to format what you write in
any way possible .ie book, manuscript, term paper ect.
To write a book in Unix you need an editor. Vi comes with
it or you can purchase WordPerfect or any other editor you want.
To check your spelling Unix already has spell to find the errors
and sed to make the corrections. After you finish writing you
need to print what you have done. Unix has roff, nroff, troff,
Tex ect. In Dos your editor has most of this built in therefore
it is a much larger program. In Unix with so many small programs
your editor is smaller because the other programs do the work.
This lets your editor be an editor not a spelling checker. Also
being smaller means that these programs run faster.
2.
Writing A Book
In this book we will be using Vi as it is very good and
comes with the system. Many people say that Vi is too hard to
use and they like using other editors like Emacs. If you take
the time to learn Vi you will be able to work on ANY system
using Unix as Vi is on all. The book will be written and for-
matted for nroff. Spelling will be checked with spell.
The first thing in a book is to set up the formatting ie.
line width which is defaulted to 6.5 inches, hyphenation, line
spacing defaulted to single space, page numbers top or bottom,
title on every page or just the first.
A good start is:
.ad
.hy 1
.HM 15 80-15
.ls 2
.fi
The .ad starts adjusting the lines in the book to jus-
tification for a straight right margin line. The .hy 1 allows
for hyphenation. .HM 15 80-15 sets line length to 50 and that in
the center of the page. .ls 2 sets line spacing to 2 and .fi
fills the line.
The title is the next command to put in a book .TL this
centers the title and bold or double strikes the title. This is
followed by .AU for the author which centers and bolds the
authors name.
Each of these commands must start a line and have no effect
on number of lines.
3
.ad
.hy 1
.fi
.FO "/ /- % -/ /"
.TL
HOW TO WRITE A BOOK IN UNIX
.AU
Adrian Carter
.ce
Copyright 1992 by Adrian Carter
.sp 5
.CH 1 "What is Unix?" 1
.PP
This is how this book starts. The .FO sets the page number
to the bottom of the page and centered. The .ce centers the next
line and by putting a number after it like .ce 5 centers the
next 5 lines. The .sp 5 puts 5 lines after the copyright and
.PP starts a new paragraph.
With this out of the way we can now start writing the book.
Following is the chapter title and first paragraph of this book.
.CH 1 "What is Unix?" 1
.PP
Unix is an operating system that was developed at Bell Labs
in the 70's. An operating system is what makes a computer
useful. It runs programs, it tells programs what section
of memory they can use, it allocates time for each program
run, it allows you to use disks to store programs. In Dos
a program uses all the memory and all the time. This only
allows one program to run at a time. In Unix a program has
it's own memory and it's own slice of time to run. This
means that unlike Dos Unix can run more programs at the
same time.
.PP
As you can see each paragraph is a solid bunch of words
with no formatting except wordwrap. Which we will discus later.
This means that when your formatting is set up your creativity
is all that is left. At this point you need to know how to exit
from the program. In Vi you hit <esc> then [:x] <return>. The
<esc> puts you in command mode. The [:x] <return> saves your
work and leaves the program. This pre writing formatting is the
same as finding paper making sure the pencil is sharp ect. we
used to do before computers. This also takes about as much
time. Of course you need to save your formatting to disk for
latter use. One for each type of writing you do.
Computers have made it very easy for us by saving to disk
everything we need to work effectively. We store formats for
manuscripts (that is the one for this book) a different one for
term papers (they need real footnotes not page number footnotes)
and a different one for tech. manuals. Each type of document
has different formatting but uses a lot of the same internal
commands ie. .PP .TL .CH .LP .QP.
3.
Format And Commands For Writing A Book
Format for a book with page numbers at the bottom center.
Line spacing 2. Line length 5 inches. Hyphenation on.
Justification and line fill on.
.ad
.hy 1
.HM 15 80-15
.ls 2
.fi
After setting up your format the next step is your title (.TL
HOW TO WRITE A BOOK IN UNIX) command. This puts the title in
the center of the page and makes it bold.
The next command is (.AU Adrian Carter) the author command.
This puts the authors name center under the title and makes it
bold.
The Chapter command is (.CH 1 "What is Unix?" 1) for the
first use and (.CH 1 "Format And Commands For Writing A Book")
for the rest. If you want to change chapter numbers adding a
number after the last parenthesis resets the counter to that
number. Useful if your boss wants another chapter and you have
erased the original.
Put it all together and you have:
.ad
.hy 1
.fi
.FO "/ /- % -/ /"
.TL
HOW TO WRITE A BOOK IN UNIX
.AU
Adrian Carter
.ce
Copyright 1992 by Adrian Carter
.sp 5
.CH 1 "What is Unix?" 1
.PP
By using .PP .QP .LP you can write a book with everything
except Table of Contents, Index, Footnotes, and endnotes.
For Table of Contents add the following to the end of your
document.
5
.rn _c Tc
.CH 0 "Table of Contents" -1
.Tc
This puts the Table of Contents at the back of the book so after
printing it is moved to the front. This formats the Table of
Contents to fill the page no matter what line length you use.
This format is the most general for use. To change it for
scholarly papers all you need add is .AB for abstract, .NH for
number headings, .SH .SS for section and sub headings, .NX for
index, .FS .FE for footnotes, and .HE for heading. Also .FO
tells where to put the footnotes whereas .FS .FE delineates the
footnote.
For manuals you would use the same as the scholarly. For
fiction you would use the general format.
4.
What To Do After The Writing
After saving your work comes spell checking ie. [spell * ]
>tmp. Then you edit the list of misspelled words in tmp to
remove those that are right. Then look up the correct spelling
and put it beside the incorrect spelling with a / separating.
Then put / in front and at back. I should look like this
/bad/good/. Add an 's in front and a g' in back so that each
bad word looks like this 's/bad/good/g'.
At this point you are ready to correct every misspelled
word in the document. Give this command sed -f tmp doc >doc1.
Now doc1 has no misspellings.
After spell checking and grammar checking then comes the
printing. This can be to printer, to disk, to screen, to
typesetter, or a filter to TeX for typesetting on a postscript
printer.
We have setup our document as an nroff -ms document.
Therefore our next command is nroff -ms doc1. This will print
to screen. Nroff -ms doc1 |lp will print to printer. Nroff -ms
doc1 >file name will print to file. This is used when we don't
want to print now but we don't want to waste time when it is
time to print. Nroff -ms doc1 |filter >file name will put doc1
through a filter and set it up for LaTeX, TeX ect.
A BOom,youyouyyouy, to f, to f,
title