1
0
Fork 0
mirror of synced 2024-11-04 08:28:57 -05:00
ultimate-vim/sources_non_forked/vim-snippets/UltiSnips/tex.snippets

524 lines
8.9 KiB
Text
Raw Normal View History

2022-08-08 09:45:56 -04:00
##########
# GLOBAL #
##########
2012-08-16 23:41:25 -04:00
2018-02-04 06:35:08 -05:00
global !p
def create_table(snip):
rows = snip.buffer[snip.line].split('x')[0]
cols = snip.buffer[snip.line].split('x')[1]
int_val = lambda string: int(''.join(s for s in string if s.isdigit()))
rows = int_val(rows)
cols = int_val(cols)
offset = cols + 1
old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1]
snip.buffer[snip.line] = ''
final_str = old_spacing + "\\begin{tabular}{|" + "|".join(['$' + str(i + 1) for i in range(cols)]) + "|}\n"
for i in range(rows):
final_str += old_spacing + '\t'
final_str += " & ".join(['$' + str(i * cols + j + offset) for j in range(cols)])
final_str += " \\\\\\\n"
final_str += old_spacing + "\\end{tabular}\n$0"
snip.expand_anon(final_str)
def add_row(snip):
row_len = int(''.join(s for s in snip.buffer[snip.line] if s.isdigit()))
old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1]
snip.buffer[snip.line] = ''
final_str = old_spacing
final_str += " & ".join(['$' + str(j + 1) for j in range(row_len)])
final_str += " \\\\\\"
snip.expand_anon(final_str)
endglobal
2022-08-08 09:45:56 -04:00
###############
# ENVIRONMENT #
###############
snippet beg "begin{} / end{}" bi
\begin{$1}
2012-08-16 23:41:25 -04:00
${0:${VISUAL}}
\end{$1}
endsnippet
2022-08-08 09:45:56 -04:00
snippet cnt "Center" bi
\begin{center}
${0:${VISUAL}}
\end{center}
2017-05-26 05:30:32 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet desc "Description" bi
\begin{description}
\item[${1:${VISUAL}}] $0
\end{description}
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet lemma "Lemma" bi
\begin{lemma}
${0:${VISUAL}}
\end{lemma}
2018-02-04 06:35:08 -05:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet prop "Proposition" bi
\begin{prop}[$1]
${0:${VISUAL}}
\end{prop}
endsnippet
snippet thrm "Theorem" bi
\begin{theorem}[$1]
${0:${VISUAL}}
\end{theorem}
endsnippet
snippet post "postulate" bi
\begin{postulate}[$1]
${0:${VISUAL}}
\end{postulate}
endsnippet
snippet prf "Proof" bi
\begin{myproof}[$1]
${0:${VISUAL}}
\end{myproof}
endsnippet
snippet def "Definition" bi
\begin{definition}[$1]
${0:${VISUAL}}
\end{definition}
endsnippet
snippet nte "Note" bi
\begin{note}[$1]
${0:${VISUAL}}
\end{note}
endsnippet
snippet prob "Problem" bi
\begin{problem}[$1]
${0:${VISUAL}}
\end{problem}
endsnippet
snippet corl "Corollary" bi
\begin{corollary}[$1]
${0:${VISUAL}}
\end{corollary}
endsnippet
snippet example "Example" bi
\begin{example}[$1]
${0:${VISUAL}}
\end{example}
endsnippet
snippet notion "Notation" bi
\begin{notation}[$1]
$0${VISUAL}
\end{notation}
endsnippet
snippet conc "Conclusion" bi
\begin{conclusion}[$1]
$0${VISUAL}
\end{conclusion}
endsnippet
snippet fig "Figure environment" bi
\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 enum "Enumerate" bi
\begin{enumerate}
\item ${0:${VISUAL}}
\end{enumerate}
endsnippet
snippet item "Itemize" bi
\begin{itemize}
\item ${0:${VISUAL}}
\end{itemize}
endsnippet
snippet case "cases" bi
\begin{cases}
${0:${VISUAL}}
\end{cases}
endsnippet
snippet abs "abstract environment" b
\begin{abstract}
${0:${VISUAL}}
.\end{abstract}
endsnippet
snippet tab "tabular / array environment" b
\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}}
$0${2/(?<=.)(c|l|r)|./(?1: & )/g}
\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}
2018-02-04 06:35:08 -05:00
endsnippet
2015-01-18 07:58:28 -05:00
snippet table "Table environment" b
\begin{table}[${1:htpb}]
\centering
\caption{${2:caption}}
\label{tab:${3:label}}
2022-08-08 09:45:56 -04:00
2015-01-18 07:58:28 -05:00
\begin{${4:t}${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${5:c}}
2022-08-08 09:45:56 -04:00
$0${5/(?<=.)(c|l|r)|./(?1: & )/g}
2015-01-18 07:58:28 -05:00
\end{$4${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}
\end{table}
endsnippet
2022-08-08 09:45:56 -04:00
########
# MATH #
########
snippet cc "subset" w
\subset
endsnippet
2022-08-08 09:45:56 -04:00
snippet inn "in " w
\in
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet Nn "cap" w
\cap
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet UU "cup" w
\cup
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet uuu "bigcup" w
\bigcup_{${1:i \in ${2: I}}} $0
endsnippet
2012-08-16 23:41:25 -04:00
2022-08-08 09:45:56 -04:00
snippet nnn "bigcap" w
\bigcap_{${1:i \in ${2: I}}} $0
endsnippet
2012-08-16 23:41:25 -04:00
2022-08-08 09:45:56 -04:00
snippet HH "H" w
\mathbb{H}
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet DD "D" w
\mathbb{D}
endsnippet
2012-08-16 23:41:25 -04:00
2022-08-08 09:45:56 -04:00
snippet inmath "Inline Math" w
\\(${1}\\) $0
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet dm "Display Math" w
\[
${1:${VISUAL}}
\]$0
endsnippet
2012-08-16 23:41:25 -04:00
2022-08-08 09:45:56 -04:00
snippet frac "Fraction" w
\frac{$1}{$2}$0
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet compl "Complement" i
^{c}
endsnippet
2017-05-02 08:42:08 -04:00
2022-08-08 09:45:56 -04:00
snippet ss "Super Script" i
^{$1}$0
2017-05-02 08:42:08 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet __ "subscript" Aw
_{$1}$0
endsnippet
2017-05-02 08:42:08 -04:00
2022-08-08 09:45:56 -04:00
snippet srt "Square Root" wi
\sqrt{${1:${VISUAL}}}$0
endsnippet
2012-08-16 23:41:25 -04:00
2022-08-08 09:45:56 -04:00
snippet srto "... Root" wi
\sqrt[$1]{${2:${VISUAL}}}$0
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet bf "Bold" wi
\bf{${1:${VISUAL}}}$0
endsnippet
2017-05-02 08:42:08 -04:00
2022-08-08 09:45:56 -04:00
snippet it "Italic" wi
\it{${1:${VISUAL}}}$0
2017-05-02 08:42:08 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet un "Underline" wi
\un{${1:${VISUAL}}}$0
endsnippet
2012-08-16 23:41:25 -04:00
2022-08-08 09:45:56 -04:00
snippet rm "Text" wi
\rm{${1:${VISUAL}}}$0
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet itm "Item" wi
\item ${0:${VISUAL}}
endsnippet
2017-05-02 08:42:08 -04:00
2022-08-08 09:45:56 -04:00
snippet ceil "Ceil" w
\left\lceil $1 \right\rceil $0
2017-05-02 08:42:08 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet floor "Floor" w
\left\lfloor $1 \right\rfloor$0
endsnippet
2012-08-16 23:41:25 -04:00
2022-08-08 09:45:56 -04:00
snippet pmat "Pmat" w
\begin{pmatrix} $1 \end{pmatrix} $0
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet bmat "Bmat" w
\begin{bmatrix} $1 \end{bmatrix} $0
endsnippet
2012-08-16 23:41:25 -04:00
2022-08-08 09:45:56 -04:00
snippet () "Left( right)" w
\left( ${1:${VISUAL}} \right) $0
endsnippet
2012-08-16 23:41:25 -04:00
2022-08-08 09:45:56 -04:00
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" wi
\left<${1:${VISUAL}} \right>$0
endsnippet
snippet conj "conjugate" w
\overline{$1}$0
endsnippet
snippet sum "sum" w
\sum_{n=${1:1}}^{${2:\infty}} ${3:a_n z^n}
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}}
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
snippet ooo "\infty" w
\infty
endsnippet
snippet rij "mrij" i
(${1:x}_${2:n})_{${3:$2}\\in${4:\\N}}$0
endsnippet
snippet => "Implies" w
\implies
endsnippet
snippet =< "Implied by" w
\impliedby
endsnippet
snippet iff "iff" w
\iff
endsnippet
snippet == "Equals" w
&= $1 \\\\
endsnippet
snippet != "Not Equal" w
\neq
endsnippet
2022-12-03 05:29:32 -05:00
snippet <= "leq" w
2022-08-08 09:45:56 -04:00
\le
endsnippet
2022-12-03 05:29:32 -05:00
snippet >= "geq" w
2022-08-08 09:45:56 -04:00
\ge
endsnippet
snippet nn "Tikz node" w
\node[$5] (${1/[^0-9a-zA-Z]//g}${2}) ${3:at (${4:0,0}) }{$${1}$};
2018-06-14 06:31:12 -04:00
$0
endsnippet
2022-08-08 09:45:56 -04:00
snippet lll "l" Aw
\ell
endsnippet
snippet xx "cross" Aw
\times
endsnippet
snippet '(?<!\\)(sin|cos|arccot|cot|csc|ln|log|exp|star|perp)' "ln" rw
\\`!p snip.rv = match.group(1)`
endsnippet
snippet <! "normal" Aw
\triangleleft
endsnippet
snippet "(\d|\w)+invs" "inverse" Awr
`!p snip.rv = match.group(1)`^{-1}
endsnippet
snippet !> "mapsto" Aw
\mapsto
endsnippet
##########
# TABLES #
#########
pre_expand "create_table(snip)"
snippet "gentbl(\d+)x(\d+)" "Generate table of *width* by *height*" r
endsnippet
pre_expand "add_row(snip)"
snippet "tr(\d+)" "Add table row of dimension ..." r
endsnippet
###########
# POSTFIX #
###########
snippet bar "bar" wi
\bar{${1:${VISUAL}}}$0
endsnippet
snippet "\<(.*?)\|" "bra" wri
\bra{`!p snip.rv = match.group(1).replace('q', f'\psi').replace('f', f'\phi')`}
endsnippet
snippet "\|(.*?)\>" "ket" wri
\ket{`!p snip.rv = match.group(1).replace('q', f'\psi').replace('f', f'\phi')`}
endsnippet
snippet "(.*)\\bra{(.*?)}([^\|]*?)\>" "braket" Awri
`!p snip.rv = match.group(1)`\braket{`!p snip.rv = match.group(2)`}{`!p snip.rv = match.group(3).replace('q', f'\psi').replace('f', f'\phi')`}
endsnippet
#############
# PRE-AMBLE #
#############
snippet pac "usepackage - removes square braces if options removed" b
\usepackage`!p snip.rv='[' if t[1] else ""`${1:options}`!p snip.rv = ']' if t[1] else ""`{${2:package}}$0
endsnippet
snippet docls "Document Class" bA
\documentclass{$1}$0
endsnippet
#########
# OTHER #
#########
snippet acl "Acroynm expanded" bi
2018-06-14 06:31:12 -04:00
\acl{${1:acronym}}
endsnippet
2022-08-08 09:45:56 -04:00
snippet ac "Acroynm normal" bi
\ac{${1:acronym}}
endsnippet
snippet ni "Non-indented paragraph" bi
\noindent
2012-08-16 23:41:25 -04:00
endsnippet
2022-08-08 09:45:56 -04:00
############
# SECTIONS #
############
snippet chap "Chapter" wi
\chapter{$1${VISUAL}}
endsnippet
2022-08-08 09:45:56 -04:00
snippet sec "Section" wi
\section{$1${VISUAL}}
endsnippet
2022-08-08 09:45:56 -04:00
snippet sec* "Section*" wi
\section*{$1${VISUAL}}
endsnippet
2018-06-14 06:31:12 -04:00
2022-08-08 09:45:56 -04:00
snippet sub "Subsection" wi
\subsection{$1${VISUAL}}
endsnippet
2020-01-28 21:07:36 -05:00
2022-08-08 09:45:56 -04:00
snippet sub* "Subsection*" wi
\subsection*{$1${VISUAL}}
2020-01-28 21:07:36 -05:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet subsub "Subsection" wi
\subsubsection{$1${VISUAL}}
endsnippet
snippet subsub* "Subsubsection" wi
\subsubsection*{$1${VISUAL}}
endsnippet
snippet par "Paragraph" wi
\paragraph{$1${VISUAL}}
2020-01-28 21:07:36 -05:00
endsnippet
2020-12-04 16:15:32 -05:00
2022-08-08 09:45:56 -04:00
snippet par* "Paragraph*" wi
\paragraph*{$1${VISUAL}}
2020-12-04 16:15:32 -05:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet subpar "Sub Paragraph" wi
\subparagraph{$1${VISUAL}}
2020-12-04 16:15:32 -05:00
endsnippet
2022-08-08 09:45:56 -04:00
snippet subpar* "Sub Paragraph*" wi
\subparagraph*{$1${VISUAL}}
2020-12-04 16:15:32 -05:00
endsnippet
2012-08-16 23:41:25 -04:00
# vim:ft=snippets: