92

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?

10
  • 1
    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.
    – Newer
    Dec 5, 2008 at 15:41
  • 11
    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, 2008 at 18:53
  • 10
    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, 2008 at 18:56
  • 1
    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, 2009 at 0:23
  • 1
    See also stackoverflow.com/questions/1240037/…, in which I got close to real-time latex. Sep 8, 2009 at 16:52

23 Answers 23

41

BaKoMa TeX (no longer in development) 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.

2
  • 1
    Looks like there is a beta of BaKoMa with linux support now.
    – stimms
    Feb 3, 2011 at 1:35
  • 1
    BaKoMa TeX would be great if it supported recent TeX compilers like PdfTeX or LuaTeX. Unfortunately, it only supports plain TeX/LaTeX. This means e.g. no fontspec package support for OpenType fonts and no UTF fonts. BaKoMa TeX development appears to have stopped in 2018.
    – divenex
    Mar 31, 2020 at 14:39
59

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: How to set up latexmk and Skim for near realtime LaTeX

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: https://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.

5
  • 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, 2008 at 19:14
  • 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. Apr 16, 2010 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, 2010 at 3:08
  • the key is the auto-refreshing previewer. Skim on OSX solves the problem for me. Preview.app and Adobe Acrobat do not. linux has some apps that do it, too. don't know about windows. for all practical purposes, the live previewer solves all your problems for short documents (say, 5-30 pages) on modern computers. it only becomes a problem again if you are typesetting books without \include.
    – ivo Welch
    May 29, 2016 at 4:41
  • Link to latexmk seems to be broken, it is still installable via some package managers such as apt
    – ljden
    Sep 20, 2021 at 3:00
28

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

[ Edit: Gummi is currently maintained here: https://github.com/alexandervdm/gummi ]

picture of gummi

4
  • 1
    @Andrioid is it not good with big documents? If so, how big (according to experience)?
    – Wolter
    Mar 21, 2012 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, 2012 at 8:38
  • 1
    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, 2013 at 13:57
  • 5
    It lacks the most important BaKoMa feature, it's only one-way, is not interactive, you can't write directly on the right panel (the results) nor modify things there.
    – skan
    Feb 11, 2016 at 18:07
21

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.

TeXShop source and preview Source

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.

3
  • 1
    I disagree with your last paragraph. See my answer below.
    – dreeves
    Jan 2, 2009 at 6:31
  • OK, I want to get to the point where I don't worry about the formatting, just focus on the content and get it all input correctly, then go back and fix any issues. The problem, unfortunately, is that if I'm going to write, say, 10 pages of LaTeX without compiling, I'm guaranteed to have a number of small errors which prevent it from compiling, and the error messages from LaTeX are generally not even close to referencing the correct place when there are several errors, so debugging will take quite a long time. How do you overcome this?
    – mboratko
    Apr 6, 2016 at 12:48
  • @process91 It's been a while since I extensively used LaTeX, but I don't remember the experience that "the error messages from LaTeX are generally not even close to referencing the correct place": maybe you can ask a separate question on this site about how to debug when there are multiple errors, describing your experience. Apr 6, 2016 at 15:13
13

To answer your second question:

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.

4
  • 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, 2008 at 0:28
  • Other accept LaTeX tarbals as input and auto-process them. You get back the "proofs" in as little as an hour! Nov 30, 2008 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, 2008 at 7:48
  • I think that those railing against WYSIWYG are missing the point. See my answer below.
    – dreeves
    Dec 29, 2008 at 19:03
11

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.

9

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

3
  • If I understand correctly it only works for formulas. not the entire document.
    – shoosh
    Nov 22, 2008 at 9:29
  • Nope that's just an example IIRC it works for everything.
    – André
    Nov 22, 2008 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, 2008 at 2:43
5

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.

0
5

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)

5

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.

1
  • 1
    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. Nov 22, 2008 at 20:16
4

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.

4

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 ;)

4

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
3
  • Just a note: if anyone starts using this and improves upon it, please do let me know about the improvements.
    – Szabolcs
    Jul 5, 2011 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, 2013 at 1:10
  • I figured it out, but the problem is that it seems sumatraPDF is not automatically changed.
    – user19832
    Dec 23, 2013 at 12:34
2

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?

2

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!".

2
  • 1
    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.] Dec 12, 2008 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, 2008 at 23:10
2

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.

2

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.

1

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.

1

look at texpad on http://new.math.uiuc.edu/math198/latex.html

1

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

1

About the "non-wysiwygness" of LaTeX, may I point out a previous question and some of its answers, which raise some interesting points. (The link points now to an archived version of that page, which had since been closed and deleted as off topic, but contained nonetheless useful ideas.)

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.

0

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.

0

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.