gvr@cs.brown.edu (George V. Reilly) (12/03/90)
I know that getting TeX/LaTeX to output ASCII is a recurring topic in the TeX world, and I'm sorry to be the one to bring it up again. However, I've never been particularly interested in the answer before now. I have a 35-page LaTeX document that I need to be able to send to people as a nicely formatted ASCII document. Essentially, I'm looking for an nroff to TeX's troff. Sending the LaTeX source isn't really an option. Neither is sending the result of filtering the LaTeX file through detex. I found dvidoc on sun.soe.clarkson.edu in ~ftp/pub/tex/tex-programs, and it goes someway towards addressing the problem. Dvidoc is a postprocessor for TeX DVI files that generates output for character devices like terminals and line printers. There is also a style file, dvidoc.sty, and a set of macros for plain TeX, docmac.tex, which tell TeX to use a fixed-width font everywhere. Dvidoc works by placing characters on a page that's at most 132 x 88 (characters). Naturally, there are rounding errors on such a low-resolution page, and overprinting and spurious blank lines occur. I ran dvidoc on my paper, and had to spend most of an hour fixing up the result: removing spurious blank lines, fixing overprinting (only occurred with footnoterules), making the section numbers in the table of contents legible (e.g., only the first three letters of 11.3.1 appeared), similar problems with footnotes, and fixing up the simple equations that appeared in the paper. In short, something I would be reluctant to do again. Some of these problems could be fixed by using a more sophisticated style file: footnotes, table of contents, line spacing, etc. \bf and \it could be set up to do Usenet-style highlighting: *bold* and _italic_ or nroff-style highlighting: bboolldd and _i_t_a_l_i_c. Getting it to fix math would probably be incredibly hard; enclosing the math in conditionals would probably be the best way to get acceptable results in both the high-resolution and ASCII versions. So, has anybody out there got a better, more automatic solution? Or an augmented dvidoc.sty? Email me and I'll post a summary of the responses. ________________ George V. Reilly `Clumsy Carp' gvr@cs.brown.edu +1 (401) 863-7684 uunet!brunix!gvr gvr@browncs.bitnet Box 1910, Brown U, Prov, RI 02912
dsmith@applga.aa.cad.slb.com (J. Daniel Smith) (01/13/91)
In article <567@hydra.bucknell.edu> droms@hydra.bucknell.edu (Ralph E. Droms) writes: >I've been working on the problem for a bit, and have generated >a first cut at a solution. The mechanism uses a new .sty file >that uses only fixed-width fonts, and redefines many LaTeX >commands to substitute fixed spacing for stretchable glue. There are >also made a few modifications to dvi2ps to generate better ASCII >output from the .dvi file generated by the .sty file. Rather than a STY file, I would like to see a different FMT file (e.g. lplainascii instead of lplain). That way one wouldn't have to change the LaTeX file at all. I know this doesn't solve all of the problems (e.g. \section is defined with strechable glue in a STY file that is read in when LaTeX starts...). But even this could perhaps be solved by having a second set of the standard STY files in another sub-dir. The "latex" and "asciilatex" commands would be shell sripts that set the environment variable TEXINPUTS properly (UNIX web2c implementation of TeX...). This seems to me to be more in line with troff/nroff users are looking for---the *same* input file formatted differently by two different processors. Dan -- =========================================================================== J. Daniel Smith Internet: dsmith@applga.aa.cad.slb.com Schlumberger CAD/CAM BITNET: smithdan@msuegr Ann Arbor, Michigan Usenet: uunet!sharkey!applga!dsmith
allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (01/13/91)
As quoted from <567@hydra.bucknell.edu> by droms@hydra.bucknell.edu (Ralph E. Droms): +--------------- | I've been working on the problem for a bit, and have generated | a first cut at a solution. The mechanism uses a new .sty file | that uses only fixed-width fonts, and redefines many LaTeX | commands to substitute fixed spacing for stretchable glue. There are | also made a few modifications to dvi2ps to generate better ASCII | output from the .dvi file generated by the .sty file. | | Anyway, I'm posting to the newsgroup to see if I'm reinventing | the wheel, and to get input as to whether the approach I've | employed is reasonable. Is there anything else available +--------------- You might look at dvi2tty and/or dvi2vdu, which convert dvi files to ASCII representations. With fixed-width fonts, it should be possible to coerce TeX and LaTeX into producing output that will display with the proper spacing using these programs, and dvi2tty at least can be run on a stream to generate ASCII on the fly from a .dvi file, while allowing dvi?ps to be run on it to produce printed Postscript output (or dvi2lj for LaserJet output, etc.). I've been playing with a macro package I wrote to generate Unix-format manpages (note: this is NOT an nroff-to-TeX conversion package, just a set of macros for TeX to produce Unix-format manpages) point will probably put together a version for use with dvi2tty to produce nroff-like output. ++Brandon -- Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440 Internet: allbery@NCoast.ORG Packet: KB8JRR @ WA8BXN America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88] uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY
droms@regulus (Ralph E. Droms) (01/13/91)
In article <1991Jan12.160250.6214@applga.aa.cad.slb.com>, dsmith@applga (J. Daniel Smith) writes: >Rather than a STY file, I would like to see a different FMT file (e.g. >lplainascii instead of lplain). That way one wouldn't have to change >the LaTeX file at all. I know this doesn't solve all of the problems >(e.g. \section is defined with strechable glue in a STY file that is >read in when LaTeX starts...). But even this could perhaps be solved >by having a second set of the standard STY files in another sub-dir. Aha! A good idea...I'm not a very sophisticated TeX hacker, and would not have thought of this solution. I'll look into moving my fixes into a new FMT file. I have the pslatex package to use as an example. Anybody have any ideas about finding *all* the stretchable glue definitions so I can flush them all out? -- - Ralph Droms Computer Science Department droms@bucknell.edu 323 Dana Engineering Bucknell University (717) 524-1145 Lewisburg, PA 17837
droms@regulus (Ralph E. Droms) (01/13/91)
In article <1991Jan12.225355.28342@NCoast.ORG>, allbery@NCoast (Brandon S. Allbery KB8JRR) writes: >As quoted from <567@hydra.bucknell.edu> by droms@hydra.bucknell.edu (Ralph E. Droms): >+--------------- [...] >| also made a few modifications to dvi2ps to generate better ASCII I misspoke myself here ... I made modifications to *dvi2tty*, not dvips. [...] > >You might look at dvi2tty and/or dvi2vdu, which convert dvi files to ASCII >representations. With fixed-width fonts, it should be possible to coerce TeX >and LaTeX into producing output that will display with the proper spacing >using these programs, and dvi2tty at least can be run on a stream to generate >ASCII on the fly from a .dvi file, while allowing dvi?ps to be run on it to Having pointed out my earlier typo, I'll explain that I am using dvi2tty, and I had to make some minor changes to dvi2tty's conversion model to generate better ASCII output for my particular application. For example, I use a fixed character width, don't fold lines, and eliminate some accumulated vertical spacing errors in the ASCII output. None of the changes to dvi2tty are very significant, but they make a tremendous difference in the quality of the output. -- - Ralph Droms Computer Science Department droms@bucknell.edu 323 Dana Engineering Bucknell University (717) 524-1145 Lewisburg, PA 17837
fischer@iesd.auc.dk (Lars P. Fischer) (01/17/91)
>>>>> On 11 Jan 91 22:24:59, droms@hydra.bucknell.edu (Ralph E. Droms) said:
Ralph> I'm trying to duplicate the function of nroff - to produce nicely
Ralph> formatted ASCII text from LaTeX input. I don't care if the output
Ralph> duplicates the non-ASCII LaTeX output ... what I want is
Ralph> nicely-formatted, machine-readable output from LaTeX.
You should check out the TeXinfo format used for manuals in the GNU
project. This format can be used with TeX to produce nicely formatted
documents, and with an info formatter (either standalone or from
within GNU Emacs) to produce ASCII version.
Using TeXinfo, you can also create documents that can be used with the
GNU equivalent of "man", the info system. Info is actually a static
hypertext system. You design your documents as a hypertext structure,
usually arranged as a tree (chapters, sections, etc) with cross
references, an active index, etc, and then "compile" it into a text
that can be read online. Such info documents are very well suited for
online browsing and a much more functional that the standard man page
system of UNIX.
There is a special version of TeXinfo called LaTeXinfo. This has the
same facilities as TeXinfo but works instead (surprise) with LaTeX.
This is a great advantage if you are used to LaTeX already, as you
will not have to learn a new way of creating chapters, say.
These systems are, naturally, limited in their handling of such things
as math. To be able to produce ASCII versions of your documents you
should be careful with the constructs used in the (La)TeXinfo files.
Ralph> The motivation for this work was a debate in the Internet community
Ralph> about the proper format for RFCs. Traditionally, RFCs have
Ralph> been submitted as ASCII text files. Some recent RFCs have been
Ralph> submitted as PostScript files - much prettier, but not
Ralph> machine-readable. I wanted to generate both PostScript and ASCII
Ralph> from the same input file.
Writing such documents in TeXinfo would be a *very* good idea. You
would be able to create beautiful documents with TeX, create
PostScript files for those without TeX (oh, boy...) and create ASCII
versions of the documents. With a bit of work these ASCII documents
could even be made in a form suitable for online browsing, which could
certainly come in handy.
Ralph> Anyway, I'm posting to the newsgroup to see if I'm reinventing
Ralph> the wheel, and to get input as to whether the approach I've
Ralph> employed is reasonable. Is there anything else available
Ralph> I should look at? The system is currently usuable, but there are
Ralph> still some details that could be tuned up a little better. Is
Ralph> there general interest in pursuing this effort further?
I wouldn't say that you are reinventing the wheel, but if you used
TeXinfo you would be using a format that was already in widespread
use. The chance of obtaining good tools supporting your work would be
bigger, and your documents would be more useful to the world.
/Lars
--
Lars Fischer, fischer@iesd.auc.dk | Life is hard, and then you die.
CS Dept., Univ. of Aalborg, DENMARK. | - The Immaterial