
% \iffalse
%%% From File: custom.dtx
% \fi
%
%    \begin{macrocode}

%<*custom>
%    \end{macrocode}
% \subsection{Подключение и настройка сторонних пакетов}
%
% Прямые символы интегралов из шрифтов семейства Euler.
%    \begin{macrocode}
\ifDis@fixint
  \DeclareSymbolFont{EulerExtension}{U}{euex}{m}{n}
  \DeclareMathSymbol\intop\mathop{EulerExtension}{"52}
  \DeclareMathSymbol\ointop\mathop{EulerExtension}{"48}
  \AtBeginDocument{%
    \def\intkern@{\mkern -6mu }%
    \def\ints@#1{\mkern -3mu
      \mathop{\mkern 3mu
        \intop
        \ifnum #1=\z@ \intdots@ \else
          \intkern@
          \ifnum #1>\tw@ \intop\intkern@
            \ifnum #1>\thr@@ \intop\intkern@ \fi
          \fi
        \fi
        \intop
       }\ilimits@
    }%
    \renewcommand{\iint}{\DOTSI\protect\MultiIntegral{2}}
    \renewcommand{\iiint}{\DOTSI\protect\MultiIntegral{3}}
    \renewcommand{\iiiint}{\DOTSI\protect\MultiIntegral{4}}
    \renewcommand{\idotsint}{\DOTSI\protect\MultiIntegral{0}}
  }{}
\fi

%    \end{macrocode}
% \subsubsection{Библиографические ссылки}
% \DescribePackage{natbib}
%    \begin{macrocode}
\ifDis@natbib
  \usepackage[square,comma,sort&compress,numbers]{natbib}
\else
%    \end{macrocode}
% Пустые определения команд из пакета |natbib|.
% \DescribeMacro{\bibsection}\index{Макросы!\verb*+\bibsection+}
% \DescribeMacro{\bibpreamble}\index{Макросы!\verb*+\bibpreamble+}
% \DescribeMacro{\bibpostamble}\index{Макросы!\verb*+\bibpostamble+}
% \DescribeMacro{\bibsep}\index{Макросы!\verb*+\bibsep+}
%    \begin{macrocode}
  \providecommand*\bibsection{}
  \providecommand*\bibpreamble{}
  \providecommand*\bibpostamble{}
  \newlength\bibsep
\fi

%    \end{macrocode}
% Команда, создающая заголовок библиографии.
% \DescribeMacro{\bibsection}\index{Макросы!\verb*+\bibsection+}
%    \begin{macrocode}
\renewcommand\bibsection{\nchapter{\bibname}}

%    \end{macrocode}
% Преамбула окружения |thebibliography|.
% \DescribeMacro{\bibpreamble}\index{Макросы!\verb*+\bibpreamble+}
%    \begin{macrocode}
\renewcommand\bibpreamble{%
%    \end{macrocode}
% Формат номера в списке литературы.
% \DescribeMacro{\@biblabel}\index{Макросы!\verb*+"\"@biblabel+}
%    \begin{macrocode}
  \renewcommand\@biblabel[1]{##1.}%
  \setlength\bibsep{0pt}
}

\@ifpackageloaded{natbib}{
  \@ifundefined{chapter}{%
    \renewcommand\bibsection{%
     \nsection{\bibname\@mkboth{\MakeUppercase{\bibname}}{\MakeUppercase{\bibname}}}%
    }%
  }{%
    \@ifxundefined\NAT@sectionbib{%
      \renewcommand\bibsection{%
        \nchapter{\bibname\@mkboth{\MakeUppercase{\bibname}}{\MakeUppercase{\bibname}}}%
      }%
    }{%
      \renewcommand\bibsection{%
        \nsection{\bibname\ifx\@mkboth\@gobbletwo\else\markright{\MakeUppercase{\bibname}}\fi}%
      }%
    }%
  }%
}{%
  \@ifundefined{chapter}{%
    \renewcommand\bibsection{%
     \nsection{\bibname\@mkboth{\MakeUppercase{\bibname}}{\MakeUppercase{\bibname}}}%
    }%
  }{}
%    \end{macrocode}
% \DescribeEnv{thebibliography}\index{Окружения!\verb*+thebibliography+}
%    \begin{macrocode}
  \renewenvironment{thebibliography}[1]{
    \bibsection
    \parindent\z@
    \bibpreamble\normalfont\selectfont
    \list{\@biblabel{\@arabic\c@enumiv}}{\settowidth\labelwidth{\@biblabel{#1}}%
    \setlength{\itemsep}{\bibsep}
    \setlength{\parsep}{\bibsep}
    \leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \@openbib@code
    \usecounter{enumiv}%
    \let\p@enumiv\@empty
    \renewcommand\theenumiv{\@arabic\c@enumiv}}%
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.\@m
  }{%
    \bibpostamble
    \def\@noitemerr
    {\@latex@warning{Empty `thebibliography' environment}}%
    \endlist
  }
}

%    \end{macrocode}
% \subsubsection{Плавающие объекты}
%
% Пакеты \pkg{caption} и \pkg{subcaption} для вложенной нумерации плавающих
% объектов.
% \DescribePackage{caption}
% \DescribePackage{subcaption}
%    \begin{macrocode}
\ifDis@subf
  \usepackage[font=small,labelsep=period]{caption}
  \usepackage[list=true,subrefformat=parens]{subcaption}
  \captionsetup{compatibility=false}
%    \end{macrocode}
% Формат счетчика.
%    \begin{macrocode}
  \DeclareCaptionSubType[asbuk]{figure}
  \def\thesubfigure{\textit{\asbuk{subfigure}}}
%    \end{macrocode}
% Формат ссылки через |\ref|.
% \DescribeMacro{\thefigsubsep}\index{Макросы!\verb*+\thefigsubsep+}
%    \begin{macrocode}
  \providecommand\thefigsubsep{,~}
  \def\p@subfigure{\@nameuse{thefigure}\thefigsubsep}
\fi

%    \end{macrocode}
% \subsubsection{Hyperref}
%    \begin{macrocode}
\ifpdf
  \ifDis@href
%    \end{macrocode}
% \DescribePackage{hyperref}
%    \begin{macrocode}
    \usepackage[pdftex,unicode]{hyperref}
    \hypersetup{
      colorlinks         = false,
      bookmarksopen      = true,
      bookmarksnumbered  = true,
      bookmarksopenlevel = 2,
      pdfstartview       = {FitH},
      pdfborder          = {0 0 0}
    }
    \pdfcompresslevel = 9
  \fi
%    \end{macrocode}
% \DescribePackage{graphicx}
% \DescribePackage{cmap}
%    \begin{macrocode}
  \usepackage[pdftex]{graphicx}
  \usepackage{cmap}
\else
  \ifDis@href
%    \end{macrocode}
% \DescribePackage{hyperref}
%    \begin{macrocode}
    \usepackage[hypertex,colorlinks=false]{hyperref}
  \fi
%    \end{macrocode}
% \DescribePackage{graphicx}
%    \begin{macrocode}
  \usepackage{graphicx}
\fi
\ifDis@href
%    \end{macrocode}
% Включение и настройка цветных ссылок.
%    \begin{macrocode}
  \ifDis@colorlinks
    \usepackage{color}
    \definecolor{darkblue}{rgb}{0,0,.6}
    \hypersetup{
      colorlinks = true,     linkcolor  = darkblue,
      citecolor  = darkblue, filecolor  = darkblue,
      menucolor  = darkblue, urlcolor   = darkblue
    }
  \fi
\fi

%    \end{macrocode}
% Команда, создающая цель для гиперссылок над заголовками ненумеруемых
% разделов.
% \DescribeMacro{\hrefphantom}\index{Макросы!\verb*+\hrefphantom+}
%    \begin{macrocode}
\providecommand\hrefphantom[1]{%
  \ifDis@href
    \Hy@GlobalStepCount\Hy@linkcounter
    \xdef\@currentHref{#1*.\the\Hy@linkcounter}%
    \Hy@raisedlink{\hyper@anchorstart{\@currentHref}\hyper@anchorend}%
  \fi
}

%    \end{macrocode}
% Команды для создания ненумеруемых глав и секций, которые включаются в
% оглавление и PDF-закладки.
% \DescribeMacro{\nchapter}\index{Макросы!\verb*+\nchapter+}
% \DescribeMacro{\nsection}\index{Макросы!\verb*+\nsection+}
% \DescribeMacro{\nsubsection}\index{Макросы!\verb*+\nsubsection+}
% \DescribeMacro{\nsubsubsection}\index{Макросы!\verb*+\nsubsubsection+}
%    \begin{macrocode}
\newcommand\nchapter[1]{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \thispagestyle{\@chapterpagestyle}%
  \global\@topnum\z@
  \hrefphantom{chapter}
  \addcontentsline{toc}{chapter}{#1}%
  \@afterindentfalse
  \@schapter{#1}
}
\newcommand\nsection[1]{%
  \hrefphantom{section}%
  \addcontentsline{toc}{section}{#1}
  \section*{#1}
}
\newcommand\nsubsection[1]{%
  \hrefphantom{subsection}%
  \addcontentsline{toc}{subsection}{#1}
  \subsection*{#1}
}
\newcommand\nsubsubsection[1]{%
  \hrefphantom{subsubsection}%
  \addcontentsline{toc}{subsubsection}{#1}
  \subsubsection*{#1}
}

%</custom>
%    \end{macrocode}
