LaTeX is a typesetting program widely used in sciences, and it is specially popular in academia.  However, even some LaTeX avid users ignore that there is a whole plethora of tools that enhance collaborative LaTeX editing, making it a powerful framework for collective document creation. We’ll cover some of these in this post.

Collaborative LaTeX: tools of the trade

Version control

You probably are familiar with some sort of version control system or VCS (if not, check why you should be). LaTeX documents are perfect candidates to be used with version control: a bunch of text-only files.  Version control becomes even more efficient if binary files (such as images) do not change over time.

I use git, both with self-hosted repositories, or using services that offer private repositories for free, like BitBucket. Some people use cloud file hosting services like Dropbox to host LaTeX files as an alternative to version control. Those cloud services keep track of document history, but users lose more advanced features of version control, such as branching or milestones. Moreover, Dropbox-like solutions are less than ideal when merging changes in simultaneously edited files. If the work is going to be collaborative, it is wiser to use these services as secondary backups only, just in case.

As with other programming languages, it is highly advisable that peers share the same versions of LaTeX packages. This will avoid compatibility issues when building documents.

I will not enter into details about how to work with LaTeX and VCSs. If you are interested, this Stackoverflow answer gives an excellent starting point for an efficient LaTeX and git workflow. Needless to say, it is not wise to track all the files present in a LaTeX project directory, tracking the ones necessary for compilation is enough.

Latexdiff

Latexdiff is a Perl script designed to highlight changes between different versions of LaTeX documents. It  is a useful tool for collaborative LaTeX editing, e.g. to show some corrections graphically. If the sentences have not been divided in different lines (i.e. one sentence per file line), Latexdiff is a must to show document changes in a sane way.

Usage:

$latexdiff old.tex new.tex > diff.tex$ pdflatex diff.tex


Original text (left) and differences with a newer version (right) using latexdiff

Tools like git-latexdiff (chances are that equivalent tools exist for your VCS of choice) act as a wrapper of latexdiff to compute differences between different versions of documents, when stored in a VCS. The resulting tex file can be compiled as a normal file to visualize changes in a PDF file.

scm-latexdiff goes one step further, as it creates PDF documents showing differences between versions. It only works with git and Mercurial repositories, though.

Todonotes

Todonotes is a LaTeX package that allows inserting To-do notes on the document. Those notes can prove useful to communicate thoughts, intentions to the other editors. Communication by using the document as a base can be an efficient method of transmitting thoughts to the team. You might ask, “What is the difference between todonotes and regular PDF annotations?” With this collaborative LaTeX tool, those notes can be read in any PDF editor and the changes can be easily tracked through VCSs.

And, it is not only about colored to-do notes; features also include inserting a dummy figure, stating that a figure should be inserted there. The package can even create  a list of pending to-do notes.

If you plan to use todonotes in a document with tight margins (most academic paper templates), you can provisionally change the paper size. Or, when using two-column layouts, changing margin length might also be a solution.

Todonotes example

All-in-one solutions

Recently, some online editors have been created with collaborative LaTeX in mind. Most of these services are not free (as in free beer); it is necessary to pay a fee to use them or to get full functionality.

Some of the most popular examples are Verbosus, ShareLaTeX, LaTeXlab, writeLaTeX and Authorea. I scarcely know them, but they look pretty similar on the surface: most of the work is carried out in a web browser  (editing, compiling…), and they usually have some sort of version control working underneath. There are, however, some differences: for example, LaTeXlab integrates in Google Drive’s environment and ShareLatex is free and open source, so you can check their code and install a similar service  in your server.

Personally, I prefer old-style, non-web solutions. The reasons vary: full control on the process, the possibility to use whichever text editor I want… that way, each member can use their environment of choice. But, I understand that online LaTeX editors can be a good choice for people aiming ease of use, or do not want to get their hands dirty. As always, user preferences transform an alternative into the best option.

More online tools can be found at this Tex Stackexchange answer. Also, the LaTeX wikibook has a whole section devoted to collaborative LaTeX editing.

Happy TeXing!