(result of SsmkT0TT1/k!T=e=LimnTTlr)1+1/nTT^n
, where T
stands for the TAB key)
Setting up a good LaTeX writing environment can be pretty hard (at least it has been for me 😅). It is the reason why I share my configuration in this repository.
Note: see associated blog post on my website LaTeX Writing Setup.
I will no longer maintain or update this repository as I moved from VSCode to Neovim for my primary text editor.
However, this repository still contains many interesting tips and snippets (especially regarding HyperSnips) that will probably be useful for you if you edit and build LaTeX documents using VSCode.
Note: if you are interested in my Neovim config, take a look at my Neovim dotfiles.
I am using VSCode as my IDE for writing LaTeX.
You will find my VSCode settings (regarding LaTeX) in the settings.json
file.
Note: My LaTeX Cheat Sheet template repository might also interest you gruvw/cookiecutter-cheatsheet !
I use many VSCode extensions in order to write LaTeX documents faster and easier:
- Clipboard History: allows me to paste previous clipboard elements
- Code Spell Checker: used for spell checking in my documents
- HyperSnips: snippet engine supporting JavaScript code interpolation, VSCode version of vim UltiSnips
- LaTeX Utilities: add-on to LaTeX Workshop providing some fancy features
- LaTeX Workshop: LaTeX typesetting, preview, compilation and code completion, highly customizable
- Vim: vim keybindings in VSCode
Extensions specific settings are also available inside the settings.json
file.
I use two types of snippets: VSCode default snippets and the HyperSnips extension.
Every snippet name starts with [G]
in order to differentiate them from regular snippets (from LaTeX Workshop for example).
You will find a CheatSheet on top of the latex.hsnips
file 😉.
If you want to add or modify a snippet, feel free to open an issue or a pull request.
If you don't understand a snippet feel free to open an issue or send me a message.
Note: I created those snippets when I started taking live notes during Lectures at EPFL.
You will find my VSCode LaTeX snippets in the latex.json
file.
I don't think any of them needs extra explanation.
You will find my HyperSnips snippets in the latex.hsnips
file.
Most of them will only trigger while typing inside a math context (while typing equations).
I explain some of them as there are some complex ones. It should help you to understand their definitions.
Example format: expression
: replaced by
What follows are some useful examples of snippets or snippets combinations (T
stands for the TAB key):
A21/L11: \frac{A_{21}}{L_{11}}
Mp321n: \begin{pmatrix}1 & 1\\1 & 1\\1 & 1\end{pmatrix} (with placeholders on values)
3zpsq/2: \frac{3\pi^2}{2}
2(x-y)rt3: 2\sqrt[3]{x-y}
aim3 inR#+*: a_{i-3} \in \mathbb{R}_+^*
SsmkTTrTa_ikcdb_kj: \sum_{k=1}^{r} a_{ik}\cdot b_{kj}
Used to generate boilerplate code for a new document.
When using this snippet, press <tab>
if you need the content of the selected text or press <backspace>
if you don't need it. After that you can fill the Title, Author and Date.
Used to generate a matrix.
How to activate:
- The first character must be
M
- The second character is the matrix type:
p
forpmatrix
,v
forvmatrix
, etc - The third character is the number of rows in the matrix
- The fourth character is the number of column in the matrix
- The fifth character is the default character placed in the matrix (often 1 or 0)
- Last character:
b
means you want to have line breaks after a row andn
means no line breaks
The snippet will trigger automatically once you typed all the characters.
On top of that, you can navigate with <tab>
to input each matrix elements.
Example: Mp241b
will result in the following
\begin{pmatrix}
1 & 1 & 1 & 1\\
1 & 1 & 1 & 1
\end{pmatrix}
Used to generate \left \right
commands.
How to activate:
- Must start with
lr
- The next character can be one of the following:
)
,]
,>
,}
,v
,V
See latex.hsnips
file for definitions.
Used to input Greek letters faster.
How to activate:
- Must start with
z
- The next character must correspond to the greek letter
Examples:
za
:\alpha
zD
:\Delta
See latex.hsnips
file for the other associations.
Used for \mathbb{}
and \mathcal{}
commands.
How to activate:
- The first character must be the letter you want to modify
- If you input the
#
character just after, it will surround your letter with\mathbb{}
- If you input another
#
after that, it will modify the command and use\mathcal{}
instead
Examples:
R#
:\mathbb{R}
\mathbb{F}#
:\mathcal{F}
F##
:\mathcal{F}
If you type a one or two digit(s) number directly after a letter or a command, it will be automatically subscripted.
Examples:
a1
:a_1
x34
:x_{34}
za2
:\alpha_2
(see Greek letter)
Special subscripts for n/i + d
or n/i - d
:
np1
:_{n+1}
nm2
:_{n-2}
ip3
:_{i+3}
Using the /
character right next to a small expression will result in a fraction.
Surrounding any expression with parenthesis followed by a /
will result in a fraction.
Examples:
1/2
:\frac{1}{2}
x/
:\frac{x}{}
\alpha/
:\frac{\alpha}{}
(x^2 + 2x - 4)/
:\frac{x^2 + 2x - 4}{}
(\alpha_3 - 2x^{12} + 9\pi)/
:\frac{\alpha_3 - 2x^{12} + 9\pi}{}
Used for \sqrt
command.
Surrounding any expression with parenthesis followed by rt
will result in the square root of the expression.
If a number is typed just after a \sqrt{}
command, it will result in the n-root (changing the current one if it already exists).
Examples:
(x^2 - x + 2)rt
:\sqrt{x^2 - x + 2}
\sqrt{x^2 - x + 2}4
:\sqrt[4]{x^2 - x + 2}
\sqrt[4]{x^2 - x + 2}5
:\sqrt[5]{x^2 - x + 2}
(x^2 - x + 2)rt6
:\sqrt[6]{x^2 - x + 2}