[comp.text] new dvidoc.sty

hedrick@porthos.rutgers.edu (Charles Hedrick) (10/08/89)

I've done a bit of work on dvidoc.sty. I've never been clear whether
the goal of dvidoc was to let people preview documents on a CRT or to
produce .doc files.  My goal is to get dvidoc to the point where I can
use it to produce online documentation.  Until recently, I have always
used Scribe for my document preparation.  Most of what I do is
computer documentation.  I feel very strongly about having online
documentation for our users.  I was unwilling to consider LaTeX as
long as it was impossible to produce .doc files.  I think dvidoc is
now good enough to produce reasonably nice-looking .doc files, as long
as you don't try to use anything beyond the simplest mathematics, and
as long as you don't need lines or boxes.  Probably lines and boxes
could be fixed, using --- and |, but I didn't need them so I didn't
try.  I think it would be possible to support a good deal of math as
well, but again, I don't need it.

It should be pretty clear from looking at the file what things have
been fixed.  The original version forced LaTeX to use a fixed width
font almost all the time, and did some adjustment of vertical spacing,
but it didn't fix enough things to let you do any serious documents.

I have also modified dvidoc.c so that it uses mostly integer
arithmetic.  This had a big impact on performace, since I'm using a
PC/AT without a floating point chip (under System V release 2).

I'd appreciate feedback on dvidoc.sty.  This will eventually replace
the original one in the official distribution, but I'd like a few
other people to try it first.  I have it on good authority that it
might be a good idea to remove the \makeatletter and \makeatother, but
I haven't tried it.  I have tried to leave the appearance of the
document as close as possible to what you would normally get from
LaTeX.  In fact for .doc files, I think things probably look better
if you use no indentation and put one blank line between paragraphs,
i.e.
   \parindent 0pt
   \parskip \baselineskip
However I'm reluctant to do that kind of change in dvidoc.  Probably
you should put them in your document source.

% dvidoc style file.  Fixes things up so your file uses only fixed width 
% non-math characters, at least if you don't use math mode 
%
% The first section defines all the font change commands to use the
% doc pseudo-font.  It is taken from John Pavel's dvidoc.sty, March 1987
%
\makeatletter
% version from John Pavel's dvidoc.sty, March 1987
\def\rm{\protect\pdoc}
\def\it{\protect\pdoc}
\def\bf{\protect\pdoc}
\def\sl{\protect\pdoc}
\def\sf{\protect\pdoc}
\def\sc{\protect\pdoc}
\def\tt{\protect\pdoc}
\newfam\docfam
\def\pdoc{\@getfont\pdoc\docfam\@xpt{doc}}
% This gets all normal text, headings, etc.
% Unfortunately it doesn't catch places where more explicit stuff
% is done.  The following is brute force but effective.  Note that
% we leave the symbol fonts alone, since otherwise we'll get TeX
% errors complaining that it couldn't find symbol fonts
% Possibly we should do this for all of the font types.  This caught
% everything in sample.tex.
\font\fivmi = doc
\font\fivrm = doc
\font\fivsy = cmsy10
\font\sixmi = doc
\font\sixrm = doc
\font\sixsy = cmsy10
\font\sevmi = doc
\font\sevrm = doc
\font\sevsy = cmsy10
\font\egtmi = doc
\font\egtrm = doc
\font\egtsy = cmsy10
\font\ninmi = doc
\font\ninrm = doc
\font\ninsy = cmsy10
\font\tenmi = doc
\font\tenrm = doc
\font\elvmi = doc
\font\elvrm = doc
\font\elvsy = cmsy10
\font\twlmi = doc
\font\twlsy = cmsy10
\font\frtnmi = doc
\font\frtnrm = doc
\font\frtnsy = cmsy10
\font\svtnmi = doc
\font\svtnrm = doc
\font\svtnsy = cmsy10
\font\twtymi = doc
\font\twtyrm = doc
\font\twtysy = cmsy10
\rm
%
% These dimensional definitions are also taken from Langdon, though with
% some changes, e.g. not ragged right/bottom and parind 3 instead of 5. 
% horizontal dimensions had best be multiples of \em
\hsize 78 em                  % 78 characters per line so fit any screen
% \rightskip=0pt plus 4em       % ragged right
% \spaceskip=1em                % forces ONE space between words
% \frenchspacing        suppresses extra blanks after punctuation -don't
\parindent=3em
\def\enspace{\kern 1em} \def\enskip{\hskip 1em\relax}
%
% vertical skips may best be multiples of \baselineskip
\baselineskip=12pt            % 6 lines per inch
% \vsize                        % default give 58 lines -OK
\voffset=\baselineskip        % so don't lose \headline
\parskip=0pt
\smallskipamount=0pt
\medskipamount= \baselineskip
\bigskipamount=2\baselineskip
% \raggedbottom
%
% By default itemize is done with bullets, which we don't have. use hyphen 
% now fix up various latexish stuff
% 
\def\labelitemi{ -}
\def\labelitemii{ -}
\def\labelitemiii{ -}
\def\labelitemiv{ -}
%
% Fix up table of contents.  Default latex uses fractional spacing between 
% the section number and title.  This comes out as no space in the doc file 
% so we add a space to numberline, and expand tempdima by one em to allow 
% for it.  Also, go out of math mode for the dot in the leader.  Dots in 
% math mode turn out to be colons! 
%
\def\@dottedtocline#1#2#3#4#5{\ifnum #1>\c@tocdepth \else
  \vskip \z@ plus .2pt
 {\hangindent #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
   \parindent #2\relax\@afterindenttrue
  \interlinepenalty\@M
  \leavevmode 
  \@tempdima #3\relax
  \addtolength\@tempdima{1em}
   #4\nobreak\leaders\hbox to 2em{\hss.\hss}\hfill \nobreak \hbox to\@pnumwidth{\hfil\rm #5}\par}\fi}
\def\numberline#1{\advance\hangindent\@tempdima \hbox to\@tempdima{#1\hfil}\ }
%
% Can't really do superscripts, so do footnotes with / /
%
\def\@makefnmark{\hbox{/\@thefnmark/}}
\long\def\@makefntext#1{\parindent 1em\noindent 
            \hbox to 3em{\hss\@thefnmark.}\ #1}
\skip\footins 24pt plus 4pt minus 2pt
\def\footnoterule{\kern-12\p@   
\hbox to .4\columnwidth{\leaders\hbox{-}\hfill}} 
%
% \arrayrulewidth 1em \doublerulesep 1em 
%
% Some fairly obvious hacks.  No odd/even pages in doc files.  Can't do the
% fancy TeX symbols.
%
\oddsidemargin 0pt \evensidemargin 0pt
\def\TeX{TeX}
\def\LaTeX{LaTeX}
\def\SliTeX{SliTeX}
\def\BibTeX{BibTeX}
%
% special versions of stuff from xxx10.sty, since only one font size
%
\def\@normalsize{\@setsize\normalsize{12pt}\xpt\@xpt
\abovedisplayskip 12pt
\belowdisplayskip \abovedisplayskip
\abovedisplayshortskip  \z@
\belowdisplayshortskip \z@
\let\@listi\@listI}   % Setting of \@listi added 9 Jun 87
\let\small\@normalsize
\let\footnotesize\@normalsize
\normalsize
\footnotesep 12pt
\labelsep 10pt
\def\@listI{\leftmargin\leftmargini \parsep 0pt%
\topsep 12pt%
\itemsep 12pt}
\let\@listi\@listI
\let\@listii\@listI
\let\@listiii\@listI
\let\@listiv\@listI
\let\@listv\@listI
\let\@listvi\@listI
\@listI
%
% We had sort of random numbers of blank lines around section numbers.
% Turns out they used various fractional spacing.  Rather than depend
% upon the definition of startsection, just wrap something around it
% that normalizes the arguments to 12pt.  Negative args have special
% meanings.
\let\@oldstartsec\@startsection
\def\@startsection#1#2#3#4#5#6{
  \@tempskipa #4\relax
  \@tempskipb #5\relax
  \ifdim \@tempskipa <\z@ \@tempskipa -12pt \else \@tempskipa 12pt \fi
  \ifdim \@tempskipb >\z@ \@tempskipb 12pt \fi
\@oldstartsec{#1}{#2}{#3}{\@tempskipa}{\@tempskipb}{#6}
}
%
% Remaining unsolved problem: hrule and vrule are no-ops.  This is
% visible mostly in the tabular stuff, where none of the lines show up,
% though it's still basically usable.
%
\makeatother