# Are there any document viewers that use Tex as a backend?

I know that many people use editing programs like MikTeX and TexWorks for TeX documents; these programs (and others like them) provide a pseudo-WYSIWIG (what you see is what you get) interface to TeX. I have not seen, however, any programs that are designed specifically for veiwing documents based on the TeX way.

Obviously, TeX is designed to produce output in a format of choice, but are there any document viewing programs that take TeX formated documents as input and display formated text?

I can see at least a few advantages to such a system:

• Dynamic zooming with appropriate
• default for viewing environment (e.g. fit to screen width)
• line wrapping
• image resizing
• Hyperreferencing independant of PDF viewer capabilities
• Reduced memory requirement for document storage (important if implemented on mobile device)

Background: This question was prompted by questions about viewing TeX generated documents on a Kindle. My mother just got a Kindle and was asking me how I navigate through documents on it. Though I primarily use PDFs, hyperreferencing doesn't work on Kindle. It occured to me that a viewer that implemented TeX on a Kindle would be an interesting application.

-
Wow, you seem to be off on quite a few points here. First off, MikTeX is not an editor. Secondly, TeXWorks is, but it is not WYSIWYG... –  qubyte Jan 16 '12 at 15:17
The rest is just nonsense. A TeX document is just a source file. It's not meant to be read like that. The point is that it's processed into a format that a viewer can read, be it pdf, ps or dvi. –  qubyte Jan 16 '12 at 15:20
I don't think that makes sense though. An editor is either WYSIWYG or not. In this case, what you edit in no way resembles the result, so it is not WYSIWYG. In any case, it's clear that what you want is something that converts TeX to an ebook format. The conversion isn't 100%, but Pandoc is probably your best bet with LaTeX. –  qubyte Jan 16 '12 at 15:46
Sorry, I still don't get what you exactly want to do. Also it seems you don't fully understand TeX yet. You have your source file and the TeX compiler compiles it into a PDF (or DVI/PS if you use the IMHO deprecated DVI mode). If you want to add formating like hyperlinks etc. as user, you need to have the source file from the author and a TeX compiler and PDF viewer. –  Martin Scharrer Jan 16 '12 at 15:53
Is this presentation of any interest? –  Torbjørn T. Jan 16 '12 at 17:55

The way I understand this question is: On current e-book readers, you can change the font size of a document, and the reader will reflow the paragraphs for you. Because of that, you cannot take advantage of one of the most powerful aspects of TeX: its line breaking algorithm. Also figure resizing is a problem. The idea AdamRedwine seems to be proposing here is to distribute the documents in a format that is a subset of TeX, without specifying things like font size, page size and margins, and process the documents on the fly in the e-book reader with something like a TeX engine, with the reader supplying the missing information about font and page size. That way you would have more or less nicely formatted document no matter what your reader screen size is, and no matter what font size you choose.

I do not think that is really possible. First, not everything in a well designed TeX document is done automatically. Things like overfull hboxes, orphans and widows, figure placement etc. have to be often adjusted manually, sometimes even by changing the text. Second, I do not know what the processing power of the new Kindle is, but I have an old Nook, and that very far from being fast enough to run TeX on the fly to reflow a document. You also do not want to waste storage space for a reasonably complete TeX distribution.

Perhaps having some very limited subset of TeX, that would just use the line and paragraph breaking algorithm, would at some point of time be viable. Or maybe something based on lout. But right now I am not aware of anything that would do the job.

-
Thank you, this is very much the sort of thing I was trying to describe. My interest is in balancing the interests of the producer and consumer of the information. It seems to me that most information formats are producer driven (either providing ease of use like MS Office, or power like LaTeX). The primary exception that I can think of is HTML with CSS; these tend to be more consumer focused but do not function well for text based information like scientific books. –  AdamRedwine Jan 16 '12 at 16:17

There are programs that are more or less WYSIWIG for TeX:

A closed system like a Kindle is not an ideal candidate for anything like that though as you would need a lot of support from Amazon. On other devices running it might be possible to install some kind of TeX distribution and hack together something. Basically you would need a pdf viewer that automatically runs the TeX compiler in the background if something like the text size is changed. Another caveat is that the .tex document also needs to be compatible with packages like geometry to allow easy change of page sizes more or less on the fly.

I think it is an interesting idea but compared to other formats for reflow like the epub format it would take quite a bit of work to have a working and easy to use package.

-
Thanks, I haven't looked into ePub much. I did see some references to generating ePub from LaTeX source; this might be a better way to go. –  AdamRedwine Jan 16 '12 at 16:28

Theoretically, this would be possible. A customized TeX compiler could be created that, for example, executed function calls to a QPainter to draw pages in a Qt application instead of outputting DVI or PDF documents. The LuaTeX team seems to be working towards this as explained by the "Backends" section of their roadmap.

However, the problem is that creating a custom TeX compiler is very, very difficult. To misquote an old proverb:

The road to hell is paved with abandoned, half-implemented TeX compilers

See Is there a BNF grammar of the TeX language? in order to get an idea of how hard it is to take the first step down this road.

-