summaryrefslogtreecommitdiff
path: root/.vim/UltiSnips/tex.snippets
blob: 65cd9c705bda4d695763e6f6e7412c3f6b98c29e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
global !p
def math():
	return vim.eval('vimtex#syntax#in_mathzone()') == '1'
def env(name):
	x, y = vim.eval(f"vimtex#env#is_inside('{name}')")
	return x != '0' and y != '0'
endglobal

snippet begin "Begin/end" bA
\begin{$1}
$0
\end{$1}
endsnippet

snippet enum "Enumerate" bA
\begin{enumerate}
	\item $0
\end{enumerate}
endsnippet

snippet item "Itemize" bA
\begin{itemize}
	\item $0
\end{itemize}
endsnippet

snippet desc "Description" bA
\begin{description}
	\item[$1] $0
\end{description}
endsnippet

snippet define "Definition" bA
\begin{definition}[$1]
$0
\end{definition}
endsnippet

snippet prob "Problem" b
\problem{$1}
$0
endsnippet

snippet part "Part" b
\subproblem{$1}
$0
endsnippet

snippet table "Table" b
\begin{table}[${1:htpb}]
\centering
\caption{${2:caption}}
\begin{tabular}{@{} ${5:c c} @{}}
	$0${5/((?<=.)[clr])|./(?1: & )/g}
\end{tabular}
\end{table}
endsnippet

snippet fig "Figure" b
\begin{figure}[${1:htpb}]
	\centering
	${2:\includegraphics[width=0.8\textwidth]{$3}}
	\caption{${4:$3}}
\end{figure}
endsnippet

snippet plot "Plot" w
\begin{figure}[$1]
\centering
\begin{tikzpicture}
	\begin{axis}[
		title=$2,
		xlabel=$3,
		ylabel=$4
	]
		\addplot[$5]{$6};
	\end{axis}
\end{tikzpicture}
\caption{$7}
\end{figure}
endsnippet

context "env('tikzpicture')"
snippet arrow "Arrow" w
\draw[thick, ->] ($1,$2) -- ($3,$4);$0
endsnippet

context "math()"
snippet // "Fraction" iA
\frac{$1}{$2}$0
endsnippet

context "math()"
snippet '((\d*\.?\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Fraction" wrA
\frac{`!p snip.rv = match.group(1)`}{$1}$0
endsnippet

priority 1000
context "math()"
snippet '^.*\)/' "Fraction" wrA
`!p
depth = 1
i = len(match.string) - 3
while depth > 0 and i >= 0:
	if match.string[i] == ')': depth += 1
	if match.string[i] == '(': depth -= 1
	i -= 1
snip.rv = match.string[0:i+1] + '\\frac{' + match.string[i+2:-2]
`}{$1}$0
endsnippet

context "math()"
snippet tt "Text" iA
\text{$1}$0
endsnippet

snippet ... "Ellipsis" iA
\ldots
endsnippet

snippet == "Equals" iA
&= $1 \\\\
endsnippet

snippet != "neq" iA
\neq
endsnippet

snippet >= "geq" iA
\ge
endsnippet

snippet <= "leq" iA
\le
endsnippet

snippet __ "Subscript" iA
_{$1}$0
endsnippet

snippet ^^ "Superscript" iA
^{$1}$0
endsnippet

snippet ** "cdot" iA
\cdot
endsnippet

priority 10
context "math()"
snippet bar "bar" iA
\overline{$1}$0
endsnippet

priority 100
context "math()"
snippet '([a-zA-Z])bar' "bar" riA
\overline{`!p snip.rv=match.group(1)`}
endsnippet