tex.snippets (12533B)
1 priority 1 2 3 global !p 4 def math(): 5 return vim.eval('vimtex#syntax#in_mathzone()') == '1' 6 def comment(): 7 return vim.eval('vimtex#syntax#in_comment()') == '1' 8 def env(name): 9 x, y = vim.eval("vimtex#env#is_inside('" + name + "')") 10 return x != '0' and y != '0' 11 endglobal 12 13 14 snippet latex "Basic template" b 15 \documentclass[a4paper]{article} 16 17 \usepackage{amsmath,amssymb} 18 19 ${1:\input macros} 20 21 \begin{document} 22 23 $0 24 25 \end{document} 26 endsnippet 27 28 snippet standalone "standalone" b 29 \documentclass{standalone} 30 \usepackage{amsmath,amssymb} 31 \begin{document} 32 $0 33 \end{document} 34 endsnippet 35 36 snippet beg "begin{} / end{}" bA 37 \\begin{$1} 38 $0 39 \\end{$1} 40 endsnippet 41 42 snippet ... "dots" iA 43 \dots 44 endsnippet 45 46 snippet table "Table environment" b 47 \begin{table}[${1:htpb}] 48 \centering 49 \caption{${2:caption}} 50 \label{tab:${3:label}} 51 \begin{tabular}{${5:c}} 52 $0${5/((?<=.)c|l|r)|./(?1: & )/g} 53 \end{tabular} 54 \end{table} 55 endsnippet 56 57 58 snippet svg "Figure SVG" b 59 \begin{figure}[${1:htpb}] 60 \centering 61 \def\svgwidth{0.8\linewidth} 62 \import{${2:img/}}{${3:name}.pdf_tex} 63 \caption{${4:$3}} 64 \label{fig:${5:${3/\W+/-/g}}} 65 \end{figure} 66 67 endsnippet 68 69 snippet xopp "Figure Xournalpp" b 70 \begin{figure}[${1:htpb}] 71 \centering 72 \includegraphics[width=0.8\textwidth]{${2:img/name}_annotated.pdf} 73 \caption{${3:$2}} 74 \label{fig:${4:${2/\W+/-/g}}} 75 \end{figure} 76 endsnippet 77 78 snippet fig "Figure environment" b 79 \begin{figure}[${1:htpb}] 80 \centering 81 ${2:\includegraphics[width=0.8\textwidth]{$3}} 82 \caption{${4:$3}} 83 \label{fig:${5:${3/\W+/-/g}}} 84 \end{figure} 85 endsnippet 86 87 snippet enum "Enumerate" bA 88 \begin{enumerate} 89 \item $0 90 \end{enumerate} 91 endsnippet 92 93 snippet item "Itemize" bA 94 \begin{itemize} 95 \item $0 96 \end{itemize} 97 endsnippet 98 99 snippet desc "Description" b 100 \begin{description} 101 \item[$1] $0 102 \end{description} 103 endsnippet 104 105 snippet pac "Package" b 106 \usepackage${1/(.+)/(?1:[)/}${1:option}${1/(.+)/(?1:])/}{${2:package}}$0 107 endsnippet 108 109 context "not math()" 110 snippet mk "Math" wA 111 \($1\)$0 112 endsnippet 113 114 snippet dm "Math" wA 115 \[ 116 ${1:${VISUAL}} 117 .\] 118 $0 119 endsnippet 120 121 122 snippet ali "Align" bA 123 \begin{align*} 124 $0 125 .\end{align*} 126 endsnippet 127 128 129 context "math()" 130 snippet // "Fraction" iA 131 \\frac{$1}{$2}$0 132 endsnippet 133 134 snippet / "Fraction" i 135 \\frac{${VISUAL}}{$1}$0 136 endsnippet 137 138 context "math()" 139 snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "symbol frac" wrA 140 \\frac{`!p snip.rv = match.group(1)`}{$1}$0 141 endsnippet 142 143 context "math()" 144 snippet '^.*\)/' "() frac" wrA 145 `!p 146 stripped = match.string[:-1] 147 depth = 0 148 i = len(stripped) - 1 149 while True: 150 if stripped[i] == ')': depth += 1 151 if stripped[i] == '(': depth -= 1 152 if depth == 0: break; 153 i-=1 154 snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}" 155 `{$1}$0 156 endsnippet 157 158 159 160 context "math()" 161 snippet && "align" iA 162 &${1:${VISUAL}} \\\\$0 163 endsnippet 164 165 context "math()" 166 snippet != "not equals" iA 167 \neq $0 168 endsnippet 169 170 context "math()" 171 snippet ceil "ceil" iA 172 \left\lceil $1 \right\rceil $0 173 endsnippet 174 175 context "math()" 176 snippet floor "floor" iA 177 \left\lfloor $1 \right\rfloor$0 178 endsnippet 179 180 snippet pmat "pmat" iA 181 \begin{pmatrix} $1 \end{pmatrix} $0 182 endsnippet 183 184 snippet bmat "bmat" iA 185 \begin{bmatrix} $1 \end{bmatrix} $0 186 endsnippet 187 188 # --------------------------------------------- # 189 context "math()" 190 snippet () "left( right)" iA 191 (${1:${VISUAL}})$0 192 endsnippet 193 194 context "math()" 195 snippet [] "left[ right]" iA 196 [${1:${VISUAL}}]$0 197 endsnippet 198 199 context "math()" 200 snippet {} "left\{ right\}" iA 201 \\{${1:${VISUAL}}\\}$0 202 endsnippet 203 204 context "math()" 205 snippet vv "left| right|" iA 206 \lvert ${1:${VISUAL}} \rvert $0 207 endsnippet 208 209 context "math()" 210 snippet VV "left| right|" iA 211 \lVert ${1:${VISUAL}} \rVert $0 212 endsnippet 213 214 # --------------------------------------------- # 215 216 context "math()" 217 snippet lim "limit" w 218 \lim_{${1:n \to \infty}}$0 219 endsnippet 220 221 context "math()" 222 snippet limsup "superior limit" w 223 \limsup_{${1:n \to \infty}}$0 224 endsnippet 225 226 context "math()" 227 snippet liminf "inferior limit" w 228 \liminf_{${1:n \to \infty}}$0 229 endsnippet 230 231 context "math()" 232 snippet uuu "bigcup" w 233 \bigcup${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 234 endsnippet 235 236 context "math()" 237 snippet nnn "bigcap" w 238 \bigcap${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 239 endsnippet 240 241 context "math()" 242 snippet uu+ "biguplus" w 243 \biguplus${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 244 endsnippet 245 246 context "math()" 247 snippet sum "sum" w 248 \sum${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 249 endsnippet 250 251 context "math()" 252 snippet prod "product" w 253 \prod${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 254 endsnippet 255 256 context "math()" 257 snippet int "real integral" w 258 \int${1/(.+)/(?1:_{)/}${1:-\infty}${1/(.+)/(?1:})/}${2/(.+)/(?1:^{)/}${2:+\infty}${2/(.+)/(?1:})/}{${3:${VISUAL}}}\:d${4:x}$0 259 endsnippet 260 261 context "math()" 262 snippet mint "measure integral" w 263 \int${1/(.+)/(?1:_{)/}${1:X}${1/(.+)/(?1:})/}{${2:${VISUAL:f}}}\,\mathrm{d}${3:\mu}$0 264 endsnippet 265 266 context "math()" 267 snippet mintu "upper measure integral" w 268 \overline{\int${1/(.+)/(?1:_{)/}${1:X}${1/(.+)/(?1:})/}}{${3:${VISUAL:f}}}\,\mathrm{d}${4:\mu}$0 269 endsnippet 270 271 context "math()" 272 snippet mintl "lower measure integral" w 273 \underline{\int${1/(.+)/(?1:_{)/}${1:X}${1/(.+)/(?1:})/}}{${3:${VISUAL:f}}}\,\mathrm{d}${4:\mu}$0 274 endsnippet 275 276 context "math()" 277 snippet seq "Sequence" w 278 \\{${1:x_n}\\}${2/(.+)/(?1:_{)/}${2:n = 1}${2/(.+)/(?1:})/}${3/(.+)/(?1:^{)/}${3:\infty}${3/(.+)/(?1:})/}${4/(.+)/(?1: \\\\subset )/}${4:\mathbb{R}}$0 279 endsnippet 280 281 context "not math()" 282 snippet seq "Sequence" w 283 \\(\\{${1:x_n}\\}${2/(.+)/(?1:_{)/}${2:n = 1}${2/(.+)/(?1:})/}${3/(.+)/(?1:^{)/}${3:\infty}${3/(.+)/(?1:})/}${4/(.+)/(?1: \\\\subset )/}${4:\mathbb{R}}\\)$0 284 endsnippet 285 286 # --------------------------------------------- # 287 288 context "math()" 289 snippet ubb "The \underbrace command" w 290 \underbrace{${1:${VISUAL:}}}_{$2} $0 291 endsnippet 292 293 context "math()" 294 snippet obb "The \overbrace command" w 295 \overbrace{${1:${VISUAL:}}}^{$2} $0 296 endsnippet 297 298 context "math()" 299 snippet op "\operatorname" w 300 \operatorname{$1}$0 301 endsnippet 302 303 context "math()" 304 snippet sq "\sqrt{}" iA 305 \sqrt{${1:${VISUAL}}}$0 306 endsnippet 307 308 context "math()" 309 snippet ^^ "to the ... power" iA 310 ^{$1}$0 311 endsnippet 312 313 context "math()" 314 snippet __ "subscript" iA 315 _{$1}$0 316 endsnippet 317 318 context "math()" 319 snippet ooo "\infty" iA 320 \infty$0 321 endsnippet 322 323 context "math()" 324 snippet << "ll" iA 325 \ll $0 326 endsnippet 327 328 context "math()" 329 snippet <= "leq" iA 330 \le $0 331 endsnippet 332 333 context "math()" 334 snippet >= "geq" iA 335 \ge $0 336 endsnippet 337 338 context "math()" 339 snippet EE "geq" iA 340 \exists $0 341 endsnippet 342 343 context "math()" 344 snippet ~~ "sim" iA 345 \sim $0 346 endsnippet 347 348 context "math()" 349 snippet AA "forall" iA 350 \forall $0 351 endsnippet 352 353 354 snippet plot "Plot" w 355 \begin{figure}[$1] 356 \centering 357 \begin{tikzpicture} 358 \begin{axis}[ 359 xmin= ${2:-10}, xmax= ${3:10}, 360 ymin= ${4:-10}, ymax = ${5:10}, 361 axis lines = middle, 362 ] 363 \addplot[domain=$2:$3, samples=${6:100}]{$7}; 364 \end{axis} 365 \end{tikzpicture} 366 \caption{$8} 367 \label{${9:$8}} 368 \end{figure} 369 endsnippet 370 371 snippet nn "Tikz node" w 372 \node[$5] (${1/[^0-9a-zA-Z]//g}${2}) ${3:at (${4:0,0}) }{$${1}$}; 373 $0 374 endsnippet 375 376 context "math()" 377 snippet nabl "nabla" iA 378 \nabla $0 379 endsnippet 380 381 context "math()" 382 snippet xx "cross" iA 383 \times $0 384 endsnippet 385 386 context "math()" 387 snippet ** "cdot" iA 388 \cdot $0 389 endsnippet 390 391 context "math()" 392 snippet -> "to" iA 393 \to $0 394 endsnippet 395 396 context "math()" 397 snippet uto "to" iA 398 \mathop{\uparrow} 399 endsnippet 400 401 context "math()" 402 snippet dto "to" iA 403 \mathop{\downarrow} 404 endsnippet 405 406 context "math()" 407 snippet <-> "leftrightarrow" iA 408 \leftrightarrow 409 endsnippet 410 411 context "math()" 412 snippet !> "mapsto" iA 413 \mapsto $0 414 endsnippet 415 416 context "math()" 417 snippet \\\ "setminus" iA 418 \setminus $0 419 endsnippet 420 421 context "math()" 422 snippet || "mid" iA 423 \mid $0 424 endsnippet 425 426 context "math()" 427 snippet cc "subset" A 428 \subset $0 429 endsnippet 430 431 context "math()" 432 snippet notin "not in " iA 433 \not\in $0 434 endsnippet 435 436 context "math()" 437 snippet inn "in" iA 438 \in $0 439 endsnippet 440 441 context "math()" 442 snippet NN "cap" iA 443 \cap $0 444 endsnippet 445 446 context "math()" 447 snippet UU "cup" iA 448 \cup $0 449 endsnippet 450 451 context "math()" 452 snippet U+ "uplus" iA 453 \uplus $0 454 endsnippet 455 456 context "math()" 457 snippet O+ "\oplus" iA 458 \oplus $0 459 endsnippet 460 461 context "math()" 462 snippet Ox "\otimes" iA 463 \otimes $0 464 endsnippet 465 466 context "math()" 467 snippet OO "emptyset" iA 468 \emptyset 469 endsnippet 470 471 472 473 # --------------------------------------------- # 474 475 context "math()" 476 snippet "([A-Z])(cal|bb|frak|scr)" "\mathcal" rA 477 \math`!p snip.rv = match.group(2)`{`!p snip.rv = match.group(1)`}$0 478 endsnippet 479 480 context "math()" 481 snippet "([a-zA-Z])(bf)" "\mathcal" rA 482 \math`!p snip.rv = match.group(2)`{`!p snip.rv = match.group(1)`}$0 483 endsnippet 484 485 context "math()" 486 snippet "([0-9a-z])(vec|hat)" "\vec hat" rA 487 \\`!p snip.rv = match.group(2)`{`!p snip.rv = match.group(1)`}$0 488 endsnippet 489 490 # --------------------------------------------- # 491 492 context "math()" 493 snippet tt "text" iA 494 \text{$1}$0 495 endsnippet 496 497 context "math()" 498 snippet case "cases" wA 499 \begin{cases} 500 $1 501 \end{cases} 502 $0 503 endsnippet 504 505 snippet bigfun "Big function" 506 \begin{align*} 507 $1\colon ${2:X} &\longrightarrow ${3:\mathbb{R}} \\\\ 508 $4 &\longmapsto $1($4) \coloneqq $5 509 .\end{align*} 510 $0 511 endsnippet 512 513 # --------------------------------------------- # 514 515 context "math()" 516 snippet fun "f: A -> B" w 517 ${1:f}\colon ${2:X} \to ${3:\mathbb{R}} 518 endsnippet 519 520 context "not math()" 521 snippet fun "f: A -> B" w 522 \(${1:f}\colon ${2:X} \to ${3:\mathbb{R}}\) 523 endsnippet 524 525 context "not math()" 526 snippet func "f: A -> B" w 527 \(${1:f}\colon ${2:X} \stackrel{C^${4:0}}{\longrightarrow} ${3:\mathbb{R}}\) 528 endsnippet 529 530 # --------------------------------------------- # 531 532 snippet h1 "section" bA 533 \section{${1:${VISUAL:}}} 534 $0 535 endsnippet 536 537 snippet h2 "subsection" bA 538 \subsection{${1:${VISUAL:}}} 539 $0 540 endsnippet 541 542 snippet h3 "subsubsection" bA 543 \subsubsection{${1:${VISUAL:}}} 544 $0 545 endsnippet 546 547 # --------------------------------------------- # 548 549 context "math()" 550 snippet ## "#" iA 551 \#(${1:${VISUAL}})$0 552 endsnippet 553 554 # --------------------------------------------- # 555 556 context "math()" 557 snippet inv "inverse" iA 558 ^{-1} 559 endsnippet 560 561 context "math()" 562 snippet compl "complement" iA 563 ^{c} 564 endsnippet 565 566 context "math()" 567 snippet '\\Rb' "\bar{\R}" wrA 568 \overline{\R} 569 endsnippet 570 571 # --------------------------------------------- # 572 573 context "math()" 574 snippet '([A-Za-z]|\\math[^{]*{[A-Za-z]})(\d)' "auto subscript" wrA 575 `!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)` 576 endsnippet 577 578 context "math()" 579 snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA 580 `!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`} 581 endsnippet 582 583 context "math()" 584 snippet "([^\\\w][A-Za-ex-z])([ijknm])" "fast subscript" rA 585 `!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)` 586 endsnippet 587 588 context "math()" 589 snippet "([^\\\w][A-Za-ex-z])_([ijknm][+-])" "fast subscript" rA 590 `!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`$1}$0 591 endsnippet 592 593 # --------------------------------------------- # 594 595 snippet :: "\colon" iA 596 \colon $0 597 endsnippet 598 599 600 context "math()" 601 snippet and "static snippet: quad-spaced 'and' in equation" A 602 \quad \text{and} \quad $0 603 endsnippet 604 605 context "math()" 606 snippet or "static snippet: quad-spaced 'or' in equation" A 607 \quad \text{or} \quad $0 608 endsnippet 609 610 # --------------------------------------------- # 611 612 context "not math()" 613 snippet sss "sí y solo sí" A 614 si y solo si $0 615 endsnippet 616 617 context "not math()" 618 snippet ee "En efecto," A 619 En efecto, $0 620 endsnippet 621 622 context "not math()" 623 snippet plt "Por lo tanto," A 624 Por lo tanto, $0 625 endsnippet 626 627 context "not math()" 628 snippet alg "algebra" 629 álgebra$0 630 endsnippet 631 632 context "not math()" 633 snippet salg "σ-álgebra" 634 \(\sigma\)-álgebra$0 635 endsnippet 636 637 context "not math()" 638 snippet psis "π-sistema" 639 \(\pi\)-sistema$0 640 endsnippet 641 642 context "not math()" 643 snippet lsis "λ-sistema" 644 \(\lambda\)-sistema$0 645 endsnippet 646 647 context "not math()" 648 snippet mctp "μ-ctp" w 649 \(\mu\)-ctp$0 650 endsnippet 651 652 context "math()" 653 snippet st "such that" w 654 \text{ such that } 655 endsnippet 656 657 658 context "not math()" 659 snippet => "(=>)" iA 660 (\(\Rightarrow\)) 661 endsnippet 662 663 context "not math()" 664 snippet =< "(=<)" iA 665 (\(\Leftarrow\)) 666 endsnippet 667 668 context "not math()" 669 snippet >< "(=><=)" iA 670 (\(\Rightarrow\!\Leftarrow\)) 671 endsnippet 672 673 context "math()" 674 snippet => "\Rightarrow" Ai 675 \Rightarrow $0 676 endsnippet 677 678 context "math()" 679 snippet =< "\Leftarrow" Ai 680 \Leftarrow $0 681 endsnippet 682 683 context "math()" 684 snippet iff "iff" Ai 685 \iff $0 686 endsnippet 687 688 context "math()" 689 snippet := "≔" iA 690 \coloneqq $0 691 endsnippet 692 693 priority 2 694 context "math()" 695 snippet thr4 "\therefore" wiA 696 \therefore $0 697 endsnippet 698 699 context "math()" 700 snippet ==> "implies" Ai 701 \implies $0 702 endsnippet 703 704 context "not math()" 705 snippet ==> "implies" Ai 706 \(\implies\) $0 707 endsnippet 708 709 710 context "math()" 711 snippet ==< "implied by" Ai 712 \impliedby $0 713 endsnippet 714 715 priority 1