From eecaf177ea63fe1da21644427f1388428744205d Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 9 Sep 2024 14:49:23 +0200 Subject: add glossary + format LaTeX code --- projdoc.cls | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'projdoc.cls') diff --git a/projdoc.cls b/projdoc.cls index c6abaca..503f049 100644 --- a/projdoc.cls +++ b/projdoc.cls @@ -14,6 +14,18 @@ \PassOptionsToPackage{nosort}{cleveref} \PassOptionsToPackage{nameinlink}{cleveref} \PassOptionsToPackage{obeyspaces}{url} +\PassOptionsToPackage{toc=false}{glossaries} +\PassOptionsToPackage{record}{glossaries-extra} +\PassOptionsToPackage{ + 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} % frequently used packages \RequirePackage{geometry} @@ -38,9 +50,13 @@ \RequirePackage{cleveref} \RequirePackage{adjustbox} \RequirePackage{xparse} +\RequirePackage{biblatex} +\RequirePackage{glossaries} +\RequirePackage{glossaries-extra} \RequirePackage{ifdraft} \RequirePackage{enumitem} \RequirePackage{subcaption} +\RequirePackage{multicol} % font style \setmainfont{TeX Gyre Schola} @@ -171,18 +187,14 @@ \makeatother % 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} +% glossary +\GlsXtrLoadResources[ + src={./glossary.bib}, + selection={recorded and deps and see}, +] + % default document header/trailer \makeatletter \def\projdoc@header{ @@ -196,8 +208,16 @@ \newbool{projdoc@cited} \apptocmd{\abx@aux@cite}{\global\booltrue{projdoc@cited}}{}{} \def\projdoc@trailer{ - % end with bibliography (if citations used) + % bibliography (if citations used) \ifbool{projdoc@cited}{\printbibliography}{}% + % glossary + \ifcsundef{printunsrtglossary}{}{% + \section*{Glossary}% + \begin{multicols}{2}% + \renewcommand{\glossarysection}[2][]{}% + \printunsrtglossary% + \end{multicols}% + }% } \AtBeginDocument{\projdoc@header} \AtEndDocument{\projdoc@trailer} -- cgit v1.2.3 From e2129e31d57eb6967094e26960e59256c1f9dbab Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 10 Sep 2024 13:13:46 +0200 Subject: add comparison environment + more example LaTeX code --- comparison.sty | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ example.tex | 27 +++++++++++++++++++- projdoc.cls | 1 + 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 comparison.sty (limited to 'projdoc.cls') diff --git a/comparison.sty b/comparison.sty new file mode 100644 index 0000000..d10f95f --- /dev/null +++ b/comparison.sty @@ -0,0 +1,80 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{comparison}[2024-01-19 package comparison] + +\RequirePackage{booktabs} +\RequirePackage{etoolbox} +\RequirePackage{tabularx} +\RequirePackage{environ} +\RequirePackage{enumitem} + +% comparison environment, usage: +% +% \begin{comparison} +% \pro{reason why thing is good} +% \pro{...} +% \con{reason why thing is bad} +% \con{...} +% \end{comparison} +% +% output: +% +% Pros (2) Cons (2) +% ---------------------------------------------------------- +% - reason why thing is good - reason why thing is bad +% - ... - ... +% + +\newcounter{pro-count} +\newcounter{pro-index} +\newcounter{con-count} +\newcounter{con-index} +\newcounter{cmp-count} +\newcounter{cmp-index} +\NewEnviron{comparison}{% + \par% + \setcounter{pro-count}{0}% + \newcommand{\pro}[1]{% + \stepcounter{pro-count}% + \csdef{pro-\the\value{pro-count}}{##1}% + }% + \setcounter{con-count}{0}% + \newcommand{\con}[1]{% + \stepcounter{con-count}% + \csdef{con-\the\value{con-count}}{##1}% + }% + \BODY% + \def\spacing{3mm}% + \newcommand{\halfbox}[1]{% + \begin{minipage}[t]{\dimexpr(\linewidth - \spacing) / 2\relax}% + ##1% + \end{minipage}% + }% + \begin{minipage}{\linewidth}% + \halfbox{\strut\centering\textsc{Benefits}~(\the\value{pro-count})\strut}% + \hfill% + \halfbox{\strut\centering\textsc{Drawbacks}~(\the\value{con-count})\strut}% + \par% + \vspace*{\dimexpr-\parskip-0.5\baselineskip\relax}% + \noindent\rule{\linewidth}{0.66pt}\par% + \vspace*{\dimexpr-\parskip\relax}% + \halfbox{% + \begin{itemize}[leftmargin=5mm]% + \setcounter{pro-index}{0}% + \whileboolexpr{test{\ifnumcomp{\value{pro-index}}{<}{\value{pro-count}}}}{% + \stepcounter{pro-index}% + \item \csuse{pro-\the\value{pro-index}}% + }% + \end{itemize}% + }\hfill\halfbox{% + \begin{itemize}[leftmargin=5mm]% + \setcounter{con-index}{0}% + \whileboolexpr{test{\ifnumcomp{\value{con-index}}{<}{\value{con-count}}}}{% + \stepcounter{con-index}% + \item \csuse{con-\the\value{con-index}}% + }% + \end{itemize}% + }% + \end{minipage}% + \par% +} + diff --git a/example.tex b/example.tex index 8525973..ce45f6f 100644 --- a/example.tex +++ b/example.tex @@ -108,7 +108,7 @@ The \codeinline{blockcode} environment can be used to insert a code block: This is all included verbatim: \verb|asdf| \ $%!(*@#&)$ \end{blockcode} -\subsection{Lists} +\subsection{Information dumps} Unordered (bullet) list: @@ -136,9 +136,34 @@ Numbered list: (See \cref{item:enum-nest-ref}) +Description: + +\begin{description} + \item[Item one] description of item one + \item[Item two] description of item two + \item[Item three] ... +\end{description} + +\subsection{Comparisons} + +\begin{comparison} + \pro{Good thing} + \con{Bad thing} + \pro{Good thing 2} + \con{Bad thing 2} +\end{comparison} + \subsection{Citations} Citations are inserted using the \codeinline{\autocite} command \autocite{rfc:3339}. +The bibliography is automatically printed after \codeinline{\end{document}}. + +\subsection{Glossary} + +Glossary entries can be inserted using the \codeinline{\gls} commands. Example: +``\Gls{sdl2} handles \glspl{hid} as well!''. In following occurrences of acronyms, +only their short form is printed: `\gls{sdl2}' and `\gls{hid}'. All of these link to +the glossary that is automatically printed after \codeinline{\end{document}}. \end{document} diff --git a/projdoc.cls b/projdoc.cls index 503f049..388f901 100644 --- a/projdoc.cls +++ b/projdoc.cls @@ -57,6 +57,7 @@ \RequirePackage{enumitem} \RequirePackage{subcaption} \RequirePackage{multicol} +\RequirePackage{comparison} % ./comparison.sty % font style \setmainfont{TeX Gyre Schola} -- cgit v1.2.3