Skip to content

Instantly share code, notes, and snippets.

@st-tran
Last active August 28, 2020 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save st-tran/5e34243ba44c3df0a2abd2a61dd4843b to your computer and use it in GitHub Desktop.
Save st-tran/5e34243ba44c3df0a2abd2a61dd4843b to your computer and use it in GitHub Desktop.
UltiSnips snippets
###############################################################################
# UltiSnips snippets for me to type LaTeX quickly
# Borrows a handful of snippets from https://castel.dev/post/lecture-notes-1/
#
# Mainly tailored to my own typing style and workflow.
# In particular:
# - I often work in temporary scratchpad windows using i3wm and have
# bindsym commands to quickly open vim+zathura with vimtex. 'tbmath' and
# its variants use my steven.sty file with various QoL improvements and
# wrappers for nice typesetting.
# - Many of these shortcuts seem cryptic but I've become accustomed to
# them over time.
###############################################################################
snippet beg "begin{} / end{}" bA
\begin{$1}
$0
\end{$1}
endsnippet
snippet mk "Math" wA
$${1}$`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
snippet dm "Math" wA
\[
$1
\] $0
endsnippet
snippet alg "algorithmic with algorithm float wrap" bA
\begin{algorithm}
\begin{algorithmic}[1]
\Procedure{$1}{$0}
\EndProcedure
\end{algorithmic}
\end{algorithm}
endsnippet
snippet minlpp "min linear program" bA
\begin{alignat*}{1}
\operatornamewithlimits{minimize}_{$1}\quad & $2\\\\
\text{subject to}\quad & $3\\\\
& $4\\\\
\end{alignat*}
endsnippet
snippet maxlpp "max linear pr" bA
\begin{alignat*}{1}
\operatornamewithlimits{maximize}_{$1}\quad & $2\\\\
\text{subject to}\quad & $3\\\\
& $4\\\\
\end{alignat*}
endsnippet
snippet state "algorithm state" bA
\State{$1}
endsnippet
snippet for "algorithm for" bA
\For{$1}
\EndFor
endsnippet
snippet while "algorithm while" bA
\While{$1}
\EndWhile
endsnippet
snippet if "algorithm if" bA
\If{$1}
\EndIf
endsnippet
snippet elsif "algorithm elsif" bA
\ElsIf{$1}
endsnippet
snippet btext "minimum to start writing text" bA
\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\begin{document}
$1
\end{document}
endsnippet
snippet bmath "minimum to start writing math" bA
\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{mathtools}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
$1
\end{document}
endsnippet
snippet tbtext "minimum to start writing text" bA
\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\begin{document}
$1
\end{document}
endsnippet
snippet tbmath "minimum to start writing math" bA
\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{mathtools}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{steven}
\begin{document}
$1
\end{document}
endsnippet
snippet tp "procedure style" wA
\textproc{$1}
endsnippet
snippet frc "frac" wA
\frac{$1}{$2}
endsnippet
snippet ubrm "underbrace math" wA
\underbrace{$1}_{$2}
endsnippet
snippet obrm "overbrace math" wA
\overbrace{$1}^{$2}
endsnippet
snippet ubrt "underbrace text" wA
\underbrace{$1}_{\text{$2}}
endsnippet
snippet obrt "overbrace text" wA
\overbrace{$1}^{\text{$2}}
endsnippet
snippet lusum "lower upper bound summation" wA
\sum_{$1}^{$2}{$3}
endsnippet
snippet luprod "lower upper bound prod" wA
\prod{$1}^{$2}{$3}
endsnippet
snippet lsum "lower bound summation" wA
\sum_{$1}{$2}
endsnippet
snippet lprod "lower bound prod" wA
\prod{$1}{$2}
endsnippet
snippet lrbr "left right bracket" wA
\left($1\right)
endsnippet
snippet limm "limit" wA
\lim_{$1}{$2}
endsnippet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment