-
Notifications
You must be signed in to change notification settings - Fork 539
Snippets
Many snippets are available to help users enter LaTeX commands or symbols. Snippet View is also available from the TeX badge.
All commands are listed as ctrl+some key. If you're on Mac, don't worry we have written equivalents, so every time you see ctrl just imagine it's ⌘.
To have intellisense automatically triggered inside snippets, set editor.suggest.snippetsPreventQuickSuggestions
to false
. This is useful for instance if you want to enter \frac{x_{1}}{2}
using @/
+ x
+ __
+ 1
+ 2
using TAB to move from one tabstop to the next.
Some environments have a dedicated snippet in the form BXY
where XY
are the two first letters of the environment name. The starred versions use the prefix BSXY
.
Prefix | Environment name |
---|---|
BEQ |
equation |
BSEQ |
equation* |
BAL |
align |
BSAL |
align* |
BGA |
gather |
BSGA |
gather* |
BMU |
multline |
BSMU |
multline* |
BIT |
itemize |
BEN |
enumerate |
BSPL |
split |
BCAS |
cases |
BFR |
frame |
BFI |
figure |
Sectioning commands can of course be inserted by just typing them as they are automatically completed by the intellisense mechanism. One can also use the following snippets.
Prefix | Sectioning level |
---|---|
SPA | part |
SCH | chapter |
SSE | section |
SSS | subsection |
SS2 | subsubsection |
SPG | paragraph |
SSP | subparagraph |
For instance, typing SSE
+ TAB
expands to \section{}
with the cursor inside the brackets.
The current section along with all its subsections can be selected by calling the command latex-workshop.select-section
. Repeated calls ends in expanding the selection in two ways:
- First, outer sections are selected
- If there is not outer section, the selection is expanded upwards be selection the previous section.
Adjusting sectioning levels can be done by calling one of the two commands latex-workshop.promote-sectioning
and latex-workshop.demote-sectioning
from the Command Palette.
These methods replace all sectioning commands with the sectioning command one level higher or lower. They apply either to the current line or to a selection.
Applying latex-workshop.promote-sectioning
to the following selection,
\subsection{Demo}
\paragraph{Content}
yields
\section{Demo}
\subsubsection{Content}
To recursively promote/demote a section and and all its subsections, first call latex-workshop.select-section
to select the section and all its subsections and then call latex-workshop.promote-sectioning
or latex-workshop.demote-sectioning
.
This functionality has two keybindings
Method | Shortcut | Alternate |
---|---|---|
Promote Sectioning | ctrl+alt+[ | ctrl+l [ |
Demote Sectioning | ctrl+alt+] | ctrl+l ] |
To use the alternate shortcuts, set latex-workshop.bind.altKeymap.enabled
to true
.
Greek letters can be inserted using the following commands (@
+ the Roman letter). The prefix @
is set by the configuration variable latex-workshop.intellisense.snippets.trigger.latex
and can be replaced by any other non-alphabetical character. Setting latex-workshop.intellisense.snippets.trigger.latex
to the empty string deactivates these snippets. Note that from an implementation point of view, these snippets are actually provided as intellisense completion.
Prefix | Letter |
---|---|
@a |
\alpha |
@b |
\beta |
@c |
\chi |
@d |
\delta |
@e |
\epsilon |
@f |
\phi |
@g |
\gamma |
@h |
\eta |
@i |
\iota |
@k |
\kappa |
@l |
\lambda |
@m |
\mu |
@n |
\nu |
@p |
\pi |
@q |
\theta |
@r |
\rho |
@s |
\sigma |
@t |
\tau |
@u |
\upsilon |
@o |
\omega |
@& |
\wedge |
@x |
\xi |
@y |
\psi |
@z |
\zeta |
@D |
\Delta |
@F |
\Phi |
@G |
\Gamma |
@Q |
\Theta |
@L |
\Lambda |
@X |
\Xi |
@Y |
\Psi |
@S |
\Sigma |
@U |
\Upsilon |
@W |
\Omega |
@ve |
\varepsilon |
@vf |
\varphi |
@vs |
\varsigma |
@vq |
\vartheta |
Some common mathematical symbols or commands have a dedicated snippet.
Prefix | Command |
---|---|
__ |
_{$1} |
** |
^{$1} |
... |
\dots |
The following commands are also as intellisense completion. The prefix @
is set by the configuration variable latex-workshop.intellisense.snippets.trigger.latex
and can be replaced by any other non-alphabetical character. Setting latex-workshop.intellisense.snippets.trigger.latex
to the empty string deactivates these snippets.
Prefix | Command |
---|---|
@( |
\left( $1 \right) |
@{ |
\left\{ $1 \right\} |
@[ |
\left[ $1 \right] |
__ |
_{$1} |
** |
^{$1} |
... |
\dots |
@. |
\cdot |
@8 |
\infty |
@6 |
\partial |
@/ |
\frac{$1}{$2} |
@% |
\frac{$1}{$2} |
@^ |
\Hat{$1} |
@_ |
\bar{$1} |
@@ |
\circ |
@0 |
^\circ |
@; |
\dot{$1} |
@: |
\ddot{$1} |
@= |
\equiv |
@* |
\times |
@< |
\leq |
@> |
\geq |
@2 |
\sqrt{$1} |
@I |
\int_{$1}^{$2} |
@| |
\Big | |
@+ |
\bigcup |
@- |
\bigcap |
@, |
\nonumber |
Prefix | Shortcut | Command |
---|---|---|
fontsize |
Opens font size select | |
FNO |
ctrl+l, ctrl+n | \textnormal{${1}} |
FRM |
ctrl+l, ctrl+r | \textrm{${1}} |
FEM |
ctrl+l, ctrl+e | \emph{${1}} |
FSF |
\textsf{${1}} |
|
FTT |
ctrl+l, ctrl+t | \texttt{${1}} |
FIT |
ctrl+l, ctrl+i | \textit{${1}} |
FSL |
ctrl+l, ctrl+s | \textsl{${1}} |
FSC |
ctrl+l, ctrl+c | \textsc{${1}} |
FUL |
ctrl+l, ctrl+u | \underline{${1}} |
FUC |
\uppercase{${1}} |
|
FLC |
\lowercase{${1}} |
|
FBF |
ctrl+l, ctrl+b | \textbf{${1}} |
FSS |
ctrl+l, ctrl+6 | \textsuperscript{${1}} |
FBS |
ctrl+l, ctrl+minus | \textsubscript{${1}} |
Prefix | Shortcut | Command |
---|---|---|
MRM |
ctrl+m, ctrl+r | \mathrm{${1}} |
MBF |
ctrl+m, ctrl+s | \mathsf{${1}} |
MBF |
ctrl+m, ctrl+b | \mathbf{${1}} |
MBB |
ctrl+m, ctrl+shift+b | \mathbb{${1}} |
MCA |
ctrl+m, ctrl+c | \mathcal{${1}} |
MIT |
ctrl+m, ctrl+i | \mathit{${1}} |
MTT |
ctrl+m, ctrl+t | \mathtt{${1}} |
Shortcut | Action |
---|---|
ctrl+l, ctrl+Enter | Insert newline + \item
|
To surround text with a command, just select some text and use ctrl+l, ctrl+w (⌘+l, ⌘+w on Mac) or call Surround selection with LaTeX command from the Command Palette (command latex-workshop.surround
). A new menu pops up to select the command. This works with multi selections.

Alternatively, you can just select the text and enter the command using autocompletion

To surround some selected text with an environment, call LaTeX Workshop: Surround/wrap selection with \begin{}...\end{} from the Command Palette (command latex-workshop.wrap-env
). A multi-cursor is added inside the braces, to insert the environment name.
