22

Bakoma is a LaTeX Editor which has the real-time preview on Windows. On Linux, one has Gummi which has a similar feature and on Windows, I use WinEdt with Sumatra PDF together with an AutoIt script to do this. When the .tex is small, then both Gummi and my method gives 99.99% real-time preview feature, namely the delay between the typing and the appearance of updated PDF content is less then 0.5 second (even more, 0.2 second, I think). When the .tex file gets bigger, the delay gets large also. Furthermore, because the frequent compiling, the CPU becomes much buiser.

But Bakoma has no such problems. Anybody knows how Bakoma can process .tex files so fast? Is it possible to make MikTeX or TexLive to speed up by the similar mechanic ?


Since someone ask the methods I mentioned, I need to share it by answering my own question, sorry.

First of all, for Gummi on Ubuntu:

After install Gummi, open /home/(user account name)/.config/gummi/gummi.cfg Then change compile_timer to 0, but keep compile_scheme = on_idle. Now for small .tex files, you have real-time preview. Notice that if you change to compile_scheme = real-time, then CPU becomes very busy even the .tex file is small.

For WinEdt + SumatraPDF + MiKTeX on Windows ( I use MiKTeX 2.9 on Windows 7 64-bit) :

  1. In WinEdt, go Options\Execution\Modes. On Accessories, choose PDFLaTeX. On Console Attributes on the right side, choose Background Window, Hidden Window, WinEdt Console but not Pause / Do not Hide the Windo. On Process Folw, only select No Interaction and press OK

  2. Open C:\Program Files (x86)\WinEdt Team\WinEdt 6\Exec\ExeCompiler.edt. Remove the following:

Prompt("Another Application is already running in WinEdt's Console.> Terminate the application or wait for the execution to finish!");

Replace ShowConsole(1) by ShowConsole(-1), there are 4 places to replace. Replace FocusConsole(1); by FocusConsole(-1);, ther are 3 places to replace. Save the file.

  1. In WinEdt, go Options\Options Interface. On Menus and Toolbar choose Main Menu. Add SHORTCUT="120::F9" after MACRO="Exe('%b\Exec\TeX\PDFLaTeX.edt');" and add SHORTCUT="119::F8" after MACRO="SaveDoc;". Remember to remove the same shortcuts appear in the original file. Save the file and reload it.

  2. Install AutoIt. Create the following script

     $size = FileGetSize("C:\test.tex")
     While 1
         sleep(40)
         If WinActive("WinEdt 6.0", "C:\test.tex") Then
             Send("{F8}")
             $newsize = FileGetSize("C:\test.tex")
             If $newsize <> $size AND ProcessExists("pdflatex.exe") = 0 Then 
                 $size = $newsize
                 Send("{F9}")
             EndIf
         EndIf   
     WEnd
    

Then after running this script, when you edit your C:\test.tex, you have the real-time preview. One can change the script to get the .tex filename you open, but I haven't done this yet.


Update:

Using the Forward search function, I get a function similar to "Auto Scroll in the viewer" in Gummi. Please check the demonstration video on youtube

Demonstration of Real-Time Preview

  • 3
    Have you tried with multiple \ref and \label and \cite? Is the output correct? I would suspect that it does a single compilation pass. Unless they implemented separate compilation of TeX, but I think it's unlikely. – Axioplase Nov 4 '11 at 2:56
  • 1
    I followed the tutorial you posted and it didn't work for me with Winedit 7.0 – user13002 Mar 26 '12 at 22:23
  • @user565739 I am sorry, but can you tell me how to use autoit to continuously compile the latex code in case of edits? – Diaa Jun 23 '16 at 23:46
  • 1
    @Diaa Abidou I didn't use this method anymore. It is not very good anyway. If you really want to have a instant preview, try Bakoma to see if it worth to buy. – user565739 Jun 24 '16 at 4:36
16

According to their website it can do this because it only formats one page at a time.

Long documents -- TeX Word Performance
I would like to clarify one misinformation that 'BaKoMa TeX Word is efficient only for short documents, because it runs TeX on background'.

In one side it is true that BaKoMa TeX Word runs TeX to display document. This approach provides True WYSWIWYG Preview (100 % compatibility with output of native LaTeX). However, BaKoMa TeX Word has no degradation of performance at editing long documents. Our users edit books of 500 and more pages and enjoy that speed is even better then at editing one-page document !!!
The reason of this scalability is that only one page of document is reformatted at editing document.

How it does this, I don't know. They do claim what is shown on the screen is equivalent to what will be printed on the pages. I doubt that that is entirely true. Perhaps the look (fonts, kerning etc.) of the document is exactly the same, but the exact location on the page is influenced by more than only the content of the current page.

  • 2
    The key is not to re-parse anything above the edit point. If you change something on the first page, then to get back to page 500 you have to wait for it to re-render the entire document. – bobobobo Aug 28 '12 at 18:39
  • 2
    @bobobobo, still some changes can propagate backwards in the document. For example references. If they have another trick with references I don't know. May be they found a set of tricks that get you 99% close to the real output for most (simple) applications. – alfC Apr 18 '14 at 4:44
  • 3
    Really, BaKoMa TeX uses some kind of incremental data processing, which takes into attention TeX registers and strings, saving and restoring them when required. Another name of such algorithms is incremental formatting. It is nearest analog of incremental compilation. In short, it is slighly more complex then reprocessing one page in loop. – Basil Malyshev May 25 '17 at 17:00
  • 1
    @alfC Bakoma TeX has a button for updating cross-references and citations. I assume that this step reruns LaTeX/Bibtex completely, to obtain a correct auxfile, but this process does indeed fail for some details (e.g. the connector lines in the todonnotes package). – kdb Sep 7 '18 at 12:19
  • 1
    As some speculation: (La)TeX has the \dump command, which dumps the current state of the TeX engine to an .fmt file. That file can then be used to preinitalize the TeX engine with state. This can be used to cache the preamble (shaving of 1-2 seconds per pdflatex run for complex documents) and they may be using it to store the state at the beginning of the page. A pdflatex run outputs page-by-page, so this would allow to quickly redo only a part of the document. – kdb Sep 7 '18 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.