aboutsummaryrefslogtreecommitdiff
path: root/projdoc.cls
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-09-04 11:20:29 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-09-04 11:20:29 +0200
commitaa58464097897f0fdd1da9d0f6c0321cea2f4e54 (patch)
tree3c302684c00bceb42e6105d128b54fcb3569ea35 /projdoc.cls
parent7b34d0b0498b5e41cbe00dbeaca0688af86f4111 (diff)
more example latex code
Diffstat (limited to 'projdoc.cls')
-rw-r--r--projdoc.cls137
1 files changed, 135 insertions, 2 deletions
diff --git a/projdoc.cls b/projdoc.cls
index cc34f70..02e9542 100644
--- a/projdoc.cls
+++ b/projdoc.cls
@@ -12,6 +12,8 @@
\PassOptionsToPackage{english}{babel}
\PassOptionsToPackage{noabbrev}{cleveref}
\PassOptionsToPackage{nosort}{cleveref}
+\PassOptionsToPackage{nameinlink}{cleveref}
+\PassOptionsToPackage{obeyspaces}{url}
% frequently used packages
\RequirePackage{geometry}
@@ -19,6 +21,8 @@
\RequirePackage{babel}
\RequirePackage{siunitx}
\RequirePackage{csquotes}
+\RequirePackage{url}
+\RequirePackage{fancyvrb}
\RequirePackage{parskip}
\RequirePackage{fontspec}
\RequirePackage{tabularx}
@@ -32,6 +36,11 @@
\RequirePackage{unicode-math}
\RequirePackage{amsmath}
\RequirePackage{cleveref}
+\RequirePackage{adjustbox}
+\RequirePackage{xparse}
+\RequirePackage{ifdraft}
+\RequirePackage{enumitem}
+\RequirePackage{subcaption}
% font style
\setmainfont{TeX Gyre Schola}
@@ -47,6 +56,69 @@
\bigskipamount=7mm
\medskipamount=4mm
+% section placement / appearance
+\newlength{\sectionpenalty}
+\newlength{\subsectionpenalty}
+\newlength{\subsubsectionpenalty}
+\setlength{\sectionpenalty}{0.4\textheight}
+\setlength{\subsectionpenalty}{0.1\textheight}
+\setlength{\subsubsectionpenalty}{0pt}
+\def\penaltycheck#1{\ifdimgreater{#1}{0pt}{\needspace{#1}}{}}
+\ifdraft{\def\penaltycheck#1{\relax}}{}
+\makeatletter
+\renewcommand\section{%
+ \@startsection{section}{1}%
+ {0pt}%
+ {1.50em}%
+ {1.50ex}%
+ {\penaltycheck{\sectionpenalty}\normalfont\bfseries\Large}%
+}
+\renewcommand\subsection{%
+ \@startsection{subsection}{2}%
+ {0pt}%
+ {1.25em}%
+ {1.25ex}%
+ {\penaltycheck{\subsectionpenalty}\normalfont\bfseries\large}%
+}
+\renewcommand\subsubsection{%
+ \@startsection{subsubsection}{2}%
+ {0pt}%
+ {1.00em}%
+ {1.00ex}%
+ {\penaltycheck{\subsubsectionpenalty}\normalfont\bfseries\normalsize}%
+}
+\makeatother
+
+% default tight list spacing
+\makeatletter
+\newlength{\style@parsep}
+\newlength{\style@itemsep}
+\newlength{\style@itemizemargin}
+\setlength{\style@parsep}{1mm}
+\setlength{\style@itemsep}{1mm}
+\setlength{\style@itemizemargin}{2mm}
+\setlist{
+ topsep=\dimexpr\style@itemizemargin-\parskip\relax,
+ itemsep=\dimexpr\style@itemsep-\style@parsep\relax,
+ parsep=\style@parsep,
+}
+\makeatother
+
+% create a label using \customlabel[<creftype>]{<refname>}{<reftext>} that displays
+% <reftext> when \ref{<refname>} is used, or <creftype> <reftext> when
+% \cref{<refname>} is used
+\makeatletter
+\NewDocumentCommand{\customlabel}{omm}{%
+ \begingroup
+ \cref@constructprefix{#1}{\cref@result}%
+ \protected@edef\@currentlabel{#3}%
+ \protected@edef\@currentlabelname{#3}%
+ \protected@edef\cref@currentlabel{[#1][][\cref@result]#3}
+ \label[#1]{#2}%
+ \endgroup
+}
+\makeatother
+
% \maketitle format
\makeatletter
\let\@project\relax
@@ -98,14 +170,38 @@
\def\fps@table{H}
\makeatother
-% always start with title page
-\AtBeginDocument{
+% bibliography
+\usepackage[
+ backend=biber,
+ bibencoding=utf8,
+ style=iso-numeric,
+ % Technically, Avans University of Applied Sciences requires that we always use APA
+ % style references, but this often results in ugly citations when working with
+ % technical or online resources. At the end of the day, the bibliography is there
+ % to prove we didn't plagiarize or make shit up, so ISO 690 is *probably* fine.
+ autocite=plain,
+]{biblatex}
+\addbibresource{sources.bib}
+
+% default document header/trailer
+\makeatletter
+\def\projdoc@header{
+ % start with title page
\clearpage
\begin{titlepage}
\maketitle
\thispagestyle{empty}
\end{titlepage}
}
+\newbool{projdoc@cited}
+\apptocmd{\abx@aux@cite}{\global\booltrue{projdoc@cited}}{}{}
+\def\projdoc@trailer{
+ % end with bibliography (if citations used)
+ \ifbool{projdoc@cited}{\printbibliography}{}%
+}
+\AtBeginDocument{\projdoc@header}
+\AtEndDocument{\projdoc@trailer}
+\makeatother
% store figure/table count in macros
\makeatletter
@@ -119,7 +215,44 @@
% generate table of contents, figures, tables
\def\tablestables{%
\tableofcontents%
+ \label{sec:toc}%
\ifnumgreater{\figurecount}{0}{\listoffigures}{}%
+ \label{sec:lof}%
\ifnumgreater{\tablecount}{0}{\listoftables}{}%
+ \label{sec:lot}%
+}
+
+% code
+\DeclareUrlCommand\code{%
+ \urlstyle{tt}%
+ \def\codebreak{\discretionary{\hbox{~\textbackslash{}}}{\hbox{~~}}{}}%
+ \def\UrlSpecials{%
+ \do\/{\hbox{/}\codebreak}%
+ \do\_{\hbox{\_}\codebreak}%
+ \do\ {\hbox{\ }\codebreak}%
+ \do\-{\hbox{-}\codebreak}%
+ }%
+ \def\UrlNoBreaks{%
+ \do\+%
+ \do\.%
+ \do\[%
+ \do\]%
+ }%
+ \def\UrlLeft{\hbox{\,}}%
+ \def\UrlRight{\hbox{\,}}%
+}
+\DefineVerbatimEnvironment{codeblock}{Verbatim}{
+ tabsize=2,
+ obeytabs,
+}
+
+% scale down image if it exceeds page margins
+\newcommand{\fitimg}[1]{%
+ \adjustbox{max width=\linewidth}{#1}%
+}
+
+% adjust scale for puml diagrams
+\newcommand{\includepumldiag}[1]{%
+ \fitimg{\includegraphics[scale=0.6]{#1}}%
}