xelatex-template/setup/preamble.tex

267 lines
9.2 KiB
TeX
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

%%%%% Проверка версии компилятора
\usepackage{ifxetex}
%%%%% Функции для работы с размерностями и счётчиками
\usepackage{calc}
%%%%% Параметры страницы
\usepackage{geometry}
%%%%% Межстрочный интервал
\usepackage{setspace}
%%%%% \onehalfspacing работает только для шрифтов 10pt, 11pt, 12pt
%%%%% Указываем явное значение
\setstretch{1.25}
%%%%% Отступ первой строки в параграфе
\setlength{\parindent}{12.5mm}
\usepackage{indentfirst}
%%%%% Правила для висячих строк
\usepackage[defaultlines=3,all]{nowidow}
%%%%% Защита от строк на полях (добавление 3 виртуальных пустых символов)
\setlength{\emergencystretch}{3em}
%%%%% Оптимизация расстановки переносов и длины последней строки абзаца
\IfFileExists{impnattypo.sty}{\usepackage[hyphenation, lastparline]{impnattypo}}{}
%%%%% Поддержка переносоустойчивых подчёркиваний и зачёркиваний
\usepackage{soulutf8}
%%%%% Запятая в десятичных дробях
\usepackage{icomma}
%%%%% Работа с цветом
\usepackage[dvipsnames,svgnames*,x11names*]{xcolor}
%%%%% Оформление блоков исходных текстов (обязательно перед локализацией)
\usepackage{fancyvrb}
\ifxetex
% Break long lines of code
\usepackage{fvextra}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}}
\fi
\VerbatimFootnotes % allows verbatim text in footnotes
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\usepackage{listings}
\providecommand{\passthrough}[1]{#1}
\lstset{defaultdialect=[5.3]Lua}
\lstset{defaultdialect=[x86masm]Assembler}
%%%%% Словари и сокращения
\usepackage{nomencl}
\usepackage[
xindy={language={russian},glsnumbers=false},
toc,
acronym,
nopostdot,
nogroupskip,
nonumberlist]{glossaries}
\usepackage[automake=true]{glossaries-extra}
%\pdfstringdefDisableCommands{%
% \let\gls\@firstofone
%}
\newcounter{fontsnotfound}
\newcommand{\iffontsexist}[3]{
\setcounter{fontsnotfound}{0}
\expandafter\forcsvlist\expandafter\checkfont\expandafter{#1}
\ifnum\value{fontsnotfound}=0
#2
\else
#3
\fi
}
%%%%% Математика
\usepackage{amsthm,amsmath,amscd} % Математические дополнения от AMS
\usepackage{amsfonts,amssymb} % Математические дополнения от AMS
\usepackage{mathtools} % Добавляет окружение multlined
\usepackage{xfrac} % Красивые дроби
\usepackage{array} % Окружение с выравниванием
%%%%% Шрифты
\ifxetex
\usepackage[no-math]{fontspec}
\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text}
\defaultfontfeatures[\rmfamily]{Scale=1}
\setsansfont[Mapping=tex-text]{Arial}
\setromanfont[Mapping=tex-text]{XITS}
\setmainfont[Ligatures=TeX]{Times New Roman}
\newfontfamily\cyrillicfont{Times New Roman}[Script=Cyrillic]
\setmonofont[Scale=0.8,Mapping=tex-text]{Pragmata Pro Mono}
\newfontfamily\listingsfont{Pragmata Pro Mono Bold}
\newfontfamily\listingsfontinline{Pragmata Pro Mono Bold}
\DeclareSymbolFont{letters}{\encodingdefault}{\rmdefault}{m}{it}
\else
\fi
%%%%% Размерности SI (обязательно после fontspec, amsmath, unicode-math)
\usepackage{siunitx}
\sisetup{
exponent-product = \ensuremath { \cdot },
inter-unit-product = \ensuremath { \cdot },
output-decimal-marker = { , },
list-separator = {;\,},
list-final-separator = {;\,},
list-pair-separator = {;\,},
range-phrase = {\text{...}},
quotient-mode = fraction, % красивые дроби могут не соответствовать ГОСТ
fraction-function = \sfrac,
separate-uncertainty
}
\usepackage{physics}
\usepackage{eqexpl}
\eqexplSetIntro{где}
%%%%% Локализация
\ifxetex
\usepackage{textcase}
\usepackage{xltxtra}
\usepackage{xunicode}
\usepackage{polyglossia}
\usepackage{xecyr}
\setmainlanguage{russian}
\let\cyr\relax
\setotherlanguage{english}
\setkeys{russian}{babelshorthands=true,indentfirst=true}
\setmathfont{XITS Math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\IfFileExists{microtype.sty}{ % use microtype if available
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\else
\usepackage{cmap}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\fi
%%%%% При переносе оставлять минимум 3 символа на первой строке и 3 на второй
\renewcommand\russianhyphenmins{33}
%%%%% Использовать для кавычек-ёлочек данные символы
\usepackage{csquotes}
\renewcommand{\flqq}{«}
\renewcommand{\frqq}{»}
%%%%% Оформление URL, разрешение переносов
\usepackage[hyphens]{xurl}
%%%%% Использование того же шрифта, что и в окружающем тексте
\urlstyle{same}
\usepackage[
unicode=true,
bookmarks=true,
bookmarksnumbered=false,
bookmarksopen=false,
colorlinks=true, % ссылки отображаются цветным текстом
linkcolor={Maroon}, % цвет ссылок типа ref, eqref и подобных
filecolor={Maroon}, %
citecolor={Blue}, % цвет ссылок-цитат
urlcolor={Blue}, % цвет гиперссылок
linktocpage=true, % ссылки с номера страницы в оглавлении, списке таблиц и списке рисунков
pdfborder={0 0 0},
pdfborderstyle={},
pdfpagelabels=false, % set PDF page labels (true|false)
pdflang={ru}
]{hyperref}
\makeatletter
\AtBeginDocument{
\hypersetup{
breaklinks=false,
% linktoc=all, % both the section and page part are links
plainpages=false, % Forces page anchors to be named by the Arabic form of the page number, rather than the formatted form
% hidelinks, % Hide links (removing color and border)
pdftitle={\@title}, % Заголовок
pdfauthor={\@author}, % Автор
% pdfsubject={\thesisSpecialtyNumber\ \thesisSpecialtyTitle}, % Тема
% pdfcreator={Создатель}, % Создатель, Приложение
% pdfproducer={Производитель},% Производитель, Производитель PDF
pdfkeywords={}, % Ключевые слова
}
}
\makeatother
%%%%% Добавление модификатора H для размещения объектов
\usepackage{float}
%%%%% Команда \FloatBarrier
\usepackage{placeins}
%%%%% Настройка таблиц
\usepackage{xltabular}
\usepackage{ltcaption}
\usepackage{multirow}
\usepackage{makecell}
\newcommand{\HY}{\hyphenpenalty=25\exhyphenpenalty=25}
\newcolumntype{Z}{>{\HY\raggedright\arraybackslash\hspace{0pt}}X}
\newcolumntype{M}{>{\HY\RaggedRight\arraybackslash\hspace{0pt}}c}
\newcolumntype{L}{>{\HY\RaggedRight\arraybackslash\hspace{0pt}}l}
\newcolumntype{C}{>{\centering\arraybackslash}p}
\usepackage{pgfplotstable}
%%%%% Заголовок на последней странице таблицы (обязательно после hyperref)
\usepackage{fr-longtable}
%%%%% Автоматический подгон ширины подписи таблицы
\usepackage{threeparttable}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
%%%%% Подключение изображений (желательно после локализации)
\usepackage{graphicx}
\usepackage[encoding,filenameencoding=utf8,extendedchars]{grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
%%%%% Расположение по умолчанию
\makeatletter
\def\fps@figure{Htbp}
\makeatother
\providecommand{\tabularnewline}{\\}
\providecommand{\strong}[1]{\textbf{#1}}
\providecommand{\No}{\textnumero}
%%%%% Компактный список
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
%%%%% Маркеры для списка
\AtBeginDocument{
\def\labelitemi{\textendash}
\def\labelitemii{\(\bullet\)}
}