nvim/UltiSnips/tex.snippets

516 lines
9.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

snippet colx "textcolor"
\\textcolor{${1:red}}{$2}$0
endsnippet
snippet tred "text red" Ai
\\textcolor{red}{$1}$0
endsnippet
snippet tblue "text blue" Ai
\\textcolor{blue}{$1}$0
endsnippet
snippet tgreen "text green" Ai
\\textcolor{green}{$1}$0
endsnippet
snippet colb "boxcolor"
\\colorbox{${1:blue}!${2:25}}{$3}$0
endsnippet
snippet ,m "inlinemath" iA
\\( $1 \\)$0
endsnippet
snippet ;M "fullmath" iA
\\[ $1 \\]
$0
endsnippet
snippet vec "Vector"
\\vec{$1}$0
endsnippet
snippet #env "Environment" bA
\\begin{$1}
$2
\\end{$1}$0
endsnippet
snippet code "listing without own config"
\\begin{lstlisting}${1:[language=${2:C++}]}
$3
\\end{lstlisting}$0
endsnippet
snippet ccpp "C++ listing configuration"
\\lstset{ basicstyle=\\ttfamily\\small, language=C++, keywordstyle=\\color{blue}\\bfseries, numbers=left } $0
endsnippet
snippet casm "Assembler listing configuration"
\\lstset{basicstyle=\\ttfamily\\small, language={[${1:x86masm}]Assembler}, keywordstyle=\\color{${2:red}}\\bfseries, numbers=left} $0
endsnippet
snippet cshell "ZSH/BASH config"
\\lstset{basicstyle=\\ttfamily\\small, language={bash}, keywordstyle=\\color{${2:green}}\\bfseries, numbers=left} $0
endsnippet
snippet cocode "Free config"
\\lstset{basicstyle=\\ttfamily\\small, language={$1}, keywordstyle=\\color{${2:blue}}\\bfseries, numbers=left} $0
endsnippet
snippet img "Images"
\\begin{figure}[${1:H}]
\\centering
\\includegraphics[width=${2:0.8}\\linewidth]{${3}}
\\caption{${4:Abbildung}}
\\label{img:`!p snip.rv = t[4].lower().replace(" ", "_")`}
\\end{figure}
$0
endsnippet
snippet figure "add figure" b
\\begin{figure}[${1:h}]
\\centering
$0
\\caption{$2}
\\end{figure}
endsnippet
snippet document "Add document environment"
\\begin{document}
\\input{~/latex/formulas.tex}
\\input{~/latex/units.tex}
$0
\\end{document}
endsnippet
snippet textemplate "include header" A
\\input{~/latex/header.tex}
\\header{${1:report/article}}{${2:Yannick Reiß}}{${3:Titel}}
\\begin{document}
\\input{~/latex/init.tex}
$0
\\end{document}
endsnippet
snippet && "Logical and"
\\wedge $0
endsnippet
snippet || "Logical or"
\\vee $0
endsnippet
snippet ubrace "Underbrace"
\\underbrace{$2}_{$1} $0
endsnippet
snippet fall "For all"
\\forall_{$1} $2
$0
endsnippet
snippet paragraph "Paragraph"
\\paragraph{$1}
$0
endsnippet
snippet xdelete "Cross out" i
\\xcancel{$1}$0
endsnippet
snippet frac "Fracture" i
\\frac{$1}{$2}$0
endsnippet
snippet mspace "Math Space"
\\quad $0
endsnippet
snippet mmspace "Math double Space"
\\qquad $0
endsnippet
snippet sum "Sum" i
\\sum_{i${1:=0}}^{${2:n}} $3 $0
endsnippet
snippet prod "Product"
\\prod_{i=${1:1}}^{${2:N}} \\quad $3 \\qquad$0
endsnippet
snippet lquote "Low Quote"
´$1\´$0
endsnippet
snippet fquote "Full Quote"
'$1´ \\textit{($2)}$0
endsnippet
snippet href "html reference"
\\href{${1:link}}{\\underline{\\textcolor{blue}{${2:Text}}}}$0
endsnippet
snippet hook "Reference to text"
\\hyperref[$1]{$2}$0
endsnippet
snippet {} "{ ... }"
\\left\\{ $1 \\right\\} $0
endsnippet
snippet [] "[...]"
\\left[ $1 \\right] $0
endsnippet
snippet () "( ... )"
\\left( $1 \\right) $0
endsnippet
snippet ,t "Mathmode-text" iA
\\text{$1}$0
endsnippet
snippet prd "Periodic number" i
\\overline{$1}$0
endsnippet
snippet leq "lesser equal"
\\leq
endsnippet
snippet geq "greater equal"
\\geq
endsnippet
snippet case "if else mathstyle"
\\begin{cases}
$1 & \\quad \\text{$2}\\\\ $3 & \\quad \\text{$4}\\\\ \\end{cases}$0
endsnippet
snippet median "Median"
\\overset{\\thicksim}{$1}$0
endsnippet
snippet ival "Intervall"
\\interval[$1]{$2}{$3}$0
endsnippet
snippet xx "multiplication" iA
\\cdot $0
endsnippet
snippet root "nth root" i
\\sqrt[$1]{$2} $0
endsnippet
snippet '(.*)__' "sub" rA
`!p snip.rv = match.group(1)`_{$1}$0
endsnippet
snippet '(.*)\*\*' "upup" rA
`!p snip.rv = match.group(1)`^{$1}$0
endsnippet
snippet ... "dots" i
\\dots
endsnippet
snippet fsf "text serif"
\\textsf{$1}$0
endsnippet
snippet fblk "text block"
\\texttt{$1}{$0}
endsnippet
snippet fit "text italic"
\\textit{$1}$0
endsnippet
snippet '//(.+)//' "Make Text italic" rA
\\textit{`!p snip.rv = match.group(1)`}$0
endsnippet
snippet '~~(.+)~~' "underline Text" rA
\\underline{`!p snip.rv = match.group(1)`} $0
endsnippet
snippet fbf "text bold"
\\textbf{$1}$0
endsnippet
snippet '\#\#(.+)\#\#' "Make Text bold" rA
\\textbf{`!p snip.rv = match.group(1)`}$0
endsnippet
snippet bit "itemize"
\\begin{itemize}
\\item $1`!p t[1] = t[1].replace(" \n", "\n\t\\item")`
\\end{itemize}
$0
endsnippet
snippet ben "enumerate"
\\begin{enumerate}
\\item $1`!p t[1] = t[1].replace(" \n", "\n\t\\item")`
\\end{enumerate}
$0
endsnippet
snippet - "new item" b
\\item $0
endsnippet
snippet sch "chapter"
\\chapter{$1}
\\label{chapter:`!p snip.rv = get_label(t[1])`}$0
endsnippet
snippet sse "Section"
\\section{$1}
\\label{section:`!p snip.rv = get_label(t[1])`}$0
endsnippet
snippet sss "Subsection"
\\subsection{$1}
\\label{subsection:`!p snip.rv = get_label(t[1])`}$0
endsnippet
snippet ssn "Subsubsection"
\\subsubsection{$1}
\\label{subsubsection:`!p snip.rv = get_label(t[1])`}$0
endsnippet
snippet par "Paragraph"
\\paragraph{$1}
\\label{paragraph:`!p snip.rv = get_label(t[1])`}$0
endsnippet
snippet mquote "max quote"
\`$1\` (${2:author} : \\textit{${3:source}}, ${4:year})$0
endsnippet
snippet <- "Easy Left" iA
\\(\\leftarrow\\)$0
endsnippet
snippet => "Double Right" iA
\\(\\Rightarrow\\)$0
endsnippet
snippet <= "Double Left" iA
\\(\\Leftarrow\\)$0
endsnippet
snippet -> "Easy Right" iA
\\(\\rightarrow\\)$0
endsnippet
snippet texmeta "Meta with stamp for better documentation"
% ${1:Name}`!p
if t[1] == "":
t[1] = "?"
else:
t[1] = t[1].replace("?", "")` `!p snip.rv = t[1][0] ``!v line('.')`: ${2:Content} on `date` by ${3:`echo $USER`}
$0
endsnippet
snippet ;L "List math with align" A
\\begin{align}
$1
\\end{align}
$0
endsnippet
snippet lexp "List math expression" A
$1 &= ${2:First} & ${3:Second} ${4:\\nonumber} \\\\
$0
endsnippet
snippet def "Box with definition"
\\framebox{
\\colorbox{blue!25}{
\\begin{minipage}{0.90\\textwidth}
\\textbf{Definition: $1}\\\\
$2
\\end{minipage}}}
$0
endsnippet
snippet attention "Box for attention"
\\framebox{
\\colorbox{red!25}{
\\begin{minipage}{0.90\\textwidth}
\\textbf{Achtung: $1}\\\\
$2
\\end{minipage}}}
$0
endsnippet
global !p
def create_table_tabs(snip):
anon_snippet_body = ""
# get start and end line number of (expanded) snippet
start = snip.snippet_start[0]
end = snip.snippet_end[0]
# Append current line into snippet
for i in range(start, end+1):
anon_snippet_body += snip.buffer[i]
anon_snippet_body += "" if i == end else '\n'
# delete expanded snippet line while preserving the line
for i in range(start, end):
del snip.buffer[start]
# Empty last line, while preserving the line
snip.buffer[start] = ''
# Expand anonymous snippet
snip.expand_anon(anon_snippet_body)
def create_table(cols, rows, sep, start, end, head="##"):
res = ""
placeholder = 1
for _ in range(0, int(rows)):
res += start + head.replace("##", f"${placeholder} ")
placeholder += 1
for _ in range(0, int(cols) - 1):
res += sep + head.replace("##", f" ${placeholder} ")
placeholder += 1
res += end
return res[:-1]
def get_label(title):
return_label = title.lower()
return_label = return_label.replace(" ", "_")
return_label = return_label.replace("ä", "ae")
return_label = return_label.replace("ö", "oe")
return_label = return_label.replace("ü", "ue")
return_label = return_label.replace("-", "__")
return return_label
endglobal
post_jump "create_table_tabs(snip)"
snippet 'table(\d+),(\d+)' "Table with given row and column count" r
\\begin{center}
\\begin{tabular}{`!p
orient = " "
for _ in range(0, int(match.group(1))): orient += "c "
snip.rv = orient`}
`!p
snip.rv = create_table(match.group(1), match.group(2), "&", "\t", "\\\\\\\\\n")
`
\end{tabular}
\end{center}
$0
endsnippet
post_jump "create_table_tabs(snip)"
snippet 'matrix(\d+),(\d+)' "Table with given row and column count" r
\\begin{pmatrix}
`!p
snip.rv = create_table(match.group(1), match.group(2), "&", "\t", "\\\\\\\\\n")
`
\\end{pmatrix}
$0
endsnippet
snippet colorbox "color box: set own caption and content"
\\framebox{
\\colorbox{${1:green}!20}{
\\begin{minipage}{0.90\\textwidth}
\\textbf{$2}\\\\
$3
\\end{minipage}}}
$0
endsnippet
snippet "menge_(\w)" "Menge der X Zahlen" rA
\\mathbb{`!p snip.rv = match.group(1)`} $0
endsnippet
snippet pq "pq-formula" i
\\pq{$1}{$2} $0
endsnippet
snippet idr "In der Regel" i
in der Regel
endsnippet
snippet usw "und so weiter" i
und so weiter
endsnippet
snippet %% "Percent" iA
\%$0
endsnippet
snippet integral "add Integral" i
\integral{$1}{$2}{$3}{$4} $0
endsnippet
snippet frame "Add a new Frame" b
\\subsection{$1}
\\begin{frame}
\\frametitle{$1}
$2
\\end{frame}$0
endsnippet
snippet != "not equal" iA
\\neq $0
endsnippet
snippet "@(\w)" "insert greek letter" ir
`!p letters = {'a': 'alpha', 'A': 'Alpha', 'b': 'beta', 'B': 'Beta', 'g': 'gamma', 'G': 'Gamma', 'e': 'epsilon', 'E': 'Epsilon', 'o': 'omega', 'O': 'Omega', 'm': 'mu', 'M': 'Mu', 'n': 'eta', 'd': 'delta', 'D': 'Delta', 'N': 'Eta', 'v': 'varphi', 'V': 'Varphi', 'P': 'partial', 'p': 'pi', 'r': 'rho', 'S': 'Sigma', 's': 'sigma'}
try:
snip.rv = "\\" + letters[ match.group(1) ]
except KeyError:
snip.rv = "!!UNDEFINED"`
endsnippet
snippet _- "Escape _ easier" iA
\\_
endsnippet
snippet bsp "Beispielsweise" A
beispielsweise
endsnippet
snippet ß "Backslash" A
\\
endsnippet
snippet \0 "Add another Backslash" iA
\\\\
endsnippet
snippet bibbook "Add a new book/journal/paper reference" b
\\bibitem{${1:Reference_name}}
${2:Author}. (${3:2023}) \`${4:Title}'. ${5:Extension} `!p
if t[6] == "":
snip.rv = ""
elif "-" in t[6]:
snip.rv = "Seiten "
else:
snip.rv = "Seite"
`$6`!p
if t[6] == "":
snip.rv = ""
else:
snip.rv = "."`
$0
endsnippet
snippet cc "Cite" i
\\cite{$1}$0
endsnippet
snippet setenv "Set Environment around Text" b
\\begin{$1}
${VISUAL}
\\end{$1}$0
endsnippet