(Optional) Install dependencies for minted and latexindent
# Install Pygments for code highlighting with minted in LaTeX
pip3 install Pygments # for Windows / macOS / Linux
brew install pygments # for macOS# Install dependencies for latexindent
cpan -i -T File::HomeDir Log::Log4perl Log::Dispatch::File \
YAML::Tiny Unicode::GCString
2. Install VS Code and Extensions
Visual Studio Code is strongly recommended as the editor for LaTeX projects. You can download and install it from the official site at https://code.visualstudio.com.
Recommended extensions:
LaTeX Workshop: boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
LaTeX Utilities: An add-on to LaTeX Workshop that provides some fancy features.
Local History (optional): maintain local history of files.
You can find them in Visual Studio Code Marketplace (shortcut: Ctrl / Cmd + Shift + X).
3. Setup Editor for LaTeX Projects
# Clone this repository
git clone --depth=1 https://github.com/XuehaiPan/LaTeX-Templates.git
# Open the project with VS Code
code LaTeX-Templates
code --new-window Assignment # open a template folder using VS Code
Open the main.tex file in a VS Code tab, then compile it with LaTeX-Workshop extension tool in the left panel, or use keyboard shortcut Ctrl / Cmd + Alt + B. See the wiki page of LaTeX-Workshop for more details about the extension features.
Some useful keyboard shortcuts (may be overridden by keymap settings):
View LaTeX PDF file (Ctrl / Cmd + Alt + V)
Build with last used recipe (Ctrl / Cmd + Alt + B)
SyncTeX from cursor in TeX file to PDF (Ctrl / Cmd + Alt + J)
SyncTeX from PDF to TeX file (hold the Ctrl / Cmd key and click on the PDF in the preview panel)
Format source files using latexindent (Ctrl / Cmd + Shift + I)
*You don't need to do cleanup frequently, please do it only when necessary (e.g., on build failed). (Keep these auxiliary files can speed up the next compilation.)
* Manual Compilation
cd Assignment # navigate to a template folder first
Compile with Latexmk (Recommended)
latexmk -xelatex -synctex=1 -shell-escape \
-interaction=nonstopmode -file-line-error \
-output-directory=out main
请发表评论