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.

I am currently in the writing of an online LaTeX tutorial and I was wondering if it was possible to have something similar to learnpython.org but for compiling and editing on the fly simple LaTeX documents on a page? Because I would love to embed this on my website so that readers could interact with LaTeX without the need to install something or having to leave the page.

An example would be to compile this in browser in the form of an image or PDF:

\documentclass{book}
\usepackage[latin1]{inputenc}    
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}     


\title{L'histoire de bob}
\author{John}
\date{June 6 2078}
\begin{document}

\maketitle


\part{Introduction}

Some stuff

\end{document}

Is it possible? If it isn't, are there any possible alternatives?

share|improve this question

migrated from stackoverflow.com Jan 14 '12 at 7:42

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

1  
@bobicool For equations there is MathJax, which is JavaScript driven. Wikipedia has something very similar. For LaTeX itself you can capture the input and sent it to the server. Depending on the server language you can then run the executable and process the input. I have tried this on localhost using php and there are no issues. However, security needs to be addressed on a public system. There is nothing off-the-shelf though that I know. –  Yiannis Lazarides Jan 14 '12 at 8:48
1  
For the purpose of an online LaTeX tutorial I would not use MathJaX. Whilst it is based on LaTeX, it is not LaTeX and any discrepancies might serve to confuse those for whom you are writing a tutorial. –  Loop Space Jan 14 '12 at 10:16
add comment

3 Answers 3

up vote 8 down vote accepted

You could look into the Common LaTeX Service Interface which powers ScribTeX and, I believe, LaTeX Lab. The CLSI exposes TeX compilers as a web service by accepting requests with document code, compiling the documents in a sandboxed environment and returning the PDF results.

For displaying PDF output in the browser, you might want to check out Mozilla's PDF.js project. The code is still in beta, but the feature set and rendering quality is pretty impressive.

share|improve this answer
    
This looks like some good code. –  Yiannis Lazarides Jan 14 '12 at 19:08
add comment

It is definitively possible, as shown by the (German language) Kochbuch für LaTeX ("cookbook for LaTeX"). It has a very nice interface where you can choose to generate an image, a dvi file or a postscript file). Currently it doesn't seem to work correctly (I'm not able to get output files), but it definitively did at some time. There are many mirrors of that (but I didn't find one which currently works), so the author might be willing to share the code with you.

share|improve this answer
    
I don't know if it's me, but all I see is some text and images, I can't seem to find the nice interface you are talking about. –  bobicool Jan 14 '12 at 15:03
1  
@bobicool: In the chapters, besides the text/images, you'll also find radio buttons left of the examples. If you select one and then click "Zur Küche" ("to the kitchen") at the bottom of the page, you'll get to a page with an input box pre-filled with the example, ready to be modified at your heart (or empty, if you didn't select anything). Also on the page there are some radio buttons to select whether you want an image, or a dvi or ps to download, and a button "TeX starten" ("start TeX") which calls (or called, at the time when it worked) LaTeX and gives you the output in the selected form. –  celtschk Jan 14 '12 at 15:40
add comment

You could use ScribTeX which runs a TeX Live 2009 distribution (at the moment). It allows you to create files (for, say, storing .bib content) and even compile using pdflatex, latex or xelatex. In fact, your document compiled without problem.

It does not require a login, but temporary users would lose their saved content without one.


Of interest, on a smaller scale, might be the Online LaTeX equation editor. It seems like this can be driven from your own web page (click on the install link). However, this only provides limit online capability for editing equations and not entire documents.

share|improve this answer
    
Is it possible to embed ScribeTeX on a webpage? –  bobicool Jan 14 '12 at 2:52
    
@bobicool: I'm not familiar with doing that kind of thing. –  Werner Jan 14 '12 at 3:36
1  
If you're only looking for math, MathJax is the best (and most common, I think) option. Other se sites like physics and math use it, I believe. –  Tikhon Jelvis Jan 14 '12 at 3:38
2  
For a tutorial, MathJaX is not a good option. It is not LaTeX and so the differences would confuse the students when they come to write real LaTeX. –  Loop Space Jan 14 '12 at 10:16
add comment

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.