You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

latex4ei.sty 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. %
  2. % Macros for LaTeX4EI
  3. %
  4. % Authors: Emanuel Regnath, Martin Zellner
  5. % Contact: info@latex4ei.de
  6. % Version: 1.1
  7. % License: TBD
  8. %
  9. % © 2011-2019, LaTeX4EI
  10. \NeedsTeXFormat{LaTeX2e}
  11. \ProvidesPackage{latex4ei/latex4ei}[2013/05/06 Macros for LaTeX4EI]
  12. % Options
  13. % ----------------------------------------------------------------------
  14. \newif\ifcolor\colortrue
  15. \def\thelanguage{english}
  16. \DeclareOption{color}{\colortrue}
  17. \DeclareOption{nocolor}{\colorfalse}
  18. \DeclareOption{german}{\def\thelanguage{ngerman}}
  19. \DeclareOption{english}{\def\thelanguage{english}}
  20. \ProcessOptions\relax
  21. % ======================================================================
  22. % Basic Settings
  23. % ======================================================================
  24. % Identify Compiler
  25. % ----------------------------------------------------------------------
  26. \RequirePackage{ifxetex}
  27. % Check compiler. Hint: delete aux files if changing the compiler
  28. \ifxetex%
  29. %\@namedef{ver@fixltx2e.sty}{9999/12/31}%
  30. %XeLaTeX
  31. \PassOptionsToPackage{no-math}{fontspec}
  32. \usepackage{unicode-math}
  33. \providecommand{\ocirc}{o}
  34. \providecommand{\mathring}{o}
  35. %\RequirePackage{xltxtra}
  36. % for unicode decalarations
  37. %\let\DeclareUnicodeCharacter\newunicodechar
  38. \setmainfont{Times New Roman} % Libertinus Serif
  39. \setromanfont{Times New Roman} % Libertinus Serif
  40. \setsansfont{Helvetica}
  41. % some hacking for scientific.sty
  42. \AtBeginDocument{
  43. % scale fonts to same x height
  44. \defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text}
  45. \renewcommand{\C}{\mathbb C}
  46. \renewcommand{\B}{\mathbb B}
  47. }
  48. \else
  49. % pdfLaTeX
  50. \RequirePackage[utf8]{inputenc} % UTF-8 input
  51. \RequirePackage{latex4ei/latex4ei_unicode} % UTF-8 input of math symbols
  52. \InputIfFileExists{glyphtounicode}{\pdfgentounicode=1}{} % Glyph-to-Unicode Translation (needs PdfTex >=1.4)
  53. %\RequirePackage{textcomp} % get rid of font warnings
  54. %\pdfminorversion=6 % for 3D Objects
  55. %\RequirePackage[osf]{mathpazo} % old style numbering
  56. \fi
  57. % Basic LaTeX Settings
  58. % ----------------------------------------------------------------------
  59. \pretolerance=60
  60. \tolerance=2000
  61. \doublehyphendemerits=10000 % No consecutive line hyphens.
  62. \brokenpenalty=10000 % No broken words across columns/pages.
  63. \widowpenalty=9999 % Almost no widows at bottom of page.
  64. \clubpenalty=9999 % Almost no orphans at top of page.
  65. \interdisplaylinepenalty=100
  66. \interfootnotelinepenalty=9999 % Almost never break footnotes.
  67. % Save \title, \author, \date before \maketitle
  68. \RequirePackage[pagebackref=true,pdfpagelabels]{hyperref}
  69. % Title
  70. \makeatletter
  71. \renewcommand{\title}[1]{%
  72. \gdef\@title{#1}%
  73. \gdef\thetitle{#1}
  74. \pdfstringdef{\@pdftitle}{\@title}%
  75. \hypersetup{pdftitle=\@pdftitle}%
  76. }
  77. % Institution
  78. \providecommand{\institution}[1]{
  79. \gdef\theinstitution{#1}
  80. }
  81. % Author
  82. \renewcommand{\author}[1]{%
  83. \gdef\@author{#1}%
  84. \gdef\theauthor{#1}
  85. \pdfstringdef{\@pdfauthor}{\@author}%
  86. \hypersetup{pdfauthor=\@pdfauthor}%
  87. }
  88. % Date
  89. \global\let\thedate\@date
  90. \renewcommand{\date}[1]{%
  91. \gdef\@date{#1}%
  92. \gdef\thedate{#1}
  93. }
  94. \makeatother
  95. % Email
  96. \providecommand{\myemail}[1]{\gdef\theemail{#1}}
  97. % Web page
  98. \providecommand{\mywebsite}[1]{\gdef\thewebsite{#1}}
  99. % Date with git commit number
  100. \providecommand{\mydate}[1]{\gdef\themydate{#1}}
  101. % set defaults
  102. \author{LaTeX4EI}
  103. \title{A LaTeX4EI Document}
  104. \myemail{info@latex4ei.de}
  105. \mywebsite{www.latex4ei.de}
  106. \mydate{\today}
  107. \AtBeginDocument{
  108. % set pdfoptions
  109. \hypersetup{
  110. pdftitle={\thetitle},
  111. pdfauthor={\theauthor},
  112. pdfcreator={LaTeX4EI template (www.latex4ei.de)},
  113. pdfkeywords={latex4ei}
  114. }
  115. }
  116. % Language
  117. % ----------------------------------------------------------------------
  118. \RequirePackage[english, ngerman]{babel}
  119. \RequirePackage{iflang}
  120. \providecommand{\EngGer}[2]{\IfLanguageName{english}{#1}{#2}}
  121. \expandafter\selectlanguage\expandafter{\thelanguage}
  122. \AtBeginDocument{\expandafter\selectlanguage\expandafter{\thelanguage}}
  123. % Graphics
  124. % ----------------------------------------------------------------------
  125. \RequirePackage{graphicx} % for including images
  126. \graphicspath{ {img/} {gfx/} } % set default search paths for figures
  127. %\RequirePackage{tikz} % tikz graphics
  128. %\RequirePackage{multirow} % multirow text
  129. % ======================================================================
  130. % Colors
  131. % ======================================================================
  132. \RequirePackage{latex4ei/latex4ei_colors}
  133. \ifcolor
  134. \colorlet{col_chapter_num}{tum_gray}
  135. \colorlet{col_chapter}{tum_blue_dark}
  136. \colorlet{col_section}{tum_blue_dark}
  137. \colorlet{col_subsection}{tum_blue_dark}
  138. \colorlet{col_subsubsection}{black}
  139. \colorlet{col_paragraph}{black}
  140. \colorlet{col_link}{tum_blue_dark}
  141. \colorlet{col_table}{tum_blue_dark}
  142. \colorlet{col_figure}{tum_blue_dark}
  143. \colorlet{col_itemize}{tum_blue_dark}
  144. \colorlet{col_lst}{tum_blue_dark}
  145. \colorlet{col_lst_keyword}{tum_blue}
  146. \colorlet{col_lst_comment}{tum_green_leaf}
  147. \colorlet{col_lst_string}{tum_orange}
  148. \colorlet{col_lst_number}{tum_gray_dark}
  149. \else
  150. \colorlet{col_chapter_num}{tum_gray}
  151. \colorlet{col_chapter}{black}
  152. \colorlet{col_section}{black}
  153. \colorlet{col_subsection}{black}
  154. \colorlet{col_subsubsection}{black}
  155. \colorlet{col_paragraph}{black}
  156. \colorlet{col_ref}{black}
  157. \colorlet{col_link}{black}
  158. \colorlet{col_table}{black}
  159. \colorlet{col_figure}{black}
  160. \colorlet{col_itemize}{black}
  161. \colorlet{col_lst}{black}
  162. \colorlet{col_lst_keyword}{black}
  163. \colorlet{col_lst_comment}{tum_gray}
  164. \colorlet{col_lst_string}{black}
  165. \colorlet{col_lst_number}{tum_gray_dark}
  166. \fi
  167. \hypersetup{
  168. colorlinks=true,
  169. linkcolor=col_link,
  170. urlcolor=col_link,
  171. citecolor=col_link,
  172. }
  173. % ======================================================================
  174. % Macros
  175. % ======================================================================
  176. % Formatting adjustments
  177. % ----------------------------------------------------------------------
  178. \RequirePackage{accents} % accent dots for derivation
  179. % Thicker dots for derivatives
  180. \renewcommand*{\dot}[1]{\accentset{\mbox{\textrm{\large\bfseries .}} }{#1}}
  181. \renewcommand*{\ddot}[1]{\accentset{\mbox{\textrm{\large\bfseries .\hspace{-0.25ex}.}}}{#1}}
  182. \renewcommand*{\dddot}[1]{\accentset{\mbox{$\overset{\textrm{\large\bfseries .}}{\textrm{\large\bfseries.\hspace{-0.25ex}.}}$}}{#1}}
  183. % Shortcuts for symbols
  184. % ----------------------------------------------------------------------
  185. \providecommand{\ul}[1]{\ensuremath{\underline{#1}}} % Underline
  186. \providecommand{\ol}[1]{\ensuremath{\overline{#1}}} % Overline
  187. \providecommand{\bs}[1]{\ensuremath{\boldsymbol{#1}}} % Bold and italic in mathmode
  188. \providecommand{\Ra}{\ensuremath{\Rightarrow}} % Rightarrow
  189. \providecommand{\ra}{\ensuremath{\rightarrow}} % Rightarrow
  190. \providecommand{\lra}{\ensuremath{\longrightarrow}} % Longrightarrow
  191. \providecommand{\upa}{\ensuremath{\uparrow}}
  192. \providecommand{\downa}{\ensuremath{\downarrow}}
  193. \providecommand{\bdot}{\ensuremath{\boldsymbol \cdot}} % Thick dot for vector product
  194. \providecommand{\svdots}{\ensuremath{\olddot :}} % Small vertical dots
  195. \providecommand{\shdots}{\ensuremath{\!\cdot \!\cdot\!\cdot\!}} % Small horizontal dots
  196. % Terms and definitions
  197. % ----------------------------------------------------------------------
  198. % Define BibTeX command
  199. \def\BibTeX{{\rmfamily B\kern-.05em{\sc i\kern-.025em b}\kern-.08em T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
  200. % ToDo Command
  201. \makeatletter
  202. \providecommand{\todo}[1]{%
  203. \textcolor{red}{\bfseries ToDo:\@ifundefined{@captype}{\marginpar{\color{red}\bfseries ToDo!}}{\relax} #1} %check for float environments
  204. }
  205. \makeatother
  206. % Special term
  207. \providecommand{\term}[1]{\textit{#1}}
  208. % small note
  209. \providecommand{\note}[1]{\textit{Note: #1}}
  210. % Related work
  211. \providecommand{\work}[1]{\textit{#1}}
  212. % Email
  213. \providecommand{\email}[1]{\href{mailto:#1}{\nolinkurl{#1}}}
  214. % References and Links
  215. % ----------------------------------------------------------------------
  216. \providecommand{\sectionname}{Section}
  217. % several ref macros
  218. \providecommand\figureref[1]{\hyperref[#1]{\figurename~\ref*{#1}}}
  219. \providecommand\figurepageref[1]{\figureref{#1}~(p.~\pageref{#1})}
  220. \providecommand\tableref[1]{\hyperref[#1]{\tablename~\ref*{#1}}}
  221. \providecommand\tablepageref[1]{\tableref{#1}~(p.~\pageref{#1})}
  222. \providecommand\listingref[1]{\hyperref[#1]{\lstlistingname~\ref*{#1}}}
  223. \providecommand\listingpageref[1]{\listingref{#1}~(p.~\pageref{#1})}
  224. \providecommand\chapterref[1]{\chaptername~\ref*{#1}~(p.~\pageref{#1})}
  225. \providecommand\sectionref[1]{\hyperref[#1]{\sectionname~\ref*{#1}~(p.~\pageref{#1})}}
  226. \providecommand\appendixref[1]{\appendixname~\ref*{#1}~(p.~\pageref{#1})}
  227. % break also on hyphens inside the \url command
  228. \def\UrlBreaks{\do\.\do\@\do\\\do\/\do\!\do\_\do\|\do\;\do\>\do\]%
  229. \do\)\do\,\do\?\do\'\do+\do\=\do\#\do-} % \do- is new!
  230. % ======================================================================
  231. % Environments
  232. % ======================================================================
  233. \RequirePackage{caption}
  234. % Tables
  235. % ----------------------------------------------------------------------
  236. \captionsetup[table]{labelfont={color=col_table,sf},textfont={sf,small}}
  237. % table rules
  238. \def\trule{\noalign{\vspace{1pt}\hrule\hrule\vspace{2pt}}} % top rule
  239. \def\mrule{\noalign{\vspace{1pt}\hrule\vspace{2pt}}} % middle rule
  240. \def\brule{\noalign{\vspace{2pt}\hrule\hrule\vspace{1pt}}} % bottom rule
  241. % colored table rules
  242. %\def\ctrule{\noalign{{\color{col_table}\hrule\hrule}\vspace{2pt}}} % colored top rule
  243. %\def\cmrule{\noalign{\vspace{1pt}{\color{col_table}\hrule}\vspace{2pt}}} % colored middle rule
  244. %\def\cbrule{\noalign{\vspace{2pt}{\color{col_table}\hrule\hrule}}} % colored bottom rule
  245. % TDB
  246. \def\ctrule{\noalign{\vspace{1pt}\begingroup\color{col_table}\hrule\hrule\endgroup\vspace{2pt}}} % colored top rule
  247. \def\cmrule{\noalign{\vspace{1pt}\begingroup\color{col_table}\hrule\endgroup\vspace{2pt}}} % colored middle rule
  248. \def\cbrule{\noalign{\vspace{2pt}\begingroup\color{col_table}\hrule\hrule\endgroup\vspace{1pt}}} % colored bottom rule
  249. % Figures
  250. % ----------------------------------------------------------------------
  251. \captionsetup[figure]{labelfont={color=col_figure,sf},textfont={sf,small}}
  252. % Sourcecode listings
  253. % ----------------------------------------------------------------------
  254. \RequirePackage{listings}
  255. \lstset{
  256. basicstyle=\normalsize\ttfamily\lst@ifdisplaystyle\small\fi,
  257. tabsize=4,
  258. %gobble=auto, % skip initial tabs %not supported yet
  259. numbers=none, % switch numbers on: left
  260. numberstyle=\tiny\sffamily\color{col_lst_number},
  261. numbersep=1em,
  262. keepspaces=true,
  263. keywordstyle=\color{tum_blue_dark},
  264. commentstyle=\color{col_lst_comment},
  265. stringstyle=\color{col_lst_string},
  266. captionpos = t,
  267. frame = tb,
  268. %framextopmargin={\smallskipamount},
  269. %framexbottommargin={\smallskipamount},
  270. framerule=1pt,
  271. rulecolor = \color{col_lst},
  272. }
  273. \captionsetup[lstlisting]{labelfont={color=col_figure,sf},textfont={sf,small}}
  274. % Inline code listings
  275. \let\code\lstinline