12

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?

Thorsten
  • 12,872
Raphael
  • 245
  • 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. – yannisl Jan 14 '12 at 08: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. – Andrew Stacey Jan 14 '12 at 10:16
  • See also: https://tex.stackexchange.com/questions/3/compiling-documents-online – user202729 Oct 15 '21 at 12:44

4 Answers4

9

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.

Sharpie
  • 12,844
  • 6
  • 48
  • 58
7

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.

Werner
  • 603,163
5

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.

celtschk
  • 2,438
  • 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. – Raphael 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
3

The site https://learnlatex.org is a tutorial being developed which works exactly as you describe. Each example may be run using an online service (Currently using https://latexcgi.xyz) with the results being shown inline in the page (using PDF.js, so as to not require a built in PDF reader in the browser).

David Carlisle
  • 757,742