2014-03-11 20:10:50 +00:00
|
|
|
priority -50
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2014-03-11 20:10:50 +00:00
|
|
|
extends texmath
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2018-02-04 11:35:08 +00: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
|
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet "b(egin)?" "begin{} / end{}" br
|
|
|
|
\begin{${1:something}}
|
|
|
|
${0:${VISUAL}}
|
|
|
|
\end{$1}
|
|
|
|
endsnippet
|
|
|
|
|
2017-05-26 09:30:32 +00:00
|
|
|
snippet abs "abstract environment" b
|
|
|
|
\begin{abstract}
|
|
|
|
$0
|
|
|
|
\end{abstract}
|
|
|
|
endsnippet
|
|
|
|
|
2014-07-02 11:18:18 +00:00
|
|
|
snippet tab "tabular / array environment" b
|
2012-08-17 03:41:25 +00:00
|
|
|
\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}}
|
2016-12-27 14:46:49 +00:00
|
|
|
$0${2/(?<=.)(c|l|r)|./(?1: & )/g}
|
2012-08-17 03:41:25 +00:00
|
|
|
\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}
|
|
|
|
endsnippet
|
|
|
|
|
2018-02-04 11:35:08 +00:00
|
|
|
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
|
|
|
|
|
2015-01-18 12:58:28 +00:00
|
|
|
snippet table "Table environment" b
|
|
|
|
\begin{table}[${1:htpb}]
|
|
|
|
\centering
|
|
|
|
\caption{${2:caption}}
|
|
|
|
\label{tab:${3:label}}
|
|
|
|
\begin{${4:t}${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${5:c}}
|
2016-12-27 14:46:49 +00:00
|
|
|
$0${5/(?<=.)(c|l|r)|./(?1: & )/g}
|
2015-01-18 12:58:28 +00:00
|
|
|
\end{$4${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}
|
|
|
|
\end{table}
|
|
|
|
endsnippet
|
|
|
|
|
2014-03-11 20:10:50 +00:00
|
|
|
snippet fig "Figure environment" b
|
2014-10-14 13:30:33 +00:00
|
|
|
\begin{figure}[${2:htpb}]
|
2014-03-11 20:10:50 +00:00
|
|
|
\centering
|
|
|
|
\includegraphics[width=${3:0.8}\linewidth]{${4:name.ext}}
|
2019-08-22 15:36:17 +00:00
|
|
|
\caption{${4/(\w+)\.\w+/\u$1/}$0}%
|
2014-03-11 20:10:50 +00:00
|
|
|
\label{fig:${4/(\w+)\.\w+/$1/}}
|
|
|
|
\end{figure}
|
|
|
|
endsnippet
|
|
|
|
|
2012-08-17 03:41:25 +00:00
|
|
|
snippet enum "Enumerate" b
|
|
|
|
\begin{enumerate}
|
|
|
|
\item $0
|
|
|
|
\end{enumerate}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet item "Itemize" b
|
|
|
|
\begin{itemize}
|
|
|
|
\item $0
|
|
|
|
\end{itemize}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet desc "Description" b
|
|
|
|
\begin{description}
|
|
|
|
\item[$1] $0
|
|
|
|
\end{description}
|
|
|
|
endsnippet
|
|
|
|
|
2014-03-11 20:10:50 +00:00
|
|
|
snippet it "Individual item" b
|
2017-11-24 13:54:40 +00:00
|
|
|
\item $0
|
2014-03-11 20:10:50 +00:00
|
|
|
endsnippet
|
2012-08-17 03:41:25 +00:00
|
|
|
|
|
|
|
snippet part "Part" b
|
2018-03-31 14:56:26 +00:00
|
|
|
\part{${1:part name}}%
|
2014-03-11 20:10:50 +00:00
|
|
|
\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}}
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2017-02-11 13:01:38 +00:00
|
|
|
$0
|
2012-08-17 03:41:25 +00:00
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet cha "Chapter" b
|
2018-03-31 14:56:26 +00:00
|
|
|
\chapter{${1:chapter name}}%
|
2014-03-11 20:10:50 +00:00
|
|
|
\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2017-02-11 13:01:38 +00:00
|
|
|
$0
|
2012-08-17 03:41:25 +00:00
|
|
|
endsnippet
|
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet sec "Section"
|
|
|
|
\section{${1:${VISUAL:section name}}}%
|
2014-03-11 20:10:50 +00:00
|
|
|
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2017-02-11 13:01:38 +00:00
|
|
|
$0
|
2012-08-17 03:41:25 +00:00
|
|
|
endsnippet
|
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet sec* "Section"
|
|
|
|
\section*{${1:${VISUAL:section name}}}%
|
2017-05-02 12:42:08 +00:00
|
|
|
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
|
|
|
|
|
|
${0}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet sub "Subsection"
|
|
|
|
\subsection{${1:${VISUAL:subsection name}}}%
|
2014-03-11 20:10:50 +00:00
|
|
|
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2017-02-11 13:01:38 +00:00
|
|
|
$0
|
2012-08-17 03:41:25 +00:00
|
|
|
endsnippet
|
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet sub* "Subsection"
|
|
|
|
\subsection*{${1:${VISUAL:subsection name}}}%
|
2017-05-02 12:42:08 +00:00
|
|
|
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
|
|
|
|
|
|
${0}
|
|
|
|
endsnippet
|
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet ssub "Subsubsection"
|
|
|
|
\subsubsection{${1:${VISUAL:subsubsection name}}}%
|
2014-03-11 20:10:50 +00:00
|
|
|
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2017-02-11 13:01:38 +00:00
|
|
|
$0
|
2012-08-17 03:41:25 +00:00
|
|
|
endsnippet
|
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet ssub* "Subsubsection"
|
|
|
|
\subsubsection*{${1:${VISUAL:subsubsection name}}}%
|
2017-05-02 12:42:08 +00:00
|
|
|
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
|
|
|
|
|
|
${0}
|
|
|
|
endsnippet
|
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet par "Paragraph"
|
|
|
|
\paragraph{${1:${VISUAL:paragraph name}}}%
|
2014-03-11 20:10:50 +00:00
|
|
|
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2017-02-11 13:01:38 +00:00
|
|
|
$0
|
2012-08-17 03:41:25 +00:00
|
|
|
endsnippet
|
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet subp "Subparagraph"
|
|
|
|
\subparagraph{${1:${VISUAL:subparagraph name}}}%
|
2014-03-11 20:10:50 +00:00
|
|
|
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2017-02-11 13:01:38 +00:00
|
|
|
$0
|
2014-03-11 20:10:50 +00:00
|
|
|
endsnippet
|
2012-08-17 03:41:25 +00:00
|
|
|
|
2018-06-14 10:31:12 +00:00
|
|
|
snippet ac "Acroynm normal" b
|
|
|
|
\ac{${1:acronym}}
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet acl "Acroynm expanded" b
|
|
|
|
\acl{${1:acronym}}
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-11 20:10:50 +00:00
|
|
|
snippet ni "Non-indented paragraph" b
|
|
|
|
\noindent
|
2017-02-11 13:01:38 +00:00
|
|
|
$0
|
2012-08-17 03:41:25 +00:00
|
|
|
endsnippet
|
|
|
|
|
2014-03-11 20:10:50 +00:00
|
|
|
snippet pac "Package" b
|
2017-05-02 12:42:08 +00:00
|
|
|
\usepackage`!p snip.rv='[' if t[1] else ""`${1:options}`!p snip.rv = ']' if t[1] else ""`{${2:package}}$0
|
2014-03-11 20:10:50 +00:00
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet lp "Long parenthesis"
|
|
|
|
\left(${1:${VISUAL:contents}}\right)$0
|
|
|
|
endsnippet
|
2017-11-24 13:54:40 +00:00
|
|
|
|
|
|
|
snippet "mint(ed)?( (\S+))?" "Minted code typeset" br
|
2018-06-14 10:31:12 +00:00
|
|
|
\begin{listing}
|
|
|
|
\begin{minted}[linenos,numbersep=5pt,frame=lines,framesep=2mm]{${1:`!p
|
2017-11-24 13:54:40 +00:00
|
|
|
snip.rv = match.group(3) if match.group(2) is not None else "language"`}}
|
|
|
|
${2:${VISUAL:code}}
|
2018-06-14 10:31:12 +00:00
|
|
|
\end{minted}
|
|
|
|
\caption{${3:caption name}}
|
|
|
|
\label{lst:${4:${3/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
|
|
|
\end{listing}
|
|
|
|
|
|
|
|
$0
|
2017-11-24 13:54:40 +00:00
|
|
|
endsnippet
|
2012-08-17 03:41:25 +00:00
|
|
|
# vim:ft=snippets:
|