Skip to content

Latest commit

 

History

History
222 lines (173 loc) · 10.5 KB

Snippets.md

File metadata and controls

222 lines (173 loc) · 10.5 KB

Snippets and shortcuts

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.

Environments

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*
BIT itemize
BEN enumerate
BSPL split
BCAS cases
BFR frame
BFI figure

Sectioning

An overview of the document

The structure of the LaTeX project (\chapter, \section, \subsection, ...) is accessible via the TeX panel on the left of the editor. The entry corresponding to the cursor position in the editor is automatically selected and follows the cursor. The outline hierarchy is defined by latex-workshop.view.outline.sections.

Note that the Explorer panel also contains an outline view but it only shows the structure of the current file and does not take into account any included file.

latex-workshop.view.outline.sections

The section names of LaTeX outline hierarchy. It is also used by the folding mechanism.

This property is an array of case-sensitive strings in the order of the document structure hierarchy. For multiple tags of the same level, separate the tags with | as delimiters, e.g., section|alternative.

type default value
array of strings [ "part", "chapter", "section", "subsection", "subsubsection" ]

Inserting a sectioning command

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.

Incrementing/decrementing sectioning levels

Adjusting sectioning levels can be done using latex-workshop.increment-sectioning and latex-workshop.decrement-sectioning.

These methods replace all sectioning commands with the sectioning command one level higher or lower. They apply either to the current line or to every selected line.

Example

Applying latex-workshop.increment-sectioning to the following selection,

\subsection{Demo}
\paragraph{Content}

yields

\section{Demo}
\subsubsection{Content}

Keybindings

This functionality has two keybindings

Method Shortcut Alternate
Increment Sectioning ctrl+alt+] ctrl+l ]
Decrement Sectioning ctrl+alt+[ ctrl+l ]

To use the alternate shortcuts, set latex-workshop.bind.altKeymap.enabled to true (you need reload/reopen vscode for the change to be taken into account).

Inserting Greek letters

Greek Letters can be inserted using the LaTeX command, which will autocomplete or using @ + letter

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
@s \sigma
@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

Handy mathematical snippets

Some common mathematical symbols or commands have a dedicated snippet.

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 |
@\ \setminus
@+ \bigcup
@- \bigcap
@, \nonumber

Font commands

Prefix Shortcut Command
fontsize Opens font size select
FNO \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}}

Mathematical font commands

Prefix Shortcut Command
MRM ctrl+m, ctrl+r \mathrm{${1}}
MBF ctrl+m, ctrl+s \mathbf{${1}}
MBB ctrl+m, ctrl+b \mathbb{${1}}
MCA ctrl+m, ctrl+c \mathcal{${1}}
MIT ctrl+m, ctrl+i \mathit{${1}}
MTT ctrl+m, ctrl+t \mathtt{${1}}

Miscellaneous Actions

Shortcut Action
ctrl+l, ctrl+Enter Insert newline + \item

Surrounding text

with a command

To surround text with a command, just select some text and use ctrl+l, ctrl+w (+l, +w on Mac). A new menu pops up to select the command. This works with multi selections.

wrap demo

With an environment

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.

Surround with environment demo