GEX thesis source code, full text, references

ctuth-pkg.tex 31KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. %!TEX ROOT = ctutest.tex
  2. \ProvidesExplFile{ctuth-pkg.tex}%
  3. {2016/04/04}{0.1 t1604041107}%MY TIMESTAMP HERE {0.1}
  4. {"Packages"\space part\space of\space the\space class\space ctuthesis}
  5. % A lot of the code here is not latex3, but rather the good'ol latex2e code. The reason is that
  6. % it heavily depends on l2e packages, and we decided not to mix the code together too much.
  7. \RequirePackage{lmodern}
  8. %\RequirePackage{cfr-lm}
  9. \RequirePackage[T1]{fontenc}
  10. \RequirePackage{microtype}
  11. \RequirePackage{graphicx}
  12. \RequirePackage{pdfpages}
  13. %%% BABEL -- LANGUAGE HANDLING
  14. % The loading of the languages is a bit wicked, but it works this way. We load the main language once more
  15. % to make it the default one.
  16. \RequirePackage[\seq_use:Nn \g_ctuthesis_languages_seq {,},\g_ctuthesis_field_mainlanguage_tl]{babel}
  17. % Used for setting title, main or second language
  18. \NewDocumentCommand \selectctulanguage { m } {
  19. \exp_args:Nx \selectlanguage { \ctuthesis_field_use:n { #1 language } }
  20. }
  21. %%% COLORS, TEXT FLOW
  22. \RequirePackage{xcolor}
  23. % Define the colors, first in monochrome, then in colour.
  24. \ctuifswitch { savetoner } {
  25. % savetoner: true
  26. \definecolor { ctublue } { CMYK } { 100, 43, 0, 0 }
  27. \definecolor { ctulightblue } { RGB }{ 172, 214, 238 }
  28. \colorlet { ctubluetext } { ctublue }
  29. \colorlet { ctubluerule } { ctulightblue }
  30. \colorlet { ctubluedarkbg } { white }
  31. \colorlet { ctubluedarkfg } { ctublue!50!black }
  32. \colorlet { ctubluedot } { white }%ctulightblue }
  33. \colorlet { ctubluebg } { white }
  34. \colorlet { ctulstbg } { ctubluebg }
  35. \colorlet { ctublueitemi } { ctublue }
  36. \colorlet { ctublueitemii } { ctulightblue }
  37. \colorlet { ctugray } { gray }
  38. \definecolor { ctuorange } { Hsb } { 22, 0.5, 1 }
  39. } {
  40. \ctuifswitch { monochrome } {
  41. % savetoner: false, monochrome: true
  42. \definecolor { ctublue } { gray } { 0.8 }
  43. \definecolor { ctulightblue } { gray } { 0.9 }
  44. \definecolor { ctubluetext } { gray } { 0.4 }
  45. \definecolor { ctubluerule } { gray } { 0.4 }
  46. \definecolor { ctubluedarkbg } { gray } { 0.2 }
  47. \definecolor { ctubluedarkfg } { gray } { 1 }
  48. \definecolor { ctubluedot } { gray } { 0.9 }
  49. \definecolor { ctubluebg } { gray } { 0.95 }
  50. \definecolor { ctulstbg } { gray } { 0.95 }
  51. \definecolor { ctublueitemi } { gray } { 0.4 }
  52. \definecolor { ctublueitemii } { gray } { 0.4 }
  53. \definecolor { ctugray } { gray } { 0.5 }
  54. \definecolor { ctuorange } { gray } { 0.9 }
  55. } {
  56. % savetoner: false, monochrome: false
  57. \definecolor { ctublue } { cmyk } { 1, .43, 0, 0 }
  58. \definecolor { ctulightblue } { cmyk }{ .3, .13, 0, 0 }
  59. \colorlet { ctubluetext } { ctublue }
  60. \colorlet { ctubluerule } { ctublue }
  61. \colorlet { ctubluedarkbg } { ctublue }
  62. \colorlet { ctubluedot } { ctulightblue }
  63. \colorlet { ctubluebg } { ctulightblue!50!white }
  64. \colorlet { ctulstbg } { ctulightblue!50!white }
  65. \colorlet { ctublueitemi } { ctublue }
  66. \colorlet { ctublueitemii } { ctulightblue }
  67. \colorlet { ctugray } { gray }
  68. \definecolor { ctuorange } { cmyk } { 0, .51, 1, 0 }
  69. }
  70. }
  71. \setlength{\parskip}{0pt plus 1pt}
  72. \setlength{\parindent}{11.2pt}
  73. %%% FRONT MATTER --- TWOCOLUMN HANDLING
  74. % This is a "ToC macro" for the twocolumn context
  75. % Arguments: 1) suffix, 2) ToC name
  76. \cs_new:Nn \ctuthesis_maketoc_twocol:nn {
  77. % Start the chapter
  78. \chapter* { #2 }
  79. % locally make rugged pages
  80. \begingroup
  81. \raggedbottom
  82. % We use this trick to add nothing, but also to make sure that
  83. % any \addvspace for less than 20pt is going to be ignored.
  84. \vspace*{-20pt}\addvspace{20pt}
  85. % call the original \@starttoc
  86. \@starttoc { #1 }
  87. \newpage
  88. \endgroup
  89. }
  90. % Environment for the twocolumn frontmatter. It can appear more times in a row
  91. % and should handle it nicely
  92. \NewDocumentEnvironment{ twocolumnfrontmatterpage } { } {
  93. % Set the page geometry to the title one (it's a bit wider)
  94. \ctuthesis_geometry_title:
  95. \newpage
  96. \pagestyle{twocol}
  97. \onecolumn\relax %ADDED (??)
  98. % Start the twocolumn.
  99. % \twocolumn[]\relax
  100. % We are narrow, so we wanna be sloppy
  101. % \sloppy % CHANGED REMOVED
  102. % Chapter behaves differently. Both the [] argument and the star * are ignored.
  103. % \DeclareDocumentCommand\chapter{ s o m }{\relax
  104. % % Vertical adjustment
  105. % \vspace* { -\baselineskip }
  106. % \nointerlineskip
  107. % % Zero measure vertical box, the contents are raised by something and typeset
  108. % \vbox to 0pt{\noindent\leavevmode\smash{\raise6pt\hbox to \linewidth{%
  109. % % In the first column its right-aligned, in the second left-aligned.
  110. % % It can't be more than one line.
  111. % \if@firstcolumn\hfil\fi
  112. % \color{ctubluetext}\LARGE\bfseries\sffamily##3
  113. % \if@firstcolumn\else\hfil\fi
  114. % }}}
  115. % \everypar{\noindent}
  116. % }
  117. \DeclareDocumentCommand\chapter{ s~o~m }{\relax
  118. % Compute the vertical adjustment
  119. \skip_gset:Nn \g_ctuthesis_tempa_skip { - \box_ht:N \strutbox }
  120. { \LARGE \skip_gsub:Nn \g_ctuthesis_tempa_skip { \box_ht:N \strutbox + \box_dp:N \strutbox } }
  121. % Space used if not at the beginning of a column
  122. \skip_vertical:n { 12pt - \g_ctuthesis_tempa_skip }
  123. % Add the space below the chapter title to the adjustment
  124. \skip_gsub:Nn \g_ctuthesis_tempa_skip { 2pt }
  125. % Vertical adjustment
  126. \vspace* { \g_ctuthesis_tempa_skip }
  127. % Zero measure vertical box, the contents are raised by something and typeset
  128. \noindent \leavevmode
  129. \hbox_to_wd:nn \linewidth {
  130. % In the first column its right-aligned, in the second left-aligned.
  131. % It can't be more than one line.
  132. %\if@firstcolumn\hfil\fi
  133. \leavevmode\color{ctubluetext}\LARGE\strut\bfseries\sffamily##3
  134. %\if@firstcolumn\else\hfil\fi
  135. }\par
  136. \skip_vertical:n { 2pt }
  137. \everypar{\noindent}
  138. }
  139. \DeclareDocumentCommand \tableofcontents { }{ \ctuthesis_maketoc_twocol:nn { toc } { \contentsname } }
  140. \DeclareDocumentCommand \listoffigures { }{ \ctuthesis_maketoc_twocol:nn { lof } { \listfigurename } }
  141. \DeclareDocumentCommand \listoftables { }{ \ctuthesis_maketoc_twocol:nn { lot } { \listtablename } }
  142. } {
  143. \ctuthesis_geometry_plain:
  144. \clearpage
  145. \onecolumn
  146. \pagestyle{plain}
  147. }
  148. %%% LANGUAGES
  149. % For every of the languages below, if it's initialized, add the
  150. % custom captions of the class
  151. \@ifundefined{captionsenglish}{}{\g@addto@macro\captionsenglish{\ctucaptionsenglish}}
  152. \@ifundefined{captionsczech}{}{\g@addto@macro\captionsczech{\ctucaptionsczech}}
  153. \@ifundefined{captionsslovak}{}{\g@addto@macro\captionsslovak{\ctucaptionsslovak}}
  154. %%% GEOMETRY
  155. % The ratios of inner:outer margins
  156. % Needs to be separate as this to make the colon ":" have the right catcode
  157. \cs_new:Nx \ctuthesis_geometry_hmarginratio: {2\string :3} %4\string :6
  158. % Target textwidth is 33*basesize (10pt to 12pt)
  159. \dim_const:Nn \g_ctuthesis_geometry_textwidth_dim { \tl_use:N \g_ctuthesis_fontsize_tl * 39 } %33
  160. % Text occupies 75% of the height of the page by default, less if layout-short is active
  161. % The vmargin ratio is set here in the same manner as the hmargin one above
  162. \ctuifswitch { layout-short } {
  163. \dim_const:Nn \g_ctuthesis_geometry_textheight_dim { 1.5\g_ctuthesis_geometry_textwidth_dim }
  164. \cs_new:Nx \ctuthesis_geometry_vmarginratio: {4\string :3}
  165. } {
  166. \dim_const:Nn \g_ctuthesis_geometry_textheight_dim { 0.75\paperheight }
  167. \cs_new:Nx \ctuthesis_geometry_vmarginratio: {5\string :6}
  168. }
  169. % Loading the geometry package.
  170. % Almost the same setting appears again in \ctuthesis_geometry_plain:
  171. \RequirePackage [ a4paper ,
  172. hmarginratio = \ctuthesis_geometry_hmarginratio: ,
  173. textwidth = \g_ctuthesis_geometry_textwidth_dim ,
  174. textheight = \g_ctuthesis_geometry_textheight_dim ,
  175. vmarginratio = \ctuthesis_geometry_vmarginratio: , ignoreheadfoot ,
  176. % Should be at least \baselineskip
  177. headheight = 16pt ,
  178. marginparsep = 10pt ,
  179. ] { geometry }
  180. % Inner margin is 1in + \oddsidemargin. We wanna preserve this value through all
  181. % the different page geometries
  182. \dim_const:Nn \g_ctuthesis_geometry_innermargin_dim { 1in + \the\oddsidemargin }
  183. % The frontmatter pages are a bit wider
  184. \cs_new:Nn \ctuthesis_geometry_title: {
  185. \newgeometry {
  186. % Use the stored innermargin value
  187. inner = \g_ctuthesis_geometry_innermargin_dim ,
  188. % Increase the width by 20%, but do not exceed 420pt
  189. textwidth = \dim_min:nn { 420pt } { 1.2 \g_ctuthesis_geometry_textwidth_dim } ,
  190. textheight = \g_ctuthesis_geometry_textheight_dim ,
  191. vmarginratio = \ctuthesis_geometry_vmarginratio: ,
  192. headheight = 16pt ,
  193. ignoreheadfoot ,
  194. columnsep=30pt ,
  195. }
  196. }
  197. \cs_new:Nn \ctuthesis_geometry_plain: {
  198. \newgeometry {
  199. % Use the stored innermargin value
  200. inner = \dim_use:N \g_ctuthesis_geometry_innermargin_dim ,
  201. % Otherwise it's the same as in \RequirePackage[...]{geometry}
  202. textwidth = \dim_use:N \g_ctuthesis_geometry_textwidth_dim ,
  203. textheight = \g_ctuthesis_geometry_textheight_dim ,
  204. vmarginratio = \ctuthesis_geometry_vmarginratio: , ignoreheadfoot ,
  205. headheight = 16pt ,
  206. marginparsep = 10pt ,
  207. }
  208. % Compute the marginparwidth so that we leave 40pt from the page boundary
  209. \marginparwidth \dimexpr \evensidemargin + 1in - \marginparsep - 40pt
  210. }
  211. % Re-initialize the geometry
  212. \ctuthesis_geometry_plain:
  213. %%% TITLES
  214. \usepackage{titlesec}
  215. % two basic parameters: the rule width and distance
  216. \newlength \ctu@title@rulewidth
  217. \newlength \ctu@title@rulesep
  218. \setlength \ctu@title@rulewidth {11pt}
  219. \setlength \ctu@title@rulesep {11pt}
  220. % box used all the time
  221. \newbox\ctu@title@box
  222. % macro that boxifies the header and adds the rule
  223. \long\def\ctu@title@boxify#1#2#3#4{
  224. \sffamily
  225. \bfseries
  226. \setbox\ctu@title@box\vbox{\hsize\dimexpr\linewidth-\ctu@title@rulewidth-\ctu@title@rulesep\relax
  227. \vskip#1
  228. \raggedright
  229. #3
  230. \vskip#2
  231. }
  232. #4
  233. \noindent\begin{tabular}{@{}l@{\hspace*{\ctu@title@rulesep}}l@{}}
  234. \color{ctubluerule}\rule[-\dp\ctu@title@box]{\ctu@title@rulewidth}{\dimexpr\ht\ctu@title@box+\dp\ctu@title@box}
  235. &
  236. \box\ctu@title@box
  237. \end{tabular}\hspace*{-10pt}
  238. \par
  239. }
  240. \long\def\ctu@title@boxify@x#1#2#3#4#5{
  241. \sffamily
  242. \bfseries
  243. \setbox\ctu@title@box\vbox{\parskip0pt\hsize\dimexpr\linewidth-\ctu@title@rulewidth-\ctu@title@rulesep\relax
  244. \vskip#1
  245. \raggedright
  246. #4
  247. \vskip#2
  248. }
  249. #5
  250. \noindent\begin{tabular}{@{}l@{\hspace*{\ctu@title@rulesep}}l@{}}
  251. \color{ctubluerule}
  252. \rule
  253. [\dimexpr\ht\ctu@title@box-#3-#1]
  254. {\ctu@title@rulewidth}
  255. {\dimexpr#1+#3}
  256. &
  257. \box\ctu@title@box
  258. \end{tabular}\hspace*{-10pt}
  259. \par
  260. }
  261. % the part style, very simply organized
  262. \def\ttlh@ctupt#1#2#3#4#5#6#7#8{
  263. \bool_gset_true:N \g_ctuthesis_title_haspart_bool
  264. \ctu@title@boxify{#5}{#3}{
  265. {#1\strut\ifttl@label#2\fi\par}
  266. \vskip30pt
  267. {\color{ctubluetext}#4\strut#8\strut\par}
  268. }{\dp\ctu@title@box\dimexpr\textheight-\ht\ctu@title@box-\baselineskip\relax
  269. }
  270. }
  271. \def\ttlh@ctuch#1#2#3#4#5#6#7#8{
  272. \vspace{-\parskip}
  273. % If the chapter is starred, we still want to \chaptermark it, just we use the variant \chapterstarmark.
  274. \ifttl@label\else\chapterstarmark{#8}\fi
  275. % If the chapter is starred, we still want it in the ToC.
  276. \ifttl@label\else\addcontentsline{toc}{chapter}{#8}\fi
  277. \ctu@title@boxify{#5}{#3}{
  278. {#1\strut\ifttl@label#2\fi\par}
  279. \medskip
  280. {\color{ctubluetext}#4\strut#8\strut\par}
  281. }{}
  282. }
  283. % The section style, very simply organized, subsection style differs only by a missing check for star variant and mark inclusion
  284. % Comments to the chapter style apply here too.
  285. \def\ttlh@ctus#1#2#3#4#5#6#7#8{
  286. \vspace{-.2em}
  287. \ifttl@label\else\sectionstarmark{#8}\fi
  288. \ifttl@label\else\addcontentsline{toc}{section}{#8}\fi
  289. \ctu@title@boxify@x{#5}{0pt}{#3}{ \vspace{-1pt} #1{\ifttl@label#2\fi\strut\color{ctubluetext}#8\strut} }{}
  290. \par\nobreak
  291. \vspace{-.5em}
  292. }
  293. \def\ttlh@ctuss#1#2#3#4#5#6#7#8{
  294. \vspace{-.2em}
  295. \ifttl@label\else\addcontentsline{toc}{subsection}{#8}\fi
  296. \ctu@title@boxify@x{#5}{0pt}{#3}{ #1{\ifttl@label#2\fi\strut\color{ctubluetext}#8\strut} }{}
  297. \par\nobreak
  298. \vspace{-.5em}
  299. }
  300. \def\ttlh@ctusss#1#2#3#4#5#6#7#8{
  301. \vspace{-.2em}
  302. \ifttl@label\else\addcontentsline{toc}{subsubsection}{#8}\fi
  303. \ctu@title@boxify@x{#5}{0pt}{#3}{ \vspace{-1pt} #1{\ifttl@label#2\fi\strut\color{ctubluetext}#8\strut} }{}
  304. \par\nobreak
  305. \vspace{-.5em}
  306. }
  307. % Modified \ttl@page@ii to use \cleardoublepage instead of some idiocy
  308. \def\ttl@page@ii#1#2#3#4#5#6#7{%
  309. \ttl@assign\@tempskipa#3\relax\beforetitleunit
  310. \if@openright
  311. \cleardoublepage
  312. \else
  313. \clearpage
  314. \fi
  315. \@ifundefined{ttl@ps@#6}%
  316. {\thispagestyle{plain}}%
  317. {\thispagestyle{\@nameuse{ttl@ps@#6}}}%
  318. \if@twocolumn
  319. \onecolumn
  320. \@tempswatrue
  321. \else
  322. \@tempswafalse
  323. \fi
  324. \vspace*{\@tempskipa}%
  325. \@afterindenttrue
  326. \ifcase#5 \@afterindentfalse\fi
  327. \ttl@assign\@tempskipb#4\relax\aftertitleunit
  328. \ttl@select{#6}{#1}{#2}{#7}%
  329. \ttl@finmarks
  330. \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}%
  331. \vspace{\@tempskipb}%
  332. \cleardoublepage
  333. \if@tempswa
  334. \twocolumn
  335. \fi
  336. \ignorespaces}
  337. % Part title setting
  338. \bool_new:N \g_ctuthesis_title_haspart_bool
  339. \titleformat \part [ctupt] {\Huge} {{\huge\partname\nobreakspace}\thepart} {0pt} {\huge} [0.6\textheight]
  340. \titlespacing* \part {0pt} {0pt} {0pt}
  341. % Tweak into titlesec to make part number contain \numberline. They did not include it for some reason.
  342. \def\ttl@tocpart{\def\ttl@a{\protect\numberline{\thepart}}}
  343. % Chapter title setting
  344. \titleformat \chapter [ctuch] {\huge} {{\LARGE\chaptertitlename\ }\thechapter} {-0\dp\strutbox} {\LARGE} [40pt]
  345. \titlespacing* \chapter {0pt} {0pt} {15pt} % CHANGED was {0pt} {40pt} {15pt}
  346. % Section title setting
  347. \titleformat \section [ctus] {\Large} {\thesection\quad} {14pt} {} [2pt]
  348. \titleformat \subsection [ctuss] {\large} {\thesubsection\quad} {11pt} {} [0pt]
  349. \titleformat \subsubsection [ctusss] {\normalsize} {\thesubsubsection\quad} {10pt} {} [0pt]
  350. % Paragraph title setting: runin, with a dot.
  351. \cs_new:Nn \ctuthesis_title_adddot:n {#1\@addpunct.\ignorespaces}
  352. \titleformat \paragraph [runin] {\normalfont\normalsize\bfseries\sffamily} {\theparagraph} {1em} {\ctuthesis_title_adddot:n}
  353. \titleformat \subparagraph [runin] {\normalfont\normalsize\itshape} {\thesubparagraph} {1em} {\ctuthesis_title_adddot:n}
  354. \titlespacing* \paragraph {0pt} {2.25ex plus 1ex minus .2ex} {1em plus 0.3em minus 0.2em}
  355. \titlespacing* \subparagraph {\parindent} {1.75ex plus 0.5ex minus .2ex} {0.7em plus 0.3em minus 0.15em}
  356. % Subsections are the lowest numbered titles, and also the lowest included in ToC.
  357. \setcounter{secnumdepth}{2}
  358. \setcounter{tocdepth}{2}
  359. % Appendix treatment: Even if a chapter in appendix has a star, it will get a number (letter in this case), since
  360. % once you get any appendix, it doesn't make sense not to number some of them.
  361. % Users can use \chapter** if-need-be to get an unnumbered chapter in appendix, but we think it's ridiculous.
  362. \cs_set_eq:NN \ctuthesis_title_orig_appendix: \appendix
  363. \cs_set_eq:NN \ctuthesis_title_orig_chapter: \chapter
  364. \cs_set_eq:NN \ctuthesis_title_orig_makeschapterhead: \@makeschapterhead
  365. % an \if that is true only after \appendix
  366. \newif\ifctu@app \ctu@appfalse
  367. % The new \appendix
  368. \DeclareDocumentCommand \appendix { s~s~} {
  369. \ctu@apptrue
  370. % Call the old \appendix
  371. \ctuthesis_title_orig_appendix:
  372. % If the document has \part division, let's make "Appendices" a part on their own
  373. \bool_if:NT \g_ctuthesis_title_haspart_bool {
  374. % But only make the notice in ToC if * is used
  375. \IfBooleanTF { #2 } {
  376. % Two stars: If nothing in ToC, at least put there a space.
  377. \addtocontents{toc}{\vskip 2ex plus 0.2pt}
  378. } {
  379. \IfBooleanTF { #1 } {
  380. % One star: Only add "Appendices" in ToC
  381. \cleardoublepage
  382. \addcontentsline { toc } { part } { \appendicesname }
  383. } {
  384. % Zero stars: Make "Appendices" page (will be in ToC implicitly
  385. \part*{ \appendicesname }
  386. }
  387. }
  388. }
  389. % \chapter ignores one star, so that things like {thebibliography} are numbered
  390. \DeclareDocumentCommand \chapter { s~} { \ctuthesis_title_orig_chapter: }
  391. % another \appendix will generate a warning and be silently ignored
  392. \DeclareDocumentCommand \appendix { s~s~} {
  393. \msg_warning:nn { ctuthesis } { appendix-twice }
  394. }
  395. }
  396. \msg_new:nnn { ctuthesis } { appendix-twice } { The~macro~ \token_to_str:N \appendix\ should~
  397. be~used~only~once.~Silently~ignoring. }
  398. %%% TABLE OF CONTENTS, LISTS OF FIGURES AND TABLES
  399. % Right margin in TOC, note that it need not be wider than the page numbers, so we're fine with 1em.
  400. \def\@tocrmarg{1em}
  401. % New dottedtocline, differs from the default by having numberline variable-width and accomodating to the number
  402. \def\ctu@dottedtocline#1#2#3#4#5{\ifnum #1>\c@tocdepth \else
  403. \addvspace{0pt plus .2pt}
  404. {
  405. \leftskip #2\relax
  406. \rightskip\dimexpr\@tocrmarg plus 1fil
  407. \parfillskip -\rightskip
  408. \parindent #3\relax
  409. \@afterindenttrue
  410. \interlinepenalty\@M
  411. \leavevmode
  412. \null
  413. \nobreak
  414. \hskip -\leftskip
  415. \def\numberline##1{##1\ }
  416. {#4}
  417. \nobreak
  418. \leaders \hbox {$\m@th \mkern 2mu\hbox {.}\mkern 2mu$}\hfill
  419. \nobreak
  420. {\kern0.5em#5}
  421. \par
  422. }
  423. \fi}
  424. % Part in ToC: centered, with no pagenumber, bf sf, and with nice space above.
  425. \def\l@part#1#2{
  426. \addvspace{2ex plus .2pt}
  427. {
  428. \centering
  429. \@afterindenttrue
  430. \interlinepenalty\@M
  431. \leavevmode
  432. \null
  433. \nobreak
  434. \def\numberline##1{\partname \nobreakspace ##1\\}%
  435. \sffamily \bfseries
  436. #1
  437. \par
  438. }\penalty10000\relax
  439. }
  440. % Chapter in ToC: bf sf, no leaders, completely left-aligned, the numberline is variable-width,
  441. % nice space above the chapter line
  442. \def\l@chapter#1#2{
  443. \addvspace{1ex plus .2pt}
  444. {
  445. \raggedright
  446. \rightskip\dimexpr\@tocrmarg plus 1fil
  447. \parfillskip -\rightskip
  448. \@afterindenttrue
  449. \interlinepenalty\@M
  450. \leavevmode
  451. \null
  452. \nobreak
  453. \def\numberline##1{##1\hspace*{0.5em}}
  454. \sffamily \bfseries
  455. #1
  456. \nobreak
  457. \hfill
  458. \nobreak
  459. {\kern0.5em#2}
  460. \par
  461. }\penalty9999\relax
  462. }
  463. % The section and lower in Toc. We hope nobody would put `\paragraph`s in ToC
  464. \def\l@section{\ctu@dottedtocline{1}{0.6em}{0em}}
  465. \def\l@subsection{\ctu@dottedtocline{2}{1.2em}{1.2em}}
  466. \def\l@subsubsection{\ctu@dottedtocline{3}{1.8em}{2.4em}}
  467. % Figures and tables in LoF and LoT exactly as sections, just the level is set to -2 so that they're always shown
  468. \def\l@figure{\ctu@dottedtocline{-2}{0.6em}{0em}}
  469. \let\l@table\l@figure
  470. %%% FANCY HEADERS
  471. \RequirePackage{fancyhdr}
  472. % Spacial pagestyle for twocolumnpages in the frontmatter: includes centered pagenumber in the bottom
  473. % and we abuse \fancyhead[C] to include the dividing rule
  474. \fancypagestyle{twocol}{
  475. \fancyhf { }
  476. \fancyfoot [ RO, LE ] { \texttt { \ctufield { preprint } } }
  477. \fancyfoot [ C ] { \thepage }
  478. % CHANGED removed the blue rule
  479. % \fancyhead [ C ] {
  480. % \leavevmode
  481. % \smash {
  482. % \color{ctubluerule}
  483. % \rule [ \dimexpr - \textheight - \headsep - 6pt ]{ 11pt }{ \textheight }
  484. % }
  485. % }
  486. \renewcommand { \headrulewidth } { 0pt }
  487. \renewcommand { \footrulewidth } { 0pt }
  488. \dim_set_eq:NN \headwidth \textwidth
  489. }
  490. \fancypagestyle { cleardoublepage } {
  491. % On \cleardoublepage (without star), we want the page number, but nothing else,
  492. % that is, the same as plain pagestyle
  493. \ps@plain
  494. }
  495. % Plain pagestyle for chapter and part titles: no rules, just the page number
  496. \fancypagestyle { plain } {
  497. \fancyhf { }
  498. \fancyfoot [ RO, LE ] { \texttt { \ctufield { preprint } } }
  499. \fancyfoot [ C ] { \thepage }
  500. \renewcommand \headrulewidth { 0pt }
  501. \renewcommand \footrulewidth { 0pt }
  502. % reset headwidth to the global textwidth
  503. \dim_set_eq:NN \headwidth \g_ctuthesis_geometry_textwidth_dim
  504. }
  505. % Headings pagestyle for standard text pages
  506. \fancypagestyle { headings } {
  507. % Copy the plain pagestyle
  508. \ps@plain
  509. % Include the left/rightmark and leaders
  510. \fancyhead [ LE ] { \ctuthesis_fancy_xlap:nn { right } { \leftmark \ctuthesis_fancy_leaders:n { l } } }
  511. \fancyhead [ RO ] { \ctuthesis_fancy_xlap:nn { left } { \ctuthesis_fancy_leaders:n { r } \rightmark } }
  512. }
  513. % The leaders macro for the fancyhead: nice little boxes. We make three of them: left, right and center-aligned
  514. \box_new:N \g_ctuthesis_fancy_bluerule_l_box
  515. \hbox_set_to_wd:Nnn \g_ctuthesis_fancy_bluerule_l_box { 10.5pt } {
  516. { \color{ctubluedot} \smash{\fontsize{28.88}{0}\fontfamily{lmss}\bfseries.} }
  517. \hfil
  518. }
  519. \box_new:N \g_ctuthesis_fancy_bluerule_r_box
  520. \hbox_set_to_wd:Nnn \g_ctuthesis_fancy_bluerule_r_box { 10.5pt } {
  521. \hfil
  522. { \color{ctubluedot} \smash{\fontsize{28.88}{0}\fontfamily{lmss}\bfseries.} }
  523. }
  524. \box_new:N \g_ctuthesis_fancy_bluerule_c_box
  525. \hbox_set_to_wd:Nnn \g_ctuthesis_fancy_bluerule_c_box { 10.5pt } {
  526. \hfil
  527. { \color{ctubluedot} \smash{\fontsize{28.88}{0}\fontfamily{lmss}\bfseries.} }
  528. \hfil
  529. }
  530. % The leaders macro for the fancyhead: nice little boxes,
  531. % the parameter #1 chooses one of the boxes above
  532. \cs_new:Nn \ctuthesis_fancy_leaders:n {
  533. \hspace*{-1pt}
  534. \leaders \box_use:c {g_ctuthesis_fancy_bluerule_#1_box} \hfill
  535. \hspace*{-1pt}
  536. }
  537. % This macro works as follows: The width of the material is actually zero. We use \hbox_overlap_left/right
  538. % to make the headers as wide as we wish, the direction is in #1. In #2 is the contents, and we suppose
  539. % that it contains \ctuthesis_fancy_leaders: and \left/rightmark in desired order; it's typeset gray sf it
  540. \cs_new:Nn \ctuthesis_fancy_xlap:nn {
  541. \color{ctugray} \sffamily\itshape
  542. \leavevmode \use:c { hbox_overlap_#1:n } {
  543. \hbox_to_wd:nn { \paperwidth - 1in - \evensidemargin + 1em } { #2 }
  544. }
  545. }
  546. % We rename the original \mark... commands and disable them; we do it ourselves
  547. \cs_set_eq:NN \ctuthesis_fancy_markboth_orig:nn \markboth
  548. \cs_set_eq:NN \ctuthesis_fancy_markright_orig:n \markright
  549. \let\markboth\@gobbletwo
  550. \let\markright\@gobble
  551. % New chapter and section marks with no \MakeUppercase
  552. \renewcommand \chaptermark [1] { \ctuthesis_fancy_markboth_orig:nn { \thechapter.\ #1 }{ \thechapter.\ #1 } }
  553. \renewcommand \sectionmark [1] { \ctuthesis_fancy_markright_orig:n { \thesection.\ #1 } }
  554. % Newly defined \chapter/sectionstarmark to be used with unnumbered chapters and sections.
  555. % Not that we like unnumbered ones, but if they need to be there, they sould be in headings, too.
  556. \newcommand \chapterstarmark [1] { \ctuthesis_fancy_markboth_orig:nn { #1 } { #1 } }
  557. \newcommand \sectionstarmark [1] { \ctuthesis_fancy_markright_orig:n { #1 } }
  558. % Better \cleardoublepage that takes proper treatment of the empty pages.
  559. % The starred variant leaves the empty page inbetween really completely empty
  560. \DeclareDocumentCommand \cleardoublepage { s~} {
  561. \clearpage
  562. \if@twoside\ifodd\c@page\else
  563. % \IfBooleanTF { #1 } {
  564. % Starred variant: completely empty page
  565. \leavevmode
  566. \thispagestyle{empty}
  567. % } {
  568. % Non-starred variant: include page number
  569. \leavevmode
  570. \thispagestyle{cleardoublepage}
  571. % }
  572. \newpage
  573. % In twocolumn, we need \newpage twice
  574. \if@twocolumn\hbox{}\newpage\fi
  575. \fi\fi
  576. }
  577. %%% FLOATS
  578. \usepackage{float,caption}
  579. % default placement of all floats is `t`
  580. \floatplacement{figure}{t}
  581. \floatplacement{table}{t}
  582. \floatplacement{figure*}{t}
  583. \floatplacement{table*}{t}
  584. % minimum 70% of page height on float pages
  585. \renewcommand{\floatpagefraction}{0.7}
  586. % 2 floats on top, no on bottom
  587. \setcounter{topnumber}{2}
  588. \setcounter{bottomnumber}{0}
  589. \setcounter{totalnumber}{4}
  590. % up to 90% of floats on a mixed page, at least 7% of text
  591. \renewcommand{\topfraction}{0.7}
  592. \renewcommand{\bottomfraction}{0.7}
  593. \renewcommand{\textfraction}{0.2}
  594. % float caption: justification with extra margins on both sides
  595. \DeclareCaptionJustification{myjustify}{\leftskip.8em \rightskip.8em \parfillskip.8em plus 1fil}
  596. % float caption: special format
  597. \DeclareCaptionFormat{myformat}{%
  598. % float name bf sf
  599. \begingroup\sffamily\bfseries#1#2:~\endgroup
  600. % float caption normal font
  601. \begingroup#3\par\endgroup
  602. }
  603. \DeclareCaptionFormat{mysubformat}{%
  604. % float name small caps
  605. #1#2 %
  606. % float caption normal font
  607. \begingroup#3\par\endgroup
  608. }
  609. % plain float style is what we like, with captions at the bottom
  610. \floatstyle{plain}
  611. % restyle already existing floats
  612. \restylefloat{figure}
  613. \restylefloat{table}
  614. % set up the captions: no indent of captions, no seperator (seperator is handled by {myformat})
  615. \captionsetup{format=myformat,indent=0pt,labelsep=none,justification=myjustify,font={small},position=below}
  616. % float-caption distance
  617. \abovecaptionskip 8pt plus 3pt minus 1pt
  618. % graphics allowed: pdf, png, jpg
  619. \DeclareGraphicsExtensions{.pdf,.png,.jpg}
  620. % floats should be centered by default:
  621. \g@addto@macro{\@floatboxreset}{\centering}
  622. % nice table rules
  623. \usepackage{booktabs}
  624. \newcommand \Midrule { \midrule[\heavyrulewidth] }
  625. % colored tables
  626. \newenvironment{ctucolortab}{\begin{lrbox}{0}}{\end{lrbox}\ht0\dimexpr\ht0 + 2pt\relax{\fboxsep0pt\colorbox{ctubluebg}{\usebox{0}}}}
  627. \newenvironment{ctucolortab*}{\begin{lrbox}{0}}{\end{lrbox}{\fboxsep0pt\colorbox{ctubluebg}{\usebox{0}}}}
  628. \iffalse
  629. %%% LISTS
  630. % Temp box
  631. \box_new:N \g_ctuthesis_tempa_box
  632. % Macro used to generate the itemize labels
  633. % parameters 1:depth, 2: raise (without ex), 3: scale, 4:color
  634. \cs_new:Nn \ctuthesis_list_prepare_labelitem:nnnn {
  635. % Each label stored in a box
  636. \box_new:c { g_ctuthesis_list_label_#1_box }
  637. % use the temp box to measure the symbol
  638. \hbox_gset:Nn \g_ctuthesis_tempa_box {
  639. \scalebox{#3}{\fontfamily{lmss}\bfseries\color{#4}.}
  640. }
  641. % The label is actually a shifted up, scaled, coloured lmss bf dot
  642. \hbox_gset:cn { g_ctuthesis_list_label_#1_box } {
  643. \box_move_up:nn { #2 ex } \hbox_to_wd:nn {
  644. \box_ht:N \g_ctuthesis_tempa_box
  645. } {
  646. \hss
  647. \scalebox{#3}{\fontfamily{lmss}\bfseries\color{#4}.}
  648. \hss
  649. }
  650. }
  651. \cs_set:cpn { labelitem #1 } { \box_use:c { g_ctuthesis_list_label_#1_box } }
  652. }
  653. % The four labels for itemize
  654. \ctuthesis_list_prepare_labelitem:nnnn { i~} { 0.18 } { 3.6 } { ctublueitemi }
  655. \ctuthesis_list_prepare_labelitem:nnnn { ii } { 0.18 } { 3.6 } { ctublueitemii }
  656. \ctuthesis_list_prepare_labelitem:nnnn { iii } { 0.36 } { 2.4 } { black }
  657. \ctuthesis_list_prepare_labelitem:nnnn { iv } { 0.48 } { 1.2 } { black }
  658. % Macro for making the box with lmss bf dot "." scaled to the size of \strutbox
  659. % #1 is the width of the box (relative to the width of the resulting dot) and
  660. % #2 is the color of the box
  661. \cs_new:Nn \ctuthesis_list_enumdot:nn {
  662. \hbox_to_wd:nn { #1\ht\strutbox + #1\dp\strutbox } {
  663. \hss
  664. \raisebox{-\dp\strutbox}{
  665. \resizebox{!}{\dimexpr\ht\strutbox+\dp\strutbox}{
  666. \fontfamily{lmss}\bfseries\color{#2}.
  667. }
  668. }
  669. \hss
  670. }
  671. }
  672. % \itembox takes 5 parameters.
  673. % (#1)(#2) are the left and right padding
  674. % [#3][#4] are the box color and text color
  675. % #5 is the text
  676. \DeclareDocumentCommand \itembox { D(){0.15em} D(){0.15em} >{\TrimSpaces}O{ctubluebg} >{\TrimSpaces}O{black} >{\TrimSpaces}m } {
  677. \ooalign{
  678. \hfil \ctuthesis_list_enumdot:nn {1} {#3}
  679. \cr
  680. \ctuthesis_list_enumdot:nn {1} {#3} \hfil
  681. \cr
  682. \skip_horizontal:n { 0.34\ht\strutbox + 0.34\dp\strutbox }
  683. \cleaders \ctuthesis_list_enumdot:nn {0.34} {#3} \hfil
  684. \skip_horizontal:n { 0.34\ht\strutbox + 0.34\dp\strutbox }
  685. \cr
  686. \hfil
  687. \hbox:n { \hspace{#1} { \color{#4} #5 } \hspace{#2} }
  688. \hfil
  689. }
  690. }
  691. % Redefine the enumerate labels. The first two levels are boxed,
  692. % the other two are not.
  693. \def\labelenumi{{\normalfont\itembox[ctubluedarkbg][white]{\bfseries\theenumi.}}}
  694. \iffalse
  695. \def\labelenumi{{\normalfont\itembox{\theenumi.}}}
  696. \def\labelenumii{{\normalfont\itembox(0.1em)(0.1em){\theenumii.}}}
  697. \def\labelenumiii{{\normalfont(\theenumiii)}}
  698. \def\labelenumiv{{\normalfont(\theenumiv)}}
  699. \fi
  700. \leftmargini22.2pt
  701. \labelsep6pt
  702. \fi
  703. %%% MATH, THEOREMS
  704. \usepackage{amsmath,amssymb,amsfonts}
  705. % Optional loading of amsthm
  706. \ctuthesis_if_switch:nT { pkg-amsthm } {
  707. \usepackage{amsthm}
  708. % Redefine standard styles: plain is slanted, definition is normal, note has an italic head (like proof)
  709. \newtheoremstyle{plain}{3pt plus 1pt}{3pt plus 1pt}{\slshape}{}{\bfseries\sffamily}{.}{.5em}{}
  710. \newtheoremstyle{plainit}{3pt plus 1pt}{3pt plus 1pt}{\slshape}{}{\bfseries\sffamily}{.}{.5em}{}
  711. \newtheoremstyle{definition}{3pt plus 1pt}{3pt plus 1pt}{}{}{\bfseries\sffamily}{.}{.5em}{}
  712. \newtheoremstyle{note}{3pt plus 1pt}{3pt plus 1pt}{}{}{\itshape}{.}{.5em}{}
  713. % Default style: plain
  714. \theoremstyle{plain}
  715. % We redefine proof to include a more reasonable spacing above it.
  716. \DeclareDocumentEnvironment { proof } { O{\proofname} } {
  717. \par
  718. \pushQED{\qed}
  719. \normalfont \topsep0pt plus 1pt
  720. \trivlist
  721. \item[
  722. \hskip\labelsep
  723. \itshape
  724. #1\@addpunct{.}
  725. ]
  726. \ignorespaces
  727. }{
  728. \popQED\endtrivlist\@endpefalse
  729. }
  730. }
  731. %%% INDEX
  732. \ctuthesis_if_switch:nT { pkg-makeidx } {
  733. % Initialize makeindex
  734. \usepackage{makeidx}
  735. \makeindex
  736. % We use multicol rather than twocolumn for the index
  737. \usepackage{multicol}
  738. % Redefine the index environment to just make the header and start the multicols* envrionment
  739. % (starred because we don't want to balance the columns), then redefine \item as in original theindex
  740. \DeclareDocumentEnvironment { theindex } { } {
  741. \chapter* {\indexname }
  742. %CHANGED commented out begin & end
  743. % \begin{multicols*}{2}
  744. \let\item\@idxitem
  745. % Do not put index sections in ToC. We save the tocdepth and set it to zero, only to restore it after.
  746. \addtocontents{toc}{\protect\ctu@savetocdepth}
  747. \addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
  748. % Inside index, the sections are tighter together
  749. \titlespacing*\section{}{10pt}{4pt}
  750. } {
  751. \addtocontents{toc}{\protect\ctu@restoretocdepth}
  752. % \end{multicols*}
  753. \clearpage
  754. }
  755. % How does this work: in \ctu@tocdepth we save the current tocdepth
  756. \newcommand\ctu@savetocdepth{\xdef\ctu@saved@tocdepth{\the\c@tocdepth}}
  757. % This macro restores the saved value.
  758. \newcommand\ctu@restoretocdepth{\global\c@tocdepth\ctu@saved@tocdepth\relax}
  759. }
  760. %%% LISTINGS
  761. \ctuthesis_if_switch:nT { pkg-listings } {
  762. \RequirePackage{listings}
  763. \lstset{
  764. backgroundcolor = \color{ctubluebg},
  765. basicstyle = \ttfamily,
  766. columns = fullflexible,
  767. keepspaces = true,
  768. tabsize = 4,
  769. % frame = leftline,
  770. % framesep = 0pt,
  771. % framexleftmargin = 3pt,
  772. % framerule = 0.667pt,
  773. % rulecolor = \color{ctubluerule},
  774. frame = single,
  775. framesep = 0pt,
  776. framexleftmargin = 2pt,
  777. framerule = 2pt,
  778. rulecolor = \color{ctubluebg},
  779. framexrightmargin = 2pt,
  780. xleftmargin = 4pt,
  781. xrightmargin = 4pt,
  782. }
  783. \cs_new_eq:NN \ctuthesis_lst_orig_lstinline:w \lstinline
  784. \newsavebox \ctuthesis_lst_box
  785. \newcommand* \ctulstsep {0.2em}
  786. \DeclareDocumentCommand \ctuthesis_lst_do_ctulstinline:nnw { m m m v~} {
  787. \leavevmode
  788. \microtypesetup{activate=false}
  789. \begin{lrbox}{\ctuthesis_lst_box}
  790. \ctuthesis_lst_orig_lstinline:w[#2]#3#4#3
  791. \end{lrbox}
  792. \str_if_eq:xnTF {#1} {none}
  793. {{ \hbox:n {\strut\hspace*{\ctulstsep}\box\ctuthesis_lst_box\hspace*{\ctulstsep}} }}
  794. {{ \fboxsep0pt\colorbox{#1} {\strut\hspace*{\ctulstsep}\box\ctuthesis_lst_box\hspace*{\ctulstsep}} }}
  795. \microtypesetup{activate=true}
  796. }
  797. \DeclareDocumentCommand \ctulst { D(){\g_ctuthesis_ctulstbg_tl} O{} m } {
  798. \ctuthesis_lst_do_ctulstinline:nnw { #1 } { #2 } { #3 } #3
  799. }
  800. \DeclareDocumentCommand \ctulstbr { D(){ctulstbg} O{} m } {
  801. \leavevmode
  802. \begin{lrbox}{\ctuthesis_lst_box}
  803. \ctuthesis_lst_orig_lstinline:w[#2]{#3}
  804. \end{lrbox}
  805. \colorbox{#1}{\box\ctuthesis_lst_box}
  806. }
  807. }
  808. %%% HYPERREF
  809. \ctuifswitch { pkg-hyperref } {
  810. \usepackage[
  811. unicode,
  812. pdfpagelayout=TwoPageRight, % Correct twopage layout with recto on the right
  813. ]{hyperref}
  814. % Links with orange borders, in ToC only the page is linked
  815. \hypersetup{
  816. colorlinks=false,
  817. linktocpage=true,
  818. allbordercolors=ctuorange,
  819. }
  820. % Prepare PDFinfo
  821. \cs_new:Nx \ctuthesis_hyperref_pdfinfo: {
  822. pdfinfo = {
  823. Title = \ctuthesis_field_use:n {pdftitle},
  824. Author = \ctuthesis_field_use:n {pdfauthor},
  825. }
  826. }
  827. \exp_args:NV \hypersetup \ctuthesis_hyperref_pdfinfo:
  828. }{}
  829. %\ctuifswitch { pkg-hyperref } {
  830. % \hypersetup{colorlinks=false,linktocpage=true,linkbordercolor=0 122 195}
  831. %}
  832. %%% VARIOUS TWEAKS
  833. % Provide \phantomsection and \texorpdfstring to make them available in case hyperref wasn't loaded
  834. \providecommand\phantomsection{}
  835. \providecommand\texorpdfstring[2]{#1}
  836. % Provide \microtypesetup to make it available in case microtype wasn't loaded
  837. \providecommand\microtypesetup[1]{}
  838. \endinput