xelatex-template/setup/preamble.tex

264 lines
9.2 KiB
TeX
Raw Normal View History

2020-05-16 08:34:28 +00:00
%%%%% Проверка версии компилятора
2020-05-15 07:20:53 +00:00
\usepackage{ifxetex}
2020-05-16 08:34:28 +00:00
%%%%% Функции для работы с размерностями и счётчиками
2020-05-15 07:20:53 +00:00
\usepackage{calc}
2020-05-16 08:34:28 +00:00
%%%%% Параметры страницы
2020-05-15 07:20:53 +00:00
\usepackage{geometry}
2020-05-16 08:34:28 +00:00
%%%%% Межстрочный интервал
2020-05-15 07:20:53 +00:00
\usepackage{setspace}
2020-05-16 08:34:28 +00:00
%%%%% \onehalfspacing работает только для шрифтов 10pt, 11pt, 12pt
%%%%% Указываем явное значение
2020-05-15 07:20:53 +00:00
\setstretch{1.25}
2020-05-16 08:34:28 +00:00
%%%%% Отступ первой строки в параграфе
2020-05-15 07:20:53 +00:00
\setlength{\parindent}{12.5mm}
\usepackage{indentfirst}
2020-05-16 08:34:28 +00:00
%%%%% Правила для висячих строк
2020-05-15 07:20:53 +00:00
\usepackage[defaultlines=3,all]{nowidow}
2020-05-16 08:34:28 +00:00
%%%%% Защита от строк на полях (добавление 3 виртуальных пустых символов)
2020-05-15 07:20:53 +00:00
\setlength{\emergencystretch}{3em}
2020-05-16 08:34:28 +00:00
%%%%% Оптимизация расстановки переносов и длины последней строки абзаца
\IfFileExists{impnattypo.sty}{\usepackage[hyphenation, lastparline]{impnattypo}}{}
2020-05-15 07:20:53 +00:00
2020-05-16 08:34:28 +00:00
%%%%% Поддержка переносоустойчивых подчёркиваний и зачёркиваний
\usepackage{soulutf8}
2020-05-15 07:20:53 +00:00
2020-05-16 08:34:28 +00:00
%%%%% Запятая в десятичных дробях
\usepackage{icomma}
2020-05-15 07:20:53 +00:00
2020-05-16 08:34:28 +00:00
%%%%% Работа с цветом
2020-05-15 07:20:53 +00:00
\usepackage[dvipsnames,svgnames*,x11names*]{xcolor}
2020-05-16 08:34:28 +00:00
%%%%% Оформление блоков исходных текстов (обязательно перед локализацией)
2020-05-15 07:20:53 +00:00
\usepackage{fancyvrb}
\ifxetex
% Break long lines of code
\usepackage{fvextra}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}}
\fi
\VerbatimFootnotes % allows verbatim text in footnotes
2020-05-16 08:34:28 +00:00
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
2020-05-15 07:20:53 +00:00
\usepackage{listings}
2020-05-16 09:24:00 +00:00
\providecommand{\passthrough}[1]{#1}
2020-05-15 07:20:53 +00:00
\lstset{defaultdialect=[5.3]Lua}
\lstset{defaultdialect=[x86masm]Assembler}
2020-05-16 09:24:00 +00:00
%%%%% Словари и сокращения
2020-05-15 07:20:53 +00:00
\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
}
2020-05-16 08:34:28 +00:00
%%%%% Математика
\usepackage{amsthm,amsmath,amscd} % Математические дополнения от AMS
\usepackage{amsfonts,amssymb} % Математические дополнения от AMS
\usepackage{mathtools} % Добавляет окружение multlined
\usepackage{xfrac} % Красивые дроби
2020-05-16 09:24:00 +00:00
\usepackage{array} % Окружение с выравниванием
2020-05-16 08:34:28 +00:00
%%%%% Шрифты
2020-05-15 07:20:53 +00:00
\ifxetex
2020-05-16 09:24:00 +00:00
\usepackage[no-math]{fontspec}
2020-05-16 08:34:28 +00:00
\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math}
2020-05-15 07:20:53 +00:00
\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
2020-05-16 08:34:28 +00:00
%%%%% Размерности 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{где}
%%%%% Локализация
2020-05-15 07:20:53 +00:00
\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}
2020-05-16 08:34:28 +00:00
\IfFileExists{microtype.sty}{ % use microtype if available
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
2020-05-15 07:20:53 +00:00
\else
\usepackage{cmap}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\fi
2020-05-16 08:34:28 +00:00
%%%%% При переносе оставлять минимум 3 символа на первой строке и 3 на второй
2020-05-15 07:20:53 +00:00
\renewcommand\russianhyphenmins{33}
2020-05-16 08:34:28 +00:00
%%%%% Использовать для кавычек-ёлочек данные символы
\usepackage{csquotes}
2020-05-15 07:20:53 +00:00
\renewcommand{\flqq}{«}
\renewcommand{\frqq}{»}
2020-05-16 08:34:28 +00:00
%%%%% Оформление URL, разрешение переносов
2020-05-15 07:20:53 +00:00
\usepackage[hyphens]{xurl}
2020-05-16 08:34:28 +00:00
%%%%% Использование того же шрифта, что и в окружающем тексте
2020-05-15 07:20:53 +00:00
\urlstyle{same}
2020-05-16 08:34:28 +00:00
\usepackage[
2020-05-15 07:20:53 +00:00
unicode=true,
2020-05-16 08:34:28 +00:00
bookmarks=true,
2020-05-15 07:20:53 +00:00
bookmarksnumbered=false,
bookmarksopen=false,
2020-05-16 08:34:28 +00:00
colorlinks=true, % ссылки отображаются цветным текстом
linkcolor={Maroon}, % цвет ссылок типа ref, eqref и подобных
filecolor={Maroon}, %
citecolor={Blue}, % цвет ссылок-цитат
urlcolor={Blue}, % цвет гиперссылок
linktocpage=true, % ссылки с номера страницы в оглавлении, списке таблиц и списке рисунков
2020-05-15 07:20:53 +00:00
pdfborder={0 0 0},
pdfborderstyle={},
2020-05-16 08:34:28 +00:00
pdfpagelabels=false, % set PDF page labels (true|false)
pdflang={ru}
]{hyperref}
2020-05-16 09:24:00 +00:00
2020-05-16 08:34:28 +00:00
\makeatletter
\AtBeginDocument{
\hypersetup{
2020-05-15 07:20:53 +00:00
breaklinks=false,
2020-05-16 08:34:28 +00:00
% 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={}, % Ключевые слова
}
2020-05-15 07:20:53 +00:00
}
2020-05-16 08:34:28 +00:00
\makeatother
%%%%% Добавление модификатора H для размещения объектов
\usepackage{float}
%%%%% Команда \FloatBarrier
\usepackage{placeins}
%%%%% Настройка таблиц
2020-05-15 07:20:53 +00:00
\usepackage{xltabular}
2020-05-16 08:34:28 +00:00
\usepackage{ltcaption}
2020-05-15 07:20:53 +00:00
\usepackage{multirow}
2020-05-16 08:34:28 +00:00
\usepackage{makecell}
2020-05-15 07:20:53 +00:00
\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}
2020-05-16 08:34:28 +00:00
%%%%% Заголовок на последней странице таблицы (обязательно после hyperref)
2020-05-15 07:20:53 +00:00
\usepackage{fr-longtable}
2020-05-16 08:34:28 +00:00
%%%%% Автоматический подгон ширины подписи таблицы
\usepackage{threeparttable}
2020-05-15 07:20:53 +00:00
% 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
2020-05-16 08:34:28 +00:00
%%%%% Подключение изображений (желательно после локализации)
2020-05-15 07:20:53 +00:00
\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}
2020-05-16 08:34:28 +00:00
%%%%% Расположение по умолчанию
2020-05-15 07:20:53 +00:00
\makeatletter
2020-05-16 08:34:28 +00:00
\def\fps@figure{Htbp}
2020-05-15 07:20:53 +00:00
\makeatother
2020-05-16 08:34:28 +00:00
\providecommand{\tabularnewline}{\\}
\providecommand{\strong}[1]{\textbf{#1}}
\providecommand{\No}{\textnumero}
%%%%% Компактный список
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
2020-05-16 09:24:00 +00:00
%%%%% Маркеры для списка
2020-05-16 08:34:28 +00:00
\AtBeginDocument{
\def\labelitemi{\textendash}
\def\labelitemii{\(\bullet\)}
}