dotfiles/nvim/ultisnips/tex.snippets

874 lines
13 KiB
Plaintext
Raw Permalink Normal View History

2022-11-09 19:09:19 -05:00
global !p
2022-11-19 13:46:44 -05:00
# thanks to gilles castel
2022-11-09 19:09:19 -05:00
def math():
return vim.eval('vimtex#syntax#in_mathzone()') == '1'
2022-11-19 13:46:44 -05:00
def env(name):
[x,y] = vim.eval("vimtex#env#is_inside('" + name + "')")
return x != '0' and y != '0'
2022-11-09 19:09:19 -05:00
endglobal
2022-11-21 00:05:55 -05:00
# General
snippet beg "Begin / End" bA
2022-11-09 19:09:19 -05:00
\\begin{$1}
$2
\\end{$1}$0
endsnippet
2022-11-19 13:46:44 -05:00
snippet pac "Package" b
\usepackage[$1]{$2}$0
endsnippet
snippet template "Basic template" b
\documentclass[$1]{$2}
$3
\begin{document}
$0
\end{document}
endsnippet
snippet item "Itemize" bA
\begin{itemize}
\item $0
\end{itemize}
endsnippet
snippet enum "Enumerate" bA
\begin{enumerate}
\item $0
\end{enumerate}
endsnippet
snippet alph "Alphabet Enumerate" bA
\begin{enumerate}[label= (\alph*)]
\item $1
\end{enumerate} $0
endsnippet
snippet desc "Description" bA
\begin{description}
\item[$1] $2
\end{description} $0
endsnippet
snippet table "Table" b
\begin{table}[${1:htpb}]
\centering
2022-12-04 01:27:12 -05:00
\caption{$2}
\label{tab:$3}
2022-11-19 13:46:44 -05:00
\begin{tabular}{${5:c}}
$6${5/((?<=.)c|l|r)|./(?1: & )/g}
\end{tabular}
\end{table} $0
endsnippet
2023-09-25 14:10:12 -04:00
snippet algorithm "Algorithm" b
\begin{algorithm}[${1:H}]
\caption{$2}\label{tab:$3}
\begin{algorithmic}[${4:1}]
$5
\end{algorithmic}
\end{algorithm} $0
endsnippet
2022-11-21 00:05:55 -05:00
priority 100
snippet ... "Ldots" iA
\ldots
endsnippet
snippet ~~ "Sim" iA
\sim
endsnippet
2022-12-04 01:27:12 -05:00
snippet section "Section" bA
\sect{$1}$0
endsnippet
2023-09-25 14:10:12 -04:00
snippet subsection "Subsection" bA
\subsect{$1}$0
endsnippet
2022-12-04 01:27:12 -05:00
snippet chapter "Chapter" bA
\chapter{$1}$0
endsnippet
2023-02-09 06:58:00 -05:00
snippet ppart "Part" bA
2022-12-04 01:27:12 -05:00
\part{$1}$0
endsnippet
snippet theorem "Theorem" bA
\begin{theorem}[$1]
$2
\end{theorem} $0
endsnippet
snippet definition "Definition" bA
\begin{definition}[$1]
$2
\end{definition} $0
endsnippet
2022-12-04 23:37:31 -05:00
snippet example "Example" bA
\begin{eg}[$1]
$2
\end{eg} $0
endsnippet
2022-11-21 00:05:55 -05:00
# Math
snippet sm "Math" wA
$${1}$`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
snippet dm "Display Math" wA
\[
$1
\] $0
endsnippet
snippet ali "Align" bA
\begin{align*}
${1:${VISUAL}}
\end{align*} $0
endsnippet
context "math()"
snippet => "Implies" Ai
\implies
endsnippet
context "math()"
snippet =< "Implied by" Ai
\impliedby
endsnippet
context "math()"
snippet iff "Iff" Ai
\iff
endsnippet
context "math()"
2022-12-12 00:13:40 -05:00
snippet `(?<!\\)bm` "Bm" rwAi
2022-11-21 00:05:55 -05:00
\bm{$1}$0
endsnippet
2022-12-12 00:13:40 -05:00
snippet `(?<!\\)emph` "Emphasize" rwAi
\emph{$1}$0
endsnippet
2022-11-21 00:05:55 -05:00
context "math()"
2022-12-12 00:13:40 -05:00
snippet `(?<!\\)sqrt` "Square root" rwAi
2022-11-21 00:05:55 -05:00
\sqrt{$1}$0
endsnippet
context "math()"
2022-12-12 00:13:40 -05:00
snippet `(?<!\\)box` "Boxed" rwAi
2022-11-21 00:05:55 -05:00
\boxed{$1}$0
endsnippet
2022-11-19 13:46:44 -05:00
2022-11-21 00:05:55 -05:00
context "math()"
snippet lll "L" iA
\ell
endsnippet
context "math()"
snippet xx "Cross" iA
\times
endsnippet
priority 100
context "math()"
snippet ** "Cdot" iA
\cdot
endsnippet
context "math()"
snippet norm "Norm" iA
\|$1\|$0
endsnippet
2024-06-24 17:24:25 -04:00
context "math()"
snippet nrml "Normal Subgroup" iA
\triangleleft
endsnippet
2022-11-21 00:05:55 -05:00
context "math()"
snippet nabl "Nabla" iA
\nabla
endsnippet
context "math()"
snippet \\\ "Set minus" iA
\setminus
endsnippet
context "math()"
snippet mcal "mathcal" iA
\mathcal{$1}$0
endsnippet
priority 100
context "math()"
snippet -> "To" iA
\to
endsnippet
2023-09-25 14:10:12 -04:00
priority 100
context "math()"
snippet -< "Gets" iA
\gets
endsnippet
2022-11-21 00:05:55 -05:00
priority 200
context "math()"
snippet <-> "Leftrightarrow" iA
\leftrightarrow
endsnippet
context "math()"
snippet !> "Maps to" iA
\mapsto
endsnippet
context "math()"
snippet set "Set" wA
\left\\{ $1 \right\\} $0
endsnippet
context "math()"
snippet || "Mid" iA
\mid
endsnippet
context "math()"
2022-12-15 18:44:43 -05:00
snippet cc "Subset" wA
2022-11-21 00:05:55 -05:00
\subset
endsnippet
context "math()"
snippet notin "Not in" iA
\not\in
endsnippet
priority 10
context "math()"
2022-12-04 01:27:12 -05:00
snippet inn "In" iA
2022-11-21 00:05:55 -05:00
\in
endsnippet
context "math()"
snippet NN "Natural" iA
\N
endsnippet
context "math()"
snippet Nn "Cap" iA
\cap
endsnippet
context "math()"
snippet isect "Cap" iA
\cap
endsnippet
context "math()"
snippet UU "Cup" iA
\cup
endsnippet
context "math()"
snippet union "Cup" iA
\cup
endsnippet
context "math()"
snippet uuu "Big cup" iA
2023-09-03 20:55:58 -04:00
\bigcup_{${1:i \in ${2: I}}} $0
2022-11-21 00:05:55 -05:00
endsnippet
context "math()"
snippet nnn "Big cap" iA
2023-09-03 20:55:58 -04:00
\bigcap_{${1:i \in ${2: I}}} $0
2022-11-21 00:05:55 -05:00
endsnippet
context "math()"
snippet OO "Empty Set" iA
\varnothing
endsnippet
context "math()"
snippet RR "Real" iA
\R
endsnippet
context "math()"
snippet QQ "Rational" iA
\Q
endsnippet
context "math()"
snippet ZZ "Integer" iA
\Z
endsnippet
context "math()"
snippet HH "H" iA
\mathbb{H}
endsnippet
context "math()"
snippet DD "D" iA
\mathbb{D}
endsnippet
context "math()"
snippet <! "Normal" iA
\triangleleft
endsnippet
context "math()"
snippet <> "Diamond" iA
\diamond
endsnippet
context "math()"
snippet '(?<!i)sts' "Text Subscript" irA
_\text{$1} $0
endsnippet
context "math()"
snippet tt "Text" iA
\text{$1}$0
endsnippet
2024-01-29 22:19:31 -05:00
context "math()"
snippet opn "Operator Name" iA
\operatorname{$1}$0
endsnippet
2022-11-21 00:05:55 -05:00
priority 200
context "math()"
snippet rowvec "Row Vector" iA
\mqty[$1]$0
endsnippet
2022-12-12 00:13:40 -05:00
priority 200
context "math()"
snippet cvec "Column Vector" iA
\begin{pmatrix} ${1:x}_${2:1}\\\\ \vdots\\\\ $1_${2:n} \end{pmatrix}
endsnippet
2022-11-21 00:05:55 -05:00
context "math()"
snippet case "Cases" wA
2023-09-25 14:10:12 -04:00
\begin{cases}
2022-11-21 00:05:55 -05:00
$1
\end{cases} $0
endsnippet
priority 10
context "math()"
snippet "bar" "Bar" riA
\overline{$1}$0
endsnippet
priority 100
context "math()"
snippet "([a-zA-Z])bar" "Bar" riA
\overline{`!p snip.rv = match.group(1)`}
endsnippet
priority 10
context "math()"
2022-12-04 01:27:12 -05:00
snippet "hat" "Hat" ri
2022-11-21 00:05:55 -05:00
\hat{$1}$0
endsnippet
priority 100
context "math()"
2022-12-04 01:27:12 -05:00
snippet "([a-zA-Z])hat" "Hat" ri
2022-11-21 00:05:55 -05:00
\hat{`!p snip.rv = match.group(1)`}
endsnippet
priority 10
context "math()"
snippet "vec" "Vec" riA
\vec{$1}$0
endsnippet
priority 100
context "math()"
snippet "([a-zA-Z])vec" "Vec" riA
\vec{`!p snip.rv = match.group(1)`}
endsnippet
priority 100
context "math()"
2023-02-08 03:09:21 -05:00
snippet '(?<!\\)(sin|cos|tan|arccot|cot|csc|ln|log|exp|star|perp|arcsin|arccos|arctan|arccot|arccsc|arcsec)' "Functions" rwA
2022-11-21 00:05:55 -05:00
\\`!p snip.rv = match.group(1)`
endsnippet
2022-12-04 01:27:12 -05:00
priority 1000
context "math()"
2022-12-12 00:13:40 -05:00
snippet `(?<!\\)epsi` "Epsilon" rwA
2022-12-04 01:27:12 -05:00
\epsilon
endsnippet
priority 500
2022-11-21 00:05:55 -05:00
context "math()"
2022-12-12 00:13:40 -05:00
snippet '(?<!\\)(alpha|beta|gamma|Delta|delta|epsilon|zeta|eta|Theta|theta|iota|kappa|Lambda|lambda|mu|nu|Xi|Pi|pi|varpi|Sigma|sigma|tau|Phi|phi|varphi|chi|Psi|psi|Omega|omega)' "Greek" rwA
2022-11-21 00:05:55 -05:00
\\`!p snip.rv = match.group(1)`
endsnippet
2023-09-03 20:55:58 -04:00
context "math()"
snippet 'emptyset' "Emptyset" rwA
\varnothing
endsnippet
2022-12-12 00:13:40 -05:00
context "math()"
snippet '(?<!\\)xxi' "Xi" rwA
\xi
endsnippet
context "math()"
snippet '(?<!\\)rho' "Rho" rwA
\rho
endsnippet
2022-11-21 00:05:55 -05:00
context "math()"
snippet // "Fraction" iA
\\frac{${VISUAL}}{$1}$0
endsnippet
context "math()"
snippet / "Fraction" i
\\frac{${VISUAL}}{$1}$0
endsnippet
context "math()"
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Symbol Fraction" wrA
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
endsnippet
priority 1000
context "math()"
snippet '^.*\)/' "() Frac" wrA
`!p
stripped = match.string[:-1]
depth = 0
i = len(stripped) - 1
while True:
if stripped[i] == ")":
depth += 1
if stripped[i] == "(":
depth -= 1
if depth == 0:
break
i -= 1
snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}"
`{$1}$0
endsnippet
context "math()"
snippet __ "Full Subscript" iA
_{$1}$0
endsnippet
context "math()"
snippet '([A-Za-z])(\d)' "Subscript" wrA
`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`
endsnippet
context "math()"
snippet '([A-Za-z])(\d\d)' "Subscript 2" wrA
`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`}
endsnippet
context "math()"
snippet xnn "Subscript xn" iA
x_{n}
endsnippet
context "math()"
snippet ynn "Subscript yn" iA
y_{n}
endsnippet
context "math()"
snippet xii "Subscript xi" iA
x_{i}
endsnippet
context "math()"
snippet yii "Subscript yi" iA
y_{i}
endsnippet
context "math()"
snippet xjj "Subscript xj" iA
x_{j}
endsnippet
context "math()"
snippet yjj "Subscript yj" iA
y_{j}
endsnippet
context "math()"
snippet xp1 "Subscript x n+1" iA
x_{n+1}
endsnippet
context "math()"
snippet xp1 "Subscript y n+1" iA
y_{n+1}
endsnippet
context "math()"
snippet xmm "Subscript xm" iA
x_{m}
endsnippet
context "math()"
snippet ymm "Subscript ym" iA
y_{m}
endsnippet
context "math()"
snippet x_ "Subscript x" iA
x_{$1}$0
endsnippet
context "math()"
snippet y_ "Subscript y" iA
y_{$1}$0
endsnippet
context "math()"
snippet == "Equals" iA
&= $1 \\\\$0
endsnippet
context "math()"
snippet != "Not Equals" iA
\neq
endsnippet
context "math()"
snippet ceil "Ceil" iA
\left\lceil $1 \right\rceil $0
endsnippet
context "math()"
snippet floor "Floor" iA
\left\lfloor $1 \right\rfloor$0
endsnippet
context "math()"
snippet pmat "Paren Matrix" iA
\begin{pmatrix} $1 \end{pmatrix} $0
endsnippet
context "math()"
2022-12-16 19:09:01 -05:00
snippet matr "Bracket Matrix" iA
2022-11-21 00:05:55 -05:00
\begin{bmatrix} $1 \end{bmatrix} $0
endsnippet
context "math()"
snippet Bmat "Brace Matrix" iA
\begin{Bmatrix} $1 \end{Bmatrix} $0
endsnippet
context "math()"
snippet vmat "Vert Matrix" iA
\begin{vmatrix} $1 \end{vmatrix} $0
endsnippet
context "math()"
snippet () "Parenthesis" iA
\left( ${1:${VISUAL}} \right) $0
endsnippet
context "math()"
snippet lr "Parenthesis" i
\left( ${1:${VISUAL}} \right) $0
endsnippet
context "math()"
snippet lr( "Parenthesis" i
\left( ${1:${VISUAL}} \right) $0
endsnippet
context "math()"
snippet lr| "Verticals" i
\left| ${1:${VISUAL}} \right| $0
endsnippet
context "math()"
snippet lr{ "Braces" i
\left\\{ ${1:${VISUAL}} \right\\} $0
endsnippet
context "math()"
snippet lrb "Braces" i
\left\\{ ${1:${VISUAL}} \right\\} $0
endsnippet
context "math()"
snippet lr[ "Brackets" i
\left[ ${1:${VISUAL}} \right] $0
endsnippet
context "math()"
snippet lra "Angled" iA
\left<${1:${VISUAL}} \right>$0
endsnippet
context "math()"
snippet conj "Conjugate" iA
\overline{$1}$0
endsnippet
context "math()"
snippet sr "Square" iA
^2
endsnippet
context "math()"
snippet cb "Cube" iA
^3
endsnippet
context "math()"
snippet invs "Inverse" iA
^{-1}
endsnippet
context "math()"
snippet compl "Complement" iA
^{c}
endsnippet
context "math()"
snippet tp "To the power" iA
^{$1}$0
endsnippet
context "math()"
snippet bp "Paren to the power" iA
^{($1)}$0
endsnippet
context "math()"
snippet sum "Bounded Sum" w
2022-12-04 01:27:12 -05:00
\sum_{${1:n=${2:1}}}^{${3:\infty}} $4
2022-11-21 00:05:55 -05:00
endsnippet
context "math()"
snippet prod "Product" w
2022-12-12 00:13:40 -05:00
\prod_{${1:n=${2:1}}}^{${3:\infty}} $4
2022-11-21 00:05:55 -05:00
endsnippet
context "math()"
snippet ssum "Sum Symbol" w
\sum $1
endsnippet
context "math()"
snippet lim "Limit" w
\lim_{${1:n} \to ${2:\infty}} $0
endsnippet
context "math()"
snippet ooo "Infinity" iA
\infty
endsnippet
context "math()"
snippet limsup "Limit Supremum" w
\limsup_{${1:n} \to ${2:\infty}} $0
endsnippet
context "math()"
snippet part "Partial Derivative" w
\pdv[$1]{${2:v}}{${3:x}} $0
endsnippet
2022-12-08 18:05:40 -05:00
context "math()"
2022-12-12 00:13:40 -05:00
snippet `(?<!\\)dd` "Differential" rwA
2022-12-08 18:05:40 -05:00
\dd{$1}$0
endsnippet
context "math()"
snippet dv "Derivative" wA
\dv{$1}{$2}$0
endsnippet
2022-11-21 00:05:55 -05:00
priority 300
context "math()"
snippet int "Definite Integral" w
\int_{${1:-\infty}}^{${2:\infty}} $3
endsnippet
priority 300
context "math()"
snippet iint "Indefinite Integral" w
\int $1
endsnippet
context "math()"
snippet <= "Less than or equal" iA
\le
endsnippet
context "math()"
snippet >= "Greater than or equal" iA
\ge
endsnippet
context "math()"
snippet >> "Greater greater" iA
\gg
endsnippet
context "math()"
snippet << "Less less" iA
\ll
endsnippet
context "math()"
snippet EE "There exists" iA
\exists
endsnippet
context "math()"
snippet AA "For all" iA
\forall
endsnippet
2023-09-25 14:10:12 -04:00
context "math()"
snippet "such that" "Such that" iA
\suchthat
endsnippet
context "math()"
snippet "suchthat" "Suchthat" iA
\suchthat
endsnippet
2023-02-09 18:06:49 -05:00
snippet image "Image" wA
\begin{figure}[${1:h}]
\includegraphics[width=${2:0.5}\textwidth]{$3}
\end{figure} $0
endsnippet
2024-02-08 02:01:17 -05:00
snippet tikzfig "Tikz Figure" wA
\begin{figure}[${1:H}]
\begin{center}
\begin{tikzpicture}
$2
\end{tikzpicture}
\end{center}
\end{figure} $0
endsnippet
2022-11-21 00:05:55 -05:00
snippet plot "Plot" w
\begin{figure}[$1]
\centering
\begin{tikzpicture}
\begin{axis}[
xmin= ${2:-10}, xmax= ${3:10},
ymin= ${4:-10}, ymax = ${5:10},
axis lines = middle,
]
\addplot[domain=$2:$3, samples=${6:100}]{$7};
\end{axis}
\end{tikzpicture}
2023-09-25 14:10:12 -04:00
\caption{$8}\label{plot:$9}
2022-11-21 00:05:55 -05:00
\end{figure} $0
endsnippet
snippet nn "Tikz node" w
\node[$5] (${1/[^0-9a-zA-Z]//g}${2}) ${3:at (${4:0,0}) }{$${1}$};
$0
endsnippet
2022-12-16 19:09:01 -05:00
snippet problem "Problem" biA
2022-11-21 00:05:55 -05:00
\pbl{$1}
$0
endsnippet
# English
2022-11-19 13:46:44 -05:00
snippet ltable "Long table" b
\begin{longtable}{${1:|p{5cm}|p{10cm}|}}
\hline
$2
\hline
\end{longtable} $0
endsnippet
2022-12-15 18:44:43 -05:00
snippet '(?<!\\)---' "Hline" rwA
2022-11-19 13:46:44 -05:00
\hline
endsnippet
2022-12-15 18:44:43 -05:00
snippet '(?<!\\)--' "Dash" rw
\---
endsnippet
2022-11-21 00:05:55 -05:00
# Code
2022-12-04 01:27:12 -05:00
snippet bsc "Blank Inline Code" wA
2022-11-21 00:05:55 -05:00
\texttt{${1}}`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
2022-12-04 23:37:31 -05:00
snippet ssc "Inline Code" wA
2023-09-25 14:10:12 -04:00
{\inlinecode{${1}}{${2}}}`!p
2022-12-04 01:27:12 -05:00
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
2023-02-08 03:04:29 -05:00
`$3
2022-12-04 01:27:12 -05:00
endsnippet
snippet dc "Block Code" wA
\begin{listing}[${1:H}]
\caption{$2}
\label{lst:$3}
\begin{code}{$4}
$5
\end{code} $0
\end{listing}
2022-11-21 00:05:55 -05:00
endsnippet
snippet impc "Import Code" wA
2022-12-04 01:27:12 -05:00
\begin{listing}[${1:H}]
\caption{$2}
\label{lst:$3}
2022-12-16 19:09:01 -05:00
\importcode{$4}{$5}$0
2022-12-04 01:27:12 -05:00
\end{listing}
2022-11-21 00:05:55 -05:00
endsnippet
2022-11-09 19:09:19 -05:00
2022-12-08 18:05:40 -05:00
# Pres
snippet frame "Frame" bA
\begin{frame}{$1}
$2
\end{frame} $0
endsnippet