# Real Time LaTeX? [duplicate]

Possible Duplicate:
Is there any way to get real-time compilation for LaTeX?

I'm looking for an application in which I can write pure LaTeX in one half of the screen and on the other half to see the compiled document in real time.
This seems really like an obvious way to do LaTeX authoring but it doesn't look like any software is able to do it.
LyX is not what I'm looking for. I want to edit the actual LaTeX and see it rendered in real time. Why isn't this already being done somewhere?

-
That is incorrect. Usability of LaTeX was much better than that of contemporary systems. It is in fact the only surviving system that is in large scale use. –  Stephan Eggermont Dec 7 '08 at 18:53
Note to those pooh-poohing Shy's goal: realtime previewing (like StackOverflow does!) does not mean WYSIWYG. WYSIWYG means hiding the source from you so that what you are editing appears like the final output. Which, yes, for technical writing is a terrible idea. –  dreeves Dec 29 '08 at 18:56
if you understand the system with which you are working, why do you need to see it all the time? When I write some mark-up, I pretty much know what it is going to look like. –  Mica Aug 26 '09 at 0:23
See also stackoverflow.com/questions/1240037/…, in which I got close to real-time latex. –  Paul Biggar Sep 8 '09 at 16:52
Try web-based TeXRendr.com. It doesn't have a lot of packages, it's mostly useful for math. –  bobobobo Jul 8 '12 at 15:24
show 1 more comment

## migrated from stackoverflow.comOct 8 '12 at 16:03

This question came from our site for professional and enthusiast programmers.

## marked as duplicate by lockstep, Stefan Kottwitz♦Oct 8 '12 at 16:28

BaKoMa TeX does what you are looking for and is the only such solution that I know of. It does real incremental LaTeX compiling in the background, so it works with practically all LaTeX packages (e.g. those for complex diagrams). The LaTeX system itself is also quite good (e.g., it had early support for SVG).

It was originally only available for Windows, but nowadays there are also versions for Linux and Mac.

It is unfortunate that it is not free or open source, but for me paying the license fee is worth it. It is so superior to any other solution that I just can't imagine going back. As far as I know it is written by a single russian physicist, so I think the price is well justified.

Btw, I am not in any way connected to BaKoMa, just a very happy user.

-
Looks like there is a beta of BaKoMa with linux support now. –  stimms Feb 3 '11 at 1:35

I recommend latexmk which, with -pvc switch (for "preview continuously"), will recompile (as many times as necessary) whenever the source changes. If you have a pdf viewer that autorefreshes the pdf view (Skim on Mac OSX does this) then you can see a refreshed preview every time you hit save.

Using latexmk is nice even without the -pvc option since it automatically compiles (including bibtex) as many times as necessary.

Added: Here's something similar to latexmk, written in python: http://iml.univ-mrs.fr/~beffara/soft/rubber/. It doesn't seem to have anything like the "preview continuously" option, though that could be added with something like this: http://stackoverflow.com/questions/393176/monitor-a-set-of-files-for-changes

### Note to those railing against WYSIWYG:

Realtime previewing (like StackOverflow does!) does not mean WYSIWYG. WYSIWYG means hiding the source from you so that what you are editing appears like the final output. Which, yes, for technical writing is a terrible idea. Seeing a realtime preview does not make LaTeX WYSIWYG -- you are still editing the plain text source. (Note that this is the way the StackOverflow editor works.)

I don't dispute that you should not typically worry about the preview. You could even argue against this feature on the grounds that it would encourage bad habits. I would actually argue the opposite -- seeing the choices TeX is making in realtime just reassures you that you can put the typesetting out of your mind and have faith in TeX.

In any case, there are plenty of times when you do need to care (like with messy equations, or in the final stages of editing when you're cleaning up bad line breaks and whatnot) and a truly realtime preview would save a lot of time.

-
Ah, I think you added this comment as I was extending my answer. Do you think my answer now addresses this point? –  dreeves Dec 29 '08 at 19:14
Yes :) I've removed the comment since it's now pointless. Thanks :) –  Mihai Limbășan Dec 29 '08 at 19:57
I actually agree with you (note that nowhere did I use "WYSIWYG"), so +1. I still think that having the preview always visible can be distracting, and encourage bad habits, but I certainly agree with you that latexmk is nice and -pvc is useful. –  ShreevatsaR Apr 16 '10 at 0:14
Cool, thanks Shreevatsa. I think we've reached rough consensus. When this question was first posted a lot of people jumped down the asker's throat, accusing them of not appreciating LaTeX's elegant separation of form and content. It seems that most everyone's now on the same page about that. Realtime compiling of the LaTeX source is at worst distracting (though personally I like it). It's not any kind of violation of the principles of LaTeX. –  dreeves Apr 16 '10 at 3:08

Many PDF and DVI viewers update their display automatically when changes occur in the file they are displaying. So for example, one common way people use LaTeX is to have their LaTeX editor on one half of the screen, a viewer on the other, and hit "Typeset" on their editor every few minutes or so. It is possible to set up your system to allow clicking on a point in the displayed output to go to the corresponding point in the editor, and vice-versa.

Now what you could do, if you wanted to avoid the step of hitting "Typeset" every few minutes, is to have a script running in the background that simply compiled your LaTeX file every few seconds. You would have to keep the following in mind:

• Compiling a LaTeX file can take a second or two, and can require more than one compilation to get all the references right.

• If there is an error in the compilation step (as there is likely to be, e.g. when you have typed a "$" in your source file but not yet typed the closing "$"), you need to just abort the compilation (better is to start the compilation in -nonstopmode), and when there are errors, make sure the existing PDF/DVI file is not modified.

Barring these, such a script more-or-less works. (I had written and was using one long ago.) The output will be updated in almost less than a sentence's worth of typing time.

[Edit: As Stephan pointed out, "Textures" for OS X does this. its website says

we reintroduced the popular Traffic Light, the Textures facility that continuously shows you the TeX status of your documents while you type. If the light is green, TeX is happy; if the light turns red, there's a problem. As soon as you fix it, the light turns green again. (The light turns yellow while TeX is working, but Textures is so fast you'll rarely see it.)
Also as he pointed out, it's not really all that useful.]

The reason I gave it up is because this is really not the right way of using LaTeX. The entire point of LaTeX is for you to not worry about the formatting when inputting the file; just type it in with the right semantic markup (paragraphs, sections, subsections) and leave the presentation up to LaTeX. Having to simultaneously worry about the presentation and content is extremely distracting and pointless; if you're going to do this you might as well use Word! The typesetting should be done only after you have a clear idea of what it is that you want to typeset.

-
I disagree with your last paragraph. See my answer below. –  dreeves Jan 2 '09 at 6:31

Gummi is better than BaKoMa Tex. It is a free, open source, program written in python, featuring a live preview pane.

http://gummi.midnightcoding.org/

-
Not sure why you're being downvoted. I've used Gummi, it's great for small documents. –  Andrioid Sep 5 '10 at 8:06
@Andrioid is it not good with big documents? If so, how big (according to experience)? –  Wolter Mar 21 '12 at 21:47
Letters, notes and separate diagrams are fine. For reports or bigger documents, I would advise against it. I am also not sure how Gummi handles multiple files. If in doubt, just try it. –  Andrioid Mar 24 '12 at 8:38
If fact, Gummi can't deal with multiple files today. But using the [ctan.org/tex-archive/macros/latex/contrib/subfiles subfiles], Gummi becomes very good. –  Sigmun Nov 20 '13 at 13:57

because it is not the way it is intended to be used. LaTeX is not (!) a WYSIWYG-system. It is a document layout system. So you write your text (in a low end teletype-terminal) with some minor layout-directives, and someone else (the tex-subsystem on a high-end maschine) is producing (compiling) the ready-to-print Paper.

So you take your focus only on your content, not on the appearance.

The idea behind this is, that you are not as skilled in the art (!) of printing (setting letters) like a professional printer (the person, not the machine), so all formatting you do may be wrong in the sense of professionalism. Tex is implemented with the knowledge of a professional printer in mind.

-
Most peer reviewed journals supply a tex template for submissions to restructure their layout, so you can submit a printworthy pdf in exactly their book format. –  Karl Nov 30 '08 at 0:28
Other accept LaTeX tarbals as input and auto-process them. You get back the "proofs" in as little as an hour! –  dmckee Nov 30 '08 at 1:43
Printing is a craft, and nobody wants to show it's secrets. And if you look at Adison-Wesley books for example, they look nice and have a common feeling over a wide range of books. The numbers (distances, spaces, font sizes) behind this appearance is one of the trade secrets of their success. –  Peter Miehle Dec 1 '08 at 7:48
I think that those railing against WYSIWYG are missing the point. See my answer below. –  dreeves Dec 29 '08 at 19:03

In reply to ShreevatsaR observation that LaTeX is not wysiwyg and that simultaneously considering presentation and content is pointless, sometimes presentation and content are not separable: try entering a multi-line \equation that takes up a quarter page in a research journal with a two-column format, or entering a data table. Sooner or later you are going to have to fix those typos and will need to refer repeatedly back and forth between the presentation and content to get it right. Another place is where you have a page or word count limit and you are trying to juggle meaning and document length. I think being able to see immediately the effects of your edits is extremely useful.

That being said, judicious use of a makefile, xdvi or gv, and your favorite editor (mine is vim) makes the need for a separate program to accomplish a wysiwyg effect for LaTeX superfluous, as has been pointed out.

-

Being a vim user, I never used it, but there is an extension for emacs that does something like that and it's called preview-latex.

HTH

-
If I understand correctly it only works for formulas. not the entire document. –  shoosh Nov 22 '08 at 9:29
Nope that's just an example IIRC it works for everything. –  André Nov 22 '08 at 16:30
In my current setup, it shows formulas, tables, and titles in emacs. When I move the cursor on such an item, I can switch to editing it so that the source is shown, and back. –  Svante Dec 26 '08 at 2:43

TeXworks may be the solution you're looking for. It opens two windows: one is the text editor for entering your LaTeX code, the other is the PDF/DVI viewer that gets live updates. It can also use SyncTeX so that you can click in the PDF document and the text editor will jump to the code that generated that output you clicked on.

You can watch a video presentation of TeXworks from the TeXLive 2008 conference.

-
I upvoted this (thanks for the link!) but TeXworks does not really do real-time previewing, any more than TeXShop does -- you still have to hit "Typeset" every few minutes yourself. That's why I mentioned the trick about having a script that compiles automatically frequently. –  ShreevatsaR Nov 22 '08 at 20:16

We had that on the mac before OS-X with Textures. It is of very limited use though. It is nice when experimenting with difficult formulas, but not when writing, as Shreevatsa already noticed.

The delay for compilation is not strictly necessary on modern machines, but that would need major surgery in the TeX engine.

You might want to take a look at TeXmacs, which is much more WYSIWYG.

-
Thanks, I happened to check out Textures (well its website) and I see what you mean. –  ShreevatsaR Dec 12 '08 at 0:20

I used to use whizzytex, a package for Emacs which uses advi to do the preview.

It has been in Debian and Ubuntu for quite a while now. It may not interact perfectly with all the LaTeX packages out there, but it does a good job of connecting your cursor in Emacs with the cursor in the preview pane.

It's true that this isn't a 100% WYSIWYG emacs editor, but it does provide real-time preview updates as you type, and the preview window is interactive. Just make sure that your LaTeX is always in a compilable state (YaTeX provides a set of macros the help maintain this property).

(I now just use emacs with YaTeX and the Evince pdf viewer which updates every time I save/compile)

-

LEd (http://www.latexeditor.org/) comes with split screen mode.
It's still not real time, but you can hit the compile key as often as you want ;)

-

Gummi is exactly what you need.

-

Because LaTeX for big(ish) documents takes at least a few milliseconds to compile. The best solution I've found (and what I'm using right now) is to use Kile and Quick Preview using (Alt-1) every few seconds. If you use evince or some similar DVI/PDF viewer, it will just update whatever page you're looking at, which allows me to make changes and see them almost instantly (almost real-time).

Lytha is absolutely right, but I've found it really difficult to learn the syntax of LaTeX without running the compiler a dozen times with all my (typically wrong) syntax to see the result.

-

It seems that latex users have learned to live with the limitation of latex. If you do complicated math or draw a picture with tikz, you will wish the realtime update stronly.

Next time ask a real mathemetician about tex and what he/she want to be improved.

-

Great idea. It's not ideal, but as people pointed out, it's possible to make something like this yourself. Here's what I did (and used for a while) on Windows:

What you need:

1. A text editor that can perform an action each time the document has changed
2. A fast way to recompile LaTeX
3. A viewer that can quickly reload the document.

I used gVim as the text editor, latexdaemon as the compilation engine, and Sumatra as the PDF viewer.

1. In Vim, issue the command :au! CursorHoldI,CursorHold <buffer> silent! :update to make it auto-save the document every time you stop typing. Also :set updatetime=800 to set the timeout after which saving happens to a low value.

2. latexdaemon will auto-compile the document in an efficient way every time it's changed. Use the following at the beginning of the file to make it produce PDF:

%Daemon> ini=pdflatex


Or just start it with latexdaemon -ini=pdflatex.

3. Sumatra will automatically re-load the file every time it is changed, and it will not lock the PDF (so it can be recompiled without closing Sumatra first).

This recipe will give you an almost real-time preview, but it takes some effort to set up, and is not without issues. For example, you might not want to continuously auto-save, in case you'd want to revert to an earlier version.

There's a lot to improve on this, but I've been using it for some time (after reading your question), and thought putting the recipe out here might be useful for others too.

Since I was lazy, I just put everything to set this up into a .bat file:

@start C:\Path\To\Sumatra\SumatraPDF.exe %1.pdf
@start latexdaemon -ini=pdflatex %1.tex
@gvim -c ":au! CursorHoldI,CursorHold <buffer> silent! :update" -c ":set updatetime=800" %1.tex

-
Just a note: if anyone starts using this and improves upon it, please do let me know about the improvements. –  Szabolcs Jul 5 '11 at 21:46
Could you make a step by step instruction? I would like to have a try (as a beginner of vim user.) –  user19832 Dec 23 '13 at 1:10
I figured it out, but the problem is that it seems sumatraPDF is not automatically changed. –  user19832 Dec 23 '13 at 12:34

BaKoMa is not 'free', and it is Windows only, but it is the closest I ever encountered as being a WYSIWYG LaTeX editor.

Personally I prefer the WYSIWYM method of LyX over the WYSIWYG method of BaKoMa...

Why did you not just Google for it?

-

I read an interview of Knuth a few years ago where he mentioned this sort of thing as his way of working. My vague and probably inaccurate memory is he'd edit the raw TeX or maybe Latex code in Emacs, keeping another window open with a viewer that'd get updated by a script that noticed when the source file changed. (C-x C-s rather than after every keystroke -- but still done often.)

Obviously this isn't a real answer to your question, but it's something to consider for the haters saying "Don't do that!".

-
Do you have a citation? I've seen too much garbage misattributed to Knuth in Stackoverflow answers :p [And Knuth certainly wouldn't be using LaTeX.] –  ShreevatsaR Dec 12 '08 at 0:20
No. I've read several interviews; the most recent was a series in CACM this past year, but I don't think that was it. (Though it might have been.) I'm sure of the general picture, though as I said the details are unlikely to all be right. –  Darius Bacon Dec 12 '08 at 23:10

Someone up there was wishing for a realtime tikz editor. I cannot add comments. It exists. It is called ktikz, I believe. I haven't used it yet, because there appears to be no windows version. niko

-

Not yet ready for prime time, but the Gliimpse project seems like a very promising way to handle the underlying problem (having the source code and the final result at the same time) in a very nice way.

Basically, the idea is that you press the alt-key in your editor, after which the editor transitions to the final (compiled) result, untill you release the key and go back to the Latex 'source code'.

The demo and video available on the page are impressive.

There's a nice post about it at the codinghorror blog.

-

Mostly nice answers. It was quite useful for myself. Just small comment about Kile and (Alt-1) (see above Stefan Mai). If I use (Alt-1) than later I have to use (Alt-Tab) to go back for editing. It is not really convenient. Better way is to put Kile on one half of screen (right|left) or (up|down). Put dvi viewer to another half of screen, then use (Alt-2). You will stay in Kile editor and dvi-viewer will be updated. It is real-time for me. Unfortunately it is useful only for Linux users. But I suppose something like this can be done in Windows with "Texmaker". P.S. Emacs is great for programming, LaTex and so on, but so difficult to learn.

-

Just use Emacs for Windows + latex-preview (auctex). It works for me :)

-

WhizzyTeX with Active-DVI does exactly what you are looking for. Its website could be a little more clear about the functionality, but I've used it, and it works well. Also, despite looking a bit dated, it is actively maintained; the documentation was updated this week.

-

In answer your second question, Why isn't this already being done somewhere? It has been done somewhere, quite some time ago. Check out Scientific Word, assuming you don't mind a commercial application. It may meet your needs, and they offer a 30 day trial version.

Note: I don't use this program myself, but I had heard seen it many years ago, and it does seem to meet your criteria.

As many of the other respondants have commented, it seems the majority of LaTeX users are happy enough without a real-time WYSIWYG editor.

-

About the "non-wysiwygness" of LaTeX, may I point out a previous question and some of its answers, which raise some interesting points.

In particular, the fact that a LaTeX file is a logical, not a physical, description of the document you are composing leads to several useful features, outlined in the above question/answers: use of comments, indenting as a way to keeps things cleaner and more readable and so on, in a spirit not different from what is done in other languages.

-

That is a bad expect. because it's against to one of principles of TeX Systems:

Visual attributes must not be mixed with logical structure

you are looking for a semi-WYSIWYG System, like most of popular HTML editors. the WYSIWYG and LaTeX words are like Hokey and Figure skating :-) LaTeX and all of TeX-based systems cannot and do not want to be WYSIWYG.

-