# Install LaTeX, AASTeX, and MN2E on Mac OS X

by on July 6, 2010

Update (March 8, 2013): New information on adding directories for package management.

LaTeX, pronounced “la tech”, is a typesetting program that we use to write our papers (instead of Word or somesuch nonsense). Over the long US holiday weekend I got LaTeX and all of its bits installed on my new 13″ MacBook Pro (named Gloria). In this post, I’ll walk you through the installation and setup that should work for any of the code and text editors that Tom discussed a couple weeks ago (e.g., TextMate, TexShop, Emacs). In a future post, I’ll describe how to get TextMate setup as the primary LaTeX editor.

Read on for step-by-step instructions for installing LaTeX, AASTeX, MN2E, and more. One new thing that I learned was how to include both EPS and PDF figures in the same document!

The easiest way to get LaTeX onto OS X is via MacTex. I recommend downloading the full package (~1.3 GB) and then customizing the install. The package comes with BibDesk, TexShop (which everybody seems to love except me), as well as lots of other stuff.

MacTex uses the paths.d method to modify the PATH environment variable. This works well if you don’t have your path explicitly set in the .cshrc/.tcshrc/.bashrc. To check if your path is set up correctly, in Terminal, typing which latex on the command line should return /usr/texbin/latex.

You’ll need to create a few directories which will store packages for producing a certain “look-and-feel” to your documents, as well as help you manage your references. Under the ~/Library/ directory, add the following subdirectories:

~/Library/texmf
~/Library/texmf/tex
~/Library/texmf/tex/latex
~/Library/texmf/bibtex
~/Library/texmf/bibtex/bst
~/Library/texmf/bibtex/bib

Thanks to Vicki in the comments for pointing out this last step!

AASTeX is the package for preparing astronomy publications for ApJ, AJ, and PASP. Download the AASTeX package and put it in ~/Library/texmf/tex/latex/aastex52. If you’re unfamiliar with AASTeX, a handy guide [PDF] comes included in the download. To use the AASTeX style, be sure this is the first line of the tex file:

\documentclass{aastex}

## Setup emulateapj

If you want to get the fancy look of a two-column ApJ paper, you’ll want to use emulateapj. The MacTex-2009 package includes an old version so you’ll want to donwload the new one — emulateapj.cls — and put it in ~/Library/texmf/tex/latex/emulateapj.cls. When you want to use it instead of the AASTeX format, modify the tex preamble:

%\documentclass{aastex} \documentclass{emulateapj}

MN2E is the package to use for submitting to MNRAS. Download mn2e.cls and put it in ~/Library/texmf/tex/latex/. Also get the guide [PDF]. To use the style file, make this the first line of the tex file:

\documentclass{mn2e}

## Set up the Bibliography for Use with BibTeX

The easiest way to create the bibliography is with BibTeX and ADS. Your .bib file (managed with BibDesk or exported from Papers) should live in ~/Library/texmf/bibtex/bib/my_bib.bib. To get the bibliography to display in the journal style format, you’ll need bibliography style files (.bst).

The bibliography style file for use with with AASTeX is part of AstroNat. (However, be advised that many of the AstroNat resources are no longer necessary.) Download apj.bst and put it in ~/Library/texmf/bibtex/bst/apj.bst. In the preamble of the tex file, include:

\bibliographystyle{apj}

For MNRAS, download the bibliography style file, mn2e.bst, put it in ~/Library/texmf/bibtex/bst/mn2e.bst, and include this in the tex file:

\bibliographystyle{mn2e}

Where you want the reference list to appear (typically after the acknowledgements, before tables and figures), put this:

\bibliography{my_bib}

## Figures

If you’re using pdftex instead of latex (as you should be…in this day and age, there’s no need for that DVI -> PS -> PDF rigamarole), you can include both EPS and PDF figures in the same document by loading these packages in the preamble of the tex file:

\usepackage{graphicx} \usepackage{epstopdf}

The filename extension is optional. For example, to include pdf_fig.pdf and eps_fig.eps:

\begin{figure} \plotone{pdf_fig} \end{figure}   \begin{figure} \plotone{eps_fig} \end{figure}

Anything else? Once ya’ll give this the once over, I’ll go ahead and add it to the LaTeX wiki entry which is fairly outdated at the moment.

1 kyle kanos July 7, 2010 at 9:58 am

Why use a text editor when you can use a front-end that will actually show you what your work looks like rather than \vec{F}=\dot{\vec{p}}=m\vec{a}. LyX operates on all the OS’s (Windows, Linux/Unix, and Mac OS X); for most Linux users it will be in the repositories, for Windows you can download the installer at http://wiki.lyx.org/Windows/Windows and for Mac users you can get the installation instructions here http://wiki.lyx.org/Mac/Mac.

For inexperienced users of LaTeX, LyX is the best way to go, but for experienced users of LaTeX who are comfortable writing in a text editor it might not be for you.

2 Gus July 7, 2010 at 9:59 am

nice tutorial, kelle. I like particularly the link to the paths.d explanation.

You may want to note though that (if you let it) macports will eventually decide it needs its own tex installation. Given the default way macports takes over inserts itself into your path it will override some aspects of this tutorial (“which latex” and which tex paths you enter in the various applications).

As I do not use it I cannot say if macports TeXLive presently respects ~/Library/texmf on a Mac. A quick google suggests it does not and a quick review of their bug list indicates that they want things done the “unix” way and macports will look for the texmf tree at ~/texmf by default.

3 Dan F-M July 7, 2010 at 10:59 am

A necessary part of my bibliography management is the little app ADS To BibDesk:

This app was mentioned in the old BibDesk post but now it works with Firefox too and it’s extremely handy for automatically importing refs from ADS. I couldn’t live without it.

4 Kurtis W. July 7, 2010 at 11:29 am

I find the modifications suggested by J.D. Smith (adding AucTeX and RefTeX) here: http://tir.astro.utoledo.edu/jdsmith/code/latex_emacs.php to be quite useful. I can compile LaTeX and BibTeX and launch xdvi from the emacs window, and clicking on text in the xdvi window takes your emacs cursor to that paragraph. And I don’t have to memorize my BibTeX reference tags; I can search for references in my BibTeX file by author or title.

5 Marshall July 7, 2010 at 11:03 pm

One reason to use a text editor rather than Lyx or an equivalent is the ease of including comments in the text with %. I don’t know about you, but I almost *always* have tons of comments in paper drafts, either detail work or numbers that don’t need to be stated explicitly but I want to remember, or notes like “%this figure was made by running foo.pro on bar.fits”, or just whole paragraphs that I’ve decided to excise from the current draft but want to keep around in case I change my mind. For all of these reasons, I find text editors still superior to WYSIWYG — though what I really wish was that there was an easy way to combine the best of both worlds. Any ideas?

6 Kelle July 8, 2010 at 8:39 am

@Gus: Why would you use MacPorts to install Tex when you can use MacTex? It’s not like it’s a bundle that needs to updated frequently…

@Dan FM: I totally agree that the Sick ADS to BibDesk script is a crucial part of bib mgmt! I haven’t tried out the app version but instead usually just open up Safari and use the Service. I’ll try it out and update the BibDesk post. I’d like to see if I can get it to work with Quick Search Box instead of putting the app in my dock.

@Kurtis: There’s also a script to search the BibDesk library in TextMate! More on that in the next post….

7 Gus July 8, 2010 at 10:01 am

@Kelle: Although installing tetex texlive via MacPorts is exactly what saurav recommended in an earlier Astrobetter post, I’m not suggesting the above conflict would result from an intentional port install of texlive.

Instead, TeX is a frequent dependency for ports (specifically for documentation). So sooner or later, whether one intends it or not, a MacPorts user will end up with TeX in /opt/local. If they are using MacTex as well then my prior concerns are relevant.

Does that make sense as a “gotcha” for your tutorial?

8 John July 8, 2010 at 2:31 pm

Why *wouldn’t* you use Macports to install TeX Live? A single system for managing all the software you need, complete with dependency tracking, automatic upgrading, and so on, seems like a great idea!

9 Kelle July 8, 2010 at 2:38 pm

yeah, even with Saurav’s nice post, I’m just not sold on MacPorts. I think it’s my preference for a GUI over the command line…plain and simple.

so, to make all the above ApJ/MNRAS things work with a MacPorts TeX Live install, is it as simple as using ~/texmf instead of ~/Library/texmf for the .cls, .sty, .bst, and .bib files?

if somehow you end up with both a TeXLive install and a MacTex install, how do you figure out who’s winning? just with a ‘which latex’?

10 Gus July 8, 2010 at 4:14 pm

@Kelle Yes, MacPorts TeX Live ‘/opt/local/bin/latex’ (or any standard TeXLive installation for that matter) will only see personal files in ~/texmf/ by default. MacTeX ‘/usr/texbin/latex’ will only see personal files in ~/Library/texmf/ by default. By “default” I mean without the user doing anything else.

11 Jessica July 8, 2010 at 6:36 pm

Perhaps the ~/texmf/ vs. ~/Library/texmf can be fixed with a simple symbolic link?

12 DS July 8, 2010 at 8:58 pm

I’m confused about why ADS To BibDesk is so great. I haven’t used it myself, so perhaps someone could enlighten me. (It seems perfectly easy to just use the web browser in BibDesk. It takes two clicks to add the entry from the paper’s ADS page – can ADS To BibDesk do it in one click, or something?)

13 John July 9, 2010 at 8:02 am

Jessica — no need for a symbolic link. Just set the environment variable TEXMFHOME to wherever you prefer to keep your texmf tree.

14 Dan F-M July 9, 2010 at 4:01 pm

@DS ADS to BibDesk adds the pdf and abstract to your library automatically which I don’t remember BibDesk doing itself… but I haven’t explored that method in quite a while. Also, the script incorporates itself into my usual workflow (I always have a browser open) which makes it worthwhile to me.

15 kyle kanos July 29, 2010 at 10:17 pm

@Marshall On LyX, there is a comment button that will bring up a very bright yellow text box, rather than using %.

16 anon October 25, 2010 at 5:04 pm

A note on MacTex-2010: AASTeX is included in the distribution (in /usr/local/texlive/2010/texmf-dist/tex/latex/aastex). Although I’m not sure, I would certainly imagine it was present in MacTeX-2009 – I mean, why include emulateapj without AASTeX?

17 Colin March 27, 2011 at 12:33 pm

Hi all,

I have installed mac tex and created a directory

/Library/texmf/tex/latex/

and added a class file which I would like to use, nmeauth.cls. However I am getting the error

Any suggestions?

18 Kelle March 27, 2011 at 12:52 pm

- you mean ~/Library, right? It should be in /Users//Library/texmf/tex/latex

- also, what are you using to run LaTeX? you might need to tell it to use the MacTex install in a preference pane somewhere.

19 Sasha July 16, 2011 at 3:21 pm

Hi Kelle,
I installed MacTex on my Mac 10.6.8 version and installation seemed to be successful. However, I don’t see any texmf directory in my ~/Library. Thats where you suggest to put the aastex package? Why did my mactex installation not creates ~/Library/texmf ?

20 Natalie October 15, 2012 at 5:51 pm

I’m having the same issue–did you ever figure it out?

21 Vicky February 27, 2013 at 3:18 pm

You need to make the directory ~/Library/texmf and its internal directories if they don’t exist. Credit to @astrokiwi for answering this question for me!

This would be a useful piece of information to add to the post or the wiki — it’s not obvious that the folder shouldn’t necessarily already be there. Everything else is great though, very clear.

22 Niall May 14, 2013 at 7:54 pm

Just FYI, MNRAS has a rule that papers with eight or more authors are treated slightly differently in the references. It’s briefly discussed in this post by Andy Lawrence

http://andyxl.wordpress.com/2011/07/12/bibliography-blues/

http://www.mpe.mpg.de/~williams/mn2ebst/

23 Simeon July 1, 2013 at 2:48 pm

If you want to be really slick, you can include arxiv and ADS links in your paper bibliography, as explained in this cosmocoffee thread:

http://cosmocoffee.info/viewtopic.php?t=304

For MNRAS, the style file linked there has the same problem noted by the previous commentator, which is solved in this version: https://github.com/sbird/mn2e-bst

24 August Muench March 16, 2016 at 2:46 pm

hi everyone,

just a quick update on LaTeX preparation for AAS Journal papers. You can find the new AASTeX 6 and our new aasjournal.bst BibTeX style file at our consolidated journals site:

http://journals.aas.org/authors/aastex.html

it is an approved fork of emulateapj, including all of that package’s functionality and adding new functionality collected from users over the past decade. the BibTeX style file is also an updated version of the AstroNat one that ADS has been maintaining for so many years. It is updated to support DOI based data and software citations.

the full AASTeX user’s guide can now be found at:

http://journals.aas.org/authors/aastex/aasguide.html