|
| 1 | +# Snippets |
| 2 | + |
| 3 | +Temp snippet document until I get a solution made with LuaSnip's `snippet_list`. It may be a bit terse, so feel free to make an issue or reformat it. |
| 4 | + |
| 5 | +> **Warning:** Most snippets require [VimTeX](https://github.com/lervag/vimtex) for the condition/show-condition to work. |
| 6 | +
|
| 7 | +## `commands.lua` |
| 8 | + |
| 9 | +### Labels/References |
| 10 | +- `alab`: add label, of the form `\label{${1:type}:${2:number}}$0` |
| 11 | +- `[acCer]ref`: add reference of the form `\(auto|c|C|eqn)ref{${1:type}:${2:number}}$0` |
| 12 | + * `cref/Cref` requires the `cleveref` package |
| 13 | + |
| 14 | +### Single-Command Snippets |
| 15 | +All of them are of the form `\COMMAND_NAME{$1}$0`, with those with `*` also having labels of the form `\label{type:${1:number}}` |
| 16 | + |
| 17 | +- `sec(*)`, `ssec(*)`, `sssec(*)`*: section, subsection, subsubsection respectively. Add `*` for the starred commands. |
| 18 | +- `sq`, `qq`: enquote* and enquote (single and double quotes). Requires `csquotes` package. |
| 19 | +- `bf`, `it`, `ttt`, `sc`, `tu`, `tov`: Text modifications (bold, italic, typewriter, small caps, underline, and overline). |
| 20 | + |
| 21 | +## `environments.lua` |
| 22 | + |
| 23 | +`beg` creates a generic environment snippet. |
| 24 | + |
| 25 | +```tex |
| 26 | +\begin{$1} |
| 27 | +$0 |
| 28 | +\end{$1} |
| 29 | +``` |
| 30 | + |
| 31 | +`-i` creates the itemize environment, and there's a choice of which bullet point to set (either default or custom bullets with `\item []` notation). |
| 32 | + |
| 33 | +```tex |
| 34 | +\begin{itemize} |
| 35 | +\item ${1:[$2]|} |
| 36 | +\end{itemize} |
| 37 | +``` |
| 38 | + |
| 39 | +`-e` deals with the enumerate environment. This one is a bit more involved than the itemize environment snippet, as it allows you to choose which labels and provides two defaults, lowercase roman numerals and lowercase alphabetical characters. |
| 40 | +```tex |
| 41 | +\begin{enumerate}${1:|[label=${2:(\alph*)|(\roman*)|}]} |
| 42 | +\item ${3:[$4]|} |
| 43 | +\end{enumerate} |
| 44 | +``` |
| 45 | + |
| 46 | +`--`, `!-` are the accompanying commands for bullet points, which map to `\item` and `\item []` respectively. These only work at the beginning of the line in itemize/enumerate environments. |
| 47 | + |
| 48 | + |
| 49 | +## `math.lua` |
| 50 | + |
| 51 | +### Entering Math Mode |
| 52 | +- `mk`: inline math `$$1$$0` |
| 53 | +- `dm`: display math |
| 54 | +- `ali`: align(|*|ed) |
| 55 | +- `gat`: gather(|*|ed) |
| 56 | +- `eqn`: equation(|*) |
| 57 | + |
| 58 | +### Useful Math Dynamic Snippets |
| 59 | +`[bBpvV]mat(%d)x(%d)(a|r)`: creates a dxd matrix, either augmented or not. Requires [this fix](https://tex.stackexchange.com/a/2238) for augments. |
| 60 | + |
| 61 | +For instance, `bmat2x2r` creates: |
| 62 | +```tex |
| 63 | +\begin{bmatrix} |
| 64 | +$1 & $2 \\ |
| 65 | +$3 & $4 \\ |
| 66 | +\end{bmatrix} |
| 67 | +``` |
| 68 | + |
| 69 | +`(%d)?cases`: creates a cases array with d rows; if no input is supplied it defaults to 2 rows. |
| 70 | + |
| 71 | +For instance, `3cases` creates: |
| 72 | +```tex |
| 73 | +\begin{cases} |
| 74 | +$1 & $2 \\ |
| 75 | +$3 & $4 \\ |
| 76 | +$5 & $6 |
| 77 | +\end{cases} |
| 78 | +``` |
| 79 | + |
| 80 | +## `math-commands.lua` |
| 81 | +These are somewhat self-explanatory unless someone convinces me otherwise. |
| 82 | + |
| 83 | +## `delimiters.lua` |
| 84 | + |
| 85 | +`lr(aAbBcmp)` creates a snippet of the form `\left[delim] $1 \right[delim] $0`; delimiters are created following this table: |
| 86 | + |
| 87 | +```lua |
| 88 | +-- brackets |
| 89 | +local brackets = { |
| 90 | + a = { "\\langle", "\\rangle" }, |
| 91 | + A = { "Angle", "Angle" }, |
| 92 | + b = { "brack", "brack" }, |
| 93 | + B = { "Brack", "Brack" }, |
| 94 | + c = { "brace", "brace" }, |
| 95 | + m = { "|", "|" }, |
| 96 | + p = { "(", ")" }, |
| 97 | +} |
| 98 | +``` |
0 commit comments