Skip to content

Instantly share code, notes, and snippets.

@LucaCappelletti94
Last active March 29, 2024 22:33
Show Gist options
  • Star 32 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save LucaCappelletti94/920186303d71c85e66e76ff989ea6b62 to your computer and use it in GitHub Desktop.
Save LucaCappelletti94/920186303d71c85e66e76ff989ea6b62 to your computer and use it in GitHub Desktop.
Firing up Latex on macOS

Firing up LaTex on macOS 🔥

As I'm writing this small tutorial, I assume you've read my previous one about setting up macOS, so if for any tool I'll use without explanation, look to that other article.

MacTex

The full version IS NOT MANDATORY, as in the tutorial that follows I installed the smaller version of MacTeX and proceded installing every needed dependency. Installing the complete package is about ~3.5GB of download and ~5GB on disk, the smaller one is just about 80MBs.

Click here to download the complete version or here to download the smaller version.

Gnuplot

GnuPlot is a small library for drawing some kind of plots, I use it all the time.

brew install gnuplot

Imagemagick

brew update && brew install imagemagick

Skim

Skim is a pdf viewer that syncs nicely with sublime text.

brew cask install skim

Packages commonly needed

What follows is a list of packages that are commonly needed (they are needed in our main project), they come installed with the ginormous package from MacTex, but I prefer a granular approach to avoid useless software. They can be installed all with the following command:

sudo tlmgr update --self
sudo tlmgr install latexmk subfiles ctablestack luacode luatex85 silence emptypage framed biblatex logreq xstring chngcntr sectsty minted fvextra ifplatform ifoddpage relsize relsize csquotes pgfplots circuitikz paralist enumitem glossaries datatool glossaries-english glossaries-italian glossaries-german mfirstuc xfor substr imakeidx fourier utopia quotchap soul collection-fontsrecommended algorithm2e xargs stanli preview standalone tikz-qtree

Here you can read to have an idea on the usage of each package:

Updating the package manager

First of all, we update the package manager as follows:

sudo tlmgr update --self

Latexmk

Latexmk is a tool used to build latex documents.

sudo tlmgr install latexmk

Subfiles

Subfiles is a package that allows to compile subfiles.

sudo tlmgr install subfiles

Ctablestack

Ctablestack is a package that allows to render tables.

sudo tlmgr install ctablestack

Luacode

Luacode is a package that allows to compile luacode in luatex.

sudo tlmgr install luacode luatex85

Silence

Silence is a package that allows to shush noise and useless warnings.

sudo tlmgr install silence

Emptypage

Emptypage is a package that allows to leave empty pages to separate topics.

sudo tlmgr install emptypage

Frames

Frames is a package that allows to frame theorems, definitions etc..

sudo tlmgr install framed

Bitlatex

Biblatex is a package that allows to load bibliographies.

sudo tlmgr install biblatex

Logreq

Logreq is a package that allows to automate some workflows.

sudo tlmgr install logreq

Xstring

Xstring is a package that allows to automate workflows on string editing.

sudo tlmgr install xstring

Chngcntr

Chngcntr is a package that allows to reset counters for images, equations etc...

sudo tlmgr install chngcntr

Sectsty

Sectsty is a package that allows you to apply custom styles to chapters and sections.

sudo tlmgr install sectsty

Minted

Minted is a package that allows you to highlight code.

sudo tlmgr install minted

fvextra

Fvextra is a package that automates line breaks.

sudo tlmgr install fvextra

Ifplatform

Ifplatform is a package that allows for if statements in latex for the various compilers (pdflatex, latex, lualatex...).

sudo tlmgr install ifplatform

Ifoddpage

ifoddpage is a package that allows to check if the current page is odd or even.

sudo tlmgr install ifoddpage

Relsize

Relsize sets relative font size.

sudo tlmgr install relsize

Csquotes

Csquotes allows for automatic smart quotes.

sudo tlmgr install csquotes

Pgfplots

Pgfplots allows compiling cool graphs.

sudo tlmgr install pgfplots

Circuitikz

Circuitikz allows to draw circuits.

sudo tlmgr install circuitikz

Paralist

Paralist allows for advanced lists.

sudo tlmgr install paralist enumitem

Glossaries

Glossaries allows to automate glossaries.

sudo tlmgr install glossaries datatool glossaries-english glossaries-italian glossaries-german

Mfirstuc

Mfirstuc allows to make first letter upper case.

sudo tlmgr install mfirstuc

Xfor

Mfirstuc reimplements stronger latex "for" cycles implementation.

sudo tlmgr install xfor

Substr

Substr enables commands to check substring relationships.

sudo tlmgr install substr

Tracklang

Substr enables you to get info about the current language from babel or polyglossia.

sudo tlmgr install tracklang

Imakeidx

Imakeidx builds automatically the index.

sudo tlmgr install imakeidx

Fourier

Fourier extends the fonts enabled in amsmath.

sudo tlmgr install fourier utopia

Quotchap

Quotchap enables nice style for chapters.

sudo tlmgr install quotchap

Quotchap

Quotchap enables nice style for chapters.

sudo tlmgr install quotchap

Soul

Soul enables Hyphenation for letterspacing, underlining, and more.

sudo tlmgr install soul

Fontsrecommended

Fontsrecommended is a collection of fonts commonly used.

sudo tlmgr install collection-fontsrecommended

Algorithm2e

(https://ctan.org/pkg/algorithm2e?lang=en)[algorithm2e] Algorithm2e is a package to write pseudocode.

sudo tlmgr install algorithm2e

Xargs

(https://ctan.org/pkg/xargs?lang=en)[Xargs] is a package that provides extended versions of \newcommand

sudo tlmgr install stanli

Stanli

(https://ctan.org/pkg/stanli?lang=en)[Stanli] is a package to draw 2d and 3d structural analysis.

sudo tlmgr install stanli

Preview and Standalone

(https://ctan.org/pkg/preview?lang=en)[Preview] and (https://ctan.org/pkg/preview?lang=en)[Standalone] are packages used to run math preview in latextools in sublime text.

sudo tlmgr install preview standalone

Tikz-qtree

(https://ctan.org/pkg/tikz-qtree?lang=enn)[Tikz-qtree] is a package to easily draw trees.

sudo tlmgr install tikz-qtree

Cpan & LatexIndent

Latexindent come with MacTex but can also be downloaded separately, when installed with the lightweight plugin, with the following commands:

sudo tlmgr option repository ctan
sudo tlmgr update --self
sudo tlmgr install latexindent

Just execute the command cpan in the terminal and follow its instruction. Then exit from the cpan ambient and install the following dependencies as follow:

sudo cpan -fi Log::Dispatch Log::Log4perl YAML::Tiny Getopt::Long File::HomeDir Unicode::GCString

Now exit from cpan and try running the command latexindent. Make sure that it runs.

Setup with sublime text

After following my guide over here we can continue here. Add to your package control settings these packages:

{
  "installed_packages":
  [
   "LaTeX-cwl",
   "LaTeXTools",
   "LaTeXYZ"
  ]
}

Shell escape

With packages such as minted you will need to enable shell escape. Just open up the package specific settings for LaTeXTools and add in the builder settings the following options:

"builder_settings" : {
    "display_log" : false,
    "options": [
        "--shell-escape"
    ],
    "osx" : {},
    "windows" : {},
    "linux" : {}
},

Get pygments

Pygments script is necessary for stuff like code highlight. You might have already this installed.

pip install pygmentize

If you have already installed it with Anaconda and your Tex editor does not find it, probably you need to create a link to the usr folder as follows:

sudo ln -s /anaconda3/bin/pygmentize /usr/local/bin/pygmentize

If the command fails you might need to look up for the current file position and create a link from there.

Adding usefull repositories

Adding BeautifyLatex

BeautifyLatex is a a package for sublime text that help format the latex code using latexindent. You need to add this by hitting super+maiusc+p and search for "Add Repository". Then you can add the package as usual, with super+maiusc+p and "Add Package".

Adding Dictionaries

Dictionaries adds multilanguage dictionaries for your latex projects. You need to add this by hitting super+maiusc+p and search for "Add Repository". Then you can add the package as usual, with super+maiusc+p and "Add Package".

@cmhughes
Copy link

Log4perl no longer required for latexindent :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment