mirror of
https://github.com/SqrtMinusOne/dotfiles.git
synced 2025-12-10 11:13:04 +03:00
119 lines
2.6 KiB
Text
119 lines
2.6 KiB
Text
priority -50
|
||
|
||
global !p
|
||
|
||
import glob
|
||
|
||
PRIORITIES = {
|
||
'generalPreamble': 0,
|
||
'Locale': 1,
|
||
'BibTex': 2,
|
||
}
|
||
|
||
def get_styles(folder):
|
||
styles = [file[:-4] for file in glob.glob(f'{folder}/*.sty')]
|
||
priorities = [1] * len(styles)
|
||
for i, filename in enumerate(styles):
|
||
for name, priority in PRIORITIES.items():
|
||
if name in filename:
|
||
priorities[i] = priority
|
||
if styles:
|
||
priorities, styles = zip(*sorted(zip(priorities, styles)))
|
||
return styles
|
||
|
||
def try_get_styles(folders):
|
||
for folder in folders:
|
||
styles = get_styles(folder)
|
||
if len(styles) > 0:
|
||
return styles
|
||
|
||
endglobal
|
||
|
||
snippet defdoc "Default document template"
|
||
\documentclass[a4paper, 14pt]{extarticle}
|
||
`!p
|
||
res = ""
|
||
for style in try_get_styles(["./styles", '.', '..', '../styles']):
|
||
res += "\\usepackage{" + style + "}\n"
|
||
snip.rv = res
|
||
`
|
||
|
||
\begin{document}
|
||
$0
|
||
\end{document}
|
||
endsnippet
|
||
|
||
snippet defrep "Default small report template"
|
||
\documentclass[a4paper, 14pt]{extarticle}
|
||
`!p
|
||
res = ""
|
||
for style in get_styles("./styles"):
|
||
res += "\\usepackage{" + style + "}\n"
|
||
snip.rv = res
|
||
`
|
||
|
||
\title{$1}
|
||
\author{${2:Корытов Павел, 6304 \\\\ СПбГЭТУ \enquote{ЛЭТИ}}}
|
||
\date{${3:\today}}
|
||
\begin{document}
|
||
\maketitle
|
||
$0
|
||
\end{document}
|
||
endsnippet
|
||
|
||
snippet etutitle "ETU default report title"
|
||
\begin{titlepage}
|
||
\centering
|
||
{\bfseries
|
||
\uppercase{
|
||
Минобрнауки России \\\\
|
||
Санкт-Петербургский государственный \\\\
|
||
Электротехнический университет \\\\
|
||
\enquote{ЛЭТИ} им. В.И.Ульянова (Ленина)\\\\
|
||
}
|
||
Кафедра ${1:МО ЭВМ}
|
||
|
||
\vspace{\fill}
|
||
\uppercase{${2:Отчёт}} \\\\
|
||
по ${3:лабораторной работе} ${4:№1} \\\\
|
||
по дисциплине \enquote{$5} \\\\
|
||
Тема: $6
|
||
}
|
||
|
||
\vspace{\fill}
|
||
\begin{tabularx}{0.8\textwidth}{l X c r}
|
||
Студент гр. 6304 & & \underline{\hspace{3cm}} & Корытов П.В.\\\\
|
||
Преподаватель & & \underline{\hspace{3cm}} & $7
|
||
\end{tabularx}
|
||
|
||
\vspace{1cm}
|
||
Санкт-Петербург \\\\
|
||
\the\year{}
|
||
\end{titlepage}
|
||
|
||
$0
|
||
endsnippet
|
||
|
||
snippet fhdr "My default fancy header"
|
||
\usepackage{fancyhdr}
|
||
\pagestyle{fancy}
|
||
|
||
\newcommand{\theversion}{${1:1.0}}
|
||
|
||
\fancyhead[L]{
|
||
\begin{tabular}{ll}
|
||
\textit{${2:Project}} \\\\
|
||
${3:Документ}
|
||
\end{tabular}
|
||
}
|
||
|
||
\fancyhead[R]{
|
||
\begin{tabular}{ll}
|
||
Версия: & \theversion{} \\\\
|
||
Дата: & \today{}
|
||
\end{tabular}
|
||
}
|
||
|
||
endsnippet
|
||
|
||
# vim:ft=snippets:
|