Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any small and simple program (or even library) that can render LaTeX locally as you type?

I'm looking for something pretty much like this page, which auto-renders immediately as you type, except that it:

  • Must not need any internet connection

  • Should be as "lightweight" as possible (it shouldn't even depend on a browser, if that can be avoided... a standalone executable would be ideal)

(The goal is to avoid going having to go through the pain of creating LaTeX documents every time you want to write a little expression to paste somewhere else, but without needing an internet connection or another program to run it.)

If there is even a C/C++-compatible library that could convert a basic LaTeX equation to a PNG file (or SVG or whatever), that would be fine too; I could write a front-end for it pretty easily.

share|improve this question
    
Try gummi. I use it on Linux but they say there is a Windows .exe as well. –  vaettchen Feb 7 '12 at 8:06
    
By 'LaTeX' here do you mean TeX-like math input? The linked web page certainly does not recognise for example \begin{document}! –  Joseph Wright Feb 7 '12 at 8:19
    
@vaettchen: The server seems down right now. xD I'll check it later, thanks. –  Mehrdad Feb 7 '12 at 8:22
    
@JosephWright: Oh yes, right... should've said TeX I guess. :) –  Mehrdad Feb 7 '12 at 8:23
1  
@matth: Ohey I just searched for LaTeXiT windows and found these... specifically, KLatexFormula. The font is ugly/too soft for my eyes but otherwise it seems to be what I want... –  Mehrdad Feb 7 '12 at 9:12

3 Answers 3

up vote 8 down vote accepted

The website you point to is using MathJax to render the LaTeX. If you don't mind using a browser, then you can simply download MathJax, unpack the zip file, go into the test subfolder and open sample-dynamic.html in your browser. This is effectively an equation editor. You can make a custom web page to cater to your needs.

enter image description here

Note: As it is this requires you to hit the return key to render. That should be simple enough to alter. Grabbing the equation as a PNG could be a little more complex to achieve.

share|improve this answer
    
In terms of "lightweightedness", what is the size of the download? Also, would it be possible to modify the code to typeset the equation on-the-fly rather than pressing RETURN? These are just inquisitive questions... –  Werner Feb 7 '12 at 7:13
    
Since the site that the question points to is using MathJax and updates on the fly, yes to the second question. The download is ~15MB, so it depends on your definition of light. Lighter than a full install of TeX Live anyway. ;) –  qubyte Feb 7 '12 at 7:16
    
I kinda already knew about MathJax but was hoping for something more lightweight (15 MB is kinda huge for this, especially when combined with a > 20 MB browser)... +1 thanks anyway. –  Mehrdad Feb 7 '12 at 8:23
    
@Mehrdad: The problem you're going to have is that TeX is simply big. If you want even a fraction of the functionality then I'm afraid you're stuck. Perhaps you can strip out some of the unnecessary fonts that come with MathJax. A modern system should include the necessary fonts without having to use them. You can also strip out docs and perhaps more stuff taking you down to 5MB. –  qubyte Feb 7 '12 at 10:59
1  
@MarkS.Everitt: Hmm... I might actually give that a try, thanks for the suggestion. –  Mehrdad Feb 7 '12 at 11:06

Is there any small and simple program (or even library) that can render LaTeX locally as you type?

The only freely available program that I know of which can handle on-the-fly rendering of TeX and friends is LyX.


(The goal is to avoid going having to go through the pain of creating LaTeX documents every time you want to write a little expression to paste somewhere else, but without needing an internet connection or another program to run it.)

If there is even a C/C++-compatible library that could convert a basic LaTeX equation to a PNG file (or SVG or whatever), that would be fine too; I could write a front-end for it pretty easily.

As far as libraries go, you could look into running MathJax. This could be embedded into a C++ program using the WebKit browser or even into a command-line tool using a "headless" browser like PhantomJS. Some more options are listed in:

What parsers for (La)TeX mathematics exist outside of the TeX engines?

The issue that prevents a proliferation of good parsing libraries for TeX math is that TeX has a context-sensitive grammer that can be altered on the fly. Because of this, it is easy to come up with pathological examples that will confound any parser that is not TeX:

\catcode`/=13
\let/\over

$y = {-b \pm \sqrt{b^2 - 4ac}} / {2a}$

\end

Add users eventually wanting to use "a specialized macro from LaTeX package X" and the most robust contenter left is an actual TeX engine.

share|improve this answer
    
+1 for PhantomJS, it would be useful for other things as well; thanks. –  Mehrdad Feb 7 '12 at 8:24

The closest thing to your needs probably is latexmk. Every time you save your #.tex-file, latexmk runs LaTeX, pdfLaTeX and probably even LuaLaTeX, plus BibTeX, if you need that also. I propose to use Sumatra-PDF to view the PDF. This great piece of software does not lock the PDF, when opened, so latexmk can change the PDF and Sumatra-PDF will render it more or less immediately.

Maybe you can connect a second screen to your computer and have on one screen your *.tex-file and on the other the PDF.

Besides that: Compiling your document every second probably won't work, while you type. Any open bracket will cause an error.

share|improve this answer
    
What you describe, does only work with the -pvc option, or has the default behaviour been changed? –  Speravir Feb 7 '12 at 18:37
    
@Speravir Yes, -pvc is needed, or more generally: you have to set up latexmk properly to use it the way I described. –  Keks Dose Feb 8 '12 at 11:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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