A simple question (in theory): is there any (La)TeX distribution for Windows that is capable of running as a daemon? I am not aware that either MiKTeX or TeX Live are capable as running as daemons on Windows, but are there any other solutions? Failing this, if I wanted to hack an existing TeX distribution to run as a daemon, what would be the best approach?

A few features that the daemon should have, ideally:

One-time loading.

Load the preamble separately, so multiple documents can be generated without reloading the preamble.

Run as a Windows Service. (optional)

Callable as a library/API. (optional)

Input TeX and output DVI/PNG via standard I/O or pipes. (optional)

Any information or suggestions on the subject would be much appreciated.

Edit 1: Specifically, I am also rather curious how the preview-latex package for EMACS works. This seems to have a very similar usage in mind to what I intend.

Edit 2: I've just recalled that the Instant Preview feature of LyX also closely represents what I want to achieve. Additionally, this seems to work on Windows. An explanation/overview of this system and the daemon it uses would be very helpful.

Thanks for the suggestion. I've actually looked at this before and it doesn't seem to be a true TeX daemon. It's mainly a file system watcher from what I can tell. It is also mysterious how it "precompiles" the preamble using only a standard MiKTeX distribution.
–
NoldorinAug 5 '10 at 11:45

In response to your other answer: Cheers, that explains half the story. However, doesn't this LaTeXDaemon still have to relaunch the LaTeX program on each run? Where is the preamble preserved in that case?
–
NoldorinAug 5 '10 at 16:13

MathTran runs TeX as a daemon. For macros it runs a secure variant of plain TeX, but with some LaTeX additions, such as \frac. Several years ago it could typeset a single formula in about 10 milliseconds (and so too cheap to be worth caching).

Looks like a pretty nice project there. Judging by the username, it seems you're also a main developer on the TeX Daemon project on SF.net, though this and the (forked?) PyTeX project look to be Linux only - correct me if I'm wrong. What does MathTran use internally? I suppose there's no chance of open-sourcing it? :)
–
NoldorinAug 5 '10 at 11:58

Yes, I'm behind the TeX daemon also. The MathTran site is open-source, but not as easy to get hold of and install as I would like. For technical reasons, the TeX daemon requires Unix style sockets (so that it can make a select()).
–
Jonathan FineAug 5 '10 at 14:07

I see... In that case, do you have any idea what Instant Preview does (for LyX), especially when running on Windows? It seems you're responsible for this project to, judging by a paper written in 2001.
–
NoldorinAug 5 '10 at 15:03

LaTeXDaemon must compile your document again loading of packages and definitions from the preamble are dumped to a format file and is therefore much quicker than if you compile in the tradidtional way. Try making a document (test.tex) that loads TikZ or other huge packages and then create a custom format with mylatex: (one line): pdftex -ini -fmt=mytest -jobname=mytest -progname=pdflatex \&pdflatex mylatex.ltx test.tex this will generate mytest.fmt and you can now compile the document with pdftex -fmt=mytest.fmt test.tex
–
Martin HellerAug 5 '10 at 16:39

Thanks Martin, that makes things pretty clear to me now. This sort of confirms my view though, that LaTeXDaemon is not a true daemon in that stays running indefinitely and can serve multiple users.
–
NoldorinAug 5 '10 at 16:54