dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 7172b760aa73dd1d894b071a16a7351a267167b0
parent db25f8471da832641a399bd331d6f7099f61e6a1
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Sun,  7 Apr 2019 14:21:06 +0200

Latex snippets


Former-commit-id: 50a83659cfe0e43ba58f55df7e7636fd9be2293e
Diffstat:
Mvim/ultisnips/tex.snippets | 56++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 48 insertions(+), 8 deletions(-)

diff --git a/vim/ultisnips/tex.snippets b/vim/ultisnips/tex.snippets @@ -27,11 +27,24 @@ endglobal # Skeletons {{{ snippet skel "Math skeleton" b -\documentclass[12pt,a4paper,oneside,fleqn]{article} +\documentclass[12pt,a4paper,oneside,fleqn,notitlepage]{article} \usepackage{amsmath} \usepackage{amssymb} +\usepackage[left=1in, right=1in, top=1in, bottom=1in]{geometry} + +\usepackage{fancyhdr} +\setlength{\headheight}{15.2pt} +\pagestyle{fancyplain} +\lhead{\today} +\rhead{${1:class name}} + +\title{${2:assignment}} +\author{Alexander Balgavy} +\date{} + \begin{document} - $1 + \maketitle + $0 \end{document} endsnippet @@ -77,7 +90,7 @@ endsnippet snippet dm "Displayed math" wA \[ $1 -.\] $0 +\] $0 endsnippet # }}} @@ -89,9 +102,13 @@ endsnippet snippet b "bold text" w \textbf{$1} endsnippet + +snippet " "quote" w +\`\`$1''$0 +endsnippet # }}} -# Math symbols {{{ +# Math {{{ context "math()" snippet '([A-Za-z])(\d)' "auto subscript" wrA `!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)` @@ -135,6 +152,33 @@ context "math()" snippet ^{ "overbrace" \overbrace{${1:expression}}^\text{${2:annotation}} endsnippet + +context "math()" +snippet // "Fraction" iA +\\frac{$1}{$2}$0 +endsnippet + +context "math()" +snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Fraction" wrA +\\frac{`!p snip.rv = match.group(1)`}{$1}$0 +endsnippet + +priority 1000 +context "math()" +snippet '^.*\)/' "() Fraction" 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 + # }}} # Custom commands {{{ @@ -147,8 +191,4 @@ snippet cmd "\given{A}{B} - (A|B)" b \makeatother %%%%%%%%%%%%%%%%%%%%%%%%%%%%% endsnippet - -snippet cmd "another one" b -this doesn't actually do anything -endsnippet # }}}