Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LaTeX from stdin

0 views
Skip to first unread message

Andrew Perrin - Demography

unread,
Feb 16, 2000, 3:00:00 AM2/16/00
to
Greetings.

I'm running a database system that outputs LaTeX for some of its
reports. I would like to be able to simply pipe the output to latex,
then to ghostview, so the user would get a nice window s/he can view
or print in final form. But as far as I can tell latex will only work
on a filename, not stdin. What I'm doing at the moment is saving the
.tex file in /tmp, then running latex on it, then running ghostview on
it, then deleting all the temp files, but that doesn't seem very
clean. Any ideas?

Thanks.

--
---------------------------------------------------------------------
Andrew J. Perrin - ape...@demog.berkeley.edu - NT/Unix Admin/Support
Department of Demography - University of California at Berkeley
2232 Piedmont Avenue #2120 - Berkeley, California, 94720-2120 USA
http://demog.berkeley.edu/~aperrin --------------------------SEIU1199

James Kilfiger

unread,
Feb 16, 2000, 3:00:00 AM2/16/00
to
Andrew Perrin - Demography wrote:
>Greetings.
>
>I'm running a database system that outputs LaTeX for some of its
>reports. I would like to be able to simply pipe the output to latex,

Can't be done with standard tex. See other thread for a discussion of
why tex file handling is so basic.
James

Sebastian Marius Kirsch

unread,
Feb 16, 2000, 3:00:00 AM2/16/00
to
Andrew Perrin - Demography schreibt:

> reports. I would like to be able to simply pipe the output to latex,
> then to ghostview, so the user would get a nice window s/he can view
> or print in final form.

You might want to use pdfTeX for this, which a) produces PDF output
directly, thus saving you one intermediary step, and b) enables you to
use Acrobat Reader as a frontend, which may be marginally more
wide-spread than GhostScript.

> But as far as I can tell latex will only work on a filename, not
> stdin.

What leads you to believe this? The following

echo '\documentclass{article}\begin{document} Hello world!
\end{document}' | latex

works all right on my system.

Yours, Sebastian

Peter Wyzlic

unread,
Feb 16, 2000, 3:00:00 AM2/16/00
to
On 16 Feb 2000 09:26:03 -0800, Andrew Perrin - Demography
<ape...@davis.DEMOG.Berkeley.EDU> wrote:

>I'm running a database system that outputs LaTeX for some of its

>reports. I would like to be able to simply pipe the output to
>latex, then to ghostview, so the user would get a nice window

>s/he can view or print in final form. But as far as I can tell
>latex will only work on a filename, not stdin. What I'm doing


>at the moment is saving the .tex file in /tmp, then running
>latex on it, then running ghostview on it, then deleting all the
>temp files, but that doesn't seem very clean. Any ideas?

It is not LaTeX as a set of macros but rather tex (the program).
And it is exactly the way TeX works. It seems piping was not a
prominent feature at the time or on the system Knuth used to
design the program tex.

In this respect troff (+ tbl etc.) is a "real" unix program and
allows data from stdin.

Peter

--
"A great many people think they are thinking when they are merely
rearranging their prejudices." -- William James

David Kastrup

unread,
Feb 17, 2000, 3:00:00 AM2/17/00
to
pwy...@uni-bonn.de (Peter Wyzlic) writes:

> On 16 Feb 2000 09:26:03 -0800, Andrew Perrin - Demography
> <ape...@davis.DEMOG.Berkeley.EDU> wrote:
>
> >I'm running a database system that outputs LaTeX for some of its
> >reports. I would like to be able to simply pipe the output to
> >latex, then to ghostview, so the user would get a nice window
> >s/he can view or print in final form. But as far as I can tell
> >latex will only work on a filename, not stdin. What I'm doing
> >at the moment is saving the .tex file in /tmp, then running
> >latex on it, then running ghostview on it, then deleting all the
> >temp files, but that doesn't seem very clean. Any ideas?
>
> It is not LaTeX as a set of macros but rather tex (the program).
> And it is exactly the way TeX works. It seems piping was not a
> prominent feature at the time or on the system Knuth used to
> design the program tex.

Actually, TeX/LaTeX will take input from stdin just fine. Just be
sure to start it off with a \ character, such as \relax, so that TeX
does not interpret it as a file name.

Granted, it will then output to a dvi file by default, but it will do
no seeks on that file, so you could make texput.dvi a named pipe and
TeX would do fine. But there it stops: dvips does not want to read
from pipes.


--
David Kastrup Phone: +49-234-32-25570
Email: d...@neuroinformatik.ruhr-uni-bochum.de Fax: +49-234-32-14209
Institut für Neuroinformatik, Universitätsstr. 150, 44780 Bochum, Germany

Jeffrey Goldberg

unread,
Feb 17, 2000, 3:00:00 AM2/17/00
to
On Feb 16, 2000 James Kilfiger <ma...@mimosa.csv.warwick.ac.uk> wrote:

> >I'm running a database system that outputs LaTeX for some of its
> >reports. I would like to be able to simply pipe the output to latex,
>

> Can't be done with standard tex. See other thread for a discussion of
> why tex file handling is so basic.

I've just done it both with Plain and LaTeX. Here is the texput.log for

% cat myfoo.tex | tex

This is TeX, Version 3.14159 (Web2C 7.3.1) (format=tex 2000.2.12) 17 FEB 2000 05:35
**\relax

*Hello, World!

*\bye
[1]
Output written on texput.dvi (1 page, 228 bytes).

And texput.dvi looks fine. It does appear that this will generate very
long log files.

Note that if the input does not begin with a control sequence, then the
\relax is necessary.

myfoo.tex contains

\relax
Hello, World!
\bye

I've also tested with LaTeX.

I do expect that bad things will happen if there is an "error" requiring
any user input during the run. As it appears that no distinction is made
between stdin and stderr, so you might want to put

\nonstopmode at the top of your input. But if you do this, make sure that
the output is actually checked by a human at some point.

-j

--
Jeffrey Goldberg +44 (0)1234 750 111 x 2826
Cranfield Computer Centre FAX 751 814
J.Gol...@Cranfield.ac.uk http://WWW.Cranfield.ac.uk/public/cc/cc047/
Relativism is the triumph of authority over truth, convention over justice.


0 new messages