An open API service indexing awesome lists of open source software.

https://github.com/xuehaipan/latex-templates

A collection of LaTeX templates in English/Chinese, with VS Code settings for LaTeX Workshop.
https://github.com/xuehaipan/latex-templates

latex-beamer latex-class latex-document latex-template latex-templates latex-workshop vscode-configs vscode-settings

Last synced: 3 months ago
JSON representation

A collection of LaTeX templates in English/Chinese, with VS Code settings for LaTeX Workshop.

Awesome Lists containing this project

README

        

# LaTeX Templates

A collection of LaTeX templates in English / Chinese, with VS Code settings for LaTeX Workshop. ([screenshots](#screenshots))

### Table of Contents

- [Editor Preparation](#editor-preparation)
- [1. Preliminaries](#1-preliminaries)
- [2. Install VS Code and Extensions](#2-install-vs-code-and-extensions)
- [3. Setup Editor for LaTeX Projects](#3-setup-editor-for-latex-projects)
- [Usage](#usage)
- [4. Compile and Preview with LaTeX Workshop](#4-compile-and-preview-with-latex-workshop)
- [* Manual Compilation](#-manual-compilation)
- [Compile with Latexmk (Recommended)](#compile-with-latexmk-recommended)
- [Compile with XeLaTeX and Biber](#compile-with-xelatex-and-biber)
- [Screenshots](#screenshots)

## Editor Preparation

### 1. Preliminaries

Download and install a TeX distribution (e.g., [TeX Live](https://www.tug.org/texlive/)) on your device.

#### Install TeX Live

**Windows:** download and invoke the TeX Live installer [install-tl-windows.exe](http://mirror.ctan.org/systems/texlive/tlnet/install-tl-windows.exe). Or install TeX Live using [Chocolatey](https://chocolatey.org):

```powershell
choco install texlive --params="'/scheme:full'"
```

**macOS:** install MacTeX using [Homebrew](https://brew.sh):

```bash
brew install --cask mactex
```

**Linux:** manual installation:

```bash
wget -O - http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz |
tar -xz --strip-components=1 --one-top-level=install-tl-unx &&
cd install-tl-unx &&
sudo ./install-tl
```

#### (Optional) Install dependencies for `minted` and `latexindent`

```bash
# 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](https://code.visualstudio.com).

Recommended extensions:

- [LaTeX Workshop](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop): boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
- [LaTeX Utilities](https://marketplace.visualstudio.com/items?itemName=tecosaur.latex-utilities): An add-on to LaTeX Workshop that provides some fancy features.
- [Local History](https://marketplace.visualstudio.com/items?itemName=xyz.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

```bash
# Clone this repository
git clone --depth=1 https://github.com/XuehaiPan/LaTeX-Templates.git

# Open the project with VS Code
code LaTeX-Templates
```

Then install recommended extensions in [`".vscode/extensions.json"`](.vscode/extensions.json), and copy the settings in [`".vscode/settings.json"`](.vscode/settings.json) to your user settings. Refer to [XuehaiPan/Dev-Setup/my-vscode-settings](https://github.com/XuehaiPan/Dev-Setup/blob/master/my-vscode-settings/settings.json) as a reference.

## Usage

### 4. Compile and Preview with LaTeX Workshop

```bash
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](https://github.com/James-Yu/LaTeX-Workshop/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)
- Clean up auxiliary files[*](#note) (Ctrl / Cmd + Alt + C)
- 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

```bash
cd Assignment # navigate to a template folder first
```

#### Compile with Latexmk (Recommended)

```bash
latexmk -xelatex -synctex=1 -shell-escape \
-interaction=nonstopmode -file-line-error \
-output-directory=out main
```

- clean up auxiliary files[*](#note)

```bash
latexmk -c -output-directory=out
```

- build and do cleanup if failed

```bash
latexmk -xelatex -synctex=1 -shell-escape \
-interaction=nonstopmode -file-line-error \
-output-directory=out main ||
latexmk -c -output-directory=out
```

#### Compile with XeLaTeX and Biber

Execute `xelatex` multiple times to resolve cross-references in the document.

```bash
# XeLaTeX ➞ Biber ➞ XeLaTeX × 2
xelatex -synctex=1 -shell-escape \
-interaction=nonstopmode -file-line-error \
-output-directory=out main
biber --output-directory=out main
xelatex -synctex=1 -shell-escape \
-interaction=nonstopmode -file-line-error \
-output-directory=out main
xelatex -synctex=1 -shell-escape \
-interaction=nonstopmode -file-line-error \
-output-directory=out main
```

## Screenshots

### Templates

---


Assignment
Essay










Presentation
NeurIPS 2021








### Workspace

---

- set `"latex-workshop.view.pdf.viewer": "tab"`



View PDF in a VS Code tab.

- set `"latex-workshop.view.pdf.viewer": "external" // or "browser"`



View PDF in the external viewer or a web browser (for multi-monitor setup).