summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/mitthesis/mitthesis.cls
blob: 92e237e18d6946efbd3abbe4659aef385791b623 (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
% 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.03}
	\def\versiondate{2023/06/26\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 on 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]{report}% [twoside] option can be issued in the .tex file; point size must be set here.

\RequirePackage{etoolbox}% provides \ifblank, \patchcmd, \apptocmd, etc.
\RequirePackage{ifthen}  % provides \whiledo, etc.

\def\ClassName{mitthesis}

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

\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}% compare version to date
\providecommand\IfPackageAtLeastTF{\@ifpackagelater}%    compare version to date

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

\IfFormatAtLeastTF{2020/02/25}{%
	\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 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...}%
}

\IfFileExists{iftex.sty}{%
	\RequirePackage{iftex}% check whether pdftex or another engine is used
	}{%
        \ClassWarning{\ClassName}{This class requires the missing package iftex.sty---trying a work-around.}
    	% Code copied from iftex package written by the LaTeX3 Project (used under LPPL).
        % \csname and \let construct useful for hiding \ifzzz tokens from outer level \if tests.
        \def\IFTEX@let#1#2{%
          \expandafter\let\csname if#1\expandafter\endcsname
          \csname if#2\endcsname}
        % pdftex (including in dvi mode)
        \begingroup\expandafter\expandafter\expandafter\endgroup
        \expandafter\ifx\csname pdftexversion\endcsname\relax
          \IFTEX@let{pdftex}{false}
        \else
          \IFTEX@let{pdftex}{true}
        \fi
        \IFTEX@let{PDFTeX}{pdftex}
	}

% check whether pdfmanagement (\DocumentMetadata) has been loaded (to fallback on hyperxmp)
\newif\ifmit@pdfmanagement
% As of 2021/07/23 we could instead do:\IfPDFManagementActiveTF{\mit@pdfmanagementtrue}{\mit@pdfmanagementfalse}
\ExplSyntaxOn
    \IfFormatAtLeastTF{2020/02/25}{%
        \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
          }
     }{\mit@pdfmanagementfalse}
\ExplSyntaxOff

%% Old installations may want textcomp load, but we only require copyright character:
\ifdefined\textcopyright\else %\def\textcopyright{©}\fi. % 2023/06/26
    \ifpdftex
    	\DeclareTextSymbol{\textcopyright}{TS1}{'251}
    	\DeclareTextSymbolDefault{\textcopyright}{TS1}
    \else
    	\newcommand*\textcopyright{\Uchar"00A9}
    \fi
\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
}{%        
    \RequirePackage{kvoptions}
    \SetupKeyvalOptions{
      family=\ClassName,
      prefix=mit@,
      setkeys=\kvsetkeys,
    }
    % set key [fontset] for font selection
    \DeclareStringOption[defaultfonts]{fontset}[]% fixed 2023/06/26
    %
    \ProcessKeyvalOptions{\ClassName}
    %
    %% Turn off these keys now that we're done with them
    \def\@KeyFamily{\ClassName}
    \NewDocumentCommand\mit@DisableOption{m}{%
      \DisableKeyvalOption[%
        action=ignore,%
        class=\ClassName%
      ]{#1}{\@KeyFamily}%
    }
    \NewDocumentCommand\@DisableKeys{>{\SplitList{;}}m}{\ProcessList{#1}{\mit@DisableOption}}
    %
    \@DisableKeys{fontset;}%


    %%%%%%%%  more options  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    %%% option to obtain line numbers [lineno] 
    \newif\ifmit@lineno\mit@linenofalse
    \DeclareOption{lineno}{\mit@linenotrue}
    
    %%% option for to load packages that customize the design [mydesign]  (caption, subcaption, titlesec, itemenum)
    \newif\ifmit@mydesign\mit@mydesignfalse
    \DeclareOption{mydesign}{\mit@mydesigntrue}
    
    %% Suppress warnings about unused global options
    \DeclareOption*{}
    
    \ProcessOptions \relax
}

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

%%% Adjustments when lineno option is used
\ifmit@lineno
    \RequirePackage[mathlines]{lineno}    
    \renewcommand{\linenumberfont}{\normalfont\footnotesize\color{red}} 
    \AtBeginDocument{\linenumbers}
\fi

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


%%%%%%%%%%%%%  Geometry, mathtools, design, graphics, bibliography, hyperrefs, bookmarks %%%%%%%%%%%%%%%%%%%%%%%

\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 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}}

% 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
	% options for xcolor
	\ifpdftex
		\def\MyColorOption{fixpdftex}\else
		\ifluatex\def\MyColorOption{luatex}\else
			\ifxetex\def\MyColorOption{xetex}\else
				\def\MyColorOption{}
			\fi
		\fi
	\fi
	\usepackage[hyperref,\MyColorOption,dvipsnames,svgnames,x11names]{xcolor}
%
	\RequirePackage{caption,subcaption}
%
    \RequirePackage{titlesec}    
    % these titlesec commands just automate the bold math in some headings (rest follows default styles)
    \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}{}    
    % ==> NOT every font includes a bold math version, so you may need to use other math macros in the headings to get bold math <==    	
\fi

%% Font loading
\typeout{^^JFontset key is \mit@fontset^^J}
\input{fontsets/\ClassName-\mit@fontset.tex}

\RequirePackage{graphicx} 

\ifmit@pdfmanagement
	\ClassInfo{\ClassName}{pdfmanagement is defined. Will not load hyperxmp}%
\else
    \ClassInfo{\ClassName}{pdfmanagement is not defined. Will load hyperxmp}%
	\RequirePackage{hyperxmp}
\fi

\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 new pdf management has not been loaded
\RequirePackage{doi} 	% create macro for hyperlinking doi numbers

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

		
%%%%%%%%%%%%% Stuff related to PDF bookmarks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% Since \bm may be useful in headings, this fix will reduce frequency with which
%%%    alternate pdfstrings must be given in revised section command as \section[pdfstring]{texstring}
\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.
\robustify{\footnote}
% \patchcmd{\section}{\sectionmark}{\let\footnote\@gobble\sectionmark}{}{}% <== not needed unless you implement running heads
\pdfstringdefDisableCommands{%
  \def\footnote#1{}%
}
}

%%% Let's have commas separate successive footnotes
\let\oldfootnote\footnote
\renewcommand\footnote[1]{%
    \oldfootnote{#1}\futurelet\nextToken\isOtherfnote}
    
\newcommand\isOtherfnote{%
    \ifx\footnote\nextToken\textsuperscript{\mdseries,}%
    \fi%
}


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

%%%%%%%%%%%%  Dates  %%%%%%%%%%%%%%%

\ExplSyntaxOn
\NewExpandableDocumentCommand\MonthCheck{mm}{%
	\str_case_e:nnF {#1}{ {June}{} {September}{} {February}{}
	 {\space June}{} {\space September}{} {\space February}{}
	 {June\space}{} {September\space}{} { February\space}{}
	 {\space June\space}{} {\space September\space}{} {\space February\space}{}
	 }{#2} 
}
\ExplSyntaxOff

\NewDocumentCommand\DegreeDate{mm}{%
	\def\@DegreeMonth{\ignorespaces#1}%
	\def\@@DegreeMonth{#1}%	
	\def\@DegreeYear{\ignorespaces#2}%
	\def\DegreeYear{\ignorespaces#2}%
}

\NewDocumentCommand\ThesisDate{m}{%
	\def\@ThesisDate{\ignorespaces#1}%
}

%%%%%%%%%%%%%%  Author, supervisor, acceptor, titles, and departments  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{authorcnt}
\setcounter{authorcnt}{0}% this counter's final value is used repeatedly.
  
\NewDocumentCommand\Author{m m oooo}{%
	\ifblank{#1}{%
		\ClassError{\ClassName}{Missing author name, check for blank in Author command}{%
			You MUST provide an author name using the \Author{name}{department} command.}%
		}{%
		\addtocounter{authorcnt}{1}%			
		\expandafter\xdef\csname aut@\theauthorcnt\endcsname{\ignorespaces#1}%
		\expandafter\xdef\csname autdep@\theauthorcnt\endcsname{\ignorespaces#2}%
		\IfNoValueF{#3}{\expandafter\xdef\csname prevdegree@\theauthorcnt\endcsname{\ignorespaces#3}}%
		\IfNoValueF{#4}{\expandafter\xdef\csname secondprevdegree@\theauthorcnt\endcsname{\ignorespaces#4}}%
		\IfNoValueF{#5}{\expandafter\xdef\csname thirdprevdegree@\theauthorcnt\endcsname{\ignorespaces#5}}%
		\IfNoValueF{#6}{\expandafter\xdef\csname fourthprevdegree@\theauthorcnt\endcsname{\ignorespaces#6}}% 
	}%
	\ifblank{#2}{\ClassWarning{\ClassName}{Missing author department, check for blank in Author command}}{}%
}% defines \aut@authorcnt as Name #1 and \autdep@authorcnt as Name #1's department

\newcounter{authorno}
\setcounter{authorno}{0}

\NewDocumentCommand\@AuthorBlock{}{% Revised 2023/06/23
	\setcounter{authorno}{1}% 
	\ifnum\value{authorcnt}=0
		\ClassError{\ClassName}{Missing author! You must issue the \Author{name}{department} command}{%
		You MUST issue the \Author{name}{department} command after \begin{document} and before \maketitle.}%
	\fi	
	{by\par
	\whiledo{\value{authorno}<\value{authorcnt}}{%
    	\ignorespaces\csname aut@\theauthorno\endcsname\par
		\ifcsundef{prevdegree@\theauthorno}{\relax}{\normalsize\csname prevdegree@\theauthorno\endcsname}%
		\ifcsundef{secondprevdegree@\theauthorno}{\relax}{\linebreak\normalsize\csname secondprevdegree@\theauthorno\endcsname}%
		\ifcsundef{thirdprevdegree@\theauthorno}{\relax}{\linebreak\normalsize\csname thirdprevdegree@\theauthorno\endcsname}%
		\ifcsundef{fourthprevdegree@\theauthorno}{\relax}{\linebreak\normalsize\csname fourthprevdegree@\theauthorno\endcsname}%
		\par and\par
		\addtocounter{authorno}{1}%
	}%
    \ignorespaces\csname aut@\theauthorno\endcsname
    \ifcsundef{prevdegree@\theauthorno}{\relax}{\par\normalsize\csname prevdegree@\theauthorno\endcsname}%
    \ifcsundef{secondprevdegree@\theauthorno}{\relax}{\linebreak \normalsize\csname secondprevdegree@\theauthorno\endcsname}%
    \ifcsundef{thirdprevdegree@\theauthorno}{\relax}{\linebreak \normalsize\csname thirdprevdegree@\theauthorno\endcsname}%
    \ifcsundef{fourthprevdegree@\theauthorno}{\relax}{\linebreak \normalsize\csname fourthprevdegree@\theauthorno\endcsname}%
    \par\medskip 
    }%
}

\newcounter{autcrcnt}
\setcounter{autcrcnt}{1}

\NewDocumentCommand\@CopyrightAuthor{}{%
	\csname aut@\theautcrcnt\endcsname
    \addtocounter{autcrcnt}{1}%
	\whiledo{\value{autcrcnt}<\value{authorcnt}}{%
	   , \ignorespaces\csname aut@\theautcrcnt\endcsname
       \addtocounter{autcrcnt}{1}%
	}%
	\ifnum\value{autcrcnt}=\value{authorcnt}%
		\space and\space\csname aut@\theauthorcnt\endcsname\ignorespaces
	\fi
	\setcounter{autcrcnt}{1}% reset so we can use this command more than once
}

\newcounter{degcnt}
\setcounter{degcnt}{0}
\newcounter{depflag}
\setcounter{depflag}{0}
\NewDocumentCommand\Degree{mm}{% Revised 2023/06/23
	\ifblank{#1}{%
		\ClassError{\ClassName}{Missing degree name, check for blank \Degree{name}{department} command}{%
		Check for blank name \Degree{name}{department} command.}%
		}{%
		\addtocounter{degcnt}{1}%
		\expandafter\xdef\csname deg@\thedegcnt\endcsname{\ignorespaces#1}%
		\expandafter\xdef\csname degdep@\thedegcnt\endcsname{\ignorespaces#2}%
	}%
	\ifblank{#2}{%
	\setcounter{depflag}{\value{degcnt}}%
	\ClassWarning{\ClassName}{Missing degree department for Degree command number \thedegcnt. Assuming to be a duplicate of previous department}}{}%
}% defines \deg@degcnt as Name #1 and \degdep@degcnt as associated dept.

\newcounter{degno}
\newcounter{depno}
\NewDocumentCommand\@DegreeBlock{}{% extensive revision 2023/06/23
	\ifnum\value{degcnt}=0
		\ClassError{\ClassName}{Missing degree! You must issue the \Degree{name}{department} command}{%
		You MUST issue the \Degree{name}{department} command after \begin{document} and before \maketitle. You do want the degree, don't you?}%
	\fi	
	\setcounter{degno}{1}
	\setcounter{depno}{1}
	\newcommand*\PrevDept{\csname degdep@\thedepno\endcsname}
	\newcommand*\CurrDept{}
	Submitted to the \mbox{\PrevDept}%
	\whiledo{\value{depno}<\value{degcnt}}{%
		\addtocounter{depno}{1}%
		\renewcommand*\CurrDept{\csname degdep@\thedepno\endcsname}%
		\ifnum\value{depflag}=\value{depno}\relax\else 
			\space and the\linebreak
			\mbox{\CurrDept}%
			\fi%
		}%
    \linebreak \mbox{in partial fulfillment of the requirements for the\space
    \ifnum\value{degcnt}>1 degrees\else degree\fi\space of}%
	\par\medskip
	\whiledo{\value{degno}<\value{degcnt}}{%
    	\MakeUppercase{\ignorespaces\csname deg@\thedegno\endcsname}\par and\par
		\addtocounter{degno}{1}%
		}%
    \MakeUppercase{\ignorespaces\csname deg@\thedegno\endcsname}\par\medskip
}

\newcounter{supcnt}
\setcounter{supcnt}{0}
\newcounter{supno}
\setcounter{supno}{0}

\NewDocumentCommand\Supervisor{mm}{%
	\ifblank{#1}{%
		\ClassError{\ClassName}{Missing supervisor name, check for blank in \Supervisor{name}{department} command}{
		Check for blank in \Supervisor{name}{department} command.}%
		}{%
		\addtocounter{supcnt}{1}%
		\expandafter\xdef\csname sup@\thesupcnt\endcsname{#1}%
		\expandafter\xdef\csname supdep@\thesupcnt\endcsname{#2}%
	}%
	\ifblank{#2}{\ClassError{\ClassName}{Missing supervisor department, check for blank in \Supervisor{name}{department} command}{%
	check for blank in \Supervisor{name}{department} command.}}{}%
}% defines \sup@supcnt as Name #1 and \supdep@supcnt as associated dept.

\newcounter{acccnt}
\setcounter{acccnt}{0}
\newcounter{accno}
\setcounter{accno}{0}
\newif\ifmit@noacctitle\mit@noacctitlefalse %  Revised 2023/06/23
\NewDocumentCommand\Acceptor{mmm}{%
	\ifblank{#1}{%
		\ClassWarning{\ClassName}{Missing acceptor name, check for blank in \Acceptor{name}{department}{title} command}%
		}{%
		\addtocounter{acccnt}{1}%
		\expandafter\xdef\csname acc@\theacccnt\endcsname{#1}%
		\expandafter\xdef\csname accdep@\theacccnt\endcsname{#2}%
		\expandafter\xdef\csname acctitle@\theacccnt\endcsname{#3}%
	}%
	\ifblank{#2}{\ClassWarning{\ClassName}{Missing acceptor department, check for blank in \Acceptor{name}{department}{title} command.}}{}%
	\ifblank{#3}{%
		\mit@noacctitletrue
		\ClassWarning{\ClassName}{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.}%
	}{}%
}% defines \acc@acccnt as Name #1, \accdep@accccnt as associated dept, and \acctitle@acccnt as title of acceptor

\newcommand*\@SigSize{\relax}
\NewDocumentCommand\SignatureBlockSize{m}{\renewcommand\@SigSize{\ignorespaces#1}}% revised 2023/06/23

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

\NewDocumentCommand\@SetSignatureBlock{}{% Revised 2023/06/23
	\ifnum\value{supcnt}=0
		\ClassError{\ClassName}{Missing supervisor! You must issue the \Supervisor{name}{department} command}{%
		You MUST issue the \Supervisor{name}{department} command after \begin{document} and before \maketitle.}%
	\fi	
	\ifnum\value{acccnt}=0
		\ClassError{\ClassName}{Missing acceptor! You must issue the \Acceptor{name}{department} command}{%
		You MUST issue the \Acceptor{name}{department} command after \begin{document} and before \maketitle.}%
	\fi	
	\ifdefined\@ThesisDate\else\ClassError{\ClassName}{Missing thesis date!}{%
	You must issue the \ThesisDate{Date thesis is submitted} command between \begin{document} and \maketitle.}%
	\fi
	\setcounter{authorno}{0}%
	\setcounter{supno}{0}%
	\setcounter{accno}{0}%
    \@SigSize
    \begin{tabbing}
    \hspace{1.35in}\=\hspace{1in}\kill
    \whiledo{\value{authorno}<\value{authorcnt}}{% starting with authorno = 0 ensures we reach authorcnt with +1
        \addtocounter{authorno}{1}%
		Authored by: \> \csname aut@\theauthorno\endcsname\\% remove \ignorespaces x9, 2023/06/23
		\> \csname autdep@\theauthorno\endcsname\\
		\> \@ThesisDate \\[1em]
		}% end whiledo
    \whiledo{\value{supno}<\value{supcnt}}{%
        \addtocounter{supno}{1}%
		Certified by: \> \csname sup@\thesupno\endcsname\\
		\> \csname supdep@\thesupno\endcsname, Thesis Supervisor\\[1em]
		}% end whiledo
    \whiledo{\value{accno}<\value{acccnt}}{%
        \addtocounter{accno}{1}%
		Accepted by: \> \csname acc@\theaccno\endcsname\\
		\> \csname accdep@\theaccno\endcsname
			\ifmit@noacctitle\else %<=== 2023/06/23
				\\
				\> \csname acctitle@\theaccno\endcsname
			\fi
		\\[1em]
		}% end whiledo
	\end{tabbing}
}
\NewDocumentCommand\@SetAbstractSupervisorBlock{}{% revised 2023/06/23
	\setcounter{supno}{1}
	\setlength{\parindent}{0pt}
	\par\bigskip\noindent
    \whiledo{\value{supno}<\value{supcnt}}{%
		Thesis supervisor: \csname sup@\thesupno\endcsname\par
		Title: \csname supdep@\thesupno\endcsname\par\medskip 
        \addtocounter{supno}{1}%
	}% end whiledo
	Thesis supervisor: \csname sup@\thesupno\endcsname\par
	Title: \csname supdep@\thesupno\endcsname\ignorespaces
}

%%%%%%%%%%%%%%%%%%%  Copyright related  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\CCurl{}% empty by default
\newif\ifmit@cclicense\mit@cclicensefalse
\NewDocumentCommand\CClicense{m m}{%
	\def\CClicensetext{\hrefurl{#2}{\ignorespaces#1}}% #1 - text, #2 - url
	\def\CCname{#1}
	\def\CCurl{#2}% for use in metadata
	\mit@cclicensetrue	
}


%%%%%%%%%%%%%%%%%%%  Create titlepage  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\MIT{MASSACHUSETTS INSTITUTE OF TECHNOLOGY}

\RenewDocumentCommand\maketitle{s}{%
%
	\ifdefined\@DegreeMonth\else\ClassError{\ClassName}{Missing degree date!}{%
		You must issue the \DegreeDate{month}{year} command between \begin{document} and \maketitle}%
	\fi
%
	\ifmit@cclicense
    	\def\CopyrightLicense{This work is licensed under a \mbox{\CClicensetext} license.\par\MITpermission}% add mbox 2023/06/23
    	\typeout{^^JUsing Creative Commons License \CCname^^J}
    	\def\PDFRightsText{This work is licensed under a \CCname\ license. \MITpermission}% for use in metadata
	\else
    	\def\CopyrightLicense{All rights reserved.\par\MITpermission}
    	\def\PDFRightsText{All rights reserved. \MITpermission}% for use in metadata
    \fi
	\ifnum\value{authorcnt}>1
		\def\CRWords{The authors hereby grant}\else\def\CRWords{The author hereby grants}
	\fi
    \def\MITpermissionLast{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.}%
    \IfBooleanTF{#1}{\def\MITpermission{\relax}}{\def\MITpermission{\CRWords\space\MITpermissionLast}}%
% 
	\clearpage
	\thispagestyle{empty}%
	\phantomsection\addcontentsline{toc}{chapter}{\protect\textbf{Title page}}%
	{\centering\vbox to \vsize{% vbox to prevent signature block from breaking across page. Remove if necessary.
        \setlength{\parskip}{0.5\baselineskip plus 2pt minus 2pt}\setlength{\parindent}{0pt}%
        {\Large\textbf{\@title}\par}%
        \@AuthorBlock
        \par
        \@DegreeBlock
        at the\par
        \MIT\par
        \@DegreeMonth\space\@DegreeYear
        \MonthCheck{\@@DegreeMonth}{%
			\ClassError{\ClassName}{Acceptable months for the degree date are February, June, and September}{Change %
				the month of your degree date to one of February, June, or September.}%
		}%
        \par
        \copyright\space\@DegreeYear\space\@CopyrightAuthor. \CopyrightLicense
        \par
        \vskip\baselineskip
        %
        \@SetSignatureBlock
    	\vfill
	}}%
	\newpage
}

%%%%%%%%%%%%%%%%%%%  Create abstract page  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RenewDocumentEnvironment{abstract}{+b}{%
	\newpage
	\phantomsection\addcontentsline{toc}{chapter}{\protect\textbf{Abstract}}%
    \begin{center}
        {\large{\textbf{\@title}}\par}
        \setlength{\parskip}{0.5\baselineskip plus 2pt minus 2pt}
        \@AuthorBlock
        \par
        \@DegreeBlock
	\end{center}
	\vskip\baselineskip
	\textbf{ABSTRACT}\par\vskip0.5em
	\ignorespaces#1\ignorespaces
	\ifblank{#1}{\typeout{Missing abstract!} MISSING ABSTRACT!}{\relax}
}{%
	\@SetAbstractSupervisorBlock
	\newpage
	\ignorespacesafterend
}

%%%%%%%  A nomenclature environment, if needed  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

\makeatletter
\NewDocumentCommand\entry{m m}{%
	\ifblank{#2}{%
		\ClassWarning{\ClassName}{The command \protect\entry requires two arguments. To obtain a subheading, use \protect\EntryHeading}
 		\itemsep3\p@ plus 1\p@ minus 1\p@%
        \goodbreak\item[\itshape#1\hfill]\setlength\itemsep\savitemsep\@itempenalty=1000%
         }{%
         \item[#1\hfill]#2%
         \@itempenalty=-\@lowpenalty%
	}%
}
% A separate command command for nomenclature subheadings 
\NewDocumentCommand\EntryHeading{m}{%
	\itemsep3\p@ plus 1\p@ minus 1\p@%
    \goodbreak\item[\itshape#1\hfill]\setlength\itemsep\savitemsep\@itempenalty=1000%
}
\makeatother
%
%   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.
\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'.