-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocument.sty
More file actions
635 lines (529 loc) 路 16.4 KB
/
Copy pathdocument.sty
File metadata and controls
635 lines (529 loc) 路 16.4 KB
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
%% document.sty - LaTeX Document Package
%% Requires LaTeX2e format
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{document}[2026/08/10 Document Package]
%%=============================================================================
%% ARGUMENTS DEPENDENCIES
%%=============================================================================
%% Parsing and conditionals
\RequirePackage{xparse}
\RequirePackage{ifthen}
\RequirePackage{etoolbox}
%%=============================================================================
%% PACKAGE OPTIONS
%%=============================================================================
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
family=doc,
prefix=doc@
}
% Define package options
\DeclareBoolOption[true]{theorems}
\DeclareBoolOption[true]{colors}
\DeclareBoolOption[true]{code}
\DeclareBoolOption[false]{draft}
\DeclareBoolOption[true]{timesfont}
\DeclareStringOption[colorful]{style}[colorful]
\DeclareStringOption[default]{header}[default]
\DeclareStringOption[ieee]{bibstyle}
\ProcessKeyvalOptions*
%%=============================================================================
%% METADATA
%%=============================================================================
% Define the author names (short and full)
\newcommand{\@shortauthor}{}
\newcommand{\@fullauthor}{}
% Redefine \author with optional argument
\RenewDocumentCommand{\author}{o m}{%
\IfNoValueTF{#1}%
{% No short name provided, use full name for both
\gdef\@shortauthor{#2}%
\gdef\@fullauthor{#2}%
\gdef\@author{#2}%
}%
{% Short name provided
\gdef\@shortauthor{#1}%
\gdef\@fullauthor{#2}%
\gdef\@author{#2}%
}%
}
% Define the titles (short and full)
\newcommand{\@shorttitle}{}
\newcommand{\@fulltitle}{}
% Redefine \title with optional argument
\RenewDocumentCommand{\title}{o m}{%
\IfNoValueTF{#1}%
{% No short title provided, leave \@shorttitle empty
\gdef\@shorttitle{}%
}%
{% Short title provided
\gdef\@shorttitle{#1}%
}%
\gdef\@fulltitle{#2}%
\gdef\@title{#2}%
}
\newcommand{\@purpose}{}
\newcommand{\@institute}{}
% Define \purpose command
\newcommand{\purpose}[1]{%
\gdef\@purpose{#1}%
}
% Define \institute command
\newcommand{\institute}[1]{%
\gdef\@institute{#1}%
}
%%=============================================================================
%% PAGE LAYOUT
%%=============================================================================
%% Geometry setup
\RequirePackage[
margin=0.5in,
bottom=1.5in,
]{geometry}
%% Headers and footers
\RequirePackage{emptypage} % Clean empty pages
\RequirePackage{fancyhdr} % For custom headers/footers
\pagestyle{fancy}
\fancyhf{}
\newcommand{\doc@header@none}{%
\fancyhead{}
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
}
% Define the handler for the header option: default
\newcommand{\doc@header@default}{%
\fancyhead[C]{\leftmark}
\fancyfoot[C]{\thepage}
\setlength{\headheight}{0.75in}
}
% Define the handler for the header option: formal
\newcommand{\doc@header@formal}{%
\RequirePackage{lastpage} % For total page count
\lhead{
\@purpose \hfill
\begingroup
\newbool{bothnotempty}
\booltrue{bothnotempty}
\ifdefempty{\@shorttitle}{\boolfalse{bothnotempty}}{}
\ifdefempty{\@shortauthor}{\boolfalse{bothnotempty}}{}
\ifdefempty{\@shorttitle}{}{\@shorttitle{}}%
\ifbool{bothnotempty}{ --- }{}%
\ifdefempty{\@shortauthor}{}{\@shortauthor{}}%
\endgroup
~~\\
\@institute \hfill page {\thepage} of {\pageref*{LastPage}}
}
\setlength{\headheight}{0.75in}
\renewcommand{\headrulewidth}{0pt}
}
% Execute the appropriate handler
\csname doc@header@\doc@header\endcsname
%% Footnote formatting
\RequirePackage[hang]{footmisc}
\setlength{\footnotemargin}{0.5em}
%%=============================================================================
%% TEXT ENCODING AND FONTS
%%=============================================================================
%% Character encoding (load early)
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\ifdoc@timesfont
\RequirePackage{times}
\fi
\RequirePackage{textcomp}
\RequirePackage{fontawesome} % Needed to add icons
% Define a command for emphasizing text
\newcommand{\alert}[1]{{\color{Bittersweet} #1}}
%%=============================================================================
%% MATHEMATICS
%%=============================================================================
%% Core math packages
\RequirePackage{amsmath}
\RequirePackage{amsfonts}
\RequirePackage{amsthm}
\RequirePackage{amssymb}
\RequirePackage{mathtools}
\RequirePackage{mathrsfs}
\RequirePackage{mathdots}
\allowdisplaybreaks % Allow page breaks in multi-line equations
%% Additional math symbols and fonts
\RequirePackage{nicefrac}
\RequirePackage{cancel}
% \RequirePackage{MnSymbol} %% This package causes \int weirdness
\RequirePackage{dsfont}
\RequirePackage{upgreek}
%% Systems of equations
\RequirePackage{systeme}
%% SI units and number formatting
\RequirePackage[locale=US]{siunitx}
\sisetup{
inter-unit-product = \ensuremath{{}\cdot{}}, % Use dot between units (m路s)
per-mode = symbol, % Use slashes (m/s) instead of negative exponents
}
%% Special symbols
\RequirePackage{pifont}
%%=============================================================================
%% COLORS AND HYPERLINKS
%%=============================================================================
\ifdoc@colors
\RequirePackage[dvipsnames]{xcolor}
\else
\RequirePackage{xcolor}
\fi
%% Hyperlinks (load after xcolor)
\RequirePackage[
colorlinks=true,
allcolors=.
]{hyperref}
%%=============================================================================
%% TEXT FORMATTING
%%=============================================================================
%% Text highlighting and spacing
\RequirePackage{soul}
\newcommand{\spaceout}[1]{\so{#1}}
%% Verbatim text
\RequirePackage{fancyvrb}
%% Quotations
\RequirePackage{csquotes}
\renewcommand{\mkbegdispquote}[2]{\itshape}
%% Enhanced lists
\RequirePackage{enumitem}
%%=============================================================================
%% CODE LISTINGS
%%=============================================================================
\ifdoc@code
\RequirePackage{minted}
%% LaTeX code environment
\newminted{latex}{
breaklines,
breakanywhere,
fontsize=\footnotesize,
linenos=true,
numbersep=5pt,
frame=lines,
framesep=2mm,
tabsize=2,
autogobble=true
}
%% Python code environment
\newminted{python}{
breaklines,
breakanywhere,
fontsize=\footnotesize,
linenos=true,
numbersep=5pt,
frame=lines,
framesep=2mm,
tabsize=4,
autogobble=true
}
\fi
%%=============================================================================
%% TABLES
%%=============================================================================
%% Professional table formatting
\RequirePackage{booktabs}
\RequirePackage{arydshln}
\RequirePackage{multirow}
\RequirePackage{multicol}
%%=============================================================================
%% FLOATS AND CAPTIONS
%%=============================================================================
%% Float control
\RequirePackage{float}
%% Caption formatting
\RequirePackage{caption}
\RequirePackage{subcaption}
\captionsetup{
labelfont=bf,
labelsep=period,
font=footnotesize
}
%%=============================================================================
%% ALGORITHMS
%%=============================================================================
\RequirePackage{algorithm}
\RequirePackage{algpseudocode}
%%=============================================================================
%% GRAPHICS AND PLOTTING
%%=============================================================================
%% Graphics inclusion
\RequirePackage{graphicx}
%% TikZ and PGFPlots
\RequirePackage{tikz}
\usetikzlibrary{
intersections,
angles,
quotes,
positioning,
arrows.meta
}
\RequirePackage{pgfplots}
\pgfplotsset{compat=1.18}
\RequirePackage{pgfplotstable}
%% Multimedia
\RequirePackage{multimedia}
%%=============================================================================
%% ADDITIONAL UTILITIES
%%=============================================================================
%% Paragraph boxes
\RequirePackage{pbox}
%% Name references
\RequirePackage{nameref}
%%=============================================================================
%% DOCUMENT STRUCTURE
%%=============================================================================
%% Appendix handling
\RequirePackage{appendix}
%% Content directory management
\newcommand{\doc@directory}{.}
\NewDocumentCommand{\setdirectory}{O{.}}{%
\renewcommand{\doc@directory}{#1}%
}
\NewDocumentCommand{\setappendix}{O{.}}{%
\renewcommand{\doc@directory}{#1}%
\appendix%
\appendixpage{}%
}
\newcommand{\addcontent}[1]{%
\input{\doc@directory/#1}%
}
%%=============================================================================
%% BIBLIOGRAPHY
%%=============================================================================
%% Load biblatex if not already loaded
\@ifpackageloaded{biblatex}{}{%
\RequirePackage[backend=biber, style=\doc@bibstyle]{biblatex}
}
%% Square brackets for citations
\renewcommand*{\mkbibparens}[1]{%
\bibopenbracket#1\bibclosebracket%
}
%%=============================================================================
%% THEOREM ENVIRONMENTS
%%=============================================================================
\ifdoc@theorems
%% Theorem tools and framing
\RequirePackage{thmtools}
\RequirePackage[most]{tcolorbox}
% Use the most option to load commonly used libraries, including
% skins - for enhanced visual styles and effects
% breakable - allows boxes to break across pages
% hooks - for customization hooks
% fitting - for content fitting options
% magazine - for advanced layout features
% raster - for arranging multiple boxes in grids
% theorems - provides integration with theorem environments
\tcbuselibrary{theorems}
%% Set default theorem style
\theoremstyle{definition}
%%-----------------------------------------------------------------------------
%% Box Styles
%%-----------------------------------------------------------------------------
%% The appearance of all theorem-like boxes is controlled by the `style`
%% package option:
%%
%% style=colorful (default): colored background and left rule
%% style=plain: no background, border, or shaded rule
%% Common plain style: tcolorbox remains invisible so that the environments
%% remain breakable, while the content appears as ordinary text.
\tcbset{
doc@plainbox/.style={
enhanced,
breakable,
colback=white,
colframe=white,
boxrule=0pt,
leftrule=0pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
sharp corners,
left=0pt,
right=0pt,
fonttitle=\bfseries\upshape,
fontupper=\itshape,
coltitle=black,
attach title to upper={~},
separator sign={},
description delimiters={(}{)},
description font=\mdseries\upshape,
},
%% Common colorful style
doc@colorbox/.style={
enhanced,
breakable,
colback=#1!5,
colframe=#1,
boxrule=-0.01pt,
leftrule=2pt,
sharp corners,
left=2mm,
right=2mm,
fonttitle=\bfseries\sffamily,
coltitle=#1!70!black,
attach title to upper={~},
separator sign={},
description delimiters={(}{)},
description font=\mdseries,
}
}
%% Helper macro for declaring theorem box styles.
\newcommand{\declarecolorbox}[2]{%
\ifdefstring{\doc@style}{plain}{%
\tcbset{#1/.style={doc@plainbox}}%
}{%
\tcbset{#1/.style={doc@colorbox={#2}}}%
}%
}
%% Declare theorem box styles.
\declarecolorbox{thmredbox}{WildStrawberry}
\declarecolorbox{thmorangebox}{BurntOrange}
\declarecolorbox{thmyellowbox}{Goldenrod}
\declarecolorbox{thmgreenbox}{ForestGreen}
\declarecolorbox{thmcyanbox}{Turquoise}
\declarecolorbox{thmbluebox}{NavyBlue}
\declarecolorbox{thmpurplebox}{Violet}
\declarecolorbox{thmbrownbox}{RawSienna}
\declarecolorbox{thmgraybox}{Gray}
%%-----------------------------------------------------------------------------
%% Theorem-like Environments
%%-----------------------------------------------------------------------------
%% Definitions
\newtcbtheorem[number within=subsection]{definition}{Definition}{thmgreenbox}{def}
%% Assumptions
\newtcbtheorem[use counter from=definition]{assumption}{Assumption}{thmorangebox}{asm}
%% Conjectures
\newtcbtheorem[use counter from=definition]{conjecture}{Conjecture}{thmpurplebox}{conj}
%% Lemmas
\newtcbtheorem[use counter from=definition]{lemma}{Lemma}{thmbrownbox}{lem}
%% Theorems
\newtcbtheorem[use counter from=definition]{theorem}{Theorem}{thmbrownbox}{thm}
%% Corollaries
\newtcbtheorem[use counter from=definition]{corollary}{Corollary}{thmbrownbox}{cor}
%% Propositions
\newtcbtheorem[use counter from=definition]{proposition}{Proposition}{thmbrownbox}{prop}
%% Remarks
\newtcbtheorem[use counter from=definition]{remark}{Remark}{thmredbox}{remk}
%% Notes
\newtcbtheorem[use counter from=definition]{note}{Note}{thmyellowbox}{note}
%% Examples
\newtcbtheorem[use counter from=definition]{example}{Example}{thmbluebox}{ex}
%% Problems
\newtcbtheorem[use counter from=definition]{problem}{Problem}{thmgraybox}{prob}
%% ToDos
\newtcbtheorem[use counter from=definition]{todo}{ToDo}{thmcyanbox}{todo}
%%-----------------------------------------------------------------------------
%% Proof and Solution Environments
%%-----------------------------------------------------------------------------
%% Proof tcolorbox style
\ifdefstring{\doc@style}{plain}{%
\tcbset{
proofstyle/.style={
doc@plainbox,
fontupper=\upshape,
fonttitle=\itshape,
before skip=0pt,
attach title to upper={\quad},
}
}%
}{%
\tcbset{
proofstyle/.style={
enhanced,
breakable,
colback=RawSienna!2,
colframe=RawSienna,
boxrule=-0.1pt,
leftrule=2pt,
sharp corners,
before skip=0pt,
left=2mm,
right=2mm,
fonttitle=\bfseries\sffamily,
coltitle=RawSienna!70!black,
attach title to upper={\quad},
}
}%
}
%% Custom proof environment
\renewenvironment{proof}[1][\proofname]{%
\par\removelastskip\vspace{-\baselineskip+2mm}%
\pushQED{\null\hfill\(\square\)}%
\begin{tcolorbox}[
proofstyle,
title=#1,
]%
}{%
\popQED%
\end{tcolorbox}%
}
%% Solution tcolorbox style
\ifdefstring{\doc@style}{plain}{%
\tcbset{
solutionstyle/.style={
doc@plainbox,
fontupper=\upshape,
fonttitle=\itshape,
before skip=0pt,
attach title to upper={\quad},
}
}%
}{%
\tcbset{
solutionstyle/.style={
enhanced,
breakable,
colback=NavyBlue!2,
colframe=NavyBlue,
boxrule=-0.01pt,
leftrule=2pt,
sharp corners,
before skip=0pt,
left=2mm,
right=2mm,
fonttitle=\bfseries\sffamily,
coltitle=NavyBlue!70!black,
attach title to upper={\quad},
}
}%
}
%% Solution environment
\newenvironment{solution}[1][Solution]{%
\par\removelastskip\vspace{-\baselineskip+2mm}%
\pushQED{\null\hfill\(\blacksquare\)}%
\begin{tcolorbox}[
solutionstyle,
title=#1,
]%
}{%
\popQED%
\end{tcolorbox}%
}
\newcommand{\refdef}[1]{Definition~\ref{def:#1}}
\newcommand{\refasm}[1]{Assumption~\ref{asm:#1}}
\newcommand{\refconj}[1]{Conjecture~\ref{conj:#1}}
\newcommand{\reflem}[1]{Lemma~\ref{lem:#1}}
\newcommand{\refthm}[1]{Theorem~\ref{thm:#1}}
\newcommand{\refcor}[1]{Corollary~\ref{cor:#1}}
\newcommand{\refprop}[1]{Proposition~\ref{prop:#1}}
\newcommand{\refremk}[1]{Remark~\ref{remk:#1}}
\newcommand{\refnote}[1]{Note~\ref{note:#1}}
\newcommand{\refex}[1]{Example~\ref{ex:#1}}
\newcommand{\refprob}[1]{Problem~\ref{prob:#1}}
\newcommand{\reftodo}[1]{ToDo~\ref{todo:#1}}
\fi % End of \ifdoc@theorems
%%=============================================================================
%% CUSTOM COMMANDS (Optional Enhancement)
%%=============================================================================
%% Quick label and reference command
\newcommand{\labelalg}[1]{\label{alg:#1}}
\newcommand{\labelfig}[1]{\label{fig:#1}}
\newcommand{\labeltab}[1]{\label{tab:#1}}
\newcommand{\refalg}[1]{Algorithm~\ref{alg:#1}}
\newcommand{\reffig}[1]{Figure~\ref{fig:#1}}
\newcommand{\reftab}[1]{Table~\ref{tab:#1}}
%%=============================================================================
%% END OF PACKAGE
%%=============================================================================
\endinput