Custom fonts in LaTeX on Mac

For some reason I thought this was super hard to set up, but it turns out it isn't.

Prerequisites

  1. MacTex - the huge 2.1GB installer
  2. Sublime Text 2 with the LaTeXTools plugin (installed via Package Control)

Once you've got this, then all you have to do is open up ~/Library/Application Support/Sublime Text 2/Packages/LaTeXTools/LaTeX.sublime-build and change this line:

"-e", "\$pdflatex = 'pdflatex %O -interaction=nonstopmode -synctex=1 %S'",

to

"-e", "\$pdflatex = 'xelatex %O -interaction=nonstopmode -synctex=1 %S'",

You should now be able to build the following with fancy fonts:

\documentclass{article}
\usepackage{fontspec,lipsum}
\defaultfontfeatures{Ligatures=TeX}
\usepackage[small,sf,bf]{titlesec}

\setromanfont{Baskerville}
\setsansfont{Myriad Pro}

egin{document}
\section{Introduction}

\lipsum[1]

\section{Nonsense}

\lipsum[2-4]
\end{document}

Source and more info: http://robjhyndman.com/hyndsight/xelatex/


🌟 Was this page helpful? Please let me know with this quick, 3 question survey.