# My LaTeX Setup

When I write almost anything related to physics, I use LaTeX. For the uninitiated, LaTeX (pronounced lah-tek or lay-tek, anything but lay-teks) is a markup language widely used in the physics community because it allows authors to create automatically-formatted manuscripts complete with beautifully typeset equations, footnotes, references, figures, captions and more. If this doesn’t sound like something you need, then you can go ahead and skip this post. But if you’re a physicist, you should be using LaTeX. The learning curve is a bit steep, but well worth the efforts. Since college I have used LaTeX for all my technical writing including papers, my dissertation, and ongoing notes on my work. There is no shortage of guides to learning and using LaTeX which I will not try to replicate here. Instead, I will offer a few remarks on how I use LaTeX in my work and some of the tips and tricks I’ve learned over the years.

### My setup

Since I am a lifelong Apple fanboy, I do all my work on a Mac. My preferred TeX editor is TeXShop, but I don’t have strong opinions about it, it’s just what I know. The LaTeX distribution for macOS is called MacTeX. The full MacTeX installer is over 3.2 gb, and most of that is for obscure packages and languages that I’ll never need, so I use the smaller installer called BasicTeX, which is only 78 mb. BasicTeX does not include all the packages I need, but it includes a package manager tlmgr that can be used to download any additional packages using the command:

sudo tlmgr install PackageName

### BibTeX

For producing my bibliography I use BibTeX, an extension of LaTeX. The beauty of BibTeX is that you need never again concern yourself with the formatting or ordering of your citations because BibTeX does that all automatically. If you want to cite a paper, simply go to the journal’s website, download the bibtex snippet that goes with the paper, copy and paste it into your .bib file, and cite it using the \cite{} command.

### Git

One of the best decisions I ever made in my scientific career was to start using git for tracking changes to my papers. Git is open-source version tracking software usually used for programming. It is often used with cloud services like github, but you can also run git locally on your computer. TeX source code is just like any other source code, so you can use git with it just like you would for C++. Using git means that I can always recover my manuscript to a previous state, and I can maintain multiple versions of the same manuscript using branches. I used this feature heavily in my dissertation when I had to prepare two different versions, one for the BU library and one for Springer.

As a writer, it is always a challenge to “murder your darlings,” i.e. delete text that no longer makes sense, no matter how lovingly it was crafted. Whenever I set out to do this, there’s always a voice in the back of my head saying “but what if you want this later?” Using Git is a great way to silence that voice because I know I can always get it back, even if I never end up needing to.

A few tips for Git + LaTeX:

• Write each sentence in your .tex file on its own line. This makes tracking your changes easier.
• Don’t commit your PDF, at least not every time. Git is not as efficient at keeping track of changes to PDFs and your repo may end up requiring a lot of storage space.
• Don’t track the auxiliary files generated by tex like .aux, .log, etc.
• You can also collaborate on papers using a private git repo on a service like github.

### A few of my favorite LaTeX packages

All these can be downloaded through texlive manager. The links below are just for finding the documentation.

• REVTeX: APS’s LaTeX package that automatically formats documents in the style of each of their journals.
• cleveref: A package that automatically inserts the appropriate text just as “Fig.” or “Eq.” in front of your figure and equation references. Just replace
Fig. \ref{f:someFig}

with

\cref{f:someFig}
• braket: Effortless Dirac bra and ket notation.
• amsmath: Among other things, includes the align environment, which is essentially a drop-in replacement for the equation environment that makes it easy to format multi-line equations.
• latexdiff: A program that takes two tex source code files and outputs a source file that highlights the changes between the two versions, showing new text in blue and striking through deleted text. This is much easier to read than directly comparing the tex source files. On the command line execute:
latexdiff oldVersion.tex newVersion.tex > difs.tex

You can then compile difs.tex as you would any other tex file.

## 3 thoughts on “My LaTeX Setup”

Hi, Adam. Re: git for writing papers, how much overhead is involved in adopting it and how long did it take you to get accustomed to using it for this purpose? Do you always use it now or just sometimes? I’m always wary that such tools that are supposed to make my life simpler will actually make me less efficient.

On a tangential note: do you have a tool of choice for managing your library of papers?

Liked by 1 person

1. iaizzi Post author

The overhead is pretty small and if you don’t end up using it, all the git stuff is in hidden directories, so its relatively out of the way. This tutorial will cover everything you need: https://www.codecademy.com/learn/learn-git

I use Mendeley for organizing my papers, but I am not at all satisfied with it, so I can’t really say I recommend it.

Like

This site uses Akismet to reduce spam. Learn how your comment data is processed.