forked from OrangeX4/OrangeX4-HyperSnips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkdown.hsnips
844 lines (662 loc) · 17.2 KB
/
markdown.hsnips
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
# Rearranged from OrangeX4/OrangeX4-HyperSnips to meet personal taste.
global
// JavaScript code
function gen_matrix(nrow, ncol) {
let results = "";
let order = 1;
for (var i=0; i < nrow; i++){
results += ' ';
for(var j = 0; j < ncol - 1; j++){
results += "$" + (order).toString() + " & ";
order ++;
}
results += "$" + (order).toString() + " \\\\" + "\\";
order ++;
}
return results;
}
function gen_matrix_transposed(nrow, ncol) {
let results = "";
for (var i = 0; i < nrow; i++){
results += ' ';
var j = 0;
for(; j < ncol - 1;j++){
results += "$" + (i + j * ncol + 1).toString() + " & ";
}
results += "$" + (i + j * ncol + 1).toString() + " \\\\" + "\\";
}
return results;
}
function tes_matrix(nrow, ncol,t) {
let results = "";
let order = 1;
for (var i=0; i<nrow; i++){
results += ' ';
for(var j = 0;j <ncol-1;j++){
if (order > 1 ){
results += "${" +(order ).toString() + ":" + t[order-2] + "}\t & ";
}
else{
results += "$" +(order ).toString() + " & ";
}
order ++;
}
results += "$"+(order).toString() +" \\\\" + "\\ ";
order ++;
}
return results;
}
// 输出一个表格
function createTable(rows, cols) {
let ret = "";
let order = 1;
for (let i = 0; i < parseInt(rows) + 2; i++) {
for (let j = 0; j < parseInt(cols); j++) {
if (i === 1) {
ret += "|---";
} else {
ret += "| $" + (order).toString() + " ";
order++;
}
}
ret += "|\n"
}
return ret;
}
endglobal
## 数学模式
snippet lm "inline Math" wA
$${1}$$0
endsnippet
snippet dm "display Math" wA
$$
${1}
$$$0
endsnippet
snippet eqt "equation" wA
\begin{equation}
${1}
\end{equation}
endsnippet
snippet eqs "equation*" wA
\begin{equation*}
${1}
\end{equation*}
endsnippet
## 分数
snippet // "Fraction" iAm
\\frac{${1:${VISUAL}}}{$2}$0
endsnippet
snippet `((\d+)|(\d*)(\\)?([A-Za-z!]+)((\^|_)(\{\d+\}|\d))*)/` "Fraction no ()" iAm
\frac{``rv = m[1]``}{$1}$0
endsnippet
priority 200
snippet `(?<=\s)(\\mu|\\alpha|\\sigma|\\rho|\\beta|\\gamma|\\delta|\\zeta|\\eta|\\varepsilon|\\theta|\\iota|\\kappa|\\vartheta|\\lambda|\\nu|\\pi|\\rho|\\tau|\\upsilon|\\phi|\\chi|\\psi|\\omega|\\Gamma|\\Delta|\\Theta|\\Lambda|\\Xi|\\Pi|\\Sigma|\\Upsilon|\\Phi|\\Psi|\\Omega|[A-Za-z]{1,2})?(_[A-Za-z0-9]|_\{[^}]+\})?(\^[A-Za-z0-9]|\^\{[^}]+\})?(_[A-Za-z0-9]|_\{[^}]+\})?(\([^)]+\))(_[A-Za-z0-9]|_\{[^}]+\})?(\^[A-Za-z0-9]|\^\{[^}]+\})?(_[A-Za-z0-9]|_\{[^}]+\})?\/` "Fraction with ()" iAm
``rv = "\\frac{" + m.slice(1, m.length).join('') + "}{$1}$2"``
endsnippet
## 帽子
#### 单个
snippet `(\\?[a-zA-Z]\w*({?\w*})?)(tld)` "波浪线" iAm
\tilde{``rv = m[1]``}
endsnippet
snippet `(\\?[a-zA-Z]\w*({?\w*})?)(bar)` "横线" iAm
\bar{``rv = m[1]``}
endsnippet
snippet `(\\?[a-zA-Z]\w*({?\w*})?)(hat)` "尖顶" iAm
\hat{``rv = m[1]``}
endsnippet
snippet `(\\?[a-zA-Z]\w*({?\w*})?)(vec)` "向量" iAm
\vec{``rv = m[1]``}
endsnippet
snippet `(\\?[a-zA-Z]\w*({?\w*})?)(VEC)` "左箭头" iAm
\overleftarrow{``rv = m[1]``}
endsnippet
snippet `(\\?[a-zA-Z]\w*({?\w*})?)(dot)` "点" iAm
\dot{``rv = m[1]``}
endsnippet
priority 200
snippet `\\?(c|d|v|l)(dot)` "点" iAm
\``rv = m[1]``dot
endsnippet
priority 1000
snippet `(\\?[a-zA-Z]\w*({?\w*})?)(ddot)` "两点" iAm
\ddot{``rv = m[1]``}
endsnippet
#### 多个
snippet tld "tilde" iAm
\tilde{$1}$0
endsnippet
snippet bar "bar" iAm
\overline{$1}$0
endsnippet
snippet hat "hat" iAm
\hat{$1}$0
endsnippet
snippet vec "vec" iAm
\overrightarrow{$1}$0
endsnippet
snippet VEC "reversed vec" iAm
\overleftarrow{$1}$0
endsnippet
snippet sqrt "根号" iAm
\sqrt{${1}}$0
endsnippet
## 数学字体
snippet txt "纯文本" iAm
\text{$1}$0
endsnippet
snippet tit "纯文本斜体" iAm
\textit{$1}$0
endsnippet
snippet mcal "手写体1" iAm
\mathcal{$1}$0
endsnippet
snippet mscr "手写体2" iAm
\mathscr{$1}$0
endsnippet
snippet mbb "空心体" iAm
\mathbb{$1}$0
endsnippet
snippet mbf "粗体" iAm
\mathbf{$1}$0
endsnippet
snippet 0bm "0bm" iAm
\bm{0}
endsnippet
snippet 1bm "1bm" iAm
\bm{1}
endsnippet
snippet TT "转置" iAm
^{\mathrm{T}}
endsnippet
snippet HH "共轭转置" iAm
^{\mathrm{H}}
endsnippet
snippet RR "R" iAm
\mathbb{R}
endsnippet
snippet NN "N" iAm
\mathbb{N}
endsnippet
snippet ZZ "Z" iAm
\mathbb{Z}
endsnippet
snippet QQ "Q" iAm
\mathbb{Q}
endsnippet
snippet CC "C" iAm
\mathbb{C}
endsnippet
## “象形”符号 及 容易漏打\的如函数名
snippet oooo "\infty" iAmm
\infty
endsnippet
snippet ... "cdots" iAm
\cdots
endsnippet
snippet `(\d+)\.\.` "e.g. 3..形成x_3,...,x_n, 其中光标停留在x上" iAm
``rv = m[1].split('').map((d) => "${1:_}" + d + "${2:, }").join('');``\cdots${3:${2:, }${1:_}n}
endsnippet
snippet `(\d+),` "e.g. 134,形成x_1,x_3,x_4, 其中光标停留在x上" iAm
``rv = m[1].split('').map((d) => "${1:_}" + d).join("${2:, }");``
endsnippet
snippet <> "菱形" iA
\diamond
endsnippet
# +... -> , \cdots
# - ... -> , \cdots
# add a space if there already is one.
priority 101
snippet `(?<=[-+])\s*\.\.\.` "smart cdots" imA
\cdots
endsnippet
# It seems that \ldots is only used when , ...,
# ,... -> , \ldots
# , ... -> , \ldots
priority 101
snippet `(?<=,)(\s*)\.\.\.` "贴地三点(只在逗号后触发)" imA
\ldots
endsnippet
snippet ** "中间一点(乘法)" iAm
\cdot
endsnippet
snippet +- "pm" iAm
\pm
endsnippet
snippet -+ "mp" iAm
\mp
endsnippet
priority 101
snippet xx "乘号" iAm
\times
endsnippet
snippet `(?<!\\)eps` "epsilon" iAm
\epsilon
endsnippet
priority 100
snippet `(?<!\\)veps` "varepsilon" iAm
\varepsilon
endsnippet
snippet oth "otherwise" iAm
\text{otherwise}
endsnippet
snippet `(?<!\\)(oint|iiint|iint|int)` "integrate" iAm
\\``rv = m[1]``
endsnippet
snippet `(?<!\\)(sum|min|max|argmin|argmax|sup|inf)` "sum|min|max|argmin|argmax|sup|inf" iAm
\\``rv = m[1]``
endsnippet
snippet `(?<!\\)(sin|cos|tan|arccot|cot|csc|ln|log|exp|det|perp|arcsin|arccos|arctan|arccot|arccsc|arcsec|ell|nabla|notin|not)` "function" iAm
\\``rv = m[1]``
endsnippet
snippet `(?<!\\)(mu|alpha|sigma|rho|beta|Beta|gamma|delta|pi|zeta|eta|varepsilon|theta|iota|kappa|vartheta|lambda|nu|pi|rho|tau|upsilon|varphi|phi|chi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)` "greek" iAm
\\``rv = m[1]``
endsnippet
snippet `(?<!\\|e)(psi)` "专门拿出psi, 因为它含于epsilon" iAm
\\``rv = m[1]``
endsnippet
snippet `(?<!\\)(quad)` "quad" iAm
\\``rv = m[1]``
endsnippet
## 逻辑学
snippet empty "empty" iAm
\empty
endsnippet
priority 200
snippet `inn|iin` "in" iAm
\in
endsnippet
priority 200
snippet `\\ln ?ot` "in" iAm
\lnot
endsnippet
snippet sse "subseteq" iAm
\subseteq
endsnippet
snippet sqs "sqsubset" iAm
\sqsubseteq
endsnippet
priority 200
snippet `tto|too|->` "to" iAm
\to
endsnippet
priority 201
snippet `rtto|rtoo|<-|-<` "leftarrow" iAm
\leftarrow
endsnippet
priority 200
snippet `(?<!\\)(cap|cup|land|lor|lnot|oplus|ominus|otimes|sqcap|sqcup|vdash|models)` "logic operator" iAm
\\``rv = m[1]``
endsnippet
priority 200
snippet `(?<=\b|\d+)(?<!\\)(bot|top|dagger)` "logic symbols" iAm
\\``rv = m[1]``
endsnippet
priority 201
snippet `\|->|mto` "mapsto" iAm
\mapsto
endsnippet
snippet `ipy|=>` "implies" iAm
\implies
endsnippet
snippet `iby|=<` "implied by" iAm
\impliedby
endsnippet
priority 200
snippet iff "if and only if" iAm
\iff
endsnippet
snippet EE "exist" iAm
\exists
endsnippet
snippet AA "forall" iAm
\forall
endsnippet
snippet bec "because" iAm
\because
endsnippet
snippet thr "therefore" iAm
\therefore
endsnippet
## 概率论
snippet Pr "Pr" iAm
\operatorname{Pr}
endsnippet
snippet Var "Var" iAm
\operatorname{Var}
endsnippet
snippet Cov "Cov" iAm
\operatorname{Cov}
endsnippet
snippet Exp "Expected" iAm
\mathbb{E}
endsnippet
## 比较符号
snippet -- "集合减法" iAm
\setminus
endsnippet
snippet >= "greater than" iAm
\ge $0
endsnippet
snippet <= "less than" iAm
\le $0
endsnippet
snippet != "no equals" iAm
\neq
endsnippet
snippet == "constant equals" iAm
\equiv
endsnippet
snippet ~ "一条波浪" iAm
\sim
endsnippet
priority 200
snippet `\\sim -` "一条波浪一条横线" iAm
\simeq
endsnippet
snippet ~~ "两条波浪" iAm
\approx
endsnippet
snippet `\\sim =` "一条波浪两条横线" iAm
\cong
endsnippet
snippet >> ">>" iAm
\gg
endsnippet
snippet << "<<" iAm
\ll
endsnippet
## 双边符号
snippet case "cases" iAm
\begin{cases} $1, & $2 \\\\ $3, & $4 \end{cases}
endsnippet
snippet ali "aligned" iAm
\begin{aligned}
$1
\end{aligned}
endsnippet
snippet `c(ei)?l` "ceil" iAm
\left\lceil $1 \right\rceil $0
endsnippet
snippet `fl(oor)?` "floor" iAm
\left\lfloor $1 \right\rfloor$0
endsnippet
priority 100
snippet @) "left( right)" Aim
\left( ${1} \right) $0
endsnippet
priority 100
snippet @| "left| right|" Aim
\left| ${1} \right| $0
endsnippet
priority 100
snippet @\ "left. right|" Aim
\left. ${1} \right|_{${2}}$0
endsnippet
priority 100
snippet @} "left\{ right\}" Aim
\left\\{ ${1} \right\\} $0
endsnippet
priority 100
snippet set "\{ \}" Aim
\\{ ${1} \\}$0
endsnippet
priority 100
snippet @] "left[ right]" Aim
\left[ ${1} \right] $0
endsnippet
priority 100
snippet @> "leftangle rightangle" iAm
\left<${1} \right>$0
endsnippet
priority 200
snippet norm "范数" iAm
\left\| ${1} \right\|$2
endsnippet
## 乱七八糟
snippet tag "tag" iAm
\tag{$1}
endsnippet
snippet xyb "Auto (x, y)" iAm
(x, y)
endsnippet
snippet xyzb "Auto (x, y ,z)" iAm
(x, y, z)
endsnippet
priority 100
snippet `\b([a-zA-Z])n(\d)` "输入xn2得到x_{n+2}" iAm
``rv = m[1]``_{${1:n}+``rv = m[2]``}$0
endsnippet
snippet seq "数列{x_n}_{n=1}^{\infty}" iAm
\\{${1:x}_${2:n}\\}_{${3:$2}=${4:1}}^{\infty}$0
endsnippet
priority 200
snippet abs "absolute value" iAm
\left\vert ${1} \right\vert $0
endsnippet
snippet beg "begin{} / end{}" bA
\\begin{$1}
$0
\\end{$1}
endsnippet
## 展开
priority 100
snippet comma "生成\alpha_1,\alpha_2,...,\alpha_n" iAm
${1:\\alpha}_1,${1:\\alpha}_2,\\cdots,${1:\\alpha}_${2:n}
endsnippet
priority 100
snippet plus "生成k_1 \alpha_1 + k_2 \alpha_2 +...+ k_n \alpha_n" iAm
${1:k}_1${2:\\alpha}_1+${1:k}_2${2:\\alpha}_2+\\cdots+${1:k}_${3:n}${2:\\alpha}_${3:n}
endsnippet
snippet `\b(i)i=n` "将ii/jj/kk=n自动展成i=1,2,...,n" iAm
i=1,2,\cdots,n
endsnippet
snippet `\b(j)j=n` iAm
j=1,2,\cdots,n
endsnippet
snippet `\b(k)k=n` iAm
k=1,2,\cdots,n
endsnippet
## 常用公式
snippet tay "taylor" iAm
\sum\limits_{${1:k}=${2:0}}^{${3:\infty}} ${4:\frac{f^{($1)\} (x_0)\}{k!\}} (x-x_0)^$1 $0
endsnippet
snippet `(?<!\\)lim` "limit" iAm
\lim\limits_{${1:n} \to ${2:\infty}}
endsnippet
snippet `(?<!\\)prod` "product" iAm
\prod\limits_{${1:n=${2:1}}}^{${3:\infty}} {$4}$0
endsnippet
snippet `(?<!\\)part` "偏/偏x" iAm
\frac{\partial ${1:F}}{\partial ${2:x}}$0
endsnippet
priority 300
snippet `(?<!\\)diff` "d/dx" iAm
\frac{\mathrm{d}${1:y}}{\mathrm{d}${2:x}}$0
endsnippet
priority 400
snippet `(?<!\\)2diff` "d2/dx2" iAm
\frac{\mathrm{d}^2${1:y}}{\mathrm{d}${2:x}^2}$0
endsnippet
priority 400
snippet `(?<!\\)3diff` "d3/dx3" iAm
\frac{\mathrm{d}^3${1:y}}{\mathrm{d}${2:x}^3}$0
endsnippet
priority 300
snippet `dd` "d" iAm
\mathrm{d}
endsnippet
snippet CUP "bigcup" iAm
\bigcup\limits_{${1:i \in ${2: I}}} $0
endsnippet
snippet CAP "bigcap" iAm
\bigcap\limits_{${1:i \in ${2: I}}} $0
endsnippet
priority 100
snippet dint "integral" iAm
\int_{${1:-\infty}}^{${2:\infty}} ${3:f(x)} \\mathrm{d}${4:x}$0
endsnippet
priority 200
snippet `c(o|n)?(l|n)?(b|c)?int` "各种积分号" iAm
``
let final = "\\"; // init
let isO = m[1] == "o";
(isO) ? final += "o" : "" // o option
let b = 1;
let isL = m[2] == "l";
(m[3] == 'b') ? b = 2 : (m[3] == 'c') ? b = 3 : 1;
for (let i = 0; i < b - 1; i++) {
final += "i";
}
final += "int";
final += ((b >= 2) || (b != 1 && !isO && isL)) ? "\\limits" : "";
let r = (b == 3) ? "E" : (b == 1 && (isL || isO)) ? "C" : "R";
final += ((b >= 2) || isO || (b == 1 && isL)) ? "_{${1:" + r + "}}" : "_{${1:-\\infty}}^{${2:\\infty}}";
let x = (b == 2) ? "A" : (b == 3) ? "V" : (b == 1 && isL) ? "s" : "x";
final += " ${3} \\mathrm{d}${4:" + x + "}$0";
rv = final;
``
endsnippet
## 自定义纯文本显示的算子
priority 100
snippet `(?<![\a-zA-Z])(rank|trace|svd|eye|ones|orth|rows|cols|zeros|diag|rref|hstack|vstack|nullspace|eigen|dim|lcm|gcd|atan2|softmax|eig|sign|const)` "math function" iAm
\\operatorname{``rv = m[1]``}
endsnippet
## 大定义
snippet `DEFF|bigdef` "详细定义映射" iAm
\begin{equation$6}
\begin{aligned}
$1\colon $2 &\longrightarrow $3 \\\\
$4 &\longmapsto $1($4) = $5
\end{aligned}
\end{equation$6}$0
endsnippet
priority 300
snippet bigmin "Optimization problem" iAm
\begin{equation$4}
\begin{aligned}
\min &\quad ${1:f(x)}\\\\
\text{s.t.} &\quad ${2:g(x)} \leq 0\\\\
&\quad ${3:h(x)} = 0\\\\
\end{aligned}
\end{equation$4}$0
endsnippet
priority 300
snippet bigmax "Optimization problem" iAm
\begin{equation$4}
\begin{aligned}
\max &\quad ${1:f(x)}\\\\
\text{s.t.} &\quad ${2:g(x)} \leq 0\\\\
&\quad ${3:h(x)} = 0\\\\
\end{aligned}
\end{equation$4}$0
endsnippet
priority 300
snippet Argmin "Optimization problem" iAm
\begin{aligned}
\argmin_{${1:\beta}}
&\quad ${2:f(x)} \\\\
\text{s.t.}
&\quad ${3:g(x) > 0} \\\\
\end{aligned}
endsnippet
priority 300
snippet Argmax "Optimization problem" iAm
\begin{aligned}
\argmax_{${1:\beta}}
&\quad ${2:f(x)} \\\\
\text{s.t.}
&\quad ${3:g(x) > 0} \\\\
\end{aligned}
endsnippet
snippet deff "定义数值函数" iAm
$1\colon ${2:\\mathbb{R\}} \to ${3:\\mathbb{R\}}, ${4:x} \mapsto $0
endsnippet
snippet iid "independent and identical distribution" iAm
\overset{\text{i.i.d.}}{\sim}
endsnippet
snippet defe "定义符号1: 等号上面一个def" iAm
\overset{\underset{\mathrm{def}}{}}{=}
endsnippet
snippet deft "定义符号2: 加热符号" iAm
\triangleq
endsnippet
## 矩阵
snippet pmat "pmat" wm
\begin{pmatrix}
${1: }
\end{pmatrix} $0
endsnippet
snippet bmat "pmat" wm
\begin{bmatrix}
$1
\end{bmatrix} $0
endsnippet
priority 300
snippet cvec "列向量" iAm
\begin{pmatrix} ${1:x}_1 \\\\ ${1:x}_2 \\\\ \vdots \\\\ ${1:x}_${2:n} \end{pmatrix}
endsnippet
priority 300
snippet rvec "行向量" iAm
\begin{pmatrix} ${1:x}_1, ${1:x}_2, \cdots, ${1:x}_${2:n} \end{pmatrix}$0
endsnippet
priority 300
snippet diag "对角矩阵" iAm
\\begin{pmatrix}${1:d_1}& &\\\\&${2:d_2}&\\\\&&\\ddots&\\\\&&&${3:d_n}\\end{pmatrix}
endsnippet
priority 301
snippet amat "矩阵(a_{ij})" iAm
\\begin{pmatrix}
${1:a}_{11} & ${1:a}_{12} & \\cdots & ${1:a}_{1n} \\\\
${1:a}_{21} & ${1:a}_{22} & \\cdots & ${1:a}_{2n} \\\\
\\vdots & \\vdots & \\ddots & \\vdots \\\\
${1:a}_{n1} & ${1:a}_{n2} & \\cdots & ${1:a}_{nn}
\\end{pmatrix}
endsnippet
priority 300
snippet `(?<!b|p|v)mat` "mat 除各...外可供修改" iAm
\\begin{pmatrix}
${1:a_{11\}} & ${2:a_{12\}} & \\cdots & ${3:a_{1n\}} \\\\
${4:a_{21\}} & ${5:a_{22\}} & \\cdots & ${6:a_{2n\}} \\\\
\\vdots & \\vdots & \\ddots & \\vdots \\\\
${7:a_{n1\}} & ${8:a_{n2\}} & \\cdots & ${9:a_{nn\}}
\\end{pmatrix}
endsnippet
snippet jacobi "jacobi" iAm
\\begin{pmatrix}\\frac{\\partial ${1:f}_1}{\\partial ${2:x}_1}&\\frac{\\partial ${1:f}_1}{\\partial ${2:x}_2}&\\cdots&\\frac{\\partial ${1:f}_1}{\\partial ${2:x}_${3:n}}\\\\\\frac{\\partial ${1:f}_2}{\\partial ${2:x}_1}&\\frac{\\partial ${1:f}_2}{\\partial ${2:x}_2}&\\cdots&\\frac{\\partial ${1:f}_2}{\\partial ${2:x}_${3:n}}\\\\\\vdots&\\vdots&\\ddots&\\vdots\\\\\\frac{\\partial ${1:f}_${3:m}}{\\partial ${2:x}_1}&\\frac{\\partial ${1:f}_${3:m}}{\\partial ${2:x}_2}&\\cdots&\\frac{\\partial ${1:f}_${3:m}}{\\partial ${2:x}_${3:n}}\\end{pmatrix}
endsnippet
priority 300
snippet `(b|p|v)mata([1-9])` "pmata3|vmata3(行列式) 填入所有元素相等" iiAm
\\begin{``rv = m[1]``matrix}``
let len = m[2];
let results = "";
for (var i=0; i<len; i++){
results += "$1 &".repeat(len-1) + " $1 \\\\\\\\";
}
rv = results;
``\\end{``rv = m[1]``matrix}$0
endsnippet
priority 300
snippet `(b|p|v)mat([1-9])` "pmat3 按行填入" iiAm
\\begin{``rv = m[1]``matrix}``
rv = gen_matrix(m[2],m[2]);
``\\end{``rv = m[1]``matrix}$0
endsnippet
priority 300
snippet `(b|p|v)matr([1-9]{1})` "pmatr3 按列填入" iiAm
\\begin{``rv = m[1]``matrix}``
rv = gen_matrix_transposed(m[2],m[2]);
``\\end{``rv = m[1]``matrix}$0
endsnippet
## 非数学相关, 方框与表格, markdown实现并不理想
snippet \box "Box"
``rv = '┌' + '─'.repeat(t[0].length + 2) + '┐'``
│ $1 │
``rv = '└' + '─'.repeat(t[0].length + 2) + '┘'``
endsnippet
priority 300
snippet `table(\d)(\d)` "create table with rows and columns" wA
``
rv = createTable(m[1], m[2]);
``
endsnippet