LaTeX Documentation#
LaTeX is sort of the default method we use to compile documents in high energy physics (but many other academic fields as well). If you’re using Word or something else to write your thesis or papers, I recommend you to switch to LaTeX soon 😉
There are several ways to use LaTeX workspaces in your personal computer, or using a cloud based service. Below are the two recommendations by me, as of Jan 2024.
Overleaf - This is a cloud based service which is very useful since you do not need to install anything in your personal computer. The only downside is, you need to be connected to the internet to compile the document. If you wish to use this service, you can easily create an account for free, or through your school or organization (like CERN). Check their homepage for more information.
Visual Studio Code LaTeX workshop - This can be installed as an extension to the popular VSCode, and has a lot of nice features and customizations. Further, the fact that you can compile the document in your personal computer is a merit. Check below on how to configure this in your personal computer.
LaTeX references#
There are so many references out there to learn LaTeX, as well as for useful packages/resources. Below I list a few pages which I found useful, and I regularly use for reference.
The Overleaf knowledge base is a great way to learn from the basics to advanced topics in LaTeX. It also has a great all rounded LaTeX documentation in almost all topics.
LaTeX symbols are something we regularly use in HEP documents, and these few sites are useful for reference:
LaTeX-Tutorial.com lists quite a diverse set of color palettes, which are useful if you’re picky (like me) with the colors you want in your document.
How to start using LaTeX workshop in your laptop#
Basic setup#
The instructions here are for MacBooks, but should be similar to Windows as well.
Of course, first you will need VSCode installed in your laptop. Go to this page to download VSCode.
Then install a Tex document production system. The current recommendation is TeX Live.
Hint
For Mac, my recommendation is to install BasicTeX - This installs the minimum software needed (and only used up around ~100 MB) and can be extended as you like. However, if you want all the packages you can also install MacTex (I do not prefer this since it also installs unwanted software which I never use).
Note
Both BasicTeX (or MacTex) can be installed through homebrew as well;
brew install --cask basictex
If you installed BasicTeX, you will also need to install latexmk (which is needed by LaTeX workshop to compile TeX to PDF). With MacTeX this should already be available (I think). Go to the terminal and do,
tlmgr install latexmk
Then in VSCode, go to the extensions tab and search for LaTeX Workshop. Find the package where the author is James Yu. Click install.
You are basically set, but it might be best to install some missing but essential packages listed below.
Also, it is good to have a spell checker extension installed. For English, you can use Code Spell Checker. Simply go to extensions tab, search for the package and install.
Note
This will highlight any words which look weird. To correct or pick from a recommend list, you can simply do command+. in your Mac.
Then start writing something and try compiling to see. For compilation you can just do option+command+b.
Installing extra LaTeX packages using Tex Live package manager#
You can check the package list installed in your computer by running,
tlmgr list --only-installed
To check and update the packages in your computer, you can do
tlmgr update --list tlmgr update --all
To install specific packages, do
tlmgr install <package-name>
It is recommend to have the below packages installed, since we will be using it quite often (I will include more to the below list which I might find useful).
collection-fontsrecommended
,biber
,biblatex
,tikz-feynman
,braket
,multirow
To use the Tikz-Feynman package, you will need a few more tricks. See below.
How to compile the Tikz-Feynman package#
To use the Tikz-Feynman package, you will need to change the default compiler from pdflatex to lualatex. To do this,
Do command+, to open the settings.
Search for
latex-workshop.latex.recipes
and then click Edit insettings.json
.Add the below lines to the
settings.json
and save the file."latex-workshop.latex.recipe.default": "latexmk (lualatex)", "latex-workshop.latex.recipes": [ { "name": "latexmk (lualatex)", "tools": [ "lualatexmk" ] } ]
Other useful changes to have#
Open the settings (command+,) and search for the below and set them to the preferred setting as you like (I am listing my preference below)
latex-workshop.latex.autoBuild.run
- Set tonever
, in order to not build every time you save.latex-workshop.latex.autoClean.run
- Set toon Succeeded
, in order to get rid of log files etc. This way it’s also easier to spot if the complain succeed without errors.