# Selfhosted collaborative webbased LaTeX editor

I'm searching for a LaTeX editor that I can run on my GNU/Linux server and allows realtime collaboration as well as online compiling and previewing.

What I've tried so far:

So my question: Can anyone suggest such an editor that is actually working or does anyone know how to solve the issues I encountered with FlyLaTeX and Cloud9 IDE.

Edit: I wrote an email to the developer of FlyLaTeX and he explained that FlyLaTeX currently doesn't support additional LaTeX packages. So FlyLaTeX is not an option right now.

I stumbled across etherTeX, based on etherpad lite. I'll try this one out.

• Is writelatex not an option ? – percusse Apr 30 '13 at 20:35
• selfhosted, so perhaps not, unless this is Hammersley. – kan Apr 30 '13 at 20:36
• @percusse I want to host it on my own server which as to my knowledge isn't possible with writelatex. – FSMaxB Apr 30 '13 at 20:37
• @FSMaxB Oops, missed that part. – percusse Apr 30 '13 at 20:38
• @FSMaxB Is this related ? texlive.js possible? – texenthusiast Apr 30 '13 at 20:40

An other solution for "selfhosted collaborative webbased LaTeX editor" is sharelatex. They have got an Homepage where you can work with there system but you can also host it on your own Server. Here is the link to the code: https://github.com/sharelatex/sharelatex

You can use the CoCalc Docker image as a very easy to install free open source self-hosted collaborative web-based LaTeX editor. See https://github.com/sagemathinc/cocalc-docker. To test out how it feels, go to https://cocalc.com, make a project, click +New, make a LaTeX file, and test out editing. This is a full featured latex editor, with forward and inverse search (double click the preview on the right to go to the corresponding point on the left, etc.). You can split the editor pane on the left to view two points in the document at once. There is syntax highlighting, code folding, and the TimeTravel button let's you view every past version of the document (see why it suddenly doesn't compile!). Sign in with another browser (or account) to test realtime collaborative editing.

I originally wrote this collaborative LaTeX editor to support writing the book http://wstein.org/rh/ with Barry Mazur, but Harald Schilly and others have greatly improved it over the years.

Since I'm the guy that started SageMath, the LaTeX editor in CoCalc also fully supports SageTex out of the box, and more generally, you can completely customize anything about the compilation pipeline.

A possible solution would be to use any online/selfhosted collaboration tool (Cloud 9/Collide etc.) to do the editing to a .tex file and then use a small php or bash script to process the TeX file through PHP/Shell on the click of a button.

Using some PHP like this perhaps:

private function runXeLaTeX($dir = '/tmp',$fileToUse, $noPDF = FALSE) {$descriptorspec = array(
0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
2 => array("file", $dir."/error-output.txt", "a") // stderr is a file to write to );$cwd = $dir; //$env = array('some_option' => 'aeiou');

if ($noPDF) {$process = proc_open('/usr/texbin/xelatex -no-pdf '.$fileToUse.'.tex',$descriptorspec, $pipes,$cwd);
}
else {
$process = proc_open('/usr/texbin/xdvipdfmx -vv '.$fileToUse.'.xdv', $descriptorspec,$pipes, $cwd); } if (is_resource($process)) {
// $pipes now looks like this: // 0 => writeable handle connected to child stdin // 1 => readable handle connected to child stdout // Any error output will be appended to /tmp/error-output.txt fwrite($pipes[0], '<?php print_r($_ENV); ?>'); fclose($pipes[0]);

//          echo stream_get_contents($pipes[1]); fclose($pipes[1]);

// It is important that you close any pipes before calling
// proc_close in order to avoid a deadlock
$return_value = proc_close($process);
}
return $return_value; }  • FlyLaTeX and Cloud9 IDE are both based on NodeJS. And are not running on a PHP capable webserver. As I don't know how to work with nodejs nor how to integrate PHP in it, this isn't anything I could do. I tried doing it myself by combining the ace text editor with a PDF preview, but my PHP and JavaScript skills are insufficient. – FSMaxB May 3 '13 at 10:04 Also have a look at http://fiduswriter.org/ It is developing quickly and supportts collaboration and uses LaTeX code in its backend. This seems to be just such a solution: Collaborative Writing Using Etherpad and LaTeX This might not be exactly what you want but you can run a simple collaborative webbased LaTeX editor by running PMWiki on your server with MathJax enabled. To enable MathJax on your server you can simply edit /pub/skins/myskin/myskin.tmpl  file by adding the following into the header <script type="text/x-mathjax-config"> MathJax.Hub.Config({tex2jax: {inlineMath: [['$','\$'],
['\$','\$']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

• Thanks for your suggestion, but I need to work on full LaTeX documents and create PDFs as an end product. – FSMaxB May 11 '13 at 5:02
• @FSMaxB PMWiki has print command which will get you PDF. – Predrag Punosevac May 11 '13 at 12:37
• But Mathjax doesn't have full LaTeX support. I am looking for the normal output of pdflatex or xetex or whatever to be displayed in the browser. – FSMaxB May 11 '13 at 14:15

FlyLatex now (since early June 2013, I believe) supports extra packages. Put any extra packages in the "texpackages." The packages/images will be available to all users (global-level access). I made it this way to save space for the administrator. But I'm working on adding an option to make packages/images uploadable and accessible on a per-user level.

Using FlyLaTeX is an option if no extra packages and document classes are needed. It can be installed by performing those steps (when using Ubuntu Server 12.04):

• Create a user for the installation of FlyLaTeX e.g. "flylatex"
• Install git and mongodb with sudo apt-get install mongodb git
• Change to the home directory of the new user and install the node version manager (git clone git://github.com/creationix/nvm.git and echo '. ~/nvm/nvm.sh' >> ~/.bashrc)
• Install nodejs (e.g. v0.10.5 nvm install v0.10.5)
• Install FlyLaTeX (git clone git://github.com/alabid/flylatex.git)
• Start FlyLaTeX with nvm use v0.10.5; node ~/flylatex/app.js

This isn't working for me, as I need extra LaTeX packages, I just post this so it can be useful to others.

Overleaf seems to be a really good option. It is a pleasure to use their editor and their tutorials are to my mind one of the best recurses for learning LaTeX.