summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/mitthesis/mitthesis.cls
blob: 964da9c2ef081b42d0d116b2b9c7a27f4d08675e (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
% MIT thesis class

% !TEX encoding = UTF-8 Unicode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%  This file provides the mitthesis LaTeX class for formatting theses according to 
%%  MIT Libraries' requirements as of 2023.
%%
%%  This file's version and date:
	\def\versionno{1.09}
	\def\versiondate{2023/09/22\space}
%%
%%  Author: John H. Lienhard, V
%%          Department of Mechanical Engineering
%%          Massachusetts Institute of Technology
%%          Cambridge, MA 02139-4307 USA
%%
%%  This class is compatible with either pdfLaTeX or LuaTeX. 
%%
%%	Use an up-to-date LaTeX distribution: TeX Live 2023 or later is strongly recommended!
%%	All packages required by the class are in TeX Live and available from CTAN (https://ctan.org/). 
%%
%%
% =========================================================
%%
%% LICENSE:
%%
%% Copyright (c) 2023 John H. Lienhard
%%
%% Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 
%% associated documentation files (the "Software"), to deal in the Software without restriction, 
%% including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
%% and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 
%% subject to the following conditions:
%%
%% The above copyright notice and this permission notice shall be included in all copies or 
%% substantial portions of the Software.
%%
%% The software is provided "as is", without warranty of any kind, express or implied, including but 
%% not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. 
%% In no event shall the authors or copyright holders be liable for any claim, damages or other liability, 
%% whether in an action of contract, tort or otherwise, arising from, out of or in connection with the 
%% software or the use or other dealings in the software.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mitthesis}[\versiondate MIT Thesis Template (JHL)]

\LoadClass[12pt,openright]{report}% [twoside] option can be issued in the .tex file; point size must be set here.

\ExplSyntaxOn
  \str_const:Nn \ClassName {mitthesis}
\ExplSyntaxOff

%%%%%%%%%%%%%  Some compatibility for older latex distributions  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}% compare version to date; \If... added to latex 2020/10/01
\providecommand\IfPackageAtLeastTF{\@ifpackagelater}%    compare version to date; \If... added to latex 2020/10/01

\IfFormatAtLeastTF{2020/10/01}{%
	\typeout{^^JYour LaTeX format is dated \fmtversion. LaTeX distributions from 2022/11/01 or later are strongly recommended for best results^^J}
	}{%
	\ClassError{\ClassName}{Your LaTeX format is dated \fmtversion.  Formats dated 2022/11/01 or later are strongly recommended for this class. Older formats may generate errors}{Please UPDATE your LaTeX distribution to obtain best results. TeX Live is available for download at no charge: \string https://www.tug.org/texlive/.  You can try to click past the errors for now...}%
}

% check whether pdfmanagement (\DocumentMetadata) has been loaded (if not, fall back to hyperxmp)
\newif\ifmit@pdfmanagement
\ExplSyntaxOn
    \msg_new:nnn { \ClassName } { loading_hyperxmp } { pdfmanagement\ is\ not\ active.\ Will\ load\ hyperxmp\ instead. } 
	% As of 2021/07/23 we could instead use \IfPDFManagementActiveTF{true code}{false code}
    \IfFormatAtLeastTF{2020/10/01}{
        \bool_if:nTF
          {
            \bool_lazy_and_p:nn
              { \cs_if_exist_p:N \pdfmanagement_if_active_p: }
              { \pdfmanagement_if_active_p: }
          }
          { \mit@pdfmanagementtrue  }
          { \mit@pdfmanagementfalse
            \msg_warning:nn { \ClassName } { loading_hyperxmp } 
          }
    }{ \mit@pdfmanagementfalse
       \msg_warning:nn { \ClassName } { loading_hyperxmp } 
    }
\ExplSyntaxOff

% Enable pre-2020/10 formats to access essential macros later moved into LaTeX kernel
\ifdefined\NewDocumentCommand\else
  \RequirePackage{xparse}
\fi

%%%%%%%%%%%%%% Options for the class %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\IfFormatAtLeastTF{2022/11/01}{%
%	\typeout{^^JUsing native keyvalue support^^J}% diagnostic info
    \DeclareKeys{
    	fontset .store  = \mit@fontset ,
    	fontset .usage  = load ,
		lineno  .if     = mit@lineno ,
		lineno 	.usage	= load ,
		mydesign .if	= mit@mydesign,
		mydesign .usage	= load ,
    } 
    \SetKeys[\ClassName]{fontset=defaultfonts}%
	\DeclareUnknownKeyHandler[\ClassName]{\relax}% suppress warning about unused keys
	\ProcessKeyOptions
}{% And more compatibility code for distributions pre-2022/11     
    \RequirePackage{kvoptions}
    \SetupKeyvalOptions{
      family=\ClassName,
      prefix=mit@,
      setkeys=\kvsetkeys,
    }
    % set key [fontset] for font selection
    \DeclareStringOption[defaultfonts]{fontset}[]
    %
    % set key [lineno] to load package lineno
    \DeclareBoolOption{lineno}
    %
    % set key [mydesign] to input file mydesign.tex
    \DeclareBoolOption{mydesign}
    %
    \ProcessKeyvalOptions{\ClassName}
    %
    %% Turn off these keys now that we're done with them
    \NewDocumentCommand\mit@DisableOption{m}{%
      \DisableKeyvalOption[%
        action=ignore,%
        class=\ClassName%
      ]{#1}{\ClassName}%
    }
    \NewDocumentCommand\mit@DisableKeys{>{\SplitList{;}}m}{\ProcessList{#1}{\mit@DisableOption}}
    %
    \mit@DisableKeys{fontset;lineno;mydesign}%
    %
    %% Suppress warnings about unused global options
    \DeclareOption*{}  
    \ProcessOptions \relax
}

%%%%%%%%%%%%%  Line numbering (class option)  %%%%%%%%%%%%%%%%%%%%%%%%%

\ifmit@lineno
    \RequirePackage[mathlines]{lineno} 
    \AtBeginDocument{\linenumbers}
\fi

%%% Enable dropping lineno option without trashing .aux file
\providecommand{\@LN@col}[1]{\relax}
\providecommand{\@LN}[2]{\relax}


%%%%%%%%%%%%%  Patch table of contents, list of figures, and list of tables  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{etoolbox}% provides \patchcmd

% We'd like these sections to have pdf bookmarks and to have the two lists appear in the table of contents

\patchcmd{\tableofcontents}{\@starttoc{toc}}{\pdfbookmark[0]{Table of Contents}{toc}\@starttoc{toc}}{}{}
\patchcmd{\listoffigures}{\chapter*{\listfigurename}}{\chapter*{\listfigurename}\addcontentsline{toc}{chapter}{\protect\textbf{\listfigurename}}}{}{}
\patchcmd{\listoftables}{\chapter*{\listtablename}}{\chapter*{\listtablename}\addcontentsline{toc}{chapter}{\protect\textbf{\listtablename}}}{}{}


%%%%%%%%%%%%%  Geometry, mathtools, graphics, design, fonts, hyperrefs, bookmarks, footnotes %%%%%%%%%%%%%%%%%%%

\RequirePackage[letterpaper,top=1in,bottom=1in,left=1in,right=1in,marginparwidth=50pt,headsep=12pt,footskip=0.5in]{geometry}

\RequirePackage{mathtools}% loads and extends amsmath; must load before hyperref and unicode-math

% To free \eqref from the normal font (i.e., for use in section headings)
\renewcommand{\eqref}[1]{\textup{\hbox{\m@th{(\ignorespaces\ref{#1}\unskip\@@italiccorr)}}}}
%
% amsmath def:  \newcommand{\eqref}[1]{\textup{\tagform@{\ref{#1}}}}
%				\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}
%				\def\maketag@@@#1{\hbox{\m@th\normalfont#1}}

\RequirePackage{graphicx}

%%%%%%%%%%%%  Design options %%%%%%%%%%%%%%%%%%%%%%%

% the packages in mydesign should come before babel (which may be loaded by fontset) and before hyperref
\ifmit@mydesign
	\IfFileExists{mydesign.tex}{\input{mydesign.tex}}{%
	\ClassError{\ClassName}{Missing file mydesign.tex. This file is necessary when using the class option [mydesign] }{%
			You have called the class option mydesign, but the file mydesign.tex is not found.  You can download a copy of that file from
			https://ctan.org/tex-archive/macros/latex/contrib/mitthesis/MIT-thesis-template.}%  
	}%
\else
	\RequirePackage[hyperref,dvipsnames,svgnames,x11names]{xcolor}
%
	\RequirePackage{caption,subcaption}
%
    \RequirePackage{titlesec}    
    % these titlesec commands just automate the bold math in some headings (rest follows default styles)
    % NOT every font includes a bold math version, so you may need to use other math macros in the headings to get bold math <== 
    \titleformat{\section}{\mathversion{bold}\normalfont\Large\bfseries}{\thesection }{1em}{}
    \titleformat{\subsection}{\mathversion{bold}\normalfont\large\bfseries}{\thesubsection}{1em}{}
    \titleformat{\subsubsection}{\mathversion{bold}\normalfont\normalsize\bfseries}{\thesubsubsection}{1em}{}    
%
	\AtBeginDocument{
		\hypersetup{
		linkcolor=Blue3,% color names from xcolor package
		citecolor=Blue3,
		urlcolor=violet,
		filecolor=red, 
		}
		\ifmit@lineno
			\renewcommand{\linenumberfont}{\sffamily\tiny\color{violet}}
		\fi
	}	  	
\fi

%%%%%%%%%%%%  Font loading  %%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{iftex}[2019/11/07]% provides \ifpdftex, etc.

\typeout{^^JFontset key is \mit@fontset.^^J}
\IfFileExists{fontsets/\ClassName-\mit@fontset.tex}{% 2023/07/03
	\input{fontsets/\ClassName-\mit@fontset.tex}
}{%
	\ClassWarning{\ClassName}{^^JFontset file \ClassName-\mit@fontset.tex or subdirectory fontsets not found, will look for \mit@fontset.tex in your working directory.}
	\IfFileExists{\mit@fontset.tex}{% 2023/08/30
		\input{\mit@fontset.tex}
		}{
    	\ClassWarning{\ClassName}{^^JFontset file \mit@fontset.tex not found, using default fonts. You may need to place the fontset file into your working directory.}
    	\ifpdftex
        	\typeout{^^JLoading Computer Modern text and math fonts (default for pdftex).^^J}
        	\RequirePackage[T1]{fontenc}
        	\RequirePackage{bm}
        \else
        	\typeout{^^JLoading Latin Modern text and math fonts (default for unicode engines).^^J}
            \RequirePackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math}
            % suppress tiresome warnings about lack of integration between mathtools and unicode-math.
            % Unicode-math loads fontspec package, but default fonts are not selected by fontspec in this case.
        \fi
       }
}

%%%%%%%%%%%%  Hyperref %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage[psdextra]{hyperref}
% the new pdf-management scheme loads the bookmarks package internally.
% authors should use hypersetup to set details, in root .tex file

\urlstyle{same} 		% this changes font for \url to the current text font
\providecommand\hrefurl[2]{\href{#1}{#2}}% in case \DocumentMetadata has not been loaded
\RequirePackage{doi} 	% create macro for hyperlinking doi numbers

\ifmit@pdfmanagement\else
    \RequirePackage{hyperxmp}
\fi

% the user can alter these choices in the preamble, or by 
% using \AtBeginDocument{ \hypersetup{..} } in mydesign.tex 
\hypersetup{
    colorlinks=true,
 	pdfborder={0 0 0},
	bookmarksnumbered=true,
	bookmarksopen=true,
	bookmarksopenlevel=1,
	pdfpagelayout=SinglePage,
	pdfdisplaydoctitle=true,
	pdfstartview=Fit,
	pdfnewwindow=true,
%
	pdfcontactaddress={Massachusetts Institute of Technology, 77 Massachusetts Avenue},
    pdfcontactcity={Cambridge, MA},
    pdfcontactpostcode={02139-4307},
    pdfcontactcountry={USA},
    pdfcontacturl={https://dspace.mit.edu/handle/1721.1/7582},% DSPACE@MIT theses page
}
 		
%%%%%%%%%%%%  PDF bookmark strings  %%%%%%%%%%%%%%%%

%%% Since \bm may be useful in headings, use this fix to reduce frequency with which alternate 
%%%   bookmark strings must be given with commands such as \section{ \texorpdfstring{texstring}{pdfstring} }
\pdfstringdefDisableCommands{%
    \def\bm#1#{\relax}%
}
%%% Let's disable \( and \) in pdf bookmarks
\pdfstringdefDisableCommands{%
    \def\({\relax}%
    \def\){\relax}%
}
%%% Let's also make sure \NoCaseChange in section headings won't break pdf bookmarks
\pdfstringdefDisableCommands{%
    \let\NoCaseChange\relax%
}
%%% Let's just remove citations from pdf bookmarks
\pdfstringdefDisableCommands{%
    \def\cite{\@gobble}%
}
%%% Let's fix \eqref in pdf bookmarks
\pdfstringdefDisableCommands{%
    \def\eqref#1{(\ref{#1})}%
}
%%% Let's make sure footnotes in section headings don't break pdf bookmarks. (Note: \footnote, as redefined below, is protected)
% \patchcmd{\section}{\sectionmark}{\let\footnote\@gobble\sectionmark}{}{}% <== not needed unless you implement running headers
\pdfstringdefDisableCommands{%
  \def\footnote#1{}%
}


\ExplSyntaxOn
%\debug_on:n {all}

%%%%%%%%%%  Commas between successive footnotes %%%

\cs_new:Npn   \__mitthesis_NoteComma:n { \peek_meaning:NT \footnote {\textsuperscript{\mdseries,}} }
\cs_new_eq:NN \__savefootnote \footnote
\cs_gset_protected:Npn \footnote #1    { \__savefootnote{#1}\__mitthesis_NoteComma:n } 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%  MACROS FOR HANDLING TITLE AND ABSTRACT PAGES  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%  Degree Date Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\tl_new:N \g__dd_month_tl	
\tl_new:N \g__dd_year_tl
%\cs_generate_variant:Nn \str_casefold:n {e} % not def'd until 2022/10/16, omit for backward compatibility
\cs_generate_variant:Nn \tl_gremove_all:Nn {No}
\cs_new_protected:Nn \__dd_setdates:nn {
	\tl_gset:Nn \g__dd_month_tl {#1}
	\tl_gset:Nn \g__dd_year_tl  {#2}
	\tl_gremove_all:No \g__dd_month_tl { \space }
	\tl_gremove_all:No \g__dd_year_tl { \space }
 	\str_case_e:nnF 
%		{ \str_casefold:e { \tl_to_str:N  \g__dd_month_tl } } % not def'd until 2022/10/16
		{ \str_lowercase:f { \tl_to_str:N  \g__dd_month_tl } }
	 	{ {february}{} {may}{} {june}{} {september}{}}
		{ \msg_error:nnn { \ClassName } { wrong_month } {#1} } 
}
\msg_new:nnnn { \ClassName } { wrong_month } {The\ degree\ month\ must\ be\ one\ of\ February,\ May,\ June,\ or\ September.} {You\ cannot\ use\ #1\ as\ the\ degree\ month.}

\cs_generate_variant:Nn \text_titlecase:n {o,V}
\NewDocumentCommand\DegreeDate{mm}{%   {month}{year}	
	\__dd_setdates:nn {#1}{#2}
	\cs_new:Npn \DegreeMonth { \text_titlecase:V { \g__dd_month_tl } }
	\cs_new:Npn \DegreeYear  { \text_titlecase:V { \g__dd_year_tl  } }
}
\msg_new:nnnn { \ClassName } { no_degree_date } {Missing\ degree\ date!}{
			You\ MUST\ issue\ the\ \DegreeDate{month}{year}\ command\ between\ \string\begin{document}\ and\ \string\maketitle.}
		
\NewDocumentCommand\ThesisDate{m}{
	\tl_if_exist:NTF \g_dd_thesisdate_tl { \g_dd_thesisdate_tl } { \__dd_thesisdate:n {#1} }% will use only value given first
}
\cs_new_protected:Nn \__dd_thesisdate:n {
	\tl_new:N  \g_dd_thesisdate_tl
	\tl_gset:Nx \g_dd_thesisdate_tl { \tl_trim_spaces:n {#1} }
}

%%%%%%%%%%  End Degree Date Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%  Author Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\seq_new:N \g_author_name_seq
\seq_new:N \g_author_department_seq
\seq_new:N \g_author_prevdegree_seq
\seq_new:N \g_author_secondprevdegree_seq
\seq_new:N \g_author_thirdprevdegree_seq
\seq_new:N \g_author_fourthprevdegree_seq
\int_gzero_new:N \g_author_authorcnt_int

\NewDocumentCommand\Author{mm O{}O{}O{}O{} }
 {
 	\tl_if_blank:nTF{#1}{
		\msg_error:nn { \ClassName } { blank_author }
		}{
		  \__author_data_add:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 }
		}
	\tl_if_blank:nT{#2}{\msg_error:nn {\ClassName} {blank_author_dep}}
 }
\cs_new_protected:Nn \__author_data_add:nnnnnn
 {
	\int_gincr:N \g_author_authorcnt_int
	\seq_gput_right:cx  { g_author_name_seq }        { \tl_trim_spaces:n {#1} } 
	\seq_gput_right:cx  { g_author_department_seq }  { \tl_trim_spaces:n {#2} }
	\seq_gput_right:cx  { g_author_prevdegree_seq }  { \tl_trim_spaces:n {#3} }
	\seq_gput_right:cx  { g_author_secondprevdegree_seq } { \tl_trim_spaces:n {#4} }
	\seq_gput_right:cx  { g_author_thirdprevdegree_seq }  { \tl_trim_spaces:n {#5} }
	\seq_gput_right:cx  { g_author_fourthprevdegree_seq } { \tl_trim_spaces:n {#6} }
 }
\msg_new:nnnn { \ClassName } { blank_author } {Missing\ author\ name,\ check\ for\ blank\ in\ \Author\ command.}{%
			You\ MUST\ provide\ an\ author\ name\ using\ the\ \Author{name}{department}\ command.}
\msg_new:nnnn { \ClassName } { blank_author_dep } {Missing\ author\ department,\ check\ for\ blank\ in\ \Author\ command.}{%
			You\ MUST\ provide\ the\ author's\ department\ using\ the\ \Author{name}{department}\ command.}

\NewExpandableDocumentCommand\CopyrightAuthor{}{
	\tl_if_exist:NTF \g__author_ca_tl
		{ \g__author_ca_tl }
		{ \__author_copyrightauthor: \g__author_ca_tl }
}

\cs_new_protected:Nn \__author_copyrightauthor: {
	\tl_new:N       \g__author_ca_tl
	\int_zero_new:N \l__author_autcrcnt_int
	\int_incr:N     \l__author_autcrcnt_int
    \tl_gset:Nx     \g__author_ca_tl  { \seq_item:cn { g_author_name_seq } { \l__author_autcrcnt_int } }
	\int_incr:N     \l__author_autcrcnt_int
	\int_while_do:nNnn { \l__author_autcrcnt_int } < { \g_author_authorcnt_int }
		{
			\tl_gput_right:Nx \g__author_ca_tl {,\ \seq_item:cn { g_author_name_seq } { \l__author_autcrcnt_int } }
			\int_incr:N \l__author_autcrcnt_int   
		}
	\int_compare:nNnT { \l__author_autcrcnt_int } = { \g_author_authorcnt_int } {
  	    \tl_gput_right:Nx \g__author_ca_tl {\ and\ \seq_item:cn { g_author_name_seq } { \l__author_autcrcnt_int } }
	}
	\tl_set:Nn \l_tmpa_tl {\tl_item:Nn \g__author_ca_tl {-1} }% get last token
 	\str_case_e:nnT 
		{ \l_tmpa_tl  }
	 	{ {.}{} }
		{ \__copyright_remove_period:N { \g__author_ca_tl } }% remove last token if it is a period 
	\__author_pdfcopyrightauthor:
}
\cs_new:Nn \__copyright_remove_period:N
	{
		\tl_gset:Nx #1 { \tl_range:Nnn #1 { 1 } { \tl_count:N #1 - 1 } }
	}
\cs_new_protected:Nn \__author_pdfcopyrightauthor: {
	\tl_new:N       \g__author_pdfca_tl
	\int_set:Nn     \l_tmpa_int {1}
    \tl_gset:Nx     \g__author_pdfca_tl  { { \seq_item:cn { g_author_name_seq } { \l_tmpa_int } } }
	\int_until_do:nNnn { \l_tmpa_int } = { \g_author_authorcnt_int }
		{
			\int_incr:N \l_tmpa_int   
			\tl_gput_right:Nx \g__author_pdfca_tl {,\ { \seq_item:cn { g_author_name_seq } { \l_tmpa_int } } }
		}	
}


\cs_new:Nn \__author_block: {
	\int_zero_new:N \l__author_authorno_int
	\int_incr:N     \l__author_authorno_int
	\int_compare:nNnTF { \g_author_authorcnt_int } = {0} {
		\msg_error:nn { \ClassName } { no_author }
	}	
	{by\par
	\int_until_do:nNnn { \l__author_authorno_int } = { \g_author_authorcnt_int } {
		\seq_item:cn { g_author_name_seq } { \l__author_authorno_int } \par
		\tl_set:Nx \l_tmpa_tl { \seq_item:cn { g_author_prevdegree_seq } { \l__author_authorno_int} }
		\tl_if_empty:NF \l_tmpa_tl { \normalsize \l_tmpa_tl }% no linebreak or par for empty items
		\tl_set:Nx \l_tmpa_tl { \seq_item:cn { g_author_secondprevdegree_seq } { \l__author_authorno_int} } 
		\tl_if_empty:NF \l_tmpa_tl { \linebreak\normalsize \l_tmpa_tl  }
		\tl_set:Nx \l_tmpa_tl { \seq_item:cn { g_author_thirdprevdegree_seq } { \l__author_authorno_int} } 
		\tl_if_empty:NF \l_tmpa_tl { \linebreak\normalsize \l_tmpa_tl  }
		\tl_set:Nx \l_tmpa_tl { \seq_item:cn { g_author_fourthprevdegree_seq } { \l__author_authorno_int} } 
		\tl_if_empty:NF \l_tmpa_tl { \linebreak\normalsize \l_tmpa_tl  }
		\par and\par
		\int_incr:N \l__author_authorno_int
	}
		\seq_item:cn { g_author_name_seq } { \l__author_authorno_int } \par
		\tl_set:Nx \l_tmpa_tl { \seq_item:cn { g_author_prevdegree_seq } { \l__author_authorno_int} }
		\tl_if_empty:NF \l_tmpa_tl { \normalsize \l_tmpa_tl }% no linebreak or par for empty items
		\tl_set:Nx \l_tmpa_tl { \seq_item:cn { g_author_secondprevdegree_seq } { \l__author_authorno_int} } 
		\tl_if_empty:NF \l_tmpa_tl { \linebreak\normalsize \l_tmpa_tl }
		\tl_set:Nx \l_tmpa_tl { \seq_item:cn { g_author_thirdprevdegree_seq } { \l__author_authorno_int} } 
		\tl_if_empty:NF \l_tmpa_tl { \linebreak\normalsize \l_tmpa_tl  }
		\tl_set:Nx \l_tmpa_tl { \seq_item:cn { g_author_fourthprevdegree_seq } {\l__author_authorno_int} } 
		\tl_if_empty:NF \l_tmpa_tl { \linebreak\normalsize \l_tmpa_tl  }
    	\par\medskip 
    }
}
\msg_new:nnnn { \ClassName } { no_author }
		{ Missing\ author!\ You\ must\ issue\ the\ \Author{name}{department}\ command. }{
		You\ MUST\ issue\ the\ \Author{name}{department}\ command\ after\ \string\begin{document}\ and\ before\ \string\maketitle. }

\cs_new:Nn \__author_abstractblock: {
	\int_zero_new:N \l__author_authorno_int
	\int_incr:N     \l__author_authorno_int
	\int_compare:nNnTF { \g_author_authorcnt_int } = {0} {
		\msg_error:nn { \ClassName } { no_author }
		}	
		{by\par
		\int_until_do:nNnn { \l__author_authorno_int } = { \g_author_authorcnt_int } {
			\seq_item:cn { g_author_name_seq } { \l__author_authorno_int }
			\par and\par
			\int_incr:N \l__author_authorno_int
		}%
		\seq_item:cn { g_author_name_seq } { \l__author_authorno_int } 
    }%
}

%%%%%%%%%%  End Author Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%  Supervisor Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\seq_new:N \g_supervisor_name_seq
\seq_new:N \g_supervisor_title_seq
\int_gzero_new:N \g_supervisor_supervisorcnt_int

\NewDocumentCommand\Supervisor{mm}{
	\tl_if_blank:nTF{#1}{
		\msg_error:nn { \ClassName } { blank_supervisor }
		}{
		\__supervisor_data_add:nn {#1} {#2}
	}
	\tl_if_blank:nT{#2}{\msg_error:nn { \ClassName } { blank_supervisor_title } }
}
\msg_new:nnnn { \ClassName } { blank_supervisor }
		{ Missing\ supervisor\ name, check\ for\ blank\ in\ \Supervisor{name}{title}\ command.}{
			You\ MUST\ provide\ the\ supervisor's\ name\ using\ the\ \Supervisor{name}{title}\ command.}
\msg_new:nnnn { \ClassName } { blank_supervisor_title }
		{ Missing\ supervisor\ title, check\ for\ blank\ in\ \Supervisor{name}{title}\ command. }{
			You\ MUST\ provide\ the\ supervisor's\ title\ using\ the\ \Supervisor{name}{title}\ command.}

\cs_new_protected:Nn \__supervisor_data_add:nn
 {
	\int_gincr:N \g_supervisor_supervisorcnt_int
	\seq_gput_right:cx  { g_supervisor_name_seq }       { \tl_trim_spaces:n {#1} } 
	\seq_gput_right:cx  { g_supervisor_title_seq } { \tl_trim_spaces:n {#2} }
 }


\cs_new:Nn \__supervisor_abstractblock: {
	\int_zero_new:N \l__supervisor_supervisorno_int
	\int_incr:N     \l__supervisor_supervisorno_int
	\setlength{\parindent}{0pt}
	\par\bigskip
	\int_compare:nNnTF { \g_supervisor_supervisorcnt_int } = {0} {
		\msg_error:nn { \ClassName } { no_supervisor }
		}	
		{\int_until_do:nNnn { \l__supervisor_supervisorno_int } = { \g_supervisor_supervisorcnt_int } {
			Thesis\ supervisor:\space \seq_item:cn { g_supervisor_name_seq } { \l__supervisor_supervisorno_int }\par
			Title:\space              \seq_item:cn { g_supervisor_title_seq } { \l__supervisor_supervisorno_int }\par\medskip
			\int_incr:N \l__supervisor_supervisorno_int
		}
			Thesis\ supervisor:\space  \seq_item:cn { g_supervisor_name_seq } { \l__supervisor_supervisorno_int }\par
			Title:\space  \seq_item:cn { g_supervisor_title_seq } { \l__supervisor_supervisorno_int }\ignorespaces
    }
}
\msg_new:nnnn { \ClassName } { no_supervisor }
		{ Missing\ supervisor!\ You\ must\ issue\ the\ \Supervisor{name}{title}\ command. }{
		You\ MUST\ issue\ the\ \Supervisor{name}{title}\ command\ after\ \string\begin{document}\ and\ before\ \string\maketitle. }


%%%%%%%%%%  End Supervisor Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%  Acceptor Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\seq_new:N \g_acceptor_name_seq
\seq_new:N \g_acceptor_department_seq
\seq_new:N \g_acceptor_title_seq
\int_gzero_new:N \g_acceptor_acceptorcnt_int

\bool_new:N \g__acceptor_title_tf_bool
\bool_gset_false:N \g__acceptor_title_tf_bool

\NewDocumentCommand\Acceptor{mmm}{
	\tl_if_blank:nTF{#1}{
		\msg_error:nn { \ClassName } { blank_acceptor }
		}{
		\__acceptor_data_add:nnn {#1} {#2} {#3}
	}
	\tl_if_blank:nT{#2}{\msg_error:nn {\ClassName} {blank_acceptor_dep}}
	\tl_if_blank:nTF{#3}{
		\bool_gset_true:N \g__acceptor_title_tf_bool
		\msg_warning:nn { \ClassName } { blank_acceptor_title }}{}
}
\msg_new:nnnn { \ClassName } { blank_acceptor }
		{ Missing\ acceptor\ name, check\ for\ blank\ in\ \Acceptor{name}{department}{title}\ command.}{
			You\ MUST\ provide\ the\ acceptor's\ name\ using\ the\ \Acceptor{name}{department}{title}\ command.}
\msg_new:nnnn { \ClassName } { blank_acceptor_dep }
		{ Missing\ acceptor\ department,\ check\ for\ blank\ in\ \Acceptor{name}{department}{title}\ command. }{
			You\ MUST\ provide\ the\ acceptor's\ department\ using\ the\ \Acceptor{name}{department}{title}\ command.}
\msg_new:nnn { \ClassName } { blank_acceptor_title }
		{ Missing\ acceptor\ title\ (blank\ in\ \Acceptor{name}{department}{title}\ command).\ Perhaps\ you\ are\ trying\ to\ save\ vertical\ space?\ 
			You\ can\ put\ the\ acceptor\ title\ into\ department\ field\ instead.\ For\ consistency,\ I\ will\ omit\ titles\ of\ ALL\ acceptors.}

\cs_new_protected:Nn \__acceptor_data_add:nnn
 {
	\int_gincr:N \g_acceptor_acceptorcnt_int
	\seq_gput_right:cx  { g_acceptor_name_seq }       { \tl_trim_spaces:n {#1} } 
	\seq_gput_right:cx  { g_acceptor_department_seq } { \tl_trim_spaces:n {#2} }
	\seq_gput_right:cx  { g_acceptor_title_seq }      { \tl_trim_spaces:n {#3} }
 }

%%%%%%%%%%  End Acceptor Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%  Degree Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\seq_new:N \g_degree_name_seq
\seq_new:N \g_degree_department_seq
\int_gzero_new:N \g_degree_degreecnt_int
\int_gzero_new:N \g__degree_degreeflag_int

\NewDocumentCommand\Degree{mm}
 {
	\tl_if_blank:nTF {#1} {
		\msg_error:nn { \ClassName } { blank_degree }
		}{
		  \__degree_data_add:nn { #1 } { #2 } 
		}
	\tl_if_blank:nT {#2} {
		\int_gset_eq:NN \g__degree_degreeflag_int \g_degree_degreecnt_int
		\msg_warning:nnx { \ClassName } { blank_degree_dep } { \int_to_arabic:n { \g__degree_degreeflag_int } }
		\tl_if_blank:nT {#1} { \int_gincr:N \g__degree_degreeflag_int }% in case both are blank
		}
 }
\cs_new_protected:Nn \__degree_data_add:nn
 {
	\int_gincr:N \g_degree_degreecnt_int
	\seq_gput_right:cx  { g_degree_name_seq }        { \tl_trim_spaces:n {#1} } 
	\seq_gput_right:cx  { g_degree_department_seq }  { \tl_trim_spaces:n {#2} }
 }
\msg_new:nnnn { \ClassName } { blank_degree } {Missing\ degree\ name,\ check\ for\ blank\ in\ \Degree\ command.} 
			{You\ MUST\ provide\ a\ degree\ name\ using\ the\ \Degree{name}{department}\ command.}
\msg_new:nnnn { \ClassName } { blank_degree_dep } {Missing\ degree\ department\ for\ Degree\ command\ number\ 
			#1.\ Will\ treat\ as\ a\ duplicate\ of\ previous\ department.}{}
		
\int_zero_new:N \l__degree_degreeno_int
\int_zero_new:N \l__degree_departmentno_int

\cs_new:Nn \__degree_block: {
	\int_compare:nNnTF { \g_degree_degreecnt_int } = {0} {
		\msg_error:nn { \ClassName } { no_degree }
	}	
	\int_zero_new:N \l__degree_degreeno_int
	\int_incr:N     \l__degree_degreeno_int
	\int_zero_new:N \l__degree_departmentno_int
	\int_incr:N     \l__degree_departmentno_int
	\cs_new:Nx \__degree_prevdept: {\seq_item:cn { g_degree_department_seq } { \l__degree_departmentno_int } }
	\cs_new:Nn \__degree_currdept: {}
	\mbox {Submitted\ to\ the\ } \mbox {\__degree_prevdept:}
	\int_until_do:nNnn { \l__degree_departmentno_int } = { \g_degree_degreecnt_int } {
		\int_incr:N      \l__degree_departmentno_int
		\cs_set:Nx \__degree_currdept: {\seq_item:cn { g_degree_department_seq } { \l__degree_departmentno_int } }
		\int_compare:nNnTF { \l__degree_departmentno_int } = {\g__degree_degreeflag_int } { \scan_stop: } 
			{
				\mbox {\ and\ the}\linebreak
				\mbox {\__degree_currdept: }
			}
		}
    \linebreak \mbox {in\ partial\ fulfillment\ of\ the\ requirements\ for\ the\ 
		\int_compare:nNnTF { \g_degree_degreecnt_int } > {1} {degrees} {degree}
	\ of}
	\par\medskip
	\int_until_do:nNnn { \l__degree_degreeno_int } = { \g_degree_degreecnt_int } {
    	\text_uppercase:n {\seq_item:cn { g_degree_name_seq } { \l__degree_degreeno_int }}\par and\par
		\int_incr:N     \l__degree_degreeno_int
		}
    \text_uppercase:n {\seq_item:cn { g_degree_name_seq } { \l__degree_degreeno_int }}\par\medskip
}
\msg_new:nnnn { \ClassName } { no_degree }
		{ Missing\ degree!\ You\ must\ issue\ the\ \Degree{name}{department}\ command. }{
		You\ MUST\ issue\ the\ \Degree{name}{department}\ command\ after\ \string\begin{document}\ and\ before\ \string\maketitle.\  You\ do\ want\ the\ degree,\ don't\ you?}


\cs_new:Nn \__degree_abstractblock: {
	\int_set:Nn  \l__degree_degreeno_int {1}
	\int_set:Nn  \l__degree_departmentno_int {1}
	\cs_set:Nx \__degree_prevdept: {\seq_item:cn { g_degree_department_seq } { \l__degree_departmentno_int } }
	\cs_set:Nn \__degree_currdept: {}
	\mbox {Submitted\ to\ the\ }\mbox{\__degree_prevdept:}
	\int_until_do:nNnn { \l__degree_departmentno_int } = { \g_degree_degreecnt_int } {
		\int_incr:N     \l__degree_departmentno_int
		\cs_set:Nx \__degree_currdept: {\seq_item:cn { g_degree_department_seq } { \l__degree_departmentno_int } }
		\int_compare:nNnTF { \g__degree_degreeflag_int } = { \g_degree_degreecnt_int } { \scan_stop: } 
			{
				\mbox {\ and\ the}\linebreak
				\mbox { \__degree_currdept: }
			}
		}
    \linebreak \mbox{on\ \g_dd_thesisdate_tl\ in\ partial\ fulfillment\ of\ the\ requirements\ for\ the\ 
		\int_compare:nNnTF { \g_degree_degreecnt_int } > {1} {degrees} {degree}
	\ of}
	\par\medskip
	\int_until_do:nNnn { \l__degree_degreeno_int } = { \g_degree_degreecnt_int } {
    	\text_uppercase:n {\seq_item:cn { g_degree_name_seq } { \l__degree_degreeno_int }}\par and\par
		\int_incr:N     \l__degree_degreeno_int
		}
    \text_uppercase:n {\seq_item:cn { g_degree_name_seq } { \l__degree_degreeno_int }}\par\medskip
}

%%%%%%%%%%  End Degree Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%  Signature Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NewDocumentCommand\SignatureBlockSize{m}{
	\__signature_sigsize:n {#1}
}
\tl_new:N \g__signature_sigsize_tl
\cs_new_protected:Nn \__signature_sigsize:n 
  {
	\tl_gset:Nf \g__signature_sigsize_tl { \tl_trim_spaces:n {#1} }
	\token_case_meaning:NnF \g__signature_sigsize_tl
	{ 
		\normalsize {} \small {} \footnotesize{} \scriptsize{} \tiny{}
	} {
		\msg_error:nn { \ClassName } { weird_sigsize }
	}
  }

\cs_new:Nn \__signature_block: {
	\int_compare:nNnT { \g_supervisor_supervisorcnt_int } = {0} {
		\msg_error:nn { \ClassName } { no_supervisor }% this message is def'd in Abstract supervisor block
	}	
	\int_compare:nNnT { \g_acceptor_acceptorcnt_int } = {0} {
		\msg_error:nn { \ClassName } { no_acceptor }
	}	
	\tl_if_exist:NF \g_dd_thesisdate_tl { 
		\msg_error:nn { \ClassName } { no_thesis_date }
	}
	\int_gzero_new:N \g__signature_autno_int
	\int_gzero_new:N \g__signature_supno_int
	\int_gzero_new:N \g__signature_accno_int
    \g__signature_sigsize_tl
    \begin{tabbing}
    \hspace{1.35in} \= \hspace{1in} \kill
	\int_do_while:nNnn { \g__signature_autno_int } < { \g_author_authorcnt_int } {
		\int_gincr:N  \g__signature_autno_int
		Authored\ by: \> \seq_item:cn { g_author_name_seq } { \g__signature_autno_int } \\  
		\> \seq_item:cn { g_author_department_seq } { \g__signature_autno_int } \\
		\> \g_dd_thesisdate_tl \\[1em]
	}
	\int_do_while:nNnn { \g__signature_supno_int } < { \g_supervisor_supervisorcnt_int } {
		\int_gincr:N  \g__signature_supno_int
		Certified\ by: \> \seq_item:cn { g_supervisor_name_seq } { \g__signature_supno_int } \\
		\> \seq_item:cn { g_supervisor_title_seq } { \g__signature_supno_int },\ Thesis\ Supervisor\\[1em]
	}
	\int_compare:nNnF { \g_acceptor_acceptorcnt_int } = {0} {
    	\int_do_while:nNnn { \g__signature_accno_int } < { \g_acceptor_acceptorcnt_int } {
    		\int_gincr:N  \g__signature_accno_int
    		Accepted\ by: \> \seq_item:cn { g_acceptor_name_seq } { \g__signature_accno_int } \\
    		\> \seq_item:cn { g_acceptor_department_seq } { \g__signature_accno_int }
    			\bool_if:NF \g__acceptor_title_tf_bool
    			{
    				\\
    				\> \seq_item:cn { g_acceptor_title_seq } { \g__signature_accno_int }
    			}
    		\\[1em]
    	}
	}
	\end{tabbing}
}
\msg_new:nnnn { \ClassName } { weird_sigsize }
		{ \SignatureBlockSize\ expects\ a\ font-sizing\ command,\ such\ as\ \small,\ \footnotesize,\ etc.}{You\ used\ a\ weird\ input\ value\ 			here.\ If\ you\ did\ so\ deliberately,\ try\ continuing.}	
\msg_new:nnnn { \ClassName } { no_acceptor }
		{ Missing\ acceptor!\ You\ must\ issue\ the\ \Acceptor{name}{department}{title}\ command. }{
		You\ MUST\ issue\ the\ \Acceptor{name}{department}{title}\ command\ after\ \string\begin{document}\ and\ before\ \string\maketitle.}
\msg_new:nnnn { \ClassName } { no_thesis_date }
		{ Missing\ thesis\ date!\ You\ must\ issue\ the\ \ThesisDate{Date\ thesis\ is\ submitted}\ command.}{
		You\ MUST\ issue\ the\ \ThesisDate{Date thesis is submitted}\ command\ after\ \string\begin{document}\ and\ before\ \string\maketitle.}

% If for some reason you don't want a warning when you omit \Acceptor
\NewDocumentCommand\SuppressAcceptorError{}
  {
  	\msg_redirect_name:nnn { \ClassName } { no_acceptor } { none }
  }

%%%%%%%%%%  End Signature Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%  Copyright Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Directly add the xmp property that shows work is copyrighted. See l3pdfmeta.pdf. 
% This is not automatic with \DocumentMetadata. "True" must be capitalized.
%
\cs_if_exist:NT \pdfmeta_xmp_add:n {\pdfmeta_xmp_add:n{<xmpRights:Marked>True</xmpRights:Marked>}}

\tl_new:N \g_copyright_ccname_tl
\tl_new:N \g_copyright_cclicensetext_tl
\tl_new:N \g_copyright_copyrightlicencse_tl
\tl_new:N \g_copyright_pdfrightstext_tl
\tl_new:N \g__copyright_crwords_tl_
\tl_new:N \g__copyright_mitpermissionlast_tl

\tl_new:N \g_copyright_mitpermission_tl
\tl_gset:Nn \g__copyright_mitpermissionlast_tl {to\ MIT\ a\ nonexclusive,\ worldwide,\ irrevocable,\ royalty-free\ license\ to\ exercise\ any\ and\ all\ rights\ under\ copyright,\ including\ to\ reproduce,\ preserve,\ distribute\ and\ publicly\ display\ copies\ of\ the\ thesis,\ or\ release\ the\  thesis\ under\ an\ open-access\ license.}

\bool_new:N \g__cclicense_tf_bool
\bool_gset_false:N \g__cclicense_tf_bool

\NewDocumentCommand\CClicense{mm}{
	\__copyright_licensedata:nn {#1}{#2}
}
\cs_new_protected:Nn \__copyright_licensedata:nn 
  {
	\tl_gset:Nf \g_copyright_cclicensetext_tl {\hrefurl{ \tl_trim_spaces:n {#2} }{ \tl_trim_spaces:n {#1} } }% #1 - text, #2 - url  
	\tl_gset:Nx \g_copyright_ccname_tl        { \tl_trim_spaces:n {#1} } 
	\bool_gset_true:N \g__cclicense_tf_bool
	\cs_if_exist:NT \pdfmeta_xmp_add:n {
			\pdfmeta_xmp_add:n {<xmpRights:WebStatement>#2</xmpRights:WebStatement>}
	}
	\cs_if_exist:NTF \msg_note:nnn % added to expl3 2021/05/18
	  {
		\msg_note:nnn { \ClassName } { cclicense} {#1}
	  }
	  {
		\msg_log:nnn  { \ClassName } { cclicense} {#1}
	  } 
  }
\msg_new:nnn { \ClassName } { cclicense } { Using\ Creative\ Commons\ License\ #1.}


%%%%%%%%%%  End Copyright Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%  Title page Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RenewDocumentCommand{\title}{m}
	{
		\__mitthesis_title:n { #1 }
		\hypersetup{
			pdftitle={\g_mitthesis_title_tl},
		}
	}
%
\tl_new:N \g_mitthesis_title_tl
%
\cs_new_protected:Nn \__mitthesis_title:n
	{
		\tl_gset:Nn \g_mitthesis_title_tl { \tl_trim_spaces:n {#1} }
	}

\tl_new:N \g_titlepage_institution_name_tl
\tl_gset:Nn \g_titlepage_institution_name_tl {Massachusetts\ Institute\ of\ Technology} 
\cs_new:Npn \Institution #1 { \tl_gset:Nn \g_titlepage_institution_name_tl {\tl_trim_spaces:n #1} }


\RenewDocumentCommand\maketitle{s}{%
	\cs_if_exist:NTF \DegreeMonth { \scan_stop: } { \msg_error:nn { \ClassName } { no_degree_date } }% msg defined in degree-date section
%	
	\bool_if:NTF \g__cclicense_tf_bool { 
		\tl_gset:Nn \g_copyright_copyrightlicencse_tl 
			{This\ work\ is\ licensed\ under\ a\ \mbox{\g_copyright_cclicensetext_tl}\ license.\par\g_copyright_mitpermission_tl}
		\tl_gset:Nn \g_copyright_pdfrightstext_tl 	 
			{This\ work\ is\ licensed\ under\ a\ \g_copyright_ccname_tl\ license.\ \g_copyright_mitpermission_tl}
	}{
		\tl_gset:Nn \g_copyright_copyrightlicencse_tl 
			{All\ rights\ reserved. \par\g_copyright_mitpermission_tl}
		\tl_gset:Nn \g_copyright_pdfrightstext_tl 	 
			{All\ rights\ reserved.\ \g_copyright_mitpermission_tl}
   }
   \int_compare:nNnTF {\g_author_authorcnt_int} > {1} 
   		{   
			\tl_gset:Nn \g__copyright_crwords_tl_ {The\ authors\ hereby\ grant} 
		}
		{
			\tl_gset:Nn \g__copyright_crwords_tl_ {The\ author\ hereby\ grants} 
		}
    \IfBooleanTF{#1}{%
	    \tl_gset:Nn \g_copyright_mitpermission_tl {\scan_stop:}
    }{
	    \tl_gset:Nn \g_copyright_mitpermission_tl {\g__copyright_crwords_tl_\ \g__copyright_mitpermissionlast_tl}
    }
% 
	\clearpage
	\thispagestyle{empty}%
	\phantomsection\addcontentsline{toc}{chapter}{\protect\textbf{Title page}}%
 	{\centering \vbox_to_ht:nn { \vsize }% to prevent signature block from breaking across page
        {
            \setlength{\parskip}{0.5\baselineskip plus 2pt minus 2pt}\setlength{\parindent}{0pt}%
            {\Large\textbf{\g_mitthesis_title_tl}\par}
            \__author_block:
            \par
            \__degree_block:
            at\ the\par
            \text_uppercase:n { \g_titlepage_institution_name_tl }\par
            \DegreeMonth\ \DegreeYear
            \par
            \copyright\space\DegreeYear\space\CopyrightAuthor\@.\c_space_token \g_copyright_copyrightlicencse_tl % In case name ends with III, IV, V,...
            \par
            \skip_vertical:n {\baselineskip}
            %
            \__signature_block:
        	\vfill % to avoid overstretched glue
		}
	}%
    	\hypersetup{
    		pdfcopyright={Copyright\ \DegreeYear\ by\ \CopyrightAuthor.\ \g_copyright_pdfrightstext_tl},
    		pdfauthor={\g__author_pdfca_tl},
    		pdfcaptionwriter = {\g__author_pdfca_tl},
    	}
	\cleardoublepage
}

%%%%%%%%%%  End title page module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%  Abstract page Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% to change abstract name, follow either of these approaches in your preamble:
%	\RenewExpandableDocumentCommand\abstractname{}{Summary}
%	\renewcommand\abstractname{Summary}

\RenewDocumentEnvironment{abstract}{+b}{
	\newpage
	\phantomsection\addcontentsline{toc}{chapter}{\protect\textbf{\abstractname}}
    \begin{center}
        {\large{\textbf{\g_mitthesis_title_tl}}\par}
        \setlength{\parskip}{0.5\baselineskip plus 2pt minus 2pt}
        \__author_abstractblock:
        \par
        \__degree_abstractblock:
	\end{center}
    \skip_vertical:n {\baselineskip}
	\textbf{ \text_uppercase:n {\abstractname} }\par
	\skip_vertical:n { 0.5em }
	\tl_trim_spaces:n {#1}
	\tl_if_blank:nT {#1} { MISSING\ ABSTRACT!  \msg_error:nn { \ClassName } { missing_abstract } }
}{
	\__supervisor_abstractblock:
	\cleardoublepage
}
\msg_new:nnnn { \ClassName } { missing_abstract } {Missing\ Abstract!! } { No\ file\ was\ input\ for\ the\ abstract.\  You\ need\ to\ do\ \string\input{abstract.tex}.}

%%%%%%%%%%  End abstract page Module  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\debug_off:n {all}
\ExplSyntaxOff

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% End title and abstract page codes  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%  A nomenclature environment  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\providecommand{\nomname}{Nomenclature}  
\newlength\nomenwidth
\newlength\savitemsep

% nomenclature entries
\NewDocumentCommand\entry{m m}{%
    \item[#1\hfill]#2%
    \@itempenalty=-\@lowpenalty
}
% nomenclature subheadings 
\NewDocumentCommand\EntryHeading{m}{%
	\itemsep3\p@ plus 1\p@ minus 1\p@
    \goodbreak\item[\itshape#1\hfill]\setlength\itemsep\savitemsep\@itempenalty=1000
}
%
%   Increase first optional argument to a dimension > 2em if wide entries cause undesired misalignment of columns. 
%   Second optional argument can be used to rename the environment, e.g., to List of Symbols.
%   Third optional argument selects section-level or chapter-level style for the nomenclature list.
\NewDocumentEnvironment{nomenclature}{O{2em} O{\nomname} O{section}}{%
    \setlength\columnsep{2em} 
    \setlength{\nomenwidth}{#1}
    \csname #3\endcsname *{#2}% this level will vary amongst users!
	\phantomsection\addcontentsline{toc}{#3}{#2}%
    \raggedright
    \begin{list}{}{%
         \setlength{\itemsep}{0pt}%
         \setlength{\parsep}{\itemsep}%
         \setlength{\labelsep}{1em}%
         \setlength{\labelwidth}{\nomenwidth}%
         \setlength{\leftmargin}{\labelwidth}%
         \addtolength{\leftmargin}{\labelsep}%
		 \setlength\savitemsep\itemsep%
    }%
}{\end{list}\ignorespacesafterend}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\endinput
%%
%% End of file `mitthesis.cls'.