\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{xcolor,colortbl}% http://ctan.org/pkg/xcolor
\usepackage{titlesec}
\usepackage{indentfirst}
\usepackage{datetime2}
\usepackage{geometry,lscape}
\usepackage{enumitem}
\usepackage{caption,subcaption}
\usepackage{multicol,multirow}
\usepackage{float,adjustbox}
\usepackage{fontawesome}
\usepackage{longtable}
\usepackage{tikz}
\usepackage{hyperref}
\usepackage{forest}
\usepackage{nomencl,imakeidx}
\usetikzlibrary{mindmap,trees}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{setspace,fontspec}
\usepackage{amsmath}
\usepackage{spreadtab}
\usepackage{svg}
\usepackage{afterpage}

\newcommand{\tabitem}{~~\llap{\textbullet}~~}

\spacing{1.15}
\babelfont{rm}{IBM Plex Sans}
\babelfont{tt}{PT Mono}

\titlelabel{\thetitle. \quad}
\setcounter{tocdepth}{2}
\renewcommand{\nomname}{Термины, определения и сокращения}
\makeindex
\makenomenclature

\newcommand\lh[2]{\texttt{\textcolor{#1}{#2}}}
\newcommand\hrf[1]{\hyperref[#1]{\ref{#1}}}
\newcommand\hRf[1]{\hyperref[#1]{\nameref{#1}}}
\newcommand{\wordcount}{\input{/tmp/wordcount.tex}}
\newcommand{\code}[1]{{\texttt{\detokenize{#1}}}}
\newcommand*{\nom}[2]{#1\nomenclature{#1}{#2}}
\renewcommand\labelitemi{\textemdash}
\newenvironment{frm}
  { \begin{center} \renewcommand*{\arraystretch}{2} \begin{tabular}{|p{0.9\textwidth}|} \hline }
  { \\\hline \end{tabular} \end{center} }

\newcommand{\info}{\cellcolor{green!20}{\Huge \faInfoCircle \quad}}
\newcommand{\excl}{\cellcolor{red!20}{\Huge \faExclamationTriangle \quad}}

\makeatletter
\newcommand{\setword}[2]{%
  \phantomsection
  #1\def\@currentlabel{\unexpanded{#1}}\label{#2}%
}
\makeatother

\fancypagestyle{plain}{
  \setlength{\headheight}{33pt}
  \fancyhf{}
  \lhead{\includegraphics[height=5mm]{logo.png}}
  \rhead{И.И. Овчинников \\ \href{https://t.me/ivanigorevichfeed}{Telegram: ivanigorevichfeed}}
  \chead{\thepage}
  \cfoot{\faRocket}
%  \rfoot{Всего слов: \wordcount}
}

\geometry{
  lmargin=1.5cm,
  rmargin=2.5cm,
  tmargin=2.5cm,
  bmargin=2.5cm,
}

\setlist{nolistsep}
\setlist[itemize]{leftmargin=10mm}
\setlist[enumerate]{leftmargin=10mm}

\makeatletter
    \providecommand\text\mbox
    \newenvironment{arithmetic}[1][]{\begin{tabular}[#1]{Al}}{\end{tabular}}
    \newcolumntype{A}{>{\bgroup\def~{\phantom{0}}$\@testOptor}r<{\@gobble\\$\egroup}}
    \def\@testOptor\ignorespaces#1#2\\{%
    \ifx#1\times
        \@OperatorRow{#1}{#2}\@tempa%
    \else\ifx#1+
        \@OperatorRow+{#2}\@tempa%
    \else\ifx#1\discretionary% detects the soft hyphen, \-
        \@ShortSubtractRow{#2}\@tempa%
    \else\ifx#1-
        \@OperatorRow-{#2}\@tempa%
    \else
        \@NormalRow{#1#2}\@tempa%
    \fi\fi\fi\fi
    \@tempa}
  \def\@OperatorRow#1#2#3{%
    \@IfEndRow#2\@gobble\\{%
        \def#3{\underline{{}#1 #2}\\}%
    }{%
        \def#3{\underline{{}#1 #2{}}}%
    }}

\def\@NormalRow#1#2{%
    \@IfEndRow#1\@gobble\\{%
        \def#2{#1\\}%
    }{%
        \def#2{#1{}}%
    }}

\def\@IfEndRow#1\@gobble#2\\#3#4{%
    \ifx#2\@gobble
        #4%
    \else
        #3%
    \fi}
\makeatother
