summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/gsemthesis/gsemthesis.dtx
blob: 569b7599420c7afdfcec40f47ecc6d8bd987c645 (plain)
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
% \iffalse meta-comment
%
% Copyright (©) 2014-2015 by Emmanuel Rousseaux <emmanuel.rousseaux@gmail.com>
% -------------------------------------------------------
% 
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, version 1.3c
% of this license.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{gsemthesis.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{gsemthesis}
%<*class>
    [2015/02/09 v0.9.4 .dtx gsemthesis file]
%</class>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[utf8]{inputenc}
\RequirePackage[top=2.5cm, bottom=2.5cm, left=4.5cm, right=3.5cm]{geometry}
\RequirePackage{xcolor}
\definecolor{erblue}{HTML}{126199}
\RequirePackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=black, filecolor=erblue, citecolor=erblue, urlcolor=erblue}
\RequirePackage{url}
\RequirePackage{float}
\newenvironment{itemize*}%
  {\vspace{-2mm}\begin{itemize}%
    \setlength{\itemsep}{0pt}%
    \setlength{\parskip}{0pt}%
  }%
  {\end{itemize}\vspace{-2mm}%
  }
\EnableCrossrefs         
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{gsemthesis.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v0.1.0}{2014/02/19}{First draft}
% \changes{v0.9.0}{2014/12/05}{Added French abstract, minor fixes}
% \changes{v0.9.1}{2014/12/06}{French option, draft option, update frontmatter, update backmatter, page numbering at the top of the page, refined cover page}
% \changes{v0.9.2}{2015/01/09}{rewriting of the cover page, improve bibliography management, and a lot of minor fixes}
% \changes{v0.9.3}{2015/01/16}{tested requirements on Debian and Windows, added the minimal working example, first complete version of the user manual}
% \changes{v0.9.4}{2015/02/09}{fixed RO-LE headers, custombib, graphicx and hyperref in final mode, utf-8, French T1, and a lot of minor fixes}
%
% \GetFileInfo{gsemthesis.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
% 
%
% \title{The \textsf{gsemthesis} class\thanks{This document
%   corresponds to \textsf{gsemthesis}~\fileversion, dated \filedate.}}
% \author{Emmanuel Rousseaux \\ \url{emmanuel.rousseaux@gmail.com}}
%
% \maketitle
%
% \begin{abstract}
% This article introduces the |gsemthesis| class for \LaTeX. The |gsemthesis| class is a PhD thesis  template for the Geneva School of Economics and Management (GSEM), University of Geneva, Switzerland. The class provides utilities to easily set up the cover page, the front matter pages, the pages headers, etc. with respect to the official guidelines of the GSEM Faculty for writing PhD dissertations.
% This class is released under the LaTeX Project Public License version 1.3c.
% \end{abstract}
%
% \newpage
%
% \tableofcontents
%
% \vfill
%
% \section{Introduction}
%
% PhD thesis published within the Geneva School of Economics and Management have to follows some guidelines, especially for the cover page. The |gsemthesis| class is a \LaTeX{} template providing utilities to easily set up these guidelines in your thesis. In addition the class loads several usefull packages generally used when writing a thesis.
% We recommend the user to have a look to the class definition in Section \ref{sec:classdef} to be aware of the list of packages that the class already includes. The Section \ref{sec:usage} details how to start with the |gsemthesis| class and how to configure your thesis. The Section \ref{sec:example} provides a minimal working example you can copy/paste for starting your dissertation. The user interested in customizing the class can read the Section \ref{sec:implementation} which details the full implementation of the class with usefull comments.
% 
% \medskip
%
% This class was successfully tested with TeX Live 2013/Debian, TeX Live 2014/CentOS;Windows7 and MiKTeX-2.9.5105/Windows7.
%
% \medskip
%
% This class has been written by Emmanuel \textsc{Rousseaux} with contributions from William \textsc{Aeberhard} and Tuan \textsc{Nguyen}.
%
% \medskip
%
% The development version is hosted on GitHub\footnote{\url{https://github.com/emmanuelrousseaux/gsemthesis}}. If you are interested in contributing to this class or if you want to beta test latest versions, please visit the repository.
% 
% \section{Usage}
% \label{sec:usage}
% 
% This Section introduces the use of the |gsemthesis| class. All macros and environments the class provides are described. We assume the user is already familiar with \LaTeX.
%
% \subsection{Requirements}
%
% The class requires a recent version of either TeX Live ($\ge$ 2014 recommended, $\ge$ 2013 minimal) or MiKTeX ($\ge$ 2.9.5x minimal). As the class preload some common packages (see Section \ref{sec:implementation} for the detailed list), we suggest to use install your \LaTeX{} distribution in full mode to make things working out-of-the-box.
% 
% \medskip
%
% \noindent The class uses biblatex/biber for managing the bibliography. Please refer to the Section \ref{sec:bibliography} for configuring your editor to use it.
%
% \subsection{Getting started}
%
% To use the class start your document with the command |\documentclass{gsemthesis}|. A minimal document is:
% \begin{verbatim}
% \documentclass{gsemthesis}
% \begin{document}
% \printcoverpage
% \newpage
% Here is it, I started my PhD!
% \end{document}
% \end{verbatim}
%
% \noindent The Section \ref{sec:example} provides a minimal working example you can copy/paste for starting your dissertation. Commands available for configuring your thesis are explained in the following sections.
%
% \subsection{Configuring your editor to store files in UTF-8}
%
% The class assumes that all your |.tex| and |.bib| files are encoded in UTF-8. The UTF-8 encoding is a dominant character encoding available on all recent systems and used by default by a lot of editors. As a consequence, it limits encoding problems when sharing files from different systems (Windows, MacOS, Unix/Linux, web sites, etc.). If some of your source files are stored with a different encoding, you may experience rendering problems with accentued/foreign characters. These characters can occur, for instance, in author names of the bibliography. For making sure you won't experience rendering problems, consider (1) storing your files in UTF-8 and (2) set UTF-8 as the default encoding of your editor.
%  Any recent text editor is able to convert files to UTF-8. TeXstudio and TeXmaker seem to used UTF-8 by default. Rstudio seems to use the system default encoding. To change this setting go to \emph{File $>$ Save with encoding}. On NotePad++ go to \emph{Encoding $>$ Convert to UTF-8}.
%
% \subsection{Writing the dissertation in French}
%
% The GSEM accepts English and French for PhD thesis dissertations. Default language is English. If you write your dissertation in French, you have to you the |fr| class option as follows:
% \begin{verbatim}
% \documentclass[fr]{gsemthesis}
% \end{verbatim}
%
% \subsection{Configuring and printing the cover page}
%
% \DescribeMacro{\printcoverpage}
% The class provides the GSEM PhD thesis cover page ready to be printed. You can ask to print it by calling |\printcoverpage| just after the |\begin{document}|. Before printing the cover page you first need to configure it with your thesis details: title, author, supervisors, committee, etc.
% 
% \DescribeMacro{\title}
% \DescribeMacro{\date}
% The class uses the classical |\title{|\emph{text}|}| and |\date{|\emph{text}|}| commands of the |book| class to set the title and the date.
% \DescribeMacro{\authorFirstname}
% \DescribeMacro{\authorLastname}
% Instead of using the |\author{|\emph{text}|}| command we provide the two commands |\authorFirstname{|\emph{text}|}| and |\authorLastname{|\emph{text}|}| to separately handle the firstname and the lastname.
% \DescribeMacro{\thesisField}
% You specify the PhD you are enrolled in with the |\thesisField{|\emph{text}|}|, among others: Economics, Management, Statistics, Information Systems. Please contact the scientific committee of your PhD to obtain the applicable title.
% \DescribeMacro{\thesisCommitteeA-F}
% You can specify information about members of your thesis committee with the six |\thesisCommitteeA-F{|\emph{title}|}{|\emph{firstname}|}{|\emph{lastname}|}{|\emph{role}|}| commands. With the \emph{role} field you specify the role played by this member in the committee and his/her affiliation. Generally you specify the role ``Chair'' in |\thesisCommitteeA|, the role ``adviser'' for your adviser/co-advisers, and leave the field empty for the other members.
% \DescribeMacro{\thesisNumber}
% When your manuscript has been accepted by your jury, the Faculty attributes a unique thesis number which has to be printed on the cover page. The |\thesisNumber{|\emph{text}|}| allows to supply it.
% 
% \subsection{Configuring and printing the front matter pages}
%
% After the cover page the thesis has to provide in a the following order (1) the acknowledgements, (2,3) an abstract in both English and French (the order depending on the main language of your dissertation: if your dissertation is written in English you will start with the English abstract; if your dissertation is written in Frenchyou will start with the French abstract), (4) the table of contents, and (5) an optional dedication. These elements are usually called the front matter. 
% \DescribeMacro{\printfrontmatter}
% These pages will be printed by calling the |\printfrontmatter| command. The best place for this command is just after the |\printcoverpage| command.
% \DescribeMacro{\acknowledgements}
% \DescribeMacro{\abstractEN}
% \DescribeMacro{\abstractFR}
% \DescribeMacro{\dedication}
% To fill these pages use the commands |\acknowledgements{|\emph{text}|}|, |\abstractEN{|\emph{text}|}|, |\abstractFR{|\emph{text}|}|, and |\dedication{|\emph{text}|}|. We suggest you use these commands in the preambule of the document, just after the commands used to set the cover page.
%
% \subsection{Introduction and conclusion}
%
% Generally we don't want to number the introduction and the conclusion, but we want they appear in the table of contents. This leads to a specific handling of the creation of these chapter, especially to have correct page headers.
% \DescribeMacro{\startintroduction}
% \DescribeMacro{\startconclusion}
% Therefore, instead of using |\chapter{introduction}| (respectively |\chapter{conclusion}|) to start a such chapter we provide the function |\startintroduction| (respectively |\startconclusion|) to easily start the chapter with a correct handling of the table of contents and page headers.
%
% \subsection{Bibliography}
% \label{sec:bibliography}
%
% To produce the bibliography, the |gsemthesis| class uses the package |biblatex| with |biber| in backend instead of the package |bibtex|. The package |biblatex| is installed by default with any recent version of TeX Live\footnote{On Ubuntu/Debian, you may have to install it manually: sudo apt-get install texlive-bibtex-extra biber} (full installation) and MiKTeX, but you must first configure your TeX Editor to use it.
%
% \subsubsection{Configure TeXstudio to run biber}
%
% In the TeXstudio preferences (click on Options $\rightarrow$ Configure TeXstudio), choose the `Build' tab and modify the `Default Bibliography' to `Biber'.
%
% \medskip
%
% \noindent Run `Build \& View' from the `Tools' menu (or press the two green arrows icon), which will create a PDF but with the bibliography not completed.
%
% \medskip
%
% \noindent Run `Bibliography' from the `Tools' menu.
%
% \medskip
%
% \noindent Run `Build \& View' again to create a PDF with the bibliography.
%
% \subsubsection{Configure Texmaker to run biber}
%
% In the Texmaker preferences (click on Options $\rightarrow$ Configure Texmaker), choose the `Commands' tab and replace |bibtex %| by |biber %| in the field |Bib(la)tex|. On Windows, you may also browse to the |biber.exe| using the folder icon on the side.
%
% \medskip
%
% \noindent Choose the `Quick Build' tab and select the second option |PdfLaTeX + Bib(la)tex +| |PdfLaTex (x2) + View Pdf|
%
% \medskip
%
% \noindent Now your `Quick Build' button will create a PDF with the bibliography.
%
% \subsubsection{Configure Rstudio/knitr to run biber}
%
% In Rstudio/knitr you have to include the following chunk in your |.Rnw| document:
%
% \begin{verbatim}
% <<tex-setup, include=FALSE, cache=FALSE, echo=FALSE>>=
% Sys.setenv(
%   TEXINPUTS=getwd(),
%   BIBINPUTS=getwd(),
%   BSTINPUTS=getwd()
% )
% @
% \end{verbatim}
%
% \subsubsection{Basic commands}
%
% To add a bibliography into your document, you have to define your bib file in the preamble of your tex file: |\addbibresource{literature-review-topic1.bib}| Then, at the end of your document, the command |\printbibliography| will create the biblography.
%
% \subsubsection{Using you own bibliography management configuration}
%
% If you prefer not to use the bibliography management configuration we implemented in this class, you can disabled it and writing you own. Disabling the \emph{gsemthesis} bibliography management configuration is easily done with the |custombib| class option:
% \begin{verbatim}
% \documentclass[custombib]{gsemthesis}
% \end{verbatim}
% When using this option you will have to provide the package you want to use for managing your bibliography (|natbib|, |chapterbib|, etc.). As the option disables all settings you will also need to load the package |biblatex| if you want to use it.
%
% \subsection{\emph{Draft} mode}
%
% When sharing draft versions of your dissertation you may prefer to hide some items of the cover page (thesis committee, thesis number, etc.) and some Sections (acknowledgments, the dedications. etc.) that probably have not been defined yet. For this purpose you can use the |draft| option:
% \begin{verbatim}
% \documentclass[draft]{gsemthesis}
% \end{verbatim}
% \noindent\emph{Note:} this draft mode extends the classical \LaTeX draft mode and then all packages supporting a draft mode will also switch to the draft mode\footnote{Common packages supporting a draft mode are: |changes| (final disables markup of changes, and list of changes), |graphics| (draw frames instead of including images), |graphicx| (draw frames instead of including images), |hyperref| (disable all linking features), |listings| (don't include external files), |listofsymbols| (final suppresses printing of macro names and unused symbols), |mfpic| (assume every latex run to be the first one), |microtype| (disable all features), |pdfcomment| (final suppresses the comments), |pdfpages| (don't include external file but print a frame box), |pgf| (similar to graphics/x: all images will be replaced by empty rectangles), |showkeys| (draft shows the labels, the default option), |thumbs| (thumbs' width=2pt, thumbs' text=black, thumbs' color=grey), |varioref| (turn warnings in error messages). \emph{Source:} \url{http://tex.stackexchange.com/questions/49277/what-does-the-draft-mode-change/49278}}. For convenience purposes we forced packages |graphicx| and |hyperref| to be in \emph{final} mode even when draft mode is on.
%
% \subsection{Miscellaneous}
%
% The class also provides some optional functions that can turn out to be usefull when writing your thesis.
% \DescribeEnv{itemize*}
% The default |itemize| environment set important spaces between each items, the previous paragraph and the next paragraph. The |itemize*| environment reduces these spaces to allow a more compact (and nicer) presentation of a list item.
% \emph{Forthcoming}. To add: section in redaction, todonotes
%
% \newpage
% \section{Minimal working example}
% \label{sec:example}
% \begin{verbatim}
% \documentclass{gsemthesis}
% 
% \title{An innovative approach to deal with a very important issue}
% \date{\today}
% \authorFirstname{Firstname}
% \authorLastname{Lastname}
% \thesisField{Econometrics}
% 
% \thesisCommitteeA{Prof.}{Mike}{Moore}{Adviser, University of Geneva}
% \thesisCommitteeB{Prof.}{Mike}{Moore}{Chair, University of Honolulu}
% \thesisCommitteeC{Prof.}{Mike}{Moore}{University of Omsk}
% \thesisCommitteeD{Dr.}{Mike}{Moore}{Eidgenössische Technische Hochschule Zürich}
% \thesisNumber{480}
% 
% \acknowledgements{Your acknowledgements}
% 
% \abstractEN{English version of the abstract}
% 
% \abstractFR{French version of the abstract}
% 
% \dedication{To my family.}
% 
% \addbibresource{literature-review-topic1.bib}
% \addbibresource{literature-review-topic2.bib}
% 
% \begin{document}
% 
% \printcoverpage
% 
% \printfrontmatter
% 
% % INTRODUCTION
% \startintroduction 
% 
% Write your introduction here.
% 
% % CHAPTER
% \chapter{A first chapter}
% \label{ch:chapterone}
%
% My chapter 1.
% 
% % CONCLUSION
% \startconclusion
% 
% The conclusion.
% 
% % BACKMATTER
% \listoftables
% \listoffigures
% 
% % Bibliography (at the end)
% \newpage
% \printbibliography
% 
% \end{document}
% \end{verbatim}
%
% \section{Implementation}
% \label{sec:implementation}
%
% In this Section the full code of the |gsemthesis| is discussed. The reader interested in customizing the class will find useful comments to understand the design of the class.
%
% \subsection{Document properties}
% \label{sec:classdef}
%
% The class is derived from the standard |book| class as follows:
%    \begin{macrocode}
\LoadClass[a4paper,12pt,twoside]{book}
%    \end{macrocode}%
% We set the document encoding to UTF-8
%    \begin{macrocode}
\usepackage[utf8]{inputenc}
%    \end{macrocode}%
% We use the |lmodern| vectorial fonts to render the document.
%    \begin{macrocode}
\usepackage{lmodern}
%    \end{macrocode}
% We use the |etoolbox| package for defining class options (fr, draft)
%    \begin{macrocode}
\usepackage{etoolbox}
%    \end{macrocode}%
% We add the option \emph{fr}
%    \begin{macrocode}
\newtoggle{fr}
\DeclareOption{fr}{\toggletrue{fr}}
%    \end{macrocode}%
% We add the option \emph{draft}
%    \begin{macrocode}
\newtoggle{draft}
\DeclareOption{draft}{\toggletrue{draft}}
%    \end{macrocode}%
% We add the option \emph{custombib}
%    \begin{macrocode}
\newtoggle{custombib}
\DeclareOption{custombib}{\toggletrue{custombib}}
%    \end{macrocode}%
% The recommended page format is A4. The B5 page format is given in option.
%    \begin{macrocode}
\DeclareOption{b5paper}{
  \PassOptionsToClass{\CurrentOption}{book}
}
%    \end{macrocode}%
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}%
% We use the |geometry| package to set margin properties
%    \begin{macrocode}
\RequirePackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
%    \end{macrocode}
% We use the || package to handle some specific text spacing (title)
%    \begin{macrocode}
\usepackage{setspace}
%    \end{macrocode}
%
% \subsection{Colors}
% We define some nice colors that will be later used for links (url, email, citations, etc.). The |gsemblue| color is the official color (to date 2014.02.20) of the GSEM Faculty.
%    \begin{macrocode}
\usepackage{xcolor}
\definecolor{erblue}{HTML}{126199}
\definecolor{erorange}{HTML}{FF7F00}
\definecolor{gsemblue}{HTML}{465F7F}
%    \end{macrocode}
% \subsection{Graphics}
% We add some practical packages to handle several image files (.png, .pdf), handle placement of graphics, and handle subfigures
%    \begin{macrocode}
\usepackage[final]{graphicx}
\usepackage{float}
\usepackage{subfigure}
%    \end{macrocode}
% \subsection{Link management}
% We use the |hyperref| package to manage internal links and set colors for each link type.
%    \begin{macrocode}
\RequirePackage{hyperref}
% \hypersetup{%
% colorlinks=true,%
% linkcolor=black,%
% filecolor=gsemblue,%
% citecolor=gsemblue,%
% urlcolor=gsemblue%
% }%
\hypersetup{
  colorlinks=true,
  linkcolor=black,
  filecolor=erblue,
  citecolor=erblue,
  urlcolor=erblue,
  final
}
%    \end{macrocode}
% We use the |url| package for a complete support of external links and define a nice font style.
%    \begin{macrocode}
\RequirePackage{url}
\urlstyle{sf}
%    \end{macrocode}
% \subsection{Maths}
% We add standard packages from the American Mathematical Society to handle mathematical symbols, environment (equations, etc.) and the Computer Modern font use by default to render math.
%    \begin{macrocode}
\usepackage{amssymb,amsmath,amsfonts}
%    \end{macrocode}
% \subsection{Page headers management}
% We use the |fancyhdr| package for a fine tuning of headers and footers of the different page type (cover page, chapters, unumbered chapters, etc.).
%    \begin{macrocode}
\usepackage{fancyhdr}
%    \end{macrocode}
% The capital letters given in option of |\fancyhead| or |\fancyfoot| commands respectively stands for:
% \begin{itemize*}
%   \item E: Even page
%   \item O: Odd page
%   \item L: Left field
%   \item C: Center field
%   \item R: Right field
%   \item H: Header
%   \item F: Footer
% \end{itemize*}
% We set the |fancy| page style (default page style) as follows:
%    \begin{macrocode}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE]{\thepage}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LO]{\nouppercase{\rightmark}}
\fancyhead[RO]{\thepage}
\fancyfoot[LE,RO]{}
%    \end{macrocode}
% We reset the |plain| style
%    \begin{macrocode}
\fancypagestyle{plain}{
  \fancyhf{}
  \renewcommand{\headrulewidth}{0pt}
  \fancyfoot[LE,RO]{}
}
%    \end{macrocode}
% We define a style for the cover page (actually not used)
%    \begin{macrocode}
\fancypagestyle{cover}{
  \fancyhf{}
  \renewcommand{\headrulewidth}{0.5pt}
  \renewcommand{\footrulewidth}{0.5pt}
}
%    \end{macrocode}
% We define a style for unumbered chapters (starred chapters)
%    \begin{macrocode}
\fancypagestyle{unnumberedchapter}{
  \fancyhf{}
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
  \fancyhead[LE]{\thepage}
  \fancyhead[RE]{}
  \fancyhead[LO]{}
  \fancyhead[RO]{\thepage}
  \fancyfoot[LE,RO]{}
}
%    \end{macrocode}
% When a new chapter starts on a odd number, we add a blank page to force it to start to a even number. We define an empty style for this blank page
%    \begin{macrocode}
\fancypagestyle{empty}{
  \fancyhf{}
  \renewcommand{\headrulewidth}{0pt}
  \fancyfoot[LE,RO]{}
}
%    \end{macrocode}
% Then we apply the empty style to odd page before a new chapter
%    \begin{macrocode}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
    \hbox{}
    \thispagestyle{empty}
    \newpage
    \if@twocolumn\hbox{}\newpage\fi\fi\fi}
\clearpage{\pagestyle{empty}\cleardoublepage}
%    \end{macrocode}
% We define the default language of the document.
%    \begin{macrocode}
\iftoggle{fr}{
  \usepackage[francais]{babel}
  \usepackage[T1]{fontenc}
}{
  \usepackage[english]{babel}
}
%    \end{macrocode}
% This package provides the commands |\og| and |\fg| for correctly handling French quotes.
%    \begin{macrocode}
\usepackage{csquotes}
%    \end{macrocode}
% We define the date format for the cover page (non-draft mode).
%    \begin{macrocode}
\usepackage{datetime}
\newdateformat{monthyeardate}{\monthname[\THEMONTH] \THEYEAR}
%    \end{macrocode}
%
% \subsection{Bibliography management}
% We use biblatex/biber to process the bibliography with the following settings: (1) citations with more than two authors will always be writen as ``First author et al.'', (2) this ``et al.'' rule is applied even if it leads to ambiguities between long list of authors with the same first author. 
%    \begin{macrocode}
\iftoggle{custombib}{}{
  \usepackage[backend=biber,natbib=true,style=authoryear-comp,sorting=nymdt,%
  maxbibnames=99,mincitenames=1,maxcitenames=2,uniquelist=false]{biblatex}
}
%    \end{macrocode}
% We use the style authoryear to print authors and the year when citing a document in the text. We define a customized sorting style to sort the list of references (printed at the end of the document) according to this (ordered) attributes: name, year, month, day, and title.
% We define the following sorting scheme:
%    \begin{macrocode}
\iftoggle{custombib}{}{
  \DeclareSortingScheme{nymdt}{
    \sort{
      \field{presort}
    }
    \sort[final]{
      \field{sortkey}
    }
    \sort{
      \name{sortname}
      \name{author}
      \name{editor}
      \name{translator}
      \field{sorttitle}
      \field{title}
    }
    \sort{
      \field{sortyear}
      \field{year}
    }
    \sort{
      \field[padside=left,padwidth=2,padchar=0]{month}
      \literal{00}
    }
    \sort{
      \field[padside=left,padwidth=2,padchar=0]{day}
      \literal{00}
    }
    \sort{
      \field{sorttitle}
    }
    \sort{
      \field[padside=left,padwidth=4,padchar=0]{volume}
      \literal{0000}
    }
  }
}
%    \end{macrocode}
% \subsection{Cover page}
% \subsubsection{System-level functions}
%  The following commands define labels for the different parts of the cover page
%    \begin{macrocode}
\def\theFaculty{Geneva School of Economics and Management}

\def\thesisLocationLabel{
  ~ \\[0.4em]%
  \iftoggle{fr}{
    Une thèse soumise à la\\[0.2em]
    \theFaculty\\[0.2em]
    Université de Genève, Suisse,\\[0.2em]
    pour l'obtention du\\[0.2em]
  }{
    A thesis submitted to the\\[0.2em]
    \theFaculty, \\[0.2em]
    University of Geneva, Switzerland,\\[0.2em]
    in fulfillment of the requirements for the degree of\\[0.2em]
  }
}

\iftoggle{fr}{
  \def\thesisByLabel{par}
}{
  \def\thesisByLabel{by}
}
\iftoggle{fr}{
  \def\thesisFieldLabel{Doctorat en}
}{
  \def\thesisFieldLabel{PhD in}
}
\iftoggle{fr}{
  \def\thesisCommitteeLabel{Membres du jury:}
}{
  \def\thesisCommitteeLabel{Members of the thesis committee:}
}
\iftoggle{fr}{
  \def\thesisNumberLabel{Thèse no.}
}{
  \def\thesisNumberLabel{Thesis No.}
}

%    \end{macrocode}
%
%
% \subsubsection{User-level functions}
% 
% Set up of the cover page and assimilated functions.
%
% \begin{macro}{\authorFirstname}
% Set up the |\theauthorFirstname| variable.
%    \begin{macrocode}
\def\theauthorFirstname{}
\newcommand{\authorFirstname}[1]{\def\theauthorFirstname{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\authorLastname}
% Set up the |\theauthorLastname| variable.
%    \begin{macrocode}
\def\theauthorLastname{}
\newcommand{\authorLastname}[1]{\def\theauthorLastname{\textsc{#1}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thesisField}
% Set up the |\thethesisField| variable.
%    \begin{macrocode}
\def\thethesisField{}
\newcommand{\thesisField}[1]{\def\thethesisField{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thesisCommitteeA}
% Set up the |\thethesisCommitteeA| variable.
%    \begin{macrocode}
\def\thethesisCommitteeA{}
\newcommand{\thesisCommitteeA}[4]{%
\ifx&#3&%
  \def\thethesisCommitteeA{}%
\else
  \def\thethesisCommitteeA{#1~#2~\textsc{#3},~#4}%
\fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thesisCommitteeB}
% Set up the |\thethesisCommitteeB| variable.
%    \begin{macrocode}
\def\thethesisCommitteeB{}
\newcommand{\thesisCommitteeB}[4]{%
\ifx&#3&%
  \def\thethesisCommitteeB{}%
\else
  \def\thethesisCommitteeB{#1~#2~\textsc{#3},~#4}%
\fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thesisCommitteeC}
% Set up the |\thethesisCommitteeC| variable.
%    \begin{macrocode}
\def\thethesisCommitteeC{}
\newcommand{\thesisCommitteeC}[4]{%
\ifx&#3&%
  \def\thethesisCommitteeC{}%
\else
  \def\thethesisCommitteeC{#1~#2~\textsc{#3},~#4}%
\fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thesisCommitteeD}
% Set up the |\thethesisCommitteeD| variable.
%    \begin{macrocode}
\def\thethesisCommitteeD{}
\newcommand{\thesisCommitteeD}[4]{%
\ifx&#3&%
  \def\thethesisCommitteeD{}%
\else
  \def\thethesisCommitteeD{#1~#2~\textsc{#3},~#4}%
\fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thesisCommitteeE}
% Set up the |\thethesisCommitteeE| variable.
%    \begin{macrocode}
\def\thethesisCommitteeE{}
\newcommand{\thesisCommitteeE}[4]{%
\ifx&#3&%
  \def\thethesisCommitteeE{}%
\else
  \def\thethesisCommitteeE{#1~#2~\textsc{#3},~#4}%
\fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thesisCommitteeF}
% Set up the |\thethesisCommitteeF| variable.
%    \begin{macrocode}
\def\thethesisCommitteeF{}
\newcommand{\thesisCommitteeF}[4]{%
\ifx&#3&%
  \def\thethesisCommitteeF{}%
\else
  \def\thethesisCommitteeF{#1~#2~\textsc{#3},~#4}%
\fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thesisNumber}
% Set up the |\thethesisNumber| variable.
%    \begin{macrocode}
\def\thethesisNumber{}
\newcommand{\thesisNumber}[1]{\def\thethesisNumber{#1}}
%    \end{macrocode}
% \end{macro}
% The cover page is created with the following code
% \begin{macro}{\printcoverpage}
% Print the cover page of the thesis.
%    \begin{macrocode}
\newcommand{\printcoverpage}{%
  \thispagestyle{empty}
  \begin{center}
  \rule{\linewidth}{0.4pt}
  
  \vspace*{1.2cm}
  
  {\huge
    {\scshape
      \begin{spacing}{0.8}
        \@title
      \end{spacing}
    }
  }
  
  \vspace*{1.2cm}
  
  \thesisByLabel
  
  \vspace*{0.4cm}
  
  {\large \theauthorFirstname~\theauthorLastname}
    
  \vspace*{0.8cm}
  
  \thesisLocationLabel
  \thesisFieldLabel{~}\thethesisField
  
  \vfill
  
  \iftoggle{draft}{
    \iftoggle{fr}{
      \emph{Ébauche}
    }{
      \emph{Draft}
    }
  }
  
  \iftoggle{draft}{~}{
    \vspace*{0.8cm}
    
    \thesisCommitteeLabel
  }

  \vspace*{0.2em}
  
  \iftoggle{draft}{~}{\thethesisCommitteeA}
  
  \vspace*{0.2em}
  
  \iftoggle{draft}{~}{\thethesisCommitteeB}
  
  \vspace*{0.2em}
  
  \iftoggle{draft}{~}{\thethesisCommitteeC}
  
  \vspace*{0.2em}
  
  \iftoggle{draft}{~}{\thethesisCommitteeD}
  
  \vspace*{0.2em}
  
  \iftoggle{draft}{~}{\thethesisCommitteeE}
  
  \vspace*{0.2em}
  
  \iftoggle{draft}{~}{\thethesisCommitteeF}
  
  \vspace*{1.4cm}  
  
  \iftoggle{draft}{~}{\thesisNumberLabel{~}\thethesisNumber}
  
  \vspace*{0.1cm}
  
  \iftoggle{draft}{\@date}{\monthyeardate\today}
  
  \vspace*{0.1cm}
  
  \rule{\linewidth}{0.4pt}
  \end{center}
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Front matter}
%
% \begin{macro}{\acknowledgements}
% Set up the |\theacknowledgements| variable.
%    \begin{macrocode}
\def\theacknowledgements{}
\newcommand{\acknowledgements}[1]{\def\theacknowledgements{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\abstractEN}
% Set up the |\theabstractEN| variable.
%    \begin{macrocode}
\def\theabstractEN{}
\newcommand{\abstractEN}[1]{\def\theabstractEN{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\abstractFR}
% Set up the |\theabstractFR| variable.
%    \begin{macrocode}
\def\theabstractFR{}
\newcommand{\abstractFR}[1]{\def\theabstractFR{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dedication}
% Set up the |\thededication| variable.
%    \begin{macrocode}
\def\thededication{}
\newcommand{\dedication}[1]{\def\thededication{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\printfrontmatter}
% The front matter pages are created with the following code
%    \begin{macrocode}
\newcommand{\printfrontmatter}{%
  
  \iftoggle{draft}{~}{
    \frontmatter
    
    \iftoggle{fr}{
      \chapter*{Remerciements}
      \addcontentsline{toc}{chapter}{Remerciements}
    }{
      \chapter*{Acknowledgements}
      \addcontentsline{toc}{chapter}{Acknowledgements}
    }
    \label{ch:acknowledgements}
    \thispagestyle{plain}
    \theacknowledgements
    
    \newpage
    
    \iftoggle{fr}{
      \chapter*{Résumé}
      \addcontentsline{toc}{chapter}{Résumé}
      \label{ch:abstractFR}
      \thispagestyle{plain}
      \theabstractFR
      
      \newpage
      
      \chapter*{Abstract}
      \addcontentsline{toc}{chapter}{Abstract}
      \label{ch:abstractEN}
      \thispagestyle{plain}
      \theabstractEN
    }{
      \chapter*{Abstract}
      \addcontentsline{toc}{chapter}{Abstract}
      \label{ch:abstractEN}
      \thispagestyle{plain}
      \theabstractEN
      
      \newpage
      
      \chapter*{Résumé}
      \addcontentsline{toc}{chapter}{Résumé}
      \label{ch:abstractFR}
      \thispagestyle{plain}
      \theabstractFR
    }
  }
  
  \tableofcontents
  
  \iftoggle{draft}{~}{
    \cleardoublepage
    
    \thispagestyle{plain}
    
    \vspace*{4cm}
    {\em
    \raggedleft\thededication\par
    }
    
    \newpage
  }
  
  \mainmatter
}%
%    \end{macrocode}
% \end{macro}
%
% \subsection{Introduction and conclusion starter}
%
% \begin{macro}{\startintroduction}
% The front matter pages are created with the following code
%    \begin{macrocode}
\newcommand{\startintroduction}{%
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}
\label{ch:introduction}
\markboth{}{Introduction}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\startconclusion}
% The front matter pages are created with the following code
%    \begin{macrocode}
\newcommand{\startconclusion}{%
\chapter*{Conclusion}
\addcontentsline{toc}{chapter}{Conclusion}
\label{ch:conclusion}
\markboth{}{Conclusion}
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Miscellaneous}
% \begin{environment}{itemize*}
% A narrowed version of the |itemize| environment.
% implementation here.
%    \begin{macrocode}
\newenvironment{itemize*}%
  {\vspace{-2mm}\begin{itemize}%
    \setlength{\itemsep}{0pt}%
    \setlength{\parskip}{0pt}%
  }%
  {\end{itemize}\vspace{-2mm}%
  }
%    \end{macrocode}
% \end{environment}
%
% \Finale
\endinput