How to Set Up LaTeX (BasicTex) with Visual Studio Code on macOS
LaTeX is a powerful typesetting system that can help you achieve that. In this post, I'll guide you through the process of installing a minimal LaTeX distribution called BasicTex on your macOS machine and setting it up with the popular Visual Studio Code (VSCode) editor.
Step 1: Install BasicTex
While the full MacTeX distribution provides a comprehensive LaTeX installation, it can be quite large (over 5GB). If you're just starting with LaTeX or have limited storage space, you might want to consider installing BasicTex instead. BasicTex is a smaller alternative that contains all the essential tools you need to create and compile LaTeX documents.
Here's how to install BasicTex:
- Visit the MacTeX website and navigate to the More Packages section.
- Scroll down to the "A Smaller Distribution, Basic TeX" section and click on the "BasicTeX.pkg" link to download the installer.
- Once the download is complete, double-click on the installer package and follow the on-screen instructions to install BasicTex.
Step 2: Install latexmk
While BasicTex provides the core LaTeX components, it doesn't include the latexmk utility, which is used by the LaTeX extension in VSCode to automatically compile your documents.
There are two ways to install latexmk:
Option 1: Command Line Installation
- Open the Terminal application.
- Run the following command to install latexmk using the TeX Live Manager (tlmgr):
tlmgr install latexmk
Option 2: GUI Installation (Recommended)
For a more user-friendly experience, I recommend using the TeX Live Utility, a graphical front-end for the TeX Live Manager.
- Visit the TeX Live Utility website and download the latest version.
- Extract the downloaded ZIP file and move the TeX Live Utility application to your Applications folder.
- Launch the TeX Live Utility app.
- When prompted to update packages, go ahead and do so. This process might take a few minutes, but it's worth the wait to ensure you have the latest updates.
- Once the updates are complete, switch to the "Packages" tab and use the search bar to find latexmk.
- Right-click on the latexmk package and select "Install Selected Packages."
You've now installed the necessary components to work with LaTeX on your macOS system.
Step 3: Install the LaTeX Extension in VSCode
Now that you have LaTeX and latexmk installed, it's time to set up the LaTeX extension in Visual Studio Code.
- Open Visual Studio Code.
- Go to the Extensions view (Cmd+Shift+X or navigate to View > Extensions).
- Search for "LaTeX Workshop" and install the extension by clicking the "Install" button.
The LaTeX Workshop extension provides a rich set of features, including automatic compilation of LaTeX documents, PDF previewing, code snippets, and autocompletion.
Another popular LaTeX extension for VSCode is TeXLab, which uses the TeXLab language server for autocompletion and other advanced features.
You can also find additional LaTeX extensions, such as spell checkers, to enhance your writing experience.
That's it! You're now ready to start writing and compiling your LaTeX documents in Visual Studio Code on your macOS machine. Happy TeXing!
Comments
Post a Comment