refactor(documentclass): implement key-value options for skripsi class

This commit is contained in:
2025-10-31 20:40:58 +07:00
parent 5fa6d8fecc
commit 03afd709ca

View File

@@ -1,16 +1,26 @@
\NeedsTeXFormat{LaTeX2e} \NeedsTeXFormat{LaTeX2e}
\ProvidesClass{skripsi}[2025/05/10 Bachelor Thesis Class] \ProvidesClass{skripsi}[2025/05/10 Bachelor Thesis Class]
\newif\if@draftmark \@draftmarkfalse \RequirePackage{kvoptions}
\newif\if@primarytitle \@primarytitletrue \SetupKeyvalOptions{
\newif\if@secondarytitle \@secondarytitletrue family=skripsikvopt,
prefix=skripsikvopt@
}
% key-value options
\DeclareBoolOption[false]{draftmark}
\DeclareBoolOption[true]{primarytitle}
\DeclareBoolOption[true]{secondarytitle}
% section number depth and tocdepth
\DeclareStringOption[3]{sectiondepth}
\DeclareStringOption[3]{tocdepth}
\DeclareOption{draftmark}{\@draftmarktrue} % Add complementary options for the "no" versions
\DeclareOption{noprimarytitle}{\@primarytitlefalse} \DeclareComplementaryOption{noprimarytitle}{primarytitle}
\DeclareOption{nosecondarytitle}{\@secondarytitlefalse} \DeclareComplementaryOption{nosecondarytitle}{secondarytitle}
\ProcessKeyvalOptions*
\ProcessOptions \relax
\LoadClass[a4paper,12pt,oneside]{book} \LoadClass[a4paper,12pt,oneside]{book}
% Load common packages % Load common packages
@@ -83,7 +93,7 @@
% \renewcommand{\bibname}{DAFTAR PUSTAKA} % \renewcommand{\bibname}{DAFTAR PUSTAKA}
% Conditionally load the watermark package and settings % Conditionally load the watermark package and settings
\if@draftmark \ifskripsikvopt@draftmark
\RequirePackage{draftwatermark} \RequirePackage{draftwatermark}
% All watermark settings in one place: % All watermark settings in one place:
\DraftwatermarkOptions{% \DraftwatermarkOptions{%
@@ -119,19 +129,6 @@
\setsansfont{Arial} \setsansfont{Arial}
\setmonofont{Courier New} \setmonofont{Courier New}
% Metadata commands
% \input{metadata}
% \newcommand{\setthesisinfo}[7]{%
% \renewcommand{\thesistitle}{#1}%
% \renewcommand{\studentname}{#2}%
% \renewcommand{\studentid}{#3}%
% \renewcommand{\program}{#4}%
% \renewcommand{\faculty}{#5}%
% \renewcommand{\university}{#6}%
% \renewcommand{\yearofsubmission}{#7}%
% }
% % Header and footer % % Header and footer
\fancypagestyle{fancy}{% \fancypagestyle{fancy}{%
\fancyhf{} \fancyhf{}
@@ -185,7 +182,7 @@
{\normalsize\bfseries}{\thesubsection}{1em}{} {\normalsize\bfseries}{\thesubsection}{1em}{}
% Section numbering depth % Section numbering depth
\setcounter{secnumdepth}{3} \setcounter{secnumdepth}{\skripsikvopt@sectiondepth}
% Ensure chapter reference in TOC matches % Ensure chapter reference in TOC matches
\renewcommand{\cftchappresnum}{\MakeUppercase\chaptername~} \renewcommand{\cftchappresnum}{\MakeUppercase\chaptername~}
@@ -197,7 +194,7 @@
\let\original@maketitle\maketitle \let\original@maketitle\maketitle
\renewcommand{\maketitle}{% \renewcommand{\maketitle}{%
\if@primarytitle \ifskripsikvopt@primarytitle
\IfFileExists{frontmatter/maketitle.tex}{% \IfFileExists{frontmatter/maketitle.tex}{%
\input{frontmatter/maketitle}% \input{frontmatter/maketitle}%
}{% }{%
@@ -206,7 +203,7 @@
\original@maketitle \original@maketitle
}% }%
\fi \fi
\if@secondarytitle \ifskripsikvopt@secondarytitle
\clearpage \clearpage
\IfFileExists{frontmatter/maketitle_secondary.tex}{% \IfFileExists{frontmatter/maketitle_secondary.tex}{%
\input{frontmatter/maketitle_secondary}% \input{frontmatter/maketitle_secondary}%
@@ -272,6 +269,9 @@
\renewcommand{\cftlottitlefont}{\hfill\bfseries\MakeUppercase} \renewcommand{\cftlottitlefont}{\hfill\bfseries\MakeUppercase}
\renewcommand{\cftafterlottitle}{\hfill} \renewcommand{\cftafterlottitle}{\hfill}
% TOC depth
\setcounter{tocdepth}{\skripsikvopt@tocdepth}
% Defines a new glossary called “notation” % Defines a new glossary called “notation”
\newglossary[nlg]{notation}{not}{ntn}{Notation} \newglossary[nlg]{notation}{not}{ntn}{Notation}