Skip to content
Snippets Groups Projects
HsH-article.cls 12 KiB
Newer Older
  • Learn to ignore specific revisions
  • \typeout{Adapted from KOMA script for use in Hochschule Hannover <2022-03-20> Jan Wille}
    
    Jan Wille's avatar
    Jan Wille committed
    \NeedsTeXFormat{LaTeX2e}
    
    \newcommand{\myClassName}{HsH-article}
    
    \ProvidesClass{\myClassName}[2021/03/20 HsH Report based on KOMA]
    
    Jan Wille's avatar
    Jan Wille committed
    
    \newcommand{\HsHlogoPath}{HSH-Logo.pdf}
    \newcommand{\HsHlogoPage}{1}
    \newif\if@german%
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    Jan Wille's avatar
    Jan Wille committed
    \DeclareOption{german}{%
    	\PassOptionsToPackage{ngerman}{babel}
    	\@germantrue
    }
    \DeclareOption{ngerman}{%
    	\PassOptionsToPackage{\CurrentOption}{babel}
    	\@germantrue
    }
    \DeclareOption{english}{%
    	\PassOptionsToPackage{\CurrentOption}{babel}
    
    Jan Wille's avatar
    Jan Wille committed
    }
    
    \DeclareOption{f1}{% use logo of fakulty 1
    
    Jan Wille's avatar
    Jan Wille committed
    	\renewcommand{\HsHlogoPage}{2}
    }
    
    \DeclareOption{f2}{% use logo of fakulty 2
    
    Jan Wille's avatar
    Jan Wille committed
    	\renewcommand{\HsHlogoPage}{3}
    }
    
    \DeclareOption{f3}{% use logo of fakulty 3
    
    Jan Wille's avatar
    Jan Wille committed
    	\renewcommand{\HsHlogoPage}{4}
    }
    
    \DeclareOption{f4}{% use logo of fakulty 4
    
    Jan Wille's avatar
    Jan Wille committed
    	\renewcommand{\HsHlogoPage}{5}
    }
    
    \DeclareOption{f5}{% use logo of fakulty 5
    
    Jan Wille's avatar
    Jan Wille committed
    	\renewcommand{\HsHlogoPage}{6}
    }
    
    \DeclareOption{sans}{% use san serif font
    	\renewcommand{\familydefault}{\sfdefault}
    }
    \DeclareOption{roman}{% use roman/serif font
    	\renewcommand{\familydefault}{\rmdefault}
    }
    
    Jan Wille's avatar
    Jan Wille committed
    \DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}}
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    \ExecuteOptions{fontsize=11pt,a4paper,sans} % standart options
    
    Jan Wille's avatar
    Jan Wille committed
    \ProcessOptions\relax
    
    
    Jan Wille's avatar
    Jan Wille committed
    % Load KOMA class
    \LoadClass{scrartcl}
    \KOMAoption{toc}{bibliography,listof}
    
    
    Jan Wille's avatar
    Jan Wille committed
    % standart options for packages
    \PassOptionsToPackage{utf8}{inputenc}
    \PassOptionsToPackage{T1}{fontenc}
    \PassOptionsToPackage{left=3cm,right=2.5cm,top=3cm,bottom=3cm}{geometry}
    \PassOptionsToPackage{hidelinks}{hyperref}
    \PassOptionsToPackage{headsepline}{scrlayer-scrpage}
    \PassOptionsToPackage{babel}{csquotes}
    \if@german\PassOptionsToPackage{german=quotes}{csquotes}\fi
    
    \PassOptionsToPackage{backend=biber,style=alphabetic,sorting=nyt}{biblatex}
    \PassOptionsToPackage{free-standing-units,abbreviations}{siunitx}
    
    \PassOptionsToPackage{european,EFvoltages,straightvoltages,betterproportions}{circuitikz}
    
    Jan Wille's avatar
    Jan Wille committed
    
    % used packages:
    \RequirePackage{inputenc} % inputencoding, utf8 recomendet
    \RequirePackage{fontenc} % outputencoding, T1 recomendet
    \RequirePackage{lmodern} % font
    \RequirePackage{babel} % required for german names
    \RequirePackage{geometry} % required for changing layout
    \RequirePackage{scrlayer-scrpage} % required for header and footer
    \RequirePackage{scrhack} % compatability with listings
    \RequirePackage{pgffor} % foreach loops
    \RequirePackage{graphicx} % required for importing images
    \RequirePackage{hyperref} % references and lists are clikable
    \RequirePackage{bookmark} % generat bookmarkes
    \RequirePackage{amsmath} % a lot of nice Math
    \RequirePackage{csquotes} % quotations
    \if@german\RequirePackage{ziffer}\fi % german dezimal numbers
    
    
    
    % internal stuff
    \newtoks\@tabtoks
    \newcommand\addtabtoks[1]{\global\@tabtoks\expandafter{\the\@tabtoks#1}}
    \newcommand\eaddtabtoks[1]{\edef\mytmp{#1}\expandafter\addtabtoks\expandafter{\mytmp}}
    %\newcommand*\resettabtoks{\global\@tabtoks{}}
    \newcommand*\printtabtoks{\the\@tabtoks}
    
    \addtokomafont{publishers}{\normalsize}
    
    Jan Wille's avatar
    Jan Wille committed
     % config for title, header and footer
    
    \newcommand*{\@matrikelnr}{}%
    \newcommand{\matrikelnr}[1]{\gdef\@matrikelnr{#1}}%
    
    Jan Wille's avatar
    Jan Wille committed
    \newcommand*{\@professor}{}%
    \newcommand{\professor}[1]{\gdef\@professor{#1}}%
    
    \newcommand*{\@keywords}{}%
    \newcommand{\keywords}[1]{\gdef\@keywords{#1}}%
    
    Jan Wille's avatar
    Jan Wille committed
    \let\@author\@empty
    
    \let\@keywords\@empty
    
    Jan Wille's avatar
    Jan Wille committed
    \InputIfFileExists{personal.tex}{
    	\ClassInfo{\myClassName}{personal.tex was found. Using it...}
    }{
    	\ClassInfo{\myClassName}{no personal.tex! Configre the titlepage yourselfe}
    }
    \pagestyle{scrheadings}
    \clearpairofpagestyles
    \automark{section}
    \ohead{\headmark}
    \ihead{\@title}
    \ofoot*{\pagemark}
    
    % typesetting indexes upright or standart
    \def\subinrm#1{\sb{\mathrm{#1}}}
    {\catcode`\_=13 \global\let_=\subinrm}
    \mathcode`_="8000
    \newcommand\upsubscripts{\catcode`\_=12 } % the toggle for upright subscripts
    \newcommand\normalsubscripts{\catcode`\_=8 } % the toggle for italic subscripts
    \upsubscripts % setting upright as default
    
    % styling for itemize
    \renewcommand{\labelitemi}{$\bullet$}
    \renewcommand{\labelitemii}{$\circ$}
    \renewcommand{\labelitemiii}{$-$}
    \renewcommand{\labelitemiv}{$\cdot$}
    
    
    % custom commands
    \newcommand{\includeHsHlogohere}[1][5cm]{\includegraphics[width=#1,page=\HsHlogoPage]{\HsHlogoPath}}
    \newcommand{\uproman}[1]{\uppercase\expandafter{\romannumeral#1}}
    \newcommand{\lowroman}[1]{\romannumeral#1\relax}
    
    
    Jan Wille's avatar
    Jan Wille committed
    % do stuff
    \setlength\parindent{0pt} % indentation of new paragraphs
    \raggedbottom
    \renewcommand{\fps@figure}{h!t} % positioning of figures
    \renewcommand{\fps@table}{h!t} % Positonierung of tables
    \renewcommand{\layercontentsmeasure}{\empty} % rulers when using draft disabled
    \MakeOuterQuote{"} % easy quotationmarks
    
    
    
    % load config at beginning of document
    \AtBeginDocument{
    	\makeatletter
    	% solve some common errors:
    	\@ifpackageloaded{biblatex}{
    		\renewcommand*{\mkbibacro}[1]{\MakeUppercase{#1}} % solves fontype warning in San-Serif
    	}{}%
    	\@ifpackageloaded{subfigure}{
    		\newcommand{\subfigureautorefname}{\figureautorefname}
    	}{}%
    	% input config File:
    	\InputIfFileExists{config.tex}{
    		\ClassInfo{\myClassName}{config.tex was found. Using it...}
    	}{
    		\ClassInfo{\myClassName}{no config.tex!! I hope you configered it yourself.}
    	}
    	% provide some usefull commands:
    	\providecommand{\abs}[1]{\ensuremath{\left\vert#1\right\vert}} % Makro for vertical lines around absolute values
    	\makeatother
    }
    
    % nicer abstract:
    \renewenvironment{abstract}{%
    	\chapter*{\centering\abstractname}
    	\addcontentsline{toc}{chapter}{\abstractname}
    		\small
    		\quotation
    }{%
    	\endquotation
    }
    
    % decloration of Authorship
    
    \newif\if@oneAuthor \@oneAuthortrue
    \if@german
    	\setlocalecaption{ngerman}{dATitle}{Selbstständigkeitserklärung}
    	\setlocalecaption{ngerman}{dAPronomen}{\if@oneAuthor ich\else wir\fi}
    	\setlocalecaption{ngerman}{dAPluralendung}{\if@oneAuthor\else n\fi}
    	\setlocalecaption{ngerman}{dAGenitiv}{\if@oneAuthor mir\else uns\fi}
    	\setlocalecaption{ngerman}{dAText}{
    			Hiermit bestätige\dAPluralendungname\space\dAPronomenname, dass die folgende Arbeit eigenständig von \dAGenitivname\space allein erstellt
    			und unter Berücksichtigung der zur Verfügung gestellten Aufgabenstellung sowie dem Arbeitsmaterial unter Angabe aller verwendeten Quellen
    			erarbeitet wurde. Die Regelungen und Konsequenzen eines Plagiats, inklusive disziplinarischer Maßnahmen, sind \dAGenitivname\space
    			bewusst. Insbesondere wurden alle Zitate und gedanklichen Übernahmen als solche kenntlich gemacht.
    	}
    \else
    	\setlocalecaption{english}{dATitle}{Declaration of Authorship}
    	\setlocalecaption{english}{dAPronomen}{\if@oneAuthor I\else we\fi}
    	\setlocalecaption{english}{dAPronomenf}{\if@oneAuthor I\else We\fi}
    	\setlocalecaption{english}{dAPronomverb}{\if@oneAuthor am\else are\fi}
    	\setlocalecaption{english}{dAGenitiv}{\if@oneAuthor my\else our\fi}
    	\setlocalecaption{english}{dAText}{
    		\dAPronomenfname\space hereby certify that the work \dAPronomenname\space\dAPronomverbname\space submitting is entirely of
    		\dAGenitivname\space own making except where otherwise indicated. \dAPronomenfname\space\dAPronomverbname\space aware of regulations
    		concerning plagiarism, including disciplinary actions that may result from it. Any use of the works of any other author, in any form, is
    		properly acknowledged at their point of use.
    	}
    \fi
    
    Jan Wille's avatar
    Jan Wille committed
    \newcommand\declarationAuthorship{
    
    	\renewcommand{\thanks}{\sbox0}
    	\foreach \x [count=\i] in \@author{\ifnum\i>1\global\@oneAuthorfalse\fi}
    %
    
    Jan Wille's avatar
    Jan Wille committed
    	\thispagestyle{plain}
    	\vspace*{\fill}
    	{\rule{\textwidth}{0.1pt}}
    
    	\vskip 3em
    	{\centering\huge\textbf{\dATitlename}\par}
    	\vskip 3em
    	{\dATextname\par}
    	{\raggedleft
    		\foreach \x in \@author{
    
    Jan Wille's avatar
    Jan Wille committed
    			\begin{tabular}[t]{r}
    				\\[3em]
    
    				\rule{4cm}{0.4pt}\\
    
    Jan Wille's avatar
    Jan Wille committed
    				{\footnotesize\x}
    			\end{tabular}
    		}
    
    Jan Wille's avatar
    Jan Wille committed
    }
    
    % reconfig Titlepage
    
    \renewcommand\maketitle[1][c]{%
    
    Jan Wille's avatar
    Jan Wille committed
    	\expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
    	\else
    		\def\and{%
    			\end{tabular}%
    			\hskip 1em \@plus.17fil%
    			\begin{tabular}[t]{c}%
    		}%
    	\fi
    
    	\par
    	\ifx\@uppertitleback\@empty\else
    		\ClassWarning{\KOMAClassName}{%
    			non empty \string\uppertitleback\space ignored
    			by \string\maketitle\MessageBreak
    			in `titlepage=false' mode%
    		}%
    	\fi
    	\ifx\@lowertitleback\@empty\else
    		\ClassWarning{\KOMAClassName}{%
    			non empty \string\lowertitleback\space ignored
    			by \string\maketitle\MessageBreak
    			in `titlepage=false' mode%
    		}%
    	\fi
    	\begingroup
    
    		\ifx\@param\@empty\ClassError{\myClassName}{\maketitle\space with empty option}{
    				\maketitle[] has been called with an empty parameter, this doesn't work. Use \maketitle instead.
    
    Jan Wille's avatar
    Jan Wille committed
    			}
    		\fi
    
    		\let\titlepage@restore\relax
    		\renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
    		\let\@oldmakefnmark\@makefnmark
    		\renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
    		\next@tdpage
    		\ifx\@extratitle\@empty
    			\ifx\@frontispiece\@empty\else \mbox{}\fi
    		\else
    			\@makeextratitle
    
    Jan Wille's avatar
    Jan Wille committed
    		\fi
    
    		\ifx\@frontispiece\@empty
    			\ifx\@extratitle\@empty\else\next@tdpage\fi
    		\else
    			\next@tpage
    			\@makefrontispiece
    
    Jan Wille's avatar
    Jan Wille committed
    			\next@tdpage
    
    		\fi
    		\global\@topnum=\z@
    		\setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
    		\IfFileExists{\HsHlogoPath}{}{
    			\ClassError{\myClassName}{HsH-Logo.pdf not found!}{
    				The HsH Logo is necasary for the titlepage! Try putting it next to your source file or use \HsHlogoPath to define the file location
    			}
    		}
    		\vspace*{1cm}
    		\begin{minipage}[t]{\textwidth}%
    			\ifx\@titlehead\@empty \else
    				\usekomafont{titlehead}{\@titlehead}%
    			\fi
    			\hfill
    			\raisebox{0pt}[\ht\strutbox][\dp\strutbox]{\includeHsHlogohere}
    		\end{minipage}
    		\raisebox{10pt}{\rule{\textwidth}{0.5pt}}
    		\null
    		\vskip 2em%
    		\if\@param c\begin{center}\fi
    		\if\@param r\begin{flushright}\fi
    			\ifx\@subject\@empty \else
    			{\usekomafont{subject}{\@subject \par}}%
    			\vskip 1.5em
    			\fi
    			{\usekomafont{title}{\huge \@title \par}}%
    			\vskip .5em
    			{\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
    			\vskip 4em
    			{\ifx\@matrikelnr\@empty
    				\if\@author\@empty\else\usekomafont{author}{
    					\parbox{\dimexpr\linewidth}{
    						\if\@param c\centering\fi
    						\if\@param r\raggedleft\fi
    						\@author
    					}
    				}\fi
    
    Jan Wille's avatar
    Jan Wille committed
    			\else
    
    				\if\@author\@empty\else
    					% sneeky comma needed after \@matrikelnr to deal with single item list
    					\foreach \x [count=\i,evaluate=\i as \y using {{\@matrikelnr,}[\i-1]}] in \@author {\eaddtabtoks{\x & \y\protect\\}}
    					\usekomafont{author}{\def\arraystretch{1.2}
    						\if\@param l\hspace{-6pt}\begin{tabular}{l l}\printtabtoks\end{tabular}\fi
    						\if\@param c\begin{tabular}{l l}\printtabtoks\end{tabular}\fi
    						\if\@param r\begin{tabular}{r r}\printtabtoks\end{tabular}\hspace{-6pt}\fi
    					}
    
    Jan Wille's avatar
    Jan Wille committed
    				\fi
    
    			{\usekomafont{date}{\@date \par}}
    			\vskip 1em
    			{\if\@professor\@empty\else\usekomafont{publishers}{Professor\if@german(in)/Lehrbeauftragte(r)\fi: \@professor}\fi}
    
    			\ifx\@dedication\@empty \else
    			\vskip 2em
    
    			{\usekomafont{dedication}{\@dedication \par}}
    
    Jan Wille's avatar
    Jan Wille committed
    			\fi
    
    		\if\@param c\end{center}\fi
    		\if\@param r\end{flushright}\fi
    		\par
    		\vskip 2em
    		\ifx\titlepagestyle\@empty\else\thispagestyle{\titlepagestyle}\fi
    		\@thanks\global\let\@thanks\@empty
    	\endgroup
    
    Jan Wille's avatar
    Jan Wille committed
    	\setcounter{footnote}{0}%
    	\expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
    		\let\thanks\relax
    		\let\maketitle\relax
    		\let\@maketitle\relax
    		\global\let\@thanks\@empty
    		\global\let\@author\@empty
    		\global\let\@date\@empty
    		\global\let\@title\@empty
    		\global\let\@subtitle\@empty
    		\global\let\@extratitle\@empty
    		\global\let\@frontispiece\@empty
    		\global\let\@titlehead\@empty
    		\global\let\@subject\@empty
    		\global\let\@publishers\@empty
    		\global\let\@uppertitleback\@empty
    		\global\let\@lowertitleback\@empty
    		\global\let\@dedication\@empty
    
    		\global\let\@matrikelnr\@empty
    		\global\let\@prof\@empty
    
    Jan Wille's avatar
    Jan Wille committed
    		\global\let\author\relax
    		\global\let\title\relax
    		\global\let\extratitle\relax
    		\global\let\titlehead\relax
    		\global\let\subject\relax
    		\global\let\publishers\relax
    		\global\let\uppertitleback\relax
    		\global\let\lowertitleback\relax
    		\global\let\dedication\relax
    		\global\let\date\relax
    
    		\global\let\matrikelnr\relax
    		\global\let\professor\relax
    
    Jan Wille's avatar
    Jan Wille committed
    	\fi
    	\global\let\and\relax
    }%