\documentclass[a4paper, oneside, openany, 14pt]{book}
% \documentclass[english]{article}
% \documentclass[a4paper,12pt,landscape,twocolumn]{book}
% fleqn - left align formulas
% openany - (book) do not make empty pages
\let\cleardoublepage\clearpage


\usepackage[T2A]{fontenc}
\usepackage{pgf}       % number output formatting
\usepackage{numprint}
\usepackage{layout}
\usepackage[onehalfspacing]{setspace}  % lines spacing
\usepackage[ampersand]{easylist}
\usepackage{multirow}            % улучшенное форматирование таблиц
\usepackage{ulem}                % подчеркивания
\usepackage[russian]{babel}



%\usepackage{extsizes}
\usepackage{cmap} % для кодировки шрифтов в pdf
%\usepackage{pscyr}
%\usepackage{cyrillic}

% long tables
\usepackage{longtable}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\LTcapwidth{\textwidth}

\usepackage{tabularx}
%\newcolumntype{C}[1]{>{\centering}m{#1}}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\usepackage[intlimits]{amsmath}
% \intlimits - чтобы пределы интеграла были не скраю от него, а сверху и снизу
\usepackage{amstext}

\usepackage{lscape}
\usepackage{indentfirst}


\usepackage{anysize}
\marginsize{3cm}{2cm}{1cm}{1cm}

% picture and table positions by default - top of the page
% we want them to be in text!
% [h] - means "here" (in text)
\usepackage{float}
\floatplacement{figure}{H}
\floatplacement{table}{H}

\usepackage{ifthen}


\usepackage{xcolor}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear all header and footer fields

% page numbers format:
% the actual code is on the first page you want to start numbering!

% sort:
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\topmargin 10mm
\textwidth 16truecm
\textheight 24truecm
\oddsidemargin 0mm
\evensidemargin 0mm

% center tables on page
\let\originaltable\table
\let\endoriginaltable\endtable
\renewenvironment{table}[1][H]{%
  \originaltable[#1]
  \centering}%
  {\endoriginaltable}

% center figures on page
\let\originalfigure\figure
\let\endoriginalfigure\endfigure
\renewenvironment{figure}[1][H]{
  \originalfigure[#1]
  \centering}%
{\endoriginalfigure}


% itemize setup:
\usepackage{enumitem}
\setitemize[1]{label=\textemdash{}}
\setlist{nolistsep} % or \setlist{noitemsep} to leave space around whole list
%\setlist[2]{noitemsep} % sets the itemsep and parsep for all level two lists to 0
%\setenumerate{noitemsep} % sets no itemsep for enumerate lists only
%\begin{enumerate}[noitemsep] % sets no itemsep for just this list
\setitemize{itemsep=1pt}
% make space after {itemize}:
\let\EndItemize\enditemize
\def\enditemize{\EndItemize\bigskip}


% pictures:
\usepackage{graphicx}
\graphicspath{{../pics/}}    % folder for our pictures



% FONTS:
\usepackage{mathptmx}
\usepackage[14pt]{extsizes}



%% For XeLaTeX:
\newif\ifxelatex
\ifx\XeTeXglyph\undefined
\xelatexfalse
\else
\xelatextrue
\fi

\usepackage{ifxetex}
\ifxelatex
\usepackage{xecyr}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{fontspec}
%\setmainfont[Ligatures=TeX]{TeX Gyre Termes}
% \setmainfont{Times New Roman}        % see comments:
%% quotes don't work with XeLaTeX   <<>>  `` ''
%% to fix it - set some parameters, not just a font
\setmainfont[Ligatures={Common,TeX}, Numbers={OldStyle}]{Times New Roman}
\defaultfontfeatures{Ligatures=TeX}

\else
\usepackage[utf8]{inputenc}
%\usepackage{tgtermes}
\fi


% russian text in formulas?
%\usepackage[math-style=tex]{unicode-math}
%\usepackage{unicode-math}



\usepackage{scrextend}
%% \changefontsizes macro. It features an optional argument to change
%% \baselineskip (the default is 1.2 * fontsize).
%%\changefontsizes[19pt]{14pt}
\changefontsizes[21pt]{14pt}


% \newcommand{\sizetwelvefixed}{\fontsize{22}{16.4}\selectfont}
\newcommand{\sizetwelvefixed}{\fontsize{22}{26.4}\selectfont}
\usepackage{sectsty}
\usepackage{textcase}

\usepackage{titlesec}

% chapters, sections, subsections / pictures, tables captions:
\input{settings/headers.tex}

% ------------------------
% Table of Contents
%\renewcommand{\contentsname}{Содержание}
\addto\captionsrussian{% Replace "english" with the language you use
  \renewcommand{\contentsname}{СОДЕРЖАНИЕ}
  %\renewcommand{\contentsname}{\centering Contents}
}
\setcounter{tocdepth}{2}       % глубина заголовков в содержании
\setcounter{secnumdepth}{3}    %

% spaces from left (toc):
% http://tex.stackexchange.com/questions/13438/changing-the-toc-style-of-an-article-document-class
\usepackage{tocloft}   % http://www.ctan.org/pkg/tocloft
%\setlength{\cftchapindent}{0cm}
%\setlength{\cftchapnumwidth}{0.75cm}
%\setlength{\cftsecnumwidth}{0.5cm}
%\setlength{\cftsubsecnumwidth}{0.95cm}
%\setlength{\cftsubsecindent}{1.25cm}
\setlength{\cftchapindent}{0cm}
\setlength{\cftchapnumwidth}{0.1cm}

\setlength{\cftsecindent}{0.1cm}
\setlength{\cftsecnumwidth}{0.5cm}

\setlength{\cftsubsecindent}{0.65cm}
\setlength{\cftsubsecnumwidth}{0.75cm}

\renewcommand\cftchapfont{\normalfont}       % not bold chapter,
\renewcommand\cftchappagefont{\normalfont}   % also for number
% change title of TOC:
%\renewcommand{\cfttoctitlefont}{\normalfont\MakeUppercase\mychapterfont}
%\renewcommand{\cfttoctitlefont}{\MakeUppercase\mychapterfont}
\renewcommand{\cfttoctitlefont} % ToC title
{\mychapterfont}








\usepackage{etoolbox}



%\patchcmd{\section}{\arabic{section}}{}{}{}
%\renewcommand{\thesection}{\arabic{section}}

%
%\sectionfont{\sc\MakeLowercase}

%\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}
%\MakeTextUppercase{\chapter}

\usepackage[inner=3cm, outer=1.9cm, top=2cm, bottom=3cm]{geometry}
%\usepackage[expert]{mathdesign}      % font for math







%\usepackage[it]{titlesec}
%\usepackage{polyglossia}  %% подключает пакет многоязыковой вёрстки
%\setmainfont{Ubuntu}  %% задаёт основной шрифт документа
% \setsansfont{Ubuntu}  %% задаёт шрифт без засечек
% \setmonofont{Ubuntu}  %% задаёт моноширинный шрифт






% equation numbering
\renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}}


% add toc to pdf bookmarks:
%\makeatletter
%\usepackage{etoolbox}
%\pretocmd{\tableofcontents}{%
%  \if@openright\cleardoublepage\else\clearpage\fi
%  \pdfbookmark[0]{\contentsname}{toc}%
%}{}{}%
%\makeatother

\usepackage{hyperref}
\hypersetup{
  pdftex,
  pdftitle    = {Автомат стабилизации движения маневренного самолета},
  pdfauthor   = {Пашинин С.А.},
  pdfproducer = {Пашинин С.А.},
  colorlinks=true,
  allcolors=black
}
\usepackage{hypcap}



% my align block
% reduce vertical space
%\makeatletter
%\newenvironment{myalign*}{%
%%\renewenvironment{align*}{
%  %\setlength{\mathindent}{0pt}%
%  %\setlength{\abovedisplayskip}{-\baselineskip}%
%  \setlength{\abovedisplayskip}{0}
%  %\setlength{\abovedisplayshortskip}{\abovedisplayskip}%
%  \setlength{\abovedisplayshortskip}{0}
%  %\start@align\@ne\st@rredtrue\m@ne
%}%
%{\endalign}
%\makeatother


% equation vertical skip
% For align environments:
\usepackage{calc} % to make calculations with lengths
%\newlength{\myMargin}
%\setlength{\myMargin}{50em}

%\let\oldalign\align
%\let\endoldalign\endalign
%\renewenvironment{align}{%
%  \oldalign\hspace{\myMargin}}{%
%  \endoldalign\ignorespacesafterend}

%\setlength{\abovedisplayshortskip}{300pt}%

%\setlength{\abovedisplayskip}     {0pt}
%\setlength{\belowdisplayskip}     {10pt}
%\setlength{\abovedisplayshortskip}{2pt}
%\setlength{\belowdisplayshortskip}{20pt}

% spacing between formulas - short skips
\usepackage{setspace}
\AtBeginDocument{%
  %\addtolength\abovedisplayskip{-0.5\baselineskip}%
  %\addtolength\belowdisplayskip{-0.5\baselineskip}%
  \addtolength\abovedisplayshortskip{-0.5\baselineskip}%
  %\addtolength\belowdisplayshortskip{-0.5\baselineskip}%
}


%\usepackage[nodisplayskipstretch]{setspace}
%\setstretch{1}
