-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcsm-thesis-sanity.sty
80 lines (72 loc) · 2.27 KB
/
csm-thesis-sanity.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
% Make a nice command for outputting errors
\newcommand{\csm@thesis@error}[1]{%
{\@latex@error{#1}\@ehd}%
%\@@end% Force early quit?
}
\newcommand{\csm@ogs@error}[1]{%
\ifx \csm@thesis@nochecks\@false \relax%
\csm@thesis@error{OGS Incompliant Document: #1}%
\fi%
}
% Make nice command sfor outputting warnings
\newcommand{\csm@thesis@warning}[1]{%
{\@latex@warning@no@line{#1}}%
}
\newcommand{\csm@thesis@warning@with@line}[1]{%
{\@latex@warning{#1}}%
}
% Make sure the variable (#1) is set, if it's not then output an error
\newcommand{\sanitize}[2]{
\ifx#1\@empty
\csm@thesis@error{No #2 given}
\fi
}
% Make sure a section/environment (#1) is set, if it's not then output an error
\newcommand{\requiredsection}[2]{
\ifx\csm@thesis@nochecks\@false
\ifx#1\@empty
\csm@thesis@error{Required section (environment) missing: #2}
\fi
\fi
}
% Make sure a section/environment (#1) is set, if it's not then output a warning
\newcommand{\suggestedsection}[2]{
\ifx\csm@thesis@nochecks\@false
\ifx#1\@empty
\csm@thesis@warning{It is recommended that you include the '#2' section (environment)}
\fi
\fi
}
% Make sure a section/environment (#1) is NOT set, if it's SET then output an error
% The reason for the failure is output in parenthesis (#3)
\newcommand{\disallowedsection}[3]{
\ifx\csm@thesis@nochecks\@false
\ifx#1\@true
\csm@thesis@warning{Disallowed section (environment) exists: #2 (#3)}
\fi
\fi
}
% Make sure ``fullpage'' does not get included!
\AtBeginDocument{
\@ifpackageloaded{fullpage}{\csm@thesis@error{The 'fullpage' package is incompatible with csm-thesis}}{}
}
% Construct a custom command for performing operations at the end of the preamble
\global\let\csm@endpreamblehook\@empty
\@onlypreamble\CSM@AtEndPreamble
\gdef\CSM@AtEndPreamble{\g@addto@macro\csm@endpreamblehook}
% and at the end of the beginning of the document
\global\let\csm@begindocumenthook\@empty
\@onlypreamble\CSM@AtBeginDocumentLast
\gdef\CSM@AtBeginDocumentLast{\g@addto@macro\csm@begindocumenthook}
% code for both:
\RequirePackage{etoolbox}
\AtEndPreamble{%
\let\CSM@AtEndPreamble\@firstofone%
\csm@endpreamblehook%
\global\let\csm@endpreamblehook\@empty%
}
\AfterEndPreamble{%
\let\CSM@AtBeginDocumentLast\@firstofone%
\csm@begindocumenthook%
\global\let\csm@begindocumenthook\@empty%
}