Category: LaTeX

Making LaTeX easier with Authorea and writeLaTeX

When I’m curious about exploring a new technical skill (such as a new programming language, a software tool, a development framework, etc), I typically try to integrate its use into my normal work schedule. I select several tasks that I have to do anyway, and force myself to use this new skill to solve the task. It ends up taking more time than it would have if I had just stuck with skills I was already comfortable with, but in the end I’m usually better for it. Sometimes, I love my new-found skill so much that I begin using it every day in my research. Often, however, it just becomes another addition to my technical “toolkit”, increasing my productivity and really enabling me to choose The Best Tool for the Job for my future work.

This was my experience with \LaTeX. As an undergraduate, I had seen several colleagues use it and had fiddled with it a bit myself. It wasn’t until later though, as a first year grad student, that I really buckled down and forced myself to learn it while writing a paper for a computational statistics class. Yielding control of text and image placement to the LaTeX typsetting system took some getting used to, but I soon came to appreciate the quality of documents I could produce with it. Focusing on the concerns of content and presentation separately, as I had previously learned to do in web development, was another big bonus I recognized early on. The fact that LaTeX source documents are plain text made it easy to maintain a revision history with tools like svn and git, which I had also come to appreciate early on in my graduate career. And, of course, there is absolutely no comparison to typesetting mathematical formulae on LaTeX versus on Microsoft Word. See this thread for a great discussion on the benefits of LaTeX over Word.

I strongly encourage all of my colleagues to consider using LaTeX for their next publication. That being said, I understand that there is a bit of a learning curve with LaTeX, and setup/installation isn’t trivial for a beginner (unless you’re running Linux). However, I’ve seen a couple of web applications recently that should make the jump from Word to LaTeX much easier. Authorea and writeLaTeX are both web-based systems for authoring documents using LaTeX markup. While editing, Authorea renders the markup in HTML and only shows plain text for the section you are currently editing (of course, the final document is downloaded in PDF format). writeLaTeX uses a different approach: a window for editing the LaTeX markup, and another window for previewing the typeset PDF file.

Both of these applications are very easy to use. Both enable you to collaboratively edit with colleagues. And both are free to use. If you’re still using Microsoft Word to write your research manuscripts, consider learning LaTeX and getting your feet wet with one of these new tools!


Frustration with Word and Endnote on Mac

Recently, I’ve been using Microsoft Word and EndNote to write a significant paper for the first time in several years (my advisor and I used LaTex + git mor my first first-author paper). After using it on my MacBook for several weeks with no more than the usual amount of frustration one can expect from EndNote and Word, EndNote stopped working all of a sudden. Every time I tried to insert a reference, it would get frozen at the “Formatting Bibliography” step and hang indefinitely. Force-quitting and restarting the programs didn’t seem to help anything.

After a bit of searching, I came across this thread which provides a simple solution. The culprit for the unstable behavior seems to ba an OS X system process called appleeventsd, and force quitting the process with this name using the System Monitor restored normal Word/EndNote behavior. I have done this several times in the last couple of weeks and haven’t seen any adverse side effects, so I will continue to do so until something goes wrong or some OS 10.8 upgrade provides better stability or until my collaborators magically decide that LaTeX + git + BitBucket is in fact a superior solution after all!

Minted package for LaTeX: syntax highlighting for source code typesetting

In a previous entry, I briefly discussed the benefits of syntax highlighting for text editors. These benefits also apply to source code that is embedded in a web page or a document for distribution. If you use LaTeX to typeset school assignments and/or scientific publications (if not, you should be), then the minted package for LaTeX is excellent for typesetting source code with syntax highlighting in your documents.

Here is an example of a document containing a block of source code that uses minted for syntax highlighting.

\documentclass[letterpaper, 10pt]{article}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae egestas nunc. Nullam non elit lacinia ante auctor gravida. Quisque id vestibulum dolor. Phasellus fermentum ante id nisi euismod nec ornare lectus fringilla. Praesent metus orci, porttitor vel lobortis eget, scelerisque non magna. In gravida felis vitae urna interdum dignissim. Maecenas tempus dui ut ipsum interdum molestie. Ut et dapibus risus. Etiam tempus, sapien quis feugiat ornare, nibh massa aliquet magna, quis interdum leo lacus eget urna. Proin aliquam lacinia metus, vitae posuere urna luctus nec. Vestibulum vitae lacus non orci placerat adipiscing quis id eros. Ut in enim orci, id pellentesque diam. Nulla dapibus sodales commodo.

  #include <zlib.h>
  #include <stdio.h>
  #include "kseq.h"
  // STEP 1: declare the type of file handler and the read() function
  KSEQ_INIT(gzFile, gzread)
  int main(int argc, char *argv[])
      gzFile fp;
      kseq_t *seq;
      int l;
      if (argc == 1) {
          fprintf(stderr, "Usage: %s <in.seq>\n", argv[0]);
          return 1;
      fp = gzopen(argv[1], "r"); // STEP 2: open the file handler
      seq = kseq_init(fp); // STEP 3: initialize seq
      while ((l = kseq_read(seq)) >= 0) { // STEP 4: read sequence
          printf("name: %s\n", seq->name.s);
          if (seq->comment.l) printf("comment: %s\n", seq->comment.s);
          printf("seq: %s\n", seq->seq.s);
          if (seq->qual.l) printf("qual: %s\n", seq->qual.s);
      printf("return value: %d\n", l);
      kseq_destroy(seq); // STEP 5: destroy seq
      gzclose(fp); // STEP 6: close the file handler
      return 0;


Here is the final typeset product.

For more information about the minted package, see the minted project homepage. Note that minted relies on the Python Pygments syntax highlighter, which can be installed with the following command.

sudo easy_install Pygments