-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtlc-article.cls
528 lines (444 loc) · 15.5 KB
/
tlc-article.cls
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
% {{{ tlc-article
%
% Class:
% tlc-article
%
% Purpose:
% This LaTeX class provides an article implementation that standardizes
% a document layout intended for formal documents.
%
% Note:
% I use 'set foldmethod=mark' in my vimrrc to enable folding when viewing or
% editing this file.
%
% -------------------------------------------------------------------------- }}}
% {{{ Base tlc-article definitions.
\NeedsTeXFormat{LaTeX2e}%
\ProvidesClass{tlc-article}[2023/09/25 v1.2.38 Traap LaTeX Class Article]%
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}%
\ProcessOptions%
\LoadClass{article}%
% -------------------------------------------------------------------------- }}}
% {{{ Page layout
\RequirePackage[a4paper,top=1.0in,bottom=1.0in,left=1.0in,right=1.0in]{geometry}%
\RequirePackage{multicol}%
% -------------------------------------------------------------------------- }}}
% {{{ Required parts to use glossaries must come first.
\RequirePackage{lmodern}%
\RequirePackage{textcomp}%
\RequirePackage[utf8]{inputenc}%
\RequirePackage[T1]{fontenc}%
\RequirePackage[colorlinks]{hyperref}%
\RequirePackage{bookmark}%
% -------------------------------------------------------------------------- }}}
% {{{ Define glossaries.
\RequirePackage[acronym, % Create 'acronym' glossary type.
nopostdot, % Do not use post dots
nonumberlist, % Do not number list.
style=altlist,% use altlist style.
toc, % Add the glossary to the table of contents.
]{glossaries}%
% -------------------------------------------------------------------------- }}}
% {{{ Color, Graphics and links.
\RequirePackage{graphicx}%
\RequirePackage[table]{xcolor}%
\definecolor{darkblue}{rgb}{0,0,0.5}%
% -------------------------------------------------------------------------- }}}
% {{{ Listings and verbatim
\RequirePackage{listings}%
\RequirePackage{spverbatim}%
% -------------------------------------------------------------------------- }}}
% {{{ Arrays, list and tables
\RequirePackage{array}%
\RequirePackage[l3]{csvsimple}%
\RequirePackage{enumitem}%
\RequirePackage{longtable}%
\RequirePackage{makecell}%
\RequirePackage{tabularx}%
\setlength{\parindent}{0pt}%
% -------------------------------------------------------------------------- }}}
% {{{ pdf
\RequirePackage{pdfpages}%
% -------------------------------------------------------------------------- }}}
% {{{ Pie Charts
\RequirePackage{pgf-pie}%
% -------------------------------------------------------------------------- }}}
% {{{ Miscellaneous
\RequirePackage[toc,page]{appendix}%
\setlength{\marginparwidth}{2cm}%
\RequirePackage{todonotes}%
\RequirePackage{ifthen}%
% -------------------------------------------------------------------------- }}}
% {{{ Table of Contents
%
% We want our table of contents to use dots as a leader.
\RequirePackage{tocloft}%
\renewcommand\cftsecleader{\cftdotfill{\cftdotsep}}%
% -------------------------------------------------------------------------- }}}
% {{{ Header and Footers
% Create a beautiful document header and document footer using the packages
% listed below.
\RequirePackage{fancyhdr}% Page layout in \LaTeX
\RequirePackage{titling}% Control over \maketitle & \thanks
\RequirePackage{lastpage}% Page n of m
\pagestyle{fancy}% fancy page style
% -------------------------------------------------------------------------- }}}
% {{{ Control header, footer, and table of contents.
%
% Keep We want our header and footer to remain consistent with a table of
% contents that span multiple pages.
\AtBeginDocument{%
\addtocontents{toc}{\protect\thispagestyle{fancy}}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Colors: Custom
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}%
\definecolor{codegray}{rgb}{0.5,0.5,0.5}%
\definecolor{codegreen}{rgb}{0,0.6,0}%
\definecolor{codepurple}{rgb}{0.58,0,0.82}%
\definecolor{darkblue}{rgb}{0,0,0.5}%
% -------------------------------------------------------------------------- }}}
% {{{ Colors: Code listings
\lstdefinestyle{tlcStyle}{%
backgroundcolor=\color{backcolour},%
commentstyle=\color{codegreen},%
keywordstyle=\color{magenta},%
numberstyle=\tiny\color{codegray},%
stringstyle=\color{codepurple},%
basicstyle=\footnotesize,%
breakatwhitespace=false,%
breaklines=true,%
captionpos=b,%
keepspaces=true,%
numbers=left,%
numbersep=4pt,%
showspaces=false,%
showstringspaces=false,%
showtabs=false,%
tabsize=2%
}%
\lstset{style=tlcStyle}%
% -------------------------------------------------------------------------- }}}
% {{{ Colors: Hyper link
\hypersetup{%
bookmarksopen = true,%
citebordercolor = white!100,%
citecolor = darkblue,%
filebordercolor = white!100,%
filecolor = darkblue ,%
linkbordercolor = white!100,%
linkcolor = darkblue,%
linktoc = all,%
menubordercolor = white!100,%
pdfauthor = {},%
pdfborder = {0 0 0 [0 0]},%
pdfkeywords = {},%
pdfstartview = FitH,%
pdfsubject = {},%
pdftitle = {},%
runbordercolor = white!100,%
urlbordercolor = white!100,%
urlcolor = darkblue%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Define the optional input files.
\def\tlc@location{data}%
\def\tlc@logoFile{\tlc@location/logo.png}%
\def\tlc@versionFile{\tlc@location/version.csv}%
\def\tlc@additionalLayout{\tlc@location/additional-layout.tex}%
\def\tlc@headerFooter{\tlc@location/header-footer.tex}%
% -------------------------------------------------------------------------- }}}
% {{{ Clear fancy header and footers.
\fancyhead[L,C,R]{}
\fancyfoot[L,C,R]{}
% -------------------------------------------------------------------------- }}}
% {{{ Command: L, C, R
% New column types: L, C, and R are Left, Center, and Right, respectively are
% designed to use with longtable. Data is wrapped within a table cell. The
% parameter defines the column width. As an example, L{2cm} yields a Left
% aligned, ragged right, wrapped text within a 2cm wide cell.
%
% Argument:
% 1 - text to left, center, or right align.
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash}p{#1}}%
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash}p{#1}}%
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash}p{#1}}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: ER
%
% This command is generally applied to the end of a table row.
\newcommand{\ER}{\\ \hline}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: inputIfExists
%
% Macro to include a file if it exists.
%
% Argument:
% 1 = the file path to input
\newcommand{\inputIfExists}[1]{\IfFileExists{#1}{\input{#1}}{}}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: tlcBeginLandscape
%
% tlcBeginLandscape and tlcEndLandscape are two new commands used to simplify
% setting page orientation to landscape and consistently setting margins.
\newcommand{\tlcBeginLandscape}{%
\begin{landscape}%
\newgeometry{top=1in, bottom=1in,left=1in,right=1in}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: tlcDarkblue
%
% This function is used to simplify making textcolor darkblue.
%
% Argument:
% 1 - the text to enclose in dark blue.
\newcommand{\tlcDarkblue}[1]{\textcolor{darkblue}{#1}}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: tlcDebug
%
% We define tlcDebug to aid our users when they are debugging their document.
% tlcDebug should be placed at the end of your document to allow LaTeX to
% fully expand all macros and definitions.
\newcommand{\tlcDebug}{%
\clearpage%
\section{tlc-article Debug}%
\subsection{tlc-article default files}%
\begin{description}[align=right,labelindent=5cm]%
\item[tlc@location:]\tlc@location%
\item[tlc@additionalLayout:]\tlc@additionalLayout%
\item[tlc@headerFooter:]\tlc@headerFooter%
\item[tlc@versionFile:]\tlc@versionFile%
\item[tlc@logoFile:]\tlc@logoFile%
\item[tlc@versionFile:]\tlc@versionFile%
\end{description}%
%
\subsection{tlc-article file hooks}%
\begin{description}[align=right,labelindent=5cm]%
\item [tlc@additionalLayout:]\tlcIsDefined{\tlc@additionalLayout}%
\item [tlc@headerFooter:]\tlcIsDefined{\tlc@headerFooter}%
\item [tlc@logoFile:]\tlcIsDefined{\tlc@logoFile}%
\item [tlc@versionFile:]\tlcIsDefined{\tlc@versionFile}%
\end{description}%
%
\subsection{tlc-article header and footer hooks}%
\begin{description}[align=right,labelindent=5cm]%
\item[tlc@version:] \tlc@version%
\item[tlc@date:] \tlc@date%
\item[tlc@status:] \tlc@status%
\item[tlc@institution:] \tlc@institution%
\item[tlc@permission:] \tlc@permission%
\end{description}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: tlcEndLandscape
%
% Simplify ending landscape.
\newcommand{\tlcEndLandscape}{%
\restoregeometry%
\end{landscape}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: tlcGetEnvironmentVariable
%
% A command to extract environment variables
%
% Arguments:
% 1 - the LaTeX variable to set.
% 2 - the environment variable to extract.
%
% Use:
% \tlcGetEnvironmentVariable{\someLaTeXVariable}{someEnviornmentVariable}
% \tlcGetEnvironmentVariable{\workingDir}{WORKINGDIR}
\RequirePackage{catchfile}%
\newcommand{\tlcGetEnvironmentVariable}[2][]{%
\CatchFileEdef{\temp}{"|kpsewhich --var-value #2"}{\endlinechar=-1}%
\if\relax\detokenize{#1}\relax\temp\else\let#1\temp\fi}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: tlcIsDefined
%
% Writes DEFINED or NOTDEFINED to your document.
%
% Argument:
% 1 - Check for the existence of the file name provided.
\newcommand{\tlcIsDefined}[1]%
{\IfFileExists{#1}%
{\textcolor{green}{DEFINED}}%
{\textcolor{red}{NOT DEFINED}}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: tlcVersionPart
%
% Extract document status, document date and document version from
% tlc@versionFile.
%
% Argument:
% 1 - the column name to extract from the data file.
\newcommand{\tlcVersionPart}[1]{%
\csvreader[separator=pipe]%
{\tlc@versionFile}%
{1=\version,%
2=\date,%
3=\status,%
4=\institution,%
5=\permission%
}%
{#1}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: tlcVspace
% Default vertical space
\newcommand{\tlcVspace}{\vspace{3mm}}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: tlcTitlePageAndTableOfContents
%
% Each document uses the same author name, title page and table of contents.
%
% Arguments:
% 1 - the title
% 2 - the author
% 3 - the abstract
\newcommand{\tlcTitlePageAndTableOfContents}[3]{%
\ifthenelse{\equal{#1}{}}{% title check
\title{}%
}{% Else: title
\title{#1}
}%
\ifthenelse{\equal{#2}{}}{% author check
\author{}%a
}{% Else: author
\author{#2}
}%
\maketitle%
\ifthenelse{\equal{#3}{}}{% abstract check
% noop: nothing
}{% Else: abstract
% \vspace{3mm}% Virtical spacing.
\begin{abstract}#3\end{abstract}%
}%
\thispagestyle{empty}%
\clearpage%
\tableofcontents%
\clearpage%
% \end{titlepage}
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: useDefaultHeaderFooter
%
% Construct a beautiful header and footer.
\newcommand{\useDefaultHeaderFooter}{%
\useLogoFile% Typeset Logo in the left side of the header.
\useTitle% Typeset thetile in the center of the header
\useVersionFile% Typeset version info in right side of the header.
\useRuler% Typeset header and footer with a ruler.
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: useLogoFile
%
% Typeset the logo in the left side of the document header. Otherwise no
% operation because tlc@logoFile does not exist.
\newcommand{\useLogoFile}{%
\IfFileExists{\tlc@logoFile}%
{%
\fancyhead[L]{\includegraphics[width=3cm,height=1cm]{\tlc@logoFile}}%
}%
{%
% Else: no operation because tlc@logoFile does not exist.
}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: useRuler
%
% Add a ruler to the header and footer.
%
% Steps:
% 1. Add a ruler to the header.
% 2. Eliminate head height too small warning, which occurs because we are
% using multiple lines in our header.
% 3. Apply page n o N to right side footer.
% 4. Add a ruler to the footer.
\newcommand{\useRuler}{%
\renewcommand{\headrulewidth}{0.1pt}%
\setlength\headheight{34.0pt}%
\fancyfoot[R]%
{\tiny%
{Page \thepage~of~\pageref{LastPage}}%
}%
\renewcommand{\footrulewidth}{0.1pt}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: useVersionFile
%
% Typeset version information in the right side of the document header.
\newcommand{\useVersionFile}{%
\IfFileExists{\tlc@versionFile}%
{%
%
% document status, document date and document version.
%
\fancyhead[R]{\tiny \tlc@status \\ \tlc@date \\ \tlc@version}%
%
% document owner. This maybe a person or company name.
%
\fancyfoot[L]{\tiny \tlc@institution}%
%
% document license. This maybe a license or word like confidential.
%
\fancyfoot[C]{\tiny \tlc@permission}%
}%
{%
% Else: no operation because tlc@versionFile does not exist.
}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Command: useTitle
%
% Typeset title in the center of the header.
\newcommand{\useTitle}{%
\fancyhead[C]{\large{\thetitle}}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Hook: tlc@additionalLayout
%
% We want to allow the calling document to setup additional layout.
\IfFileExists{\tlc@additionalLayout}%
{\input{\tlc@additionalLayout}}%
{%
% Else: no operation because tlc@additionalLayout does not exist.
}%
% {{{ Hook: tlc@versionFile
% -------------------------------------------------------------------------- }}}
%
% Extract version parts when tlc@versionFile exists.
\IfFileExists{\tlc@versionFile}%
{%
\def\tlc@version{\tlcVersionPart{\version}}%
\def\tlc@date{\tlcVersionPart{\date}}%
\def\tlc@status{\tlcVersionPart{\status}}%
\def\tlc@institution{\tlcVersionPart{\institution}}%
\def\tlc@permission{\tlcVersionPart{\permission}}%
}%
{% Else: no operation because tlc@versionFile does not exist.
\def\tlc@version{\textcolor{red}{NOT USED}}%
\def\tlc@date{\textcolor{red}{NOT USED}}%
\def\tlc@status{\textcolor{red}{NOT USED}}%
\def\tlc@institution{\textcolor{red}{NOT USED}}%
\def\tlc@permission{\textcolor{red}{NOT USED}}%
}%
% -------------------------------------------------------------------------- }}}
% {{{ Hook: tlc@headerFooter
%
% Setup Header and Footer.
%
% We want to allow the calling document to override the headers and footers that
% we are defining.
\IfFileExists{\tlc@headerFooter}%
{% use the customer header and footer defined by \tlc@headerfooter
\input{\tlc@headerFooter}%
}%
{% Else : user default header and footer
\useDefaultHeaderFooter%
}%
% -------------------------------------------------------------------------- }}}
% {{{ The end
\endinput%
% -------------------------------------------------------------------------- }}}