-
Notifications
You must be signed in to change notification settings - Fork 1
/
plaintex.hsnips
895 lines (708 loc) · 14 KB
/
plaintex.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
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
global !p
texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']]
texIgnoreMathZones = ['texMathText']
texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')")
texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')")
ignore = texIgnoreMathZoneIds[0]
def math():
synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))")
try:
first = next(i for i in reversed(synstackids) if i in texIgnoreMathZoneIds or i in texMathZoneIds)
return first != ignore
except StopIteration:
return False
endglobal
snippet template "Basic template" b
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[dutch]{babel}
\usepackage{amsmath, amssymb}
% figure support
\usepackage{import}
\usepackage{xifthen}
\pdfminorversion=7
\usepackage{pdfpages}
\usepackage{transparent}
\newcommand{\incfig}[1]{%
\def\svgwidth{\columnwidth}
\import{./figures/}{#1.pdf_tex}
}
\pdfsuppresswarningpagegroup=1
\begin{document}
$0
\end{document}
endsnippet
snippet patemplate "programming assessment template" b
\documentclass[format]{assessment}
\usepackage{programminggeneral}
\input{../generalCourse}
\input{info/generalUnit}
\title{$1}
\author{} \date{}
\begin{document}
\namepoints
\writtenSection
$2
\programsSection
\end{document}
endsnippet
snippet atemplate "Assessment template" b
\documentclass[format]{assessment}
\usepackage{mathgeneral}
\input{../generalCourse}
\input{info/generalUnit}
\title{$1}
\author{} \date{}
\begin{document}
\namepoints
\begin{questions}
$2
\end{questions}
\end{document}
endsnippet
snippet wtemplate "Worksheet template" b
\documentclass[format]{worksheet}
\usepackage{mathgeneral}
\input{../generalCourse}
\input{info/generalUnit}
\title{$1}
\author{} \date{}
\begin{document}
\name
\begin{questions}
$2
\end{questions}
\end{document}
endsnippet
snippet pictemplate "picture/plot template" b
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
$1
\end{tikzpicture}
\end{document}
endsnippet
snippet mcanswers "Multiple Choice Answer Sheet"
{\large \textbf{Version: \assessmentVersion}}
\begin{multicols}{2}
\ifprintanswers
\ifnum\totvalue{mccount}<1
FIRST RUN
\else
\begin{enumerate}
\foreach \x in {1,...,\totvalue{mccount}}
{
\item \ref{question@\x@correctchoice}
}
\end{enumerate}
\fi
\else
\ifnum\totvalue{mccount}<1
FIRST RUN
\else
\generateMCAnswers{\totvalue{mccount}}
\fi
\fi
\end{multicols}
endsnippet
snippet nranswers "Numerical Response Answer Sheet"
\begin{multicols}{2}
\generateNRAnswers{\thenrcount}
\end{multicols}
endsnippet
snippet vs "Add Vertical Stretch Space"
\vspace{\stretch{1}}
endsnippet
snippet np "Add a newpage"
%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
endsnippet
snippet qp "Question with points"
\question[$1]
endsnippet
snippet mcq "Multiple Choice Question"
\question[1] $1
\begin{randomizechoices}
$2
\end{randomizechoices}
$0
endsnippet
snippet nrq "Numerical Response Question"
\begin{nrquestion}
\question[1] $1
\end{nrquestion}
$0
endsnippet
snippet q "Question"
\question $1
endsnippet
snippet beg "begin{} / end{}" b
\\begin{$1}
$2
\\end{$1}$0
endsnippet
snippet lsi "lstinputlisting" b
\lstinputlisting[$1]{$2}$3
endsnippet
snippet lstl "\begin{lstlisting}[options]...\end{lstlisting}" b
\begin{lstlisting}[style = $1, autogobble]
$2
\end{lstlisting}$3
endsnippet
snippet ig "includegraphics" w
\includegraphics[$1]{$2} $3
endsnippet
priority 100
snippet ... "ldots" i
\dots
endsnippet
snippet table "Table environment" b
\begin{table}[${1:htpb}]
\centering
\caption{${2:caption}}
\label{tab:${3:label}}
\begin{tabular}{${5:c}}
$0${5/((?<=.)c|l|r)|./(?1: & )/g}
\end{tabular}
\end{table}
endsnippet
snippet fig "Figure environment" b
\begin{figure}[${1:htpb}]
\centering
${2:\includegraphics[width=0.8\textwidth]{$3}}
\caption{${4:$3}}
\label{fig:${5:${3/\W+/-/g}}}
\end{figure}
endsnippet
snippet rc "randomizechoices enviroment" bA
\begin{randomizechoices}
\choice $0
\end{randomizechoices}
endsnippet
snippet frame "A frame!" bA
\begin{frame}{$1}
$2
\end{frame}
endsnippet
snippet optframe "A frame with optional parameters" bA
\begin{frame}[$1]{$2}
$3
\end{frame}
endsnippet
snippet exframe "An example frame" bA
\begin{frame}[fragile, allowframebreaks]{Example --- $1}
$2
\end{frame}
endsnippet
snippet part "Parts environment" bA
\begin{parts}
\\part$0
\end{parts}
endsnippet
snippet enum "Enumerate" bA
\begin{enumerate}
\\item $0
\end{enumerate}
endsnippet
snippet aenum "Enumerate with alphabetical bullets" bA
\begin{enumerate}[label = \alph*)]
\\item $0
\end{enumerate}
endsnippet
snippet item "Itemize" b
\begin{itemize}
\item $0
\end{itemize}
endsnippet
snippet desc "Description" b
\begin{description}
\item[$1] $0
\end{description}
endsnippet
snippet def "Definition" b
\begin{definition}[$1]
$0
\end{definition}
endsnippet
snippet pac "Package" b
\usepackage[${1:options}]{${2:package}}$0
endsnippet
snippet => "implies" i
\implies
endsnippet
snippet =< "implied by" Ai
\impliedby
endsnippet
context "math()"
snippet iff "iff" i
\iff
endsnippet
snippet mk "Math" wA
$${1}$`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
snippet mdk "inline Math with displaystyle" wA
$\displaystyle ${1}$`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
snippet dm "Math" wA
\[
${1:${VISUAL}}
\] $0
endsnippet
snippet ali "Align" bA
\begin{align}
${1:${VISUAL}}
\end{align}
endsnippet
snippet si "\SI{}{}" w
\SI{$1}{$2}$0
endsnippet
snippet 'sect?i?o?n?' "section" b
\section{$1}$0
endsnippet
context "math()"
snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet
snippet / "Fraction" i
\\frac{${VISUAL}}{$1}$0
endsnippet
context "math()"
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "symbol frac" 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 '([A-Za-z])(\d)' "auto subscript" wrA
`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`
endsnippet
context "math()"
snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA
`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`}
endsnippet
snippet sympy "sympyblock " w
sympy $1 sympy$0
endsnippet
priority 10000
snippet 'sympy(.*)sympy' "sympy" wr
`!p
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
init_printing()
snip.rv = eval('latex(' + match.group(1).replace('\\', '').replace('^', '**').replace('{', '(').replace('}', ')') + ')')
`
endsnippet
priority 1000
snippet math "mathematicablock" w
math $1 math$0
endsnippet
priority 10000
snippet 'math(.*)math' "math" wr
`!p
import subprocess
code = match.group(1)
code = 'ToString[' + code + ', TeXForm]'
snip.rv = subprocess.check_output(['wolframscript', '-code', code])
`
endsnippet
snippet == "equals" i
&= $1 \\\\
endsnippet
snippet != "equals" i
\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
snippet pmat "pmat" iA
\begin{pmatrix} $1 \end{pmatrix} $0
endsnippet
snippet bmat "bmat" iA
\begin{bmatrix} $1 \end{bmatrix} $0
endsnippet
context "math()"
snippet () "left( right)" iA
\left( ${1:${VISUAL}} \right) $0
endsnippet
snippet lr "left( right)" i
\left( ${1:${VISUAL}} \right) $0
endsnippet
snippet lr( "left( right)" i
\left( ${1:${VISUAL}} \right) $0
endsnippet
snippet lr| "left| right|" i
\left| ${1:${VISUAL}} \right| $0
endsnippet
snippet lr{ "left\{ right\}" i
\left\\{ ${1:${VISUAL}} \right\\} $0
endsnippet
snippet lrb "left\{ right\}" i
\left\\{ ${1:${VISUAL}} \right\\} $0
endsnippet
snippet lr[ "left[ right]" i
\left[ ${1:${VISUAL}} \right] $0
endsnippet
snippet lra "leftangle rightangle" iA
\left<${1:${VISUAL}} \right>$0
endsnippet
context "math()"
snippet conj "conjugate" iA
\overline{$1}$0
endsnippet
snippet sum "sum" w
\sum_{$1}^{$2} $3
endsnippet
snippet taylor "taylor" w
\sum_{${1:k}=${2:0}}^{${3:\infty}} ${4:c_$1} (x-a)^$1 $0
endsnippet
snippet lim "limit" w
\lim_{${1:n} \to ${2:\infty}} $3
endsnippet
snippet limsup "limsup" w
\limsup_{${1:n} \to ${2:\infty}}
endsnippet
snippet prod "product" w
\prod_{${1:n=${2:1}}}^{${3:\infty}} ${4:${VISUAL}} $0
endsnippet
snippet part "d/dx" w
\frac{\partial ${1:V}}{\partial ${2:x}} $0
endsnippet
context "math()"
snippet sq "\sqrt{}" iA
\sqrt{${1:${VISUAL}}} $0
endsnippet
context "math()"
snippet td "to the ... power" iA
^{$1}$0
endsnippet
context "math()"
snippet rd "to the ... power" iA
^{($1)}$0
endsnippet
snippet __ "subscript" iA
_{$1}$0
endsnippet
snippet ooo "\infty" iA
\infty
endsnippet
snippet rij "mrij" i
(${1:x}_${2:n})_{${3:$2}\\in${4:\\N}}$0
endsnippet
snippet <= "leq" iA
\le
endsnippet
snippet >= "geq" i
\ge
endsnippet
context "math()"
snippet EE "exists" iA
\exists
endsnippet
context "math()"
snippet AA "forall" iA
\forall
endsnippet
context "math()"
snippet xnn "xn" iA
x_{n}
endsnippet
context "math()"
snippet ynn "yn" iA
y_{n}
endsnippet
context "math()"
snippet xii "xi" iA
x_{i}
endsnippet
context "math()"
snippet yii "yi" iA
y_{i}
endsnippet
context "math()"
snippet xjj "xj" iA
x_{j}
endsnippet
context "math()"
snippet yjj "yj" iA
y_{j}
endsnippet
context "math()"
snippet xp1 "x" iA
x_{n+1}
endsnippet
context "math()"
snippet xmm "x" iA
x_{m}
endsnippet
snippet R0+ "R0+" iA
\\R_0^+
endsnippet
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}
\caption{$8}
\label{${9:$8}}
\end{figure}
endsnippet
snippet nn "Tikz node" w
\node[$5] (${1/[^0-9a-zA-Z]//g}${2}) ${3:at (${4:0,0}) }{$${1}$};
$0
endsnippet
context "math()"
snippet mcal "mathcal" iA
\mathcal{$1}$0
endsnippet
snippet lll "l" iA
\ell
endsnippet
context "math()"
snippet nabl "nabla" iA
\nabla
endsnippet
context "math()"
snippet xx "cross" iA
\times
endsnippet
priority 100
snippet *** "cdot" iA
\cdot
endsnippet
context "math()"
snippet norm "norm" iA
\|$1\|$0
endsnippet
priority 100
context "math()"
snippet '(?<!\\)(sin|cos|tan|sec|cot|csc|log|exp|star|perp)' "functions" rwA
\\`!p snip.rv = match.group(1)`
endsnippet
priority 300
context "math()"
snippet dint "integral" wA
\int_{${1:-\infty}}^{${2:\infty}} ${3:${VISUAL}} $0
endsnippet
priority 200
context "math()"
snippet '(?<!\\)(arcsin|arccos|arctan|arccot|arccsc|arcsec|pi|zeta|xi|varphi|phi|int|theta|mu|sigma)' "ln" rwA
\\`!p snip.rv = match.group(1)`
endsnippet
priority 100
context "math()"
snippet -> "to" iA
\to
endsnippet
priority 200
context "math()"
snippet <-> "leftrightarrow" iA
\leftrightarrow
endsnippet
context "math()"
snippet !> "mapsto" iA
\mapsto
endsnippet
context "math()"
snippet invs "inverse" iA
^{-1}
endsnippet
context "math()"
snippet compl "complement" iA
^{c}
endsnippet
context "math()"
snippet \\\ "setminus" iA
\setminus
endsnippet
snippet >> ">>" iA
\gg
endsnippet
snippet << "<<" iA
\ll
endsnippet
snippet ~~ "~" iA
\sim
endsnippet
context "math()"
snippet set "set" wA
\left\\{$1\right\\} $0
endsnippet
context "math()"
snippet not "Logical not" w
\lnot
endsnippet
context "math()"
snippet and "Logical and" wA
\land
endsnippet
context "math()"
snippet or "Logical or" wA
\lor
endsnippet
context "math()"
snippet equiv "Logically equivalent" wA
\equiv
endsnippet
context "math()"
snippet implies "Logical implication" wA
\implies
endsnippet
snippet || "mid" i
\mid
endsnippet
priority 100
context "math()"
snippet cc "subset" i
\subset
endsnippet
priority 101
context "math()"
snippet pcc "proper subset" iA
\subsetneq
endsnippet
priority 102
context "math()"
snippet ccc "subset or equal to" iA
\subseteq
endsnippet
snippet notin "not in " iA
\not\in
endsnippet
context "math()"
snippet inn "in " iA
\in
endsnippet
snippet NN "n" iA
\N
endsnippet
snippet Nn "cap" iA
\cap
endsnippet
snippet UU "cup" iA
\cup
endsnippet
snippet uuu "bigcup" iA
\bigcup_{${1:i \in ${2: I}}} $0
endsnippet
snippet nnn "bigcap" iA
\bigcap_{${1:i \in ${2: I}}} $0
endsnippet
snippet OO "emptyset" iA
\O
endsnippet
snippet RR "real" iA
\R
endsnippet
snippet QQ "Q" iA
\Q
endsnippet
snippet ZZ "Z" iA
\Z
endsnippet
snippet <! "normal" iA
\triangleleft
endsnippet
snippet <> "hokje" 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
context "math()"
snippet case "cases" wA
\begin{cases}
$1
\end{cases}
endsnippet
snippet SI "SI" i
\SI{$1}{$2}
endsnippet
snippet bigfun "Big function" iA
\begin{align*}
$1: $2 &\longrightarrow $3 \\\\
$4 &\longmapsto $1($4) = $0
.\end{align*}
endsnippet
snippet cvec "column vector" iA
\begin{pmatrix} ${1:x}_${2:1}\\\\ \vdots\\\\ $1_${2:n} \end{pmatrix}
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()"
snippet "hat" "hat" riA
\hat{$1}$0
endsnippet
priority 100
context "math()"
snippet "([a-zA-Z])hat" "hat" riA
\hat{`!p snip.rv=match.group(1)`}
endsnippet
snippet letw "let omega" iA
Let $\Omega \subset \C$ be open.
endsnippet
snippet HH "H" iA
\mathbb{H}
endsnippet
snippet DD "D" iA
\mathbb{D}
endsnippet
# vim:ft=snippets