Homebrew is a package manager for macOS that simplifies the installation of software. Open Terminal and execute:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After installation, add Homebrew to your PATH by following the instructions provided in the Terminal output.
MacTeX is a comprehensive TeX/LaTeX distribution specifically for macOS. Use Homebrew to install MacTeX:
brew install --cask mactex
This process might take some time as MacTeX is large. After installation, verify it by checking the version of latexmk, a tool included with MacTeX:
latexmk -v
TeX Live Manager (tlmgr) manages the TeX Live installation, allowing you to update and install new packages. Update tlmgr itself and then latexmk:
sudo tlmgr update --self sudo tlmgr install latexmk
Install chktex, a LaTeX semantic checker, to help with linting your documents:
brew install chktex
Verify its installation:
which chktex
Ensure your system recognizes the newly installed binaries by adding them to your PATH. Find the installation path of latexmk:
find /usr/local/texlive -name latexmk
This will output a path similar to /usr/local/texlive/2024basic/bin/universal-darwin. Use this path to update your .zshrc file (assuming you are using the default shell, Zsh):
echo 'export PATH="/usr/local/texlive/2024basic/bin/universal-darwin:$PATH"' >> ~/.zshrc
Replace /usr/local/texlive/2024basic/bin/universal-darwin with your actual path. Reload your shell configuration:
source ~/.zshrc
Verify that the system recognizes the LaTeX tools:
echo $PATH
latexmk -v
If you haven't already, download and install VS Code from the official site.
In VS Code, install the LaTeX Workshop extension by James Yu. It provides rich LaTeX support:
Open VS Code. Go to the Extensions view by clicking on the square icon on the sidebar or pressing Cmd+Shift+X. Search for "LaTeX Workshop" and click on the Install button.
The LaTeX Workshop extension works out of the box, but you might need to configure it based on your project. To do this, open the settings JSON file by pressing Cmd+Shift+P, typing Preferences: Open Settings (JSON), and pressing Enter. Add or modify settings according to your needs, for example:
Copy code
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
}
]
This configuration sets latexmk as the default tool to compile LaTeX documents.
To compile a LaTeX document, open your .tex file in VS Code and click on the "Build LaTeX project" button in the TeX sidebar or press Cmd+Alt+B. View the output PDF by clicking on the "View LaTeX PDF" button or pressing Cmd+Alt+V.
.Net Installation: macOS doesn't require a separate .Net installation for LaTeX or the LaTeX Workshop extension. Troubleshooting: If you encounter any issues, consult the MacTeX FAQ and the LaTeX Workshop Wiki. This guide should provide a comprehensive setup for working with LaTeX on macOS and Visual Studio Code. Adjustments might be necessary based on specific project requirements or macOS updates