LaTeX hacks to save your life (and your co-authors')

In light of this recent study by Knauff and Nejasmic (2014) that makes a lot of presumptive leaps on the utility and effectiveness of \LaTeX in scientific writing, my case for the utility of \LaTeX for every equation, reference, table, figure, and revision will hopefully sit well with MS Word loyalists (I used to be one too).

We conclude that even experienced LaTeX users may suffer a loss in productivity when LaTeX is used, relative to other document preparation systems. Individuals, institutions, and journals should carefully consider the ramifications of this finding when choosing document preparation strategies, or requiring them of authors – Knauff and Nejasmic (2014)

At the same time, this blog-post (and scores of other text documents that I have written) was typed in Programmer’s Notepad. I could have very well typed this in Vi/Vim/EMACS/Notepad/WordPad/MS Word or any editor of choice – in fact, I write all my \TeX files (and C/C++) in Programmer’s Notepad/Vi. The fundamental difference between an editor (which MS Word is), and a typesetting language (which \LaTeX is) is often overlooked. While I point you to some very valid arguments laid forth by Claus Wilke here, a breakfast conversation with him over the utility of \LaTeX over MS Word prompted me to come up with a list of cool things that you can do using \LaTeX, which you invariably will have trouble with achieving in MS Word to produce publication quality documents. My objective here is to point out some easy to use \LaTeX hacks, and definitely not to belittle MS Word’s utility – all journals will end up typesetting your text nevertheless in accordance with their requirements. As Claus rightfully points out, there is also no one correct/perfect tool to use.

John Lees-Miller and I collaboratively editing the \LaTeX version of this post on www.overleaf.com


  • Templates – Most (if not all) journals, publishers, and University presses have \LaTeX templates. For example, see here for a comprehensive list of templates for biology journals. Most templates come with a ‘.cls’ file (\LaTeX class), a ‘.sty’ file (\LaTeX style), and a ‘.bst’ file (BiB\TeX style). Once you have your basic text in ‘.tex’ files (I like to either organize my text by sections, or easier still, just one ‘main.tex’ that contains all text), all you really have to do is to include the style files in your main file, and compile it (using a compiler of your choice – start here or here for some good introductory documentation on creating basic \TeX documents).
  • Tables – I despise table formatting in MS Word. I daresay a lot of people do. The reason – there really isn’t a smart way to insert/copy-paste tables into a Word document without some considerable amount of resizing/reworking (see link for some tips). Having wasted hours on resizing things, only to be completely offset upon insertion of some other text or figure, I decided to stick to \LaTeX for tables. Here’s the kicker though – making neat tables in \LaTeX takes quite the learning curve. But what with smart packages (see XTable, or Excel-to-LaTeX), this job just got so much easier. I simply save my tables in some easy format (CSV/Tab delimited/XLS/XLSX/ODS), read it into R, convert it to \LaTeX markup. Works like a charm, every time. For larger tables, I’d recommend flipping them sideways using the `rotating’ package. See this link for some easy instructions.

ugly

Before (MS Word) – Blarrgh!


pretty

After (\LaTeX) – Aha!

  • Equations/Mathematical Notation – This goes without saying – if you’ve ever tried writing equations using MS Office, you know how it can get out-of-hand. \LaTeX clearly has an upper hand in this area (surprisingly the only area that reflects a plus in this controversial study by Knauff and Nejasmic, 2014. See this link for detailed instructions
  • Citation Management – While several citation managers are now available (along with plug-ins for MS Word – see this comprehensive list), reference management in \LaTeX is by far the easiest I have encountered. I use my citation manager to download references into BiB\TeX style, and call it from inside my ‘main.tex’ file. Editing/adding citations just requires editing the ‘.bib’ file – everything else changes automatically. I also use the ‘hyperref’ package to create dynamic references across the document. There are some downsides to downloading references in BiB\TeX format from citation managers (and Google Scholar) though – capitalization isn’t usually preserved and would require some manual editing to your ‘.bib’ file prior to compiling. However, online collaborative tools for \LaTeX like Overleaf are integrated with citation managers (eg. Zotero, Mendeley)
  • WYSIWYG Editors – \LaTeX no longer requires separate layers of markup and compilation – with the coming of online collaborative \LaTeX editors like ShareLatex, and Overleaf (formerly write\LaTeX) , etc, collaborative \LaTeX writing has reached new levels of ease of use – while you type your markup on one pane of the browser window, the tools automatically compile and display your markup onto the other pane. Other significant features of online editors include version control (sensu git/svn), easy commenting, hundreds of ready-made templates, secure sharing/collaborating, cloud-based backups, spell-check, and support.
  • Pre-print submission Pre-print servers (eg. arXiv, bioRxiv, PeerJ) require PDF/\LaTeX uploads – something inherently, and seamlessly incorporated into building \LaTeX using online editors mentioned above.

Overleaf has a full collaborative rich text editor, including tracked changes and comments, which makes it very friendly to collaborators who are new to \LaTeX. We also have full git integration in beta (https://www.overleaf.com/blog/195), so you can pull from and push to Overleaf projects via git – John Lees-Miller, Cofounder, Overleaf.com

You can access a \TeX version of this post here. I used latex2wp to convert my \TeX file to a WordPress friendly HTML format.
Addendum:
Here’s a link to a webinar on \LaTeX for biologists, put together by John Hammersley, co-founder of Overleaf.com.

This entry was posted in howto, science publishing and tagged , , . Bookmark the permalink.