-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.sty
67 lines (55 loc) · 2.19 KB
/
commands.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
\ProvidesPackage{commands}
%%
%% Объявление новых команд
%%
% \newcommand{\имя-команды}{определение команды}
% Если длинным сложным командам LaTeX надо присвоить имя, это делается с помощью \newcommand. Ниже определяется след оператора
\newcommand{\tr}{\operatorname{tr}}
\newcommand{\E}{\mathds{E}}
\newcommand{\R}{\mathds{R}}
\renewcommand{\P}{\mathds{P}}
\newcommand{\Y}{\mathds{Y}}
% Если команду надо переопределить используется \renewcommand. В этом есть необходимость, например, для определения мнимой части комплексного числа. Исходная LaTeX команда выдает не общепринятое обозначение
\renewcommand{\Im}{\operatorname{Im}}
\renewcommand{\Re}{\operatorname{Re}}
\newcommand{\scalar}[1]{\langle #1 \rangle}
\newcommand{\like}[2]{\ell\left( #1\ |\ #2 \right)}
\newcommand{\cprob}[2]{p\left( #1\ |\ #2 \right)}
\newcommand{\KL}[2]{\text{KL}\left( #1\ ||\ #2 \right)}
\newcommand{\norm}[1]{\lVert #1 \rVert}
\newcommand{\btfl}[1]{\mathcal{#1}}
\DeclareMathOperator{\mse}{MSE}
\DeclareMathOperator{\mae}{MAE}
\DeclareMathOperator{\rmse}{RMSE}
\DeclareMathOperator{\sign}{sign}
% Custom colors
\usepackage{color}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}
\usepackage{listings}
% Python style for highlighting
\newcommand\pythonstyle{\lstset{
language=Python,
basicstyle=\ttm,
morekeywords={self}, % Add keywords here
keywordstyle=\ttb\color{deepblue},
emph={MyClass,__init__}, % Custom highlighting
emphstyle=\ttb\color{deepred}, % Custom highlighting style
stringstyle=\color{deepgreen},
frame=tb, % Any extra options here
showstringspaces=false
}}
% Python environment
\lstnewenvironment{python}[1][]
{
\pythonstyle
\lstset{#1}
}
{}
% Python for external files
\newcommand\pythonexternal[2][]{{
\pythonstyle
\lstinputlisting[#1]{#2}}}
% Python for inline
\newcommand\pythoninline[1]{{\pythonstyle\lstinline!#1!}}