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