From 73a360ab2f5fa3c95f796fed399e96dd8a07585e Mon Sep 17 00:00:00 2001 From: Kim Wittenburg Date: Sun, 16 Apr 2017 15:51:11 +0200 Subject: [PATCH] Add homework Class --- homework.cls | 342 +++++++++++++++++++++++++++ homework.dtx | 640 +++++++++++++++++++++++++++++++++++++++++++++++++++ homework.ins | 51 ++++ 3 files changed, 1033 insertions(+) create mode 100644 homework.cls create mode 100644 homework.dtx create mode 100644 homework.ins diff --git a/homework.cls b/homework.cls new file mode 100644 index 0000000..a4bd6cc --- /dev/null +++ b/homework.cls @@ -0,0 +1,342 @@ +%% +%% This is file `homework.cls', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% homework.dtx (with options: `class') +%% +%% Copyright (C) 2017 by Kim Wittenburg +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. + +\NeedsTeXFormat{LaTeX2e}[2005/12/01] +\ProvidesClass{homework}[2017/04/15 v1.1 The Homework Class] + + + +\newif\ifhomework@shorttitle +\DeclareOption{shorttitle}{ + \homework@shorttitletrue +} + +\DeclareOption{longtitle}{ + \homework@shorttitlefalse +} + +\newif\ifhomework@shortheader +\DeclareOption{shortheader}{ + \homework@shortheadertrue +} + +\DeclareOption{longheader}{ + \homework@shortheaderfalse +} + +\ExecuteOptions{longtitle,longheader} + +\ProcessOptions\relax +\LoadClassWithOptions{scrartcl} + +%%%%%%%% Dependencies %%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%\fi + +\RequirePackage[utf8]{inputenc} % UTF-8 Encoding +\RequirePackage{cmap} % Special Character +\RequirePackage[T1]{fontenc} % Font Encoding +\RequirePackage[ngerman]{babel} % German Language +\RequirePackage{etoolbox} % Programming +\RequirePackage{calc} % Calculations + +\RequirePackage[a4paper, + left=25mm, + right=25mm, + top=20mm, + bottom=50mm]{geometry} % Page Margins + +\RequirePackage[headsepline]{scrlayer-scrpage} % Header and Footer +\RequirePackage{lastpage} % Page Numbers + +\RequirePackage{xcolor} % Colors +\RequirePackage{framed} % Colored Boxes +\RequirePackage[colorlinks,linkcolor=blue!70]{hyperref} % Links and References +\RequirePackage{lmodern} % Better Font + +%%%%%%% Custom Commands %%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%\fi + +\newcommand{\university}[2][]{ + \ifstrempty{#1}{ + \gdef\@shortuniversity{#2} + }{ + \gdef\@shortuniversity{#1} + } + \gdef\@university{#2} +} + +\newcommand{\course}[2][]{ + \ifstrempty{#1}{ + \gdef\@shortcourse{#2} + }{ + \gdef\@shortcourse{#1} + } + \gdef\@course{#2} +} + +\newcommand{\teacher}[1]{ + \gdef\@teacher{#1} +} + +\newcommand{\group}[1]{ + \gdef\@group{#1} +} + +\newcommand{\sheetno}[1]{ + \gdef\@sheetno{#1} +} + +\newcommand{\id}[1]{\\\ttfamily\footnotesize(#1)} + +\university[Uni Hamburg]{Universität Hamburg} +\course{} +\group{} +\teacher{} +\sheetno{} +\title{} + + +\newcommand{\todomark}{% + \colorbox{purple}{% + \textnormal\ttfamily\bfseries\color{white}% + TODO% + }% +} + +\newcommand{\todo}[1][]{% + \ifstrempty{#1}{% + \def\todotext{Todo}% + }{% + \def\todotext{Todo: #1}% + }% + \todomark% + {% + \marginpar{% + \raggedright\normalfont\sffamily\scriptsize\todotext% + }% + }% +} + + +\setcounter{secnumdepth}{0} + +\newif\if@tasknumbers +\@tasknumberstrue + +\newcounter{task} +\newcommand{\task}[2][]{% + \ifstrempty{#1}{% + \stepcounter{task}% + }{% + \setcounter{task}{#1}% + }% + \if@tasknumbers% + \section{Aufgabe \arabic{task}: #2}% + \else% + \section{#2}% + \fi% +} + +\newcounter{subtask}[task] +\newcommand{\subtask}[2][]{% + \ifstrempty{#1}{% + \stepcounter{subtask}% + }{% + \setcounter{subtask}{#1}% + }% + \if@tasknumbers% + \subsection{\arabic{task}.\arabic{subtask}. #2}% + \else% + \subsection{#2}% + \fi% +} + +\newcounter{subsubtask}[subtask] +\newcommand{\subsubtask}[2][]{% + \ifstrempty{#1}{% + \stepcounter{subsubtask}% + }{% + \setcounter{subsubtask}{#1}% + }% + \if@tasknumbers% + \subsubsection{\arabic{task}.\arabic{subtask}.\arabic{subsubtask}. #2}% + \else% + \subsubsection{#2}% + \fi% +} + +%%%%%%%%% Page Setup %%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%\fi + + +\setlength{\headheight}{50pt} +\pagestyle{scrheadings} +\clearpairofpagestyles + +\ifhomework@shortheader + \ihead{\textbf{\@shortcourse}\\Aufgabenblatt \@sheetno} + \ohead{\textbf{\@shortuniversity}\\\@date} +\else + \ihead{\textbf{\@course}\\Aufgabenblatt \@sheetno} + \ohead{\textbf{\@university}\\\@date} +\fi + +\setkomafont{pagefoot}{\textnormal} +\cfoot[Seite \pagemark{} von \pageref{LastPage}]{Seite \pagemark{} von \pageref{LastPage}} + +\newpagestyle{firstpage}[]{% + \ihead{h} + \cfoot{\pagemark{}} +} + +%%%%%%%%%%% Layout %%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%\fi + + +\setlength{\parindent}{0em} +\setlength{\parskip}{5pt} + +\setkomafont{section}{\normalfont\bfseries\Large} +\setkomafont{subsection}{\normalfont\bfseries\large} +\RedeclareSectionCommands[afterskip=.25\baselineskip]{section} +\RedeclareSectionCommands[ + beforeskip=0.5\baselineskip, + afterskip=.125\baselineskip]{subsection} + +\renewcommand*{\maketitle}{% + \thispagestyle{plain}% + + \newif\ifextended + \extendedtrue + + \def\homework@university{\@university} + \def\homework@course{\@course} + \ifhomework@shorttitle + \def\homework@university{\@shortuniversity} + \def\homework@course{\@shortcourse} + \else + \def\homework@university{\@university} + \def\homework@course{\@course} + \fi + + % \end{macrocode} + % First we define the different layout parts. The title has six \emph{slots} + % each of which can hold a piece of text: + % \begin{description} + % \item[Top Left] On the top left the course name ist printed in a bold + % font. + % \item[Top Right] On the top right the name of the university is printed + % in a bold font. + % \item[Meta Left] Below the course name a piece of information is + % printed. The contents of this slot depend on the + % specified information and can be either the group + % number or the teacher. + % \item[Meta Right] Similar to meta left but below the university name. + % This slot typically holds the teacher or the date. + % \item[Title Left] Above the actual title there is a row of secondary + % titles. On the left of this row the sheet number is + % printed. + % \item[Title Right] Similarly to title left this slot may contain the + % date. + % \end{description} + % Below the header the actual document title and the author(s) are printed. + % If no |\title| is specified the sheet number becomes the title (|\title| + % however remains empfy). + % \begin{macrocode} + \ifdefempty{\@title}{% + \ifdefempty{\@group}{% + \def\metaleft{\@teacher}% + \def\metaright{\@date}% + \def\titleright{}% + \extendedfalse + }{% + \def\metaleft{Übungsgruppe \@group}% + \def\metaright{\@teacher}% + \def\titleright{\@date}% + }% + \def\titleleft{}% + \def\title{Aufgabenblatt \@sheetno}% + }{% + \ifdefempty{\@group}{% + \def\metaleft{}% + \def\metaright{\@teacher}% + }{% + \def\metaleft{Übungsgruppe \@group}% + \def\metaright{\@teacher}% + }% + \def\titleleft{Aufgabenblatt \@sheetno}% + \def\titleright{\@date}% + \def\title{\@title}% + }% + + % \end{macrocode} + % The following code prints the title with the information specified above. + % Depending on the value of |\ifextended| the title will be longer or + % shorter. + % + % Each field (heading, secondary title, title, author) is put in a separate + % group to avoid interference. + % \begin{macrocode} + + \begingroup% Heading Group + \usekomafont{pageheadfoot}% + \usekomafont{pagehead}% + \setlength{\parskip}{0pt}% + + \textbf{\homework@course} \hfill \textbf{\homework@university}\par% + + \begin{minipage}[t]{\widthof{\metaleft}}% + \metaleft% + \end{minipage}% + \hfill% + \begin{minipage}[t]{\widthof{\metaright}}% + \raggedleft% + \metaright% + \end{minipage}% + \endgroup% + + \ifextended% + \vspace{\baselineskip}% + \fi% + + \begingroup% Secondary Title Group + \Large\bfseries\titleleft\hfill\titleright% + \endgroup% + + \begingroup% Title Group + \begin{center}% + \Huge\textsc{\title}% + \end{center}% + \endgroup% + + \begingroup% Author Group + \setlength{\baselineskip}{2.75\baselineskip}% + \vspace{-\baselineskip}% + \begin{center}% + \begin{tabular}[t]{c}% + \@author% + \end{tabular}% + \end{center}% + \endgroup% +} + +\endinput +%% +%% End of file `homework.cls'. diff --git a/homework.dtx b/homework.dtx new file mode 100644 index 0000000..878c30c --- /dev/null +++ b/homework.dtx @@ -0,0 +1,640 @@ +% \iffalse meta-comment +% +% Copyright (C) 2017 by Kim Wittenburg +% +% This file may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either +% version 1.3 of this license or (at your option) any later +% version. The latest version of this license is in: +% +% http://www.latex-project.org/lppl.txt +% +% and version 1.3 or later is part of all distributions of +% LaTeX version 2005/12/01 or later. +% +% \fi + + +% \iffalse +%\ProvidesFile{homework.dtx} +% +%\NeedsTeXFormat{LaTeX2e}[2005/12/01] +%\ProvidesClass{homework}[2017/04/15 v1.1 The Homework Class] +%<*driver> +\documentclass{ltxdoc} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage[english]{babel} + +\usepackage{enumitem} + +\usepackage{lmodern} + +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{homework.dtx} +\end{document} +% +% \fi + + +% \CheckSum{0} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} + + +% \changes{v1.0}{2017/04/12}{Initial version} +% +% \GetFileInfo{homework.cls} +% +% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ } +% \DoNotIndex{\@ne} +% \DoNotIndex{\advance,\begingroup,\catcode,\closein} +% \DoNotIndex{\closeout,\day,\def,\edef,\else,\empty,\endgroup} + +% \title{The \textsf{homework} package\thanks{This document +% corresponds to \textsf{homework}~\fileversion, +% dated~\filedate.}} +% \author{Kim Wittenburg \\ \texttt{5wittenb@informatik.uni-hamburg.de}} +% +% \maketitle +% +% \begin{abstract} +% The \textsf{homework} document class is a document class designed to be used +% for homework in university (or school). The class predominantly implements a +% custom layout for titles but also featues some helpful new commands. +% \end{abstract} +% +% \tableofcontents +% +% \section{Usage} +% +% \subsection{Class Options} +% +% Currently the \textsf{homework} class supports two (or rather four) options: +% +% \DescribeMacro{shorttitle} +% You can pass \texttt{shorttitle} class option to display the short university +% name and short course name in the title. You could also explicitly pass +% \texttt{longtitle} which is the default. +% +% \DescribeMacro{shortheader} +% Similarly you cann pass \texttt{shortheader} or \texttt{longheader} to display +% the short or regular university and course name in the header on each +% subsequent page. +% +% \subsection{The Title} +% +% The main feature of the \textsf{homework} class is the custom title layout. +% The layout implements some new fields like the name of university (or school), +% the name of the teacher or the number of the exercise sheet. The full list of +% supported fields is listed below. The actual title layout may be different +% depending on which of the following fields are actually specified. +% +% \begingroup +% \setlist[description]{ +% font={\normalfont} +% } +% +% \begin{description} +% \item[|\textbackslash university|\oarg{short uni}\marg{uni}] +% \DescribeMacro{\university} +% Lets you specify the name of the university (or school). The default +% value is \texttt{Universität Hamburg}. +% \item[|\textbackslash course|\oarg{short course} \marg{course}] +% \DescribeMacro{\course} +% Lets you specify the name of the course of the assignment. The +% course is sometimes referred to as a \emph{module}. +% \item[|\textbackslash teacher|\marg{teacher}] \DescribeMacro{\teacher} +% Lets you specify the name of the teacher or teachers of the course. +% If you want to specify multiple teachers it is recommended that you +% separate them with the |\\| command. +% \item[|\textbackslash group|\marg{group number}] \DescribeMacro{\group} +% The exercises for many university courses are divided into multiple +% exercise groups. Using this command you can specify the number of +% your group. +% \item[|\textbackslash sheetno|\marg{sheet number}] \DescribeMacro{\sheetno} +% Lets you specify the current exercise sheet. If no |\title| is +% provided the sheet number is used as title of the document. +% \end{description} +% \endgroup +% +% In addition to the above new commands you can also specify a |\title|, |\date| +% and one or more |\author|s. +% +% \DescribeMacro{\id} +% Sometimes you have to provide your student ID with your solutions to an +% exercise sheet. The \textsf{homework} class provides the |\id|\marg{id} +% command for this case. This command should be used when specifying the authors +% with the |\author| command. It might look like this: +% |\author{John Doe\id{1234567}}| +% +% \subsection{Tasks and Subtasks} +% +% The \textsf{homework} class is based on \textsf{srcarctl} from the KOMA +% packages so its main sectioning level are sections (not chapters). Sections +% and subsections however do not always accurately reflect the semantics of +% solutions to an assignment. Instead the \textsf{homework} class provides the +% following commands: +% +% \smallskip +% +% \DescribeMacro{\task}|\task|\oarg{task number}\marg{task name}\\ +% The |\task| command replaces the |\section| command. It incrementally numbers +% the tasks (starting at 1). If you want to skip a task you can use the optional +% \meta{task number} argument to set the task number to a specific value. +% Subsequent tasks are then incrementally numbered. +% +% \smallskip +% +% \DescribeMacro{\subtask}|\subtask|\oarg{task number}\marg{task name}\\ +% \DescribeMacro{\subsubtask}|\subsubtask|\oarg{task number}\marg{task name}\\ +% The |\subtask| and |\subsubtask| replace |\subsection| and |\subsubsection| +% respectively. They work analogous to |\task|. +% +% \smallskip +% +% The standard sectioning commands are not modified by the \textsf{homework} +% class so it is still possible to use them. In fact the |\task| commands do +% create sections and subsections internally. You should however be careful in +% using |\section|s yourself because it may be difficult to distinguish |\task|s +% from |\section|s. +% +% \subsection{Todos} +% +% The \textsf{homework} class offers rudimentary support for todo notes. +% Currently todo support is very limited and may not work in some cases. +% +% \smallskip +% +% \DescribeMacro{\todo}|\todo|\oarg{todo text}\\ +% The |\todo| command does two things: +% \begin{enumerate} +% \item It puts a todo marker in the text where the |\todo| command is +% specified. The todo marker is defined by the |\todomarker| command. +% \DescribeMacro{\todomarker} +% \item It puts a todo note at the page margin so that you can easily spot +% open todos in the PDF. The text of the todo note can be customized using +% the \meta{todo text} optional argument. +% \end{enumerate} +% +% \StopEventually{ +% \PrintIndex +% \PrintChanges +% } +% +% \section{Implementation} +% +% \changes{v1.1}{2017/04/15}{Add Class Options} +% In addition to the options provided by \textsf{scrartcl} the \textsf{homework} +% class supports the following options. +% \begin{macrocode} +\newif\ifhomework@shorttitle +\DeclareOption{shorttitle}{ + \homework@shorttitletrue +} + +\DeclareOption{longtitle}{ + \homework@shorttitlefalse +} + +\newif\ifhomework@shortheader +\DeclareOption{shortheader}{ + \homework@shortheadertrue +} + +\DeclareOption{longheader}{ + \homework@shortheaderfalse +} + +\ExecuteOptions{longtitle,longheader} + +\ProcessOptions\relax +% \end{macrocode} +% +% The \textsf{homework} class is based on \textsf{scrartcl}. +% \begin{macrocode} +\LoadClassWithOptions{scrartcl} +% \end{macrocode} + +% \iffalse %%%%%%%%%%%%%%%%%%% +%%%%%%%% Dependencies %%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%\fi + +% \subsection{Dependencies} +% +% \begin{macrocode} +\RequirePackage[utf8]{inputenc} % UTF-8 Encoding +\RequirePackage{cmap} % Special Character +\RequirePackage[T1]{fontenc} % Font Encoding +\RequirePackage[ngerman]{babel} % German Language +\RequirePackage{etoolbox} % Programming +\RequirePackage{calc} % Calculations + +\RequirePackage[a4paper, + left=25mm, + right=25mm, + top=20mm, + bottom=50mm]{geometry} % Page Margins + +\RequirePackage[headsepline]{scrlayer-scrpage} % Header and Footer +\RequirePackage{lastpage} % Page Numbers + +\RequirePackage{xcolor} % Colors +\RequirePackage{framed} % Colored Boxes +\RequirePackage[colorlinks,linkcolor=black]{hyperref} % Links and References +\RequirePackage{lmodern} % Better Font +% \end{macrocode} + +% \iffalse %%%%%%%%%%%%%%%%%%% +%%%%%%% Custom Commands %%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%\fi + +% \subsection{Definitions} +% +% \subsubsection{Title Elements} +% +% \begin{macro}{\university} +% The |\university| command stores the name of the university for later use. +% \begin{macrocode} +\newcommand{\university}[2][]{ + \ifstrempty{#1}{ + \gdef\@shortuniversity{#2} + }{ + \gdef\@shortuniversity{#1} + } + \gdef\@university{#2} +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\course} +% The |\course| command stores the name of the course for later use. +% \begin{macrocode} +\newcommand{\course}[2][]{ + \ifstrempty{#1}{ + \gdef\@shortcourse{#2} + }{ + \gdef\@shortcourse{#1} + } + \gdef\@course{#2} +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\teacher} +% The |\teacher| command stores the name of the teacher for later use. +% \begin{macrocode} +\newcommand{\teacher}[1]{ + \gdef\@teacher{#1} +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\group} +% The |\group| command stores the name of the group for later use. +% \begin{macrocode} +\newcommand{\group}[1]{ + \gdef\@group{#1} +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\sheetno} +% The |\sheetno| command stores the assignment sheet number for later use. +% \begin{macrocode} +\newcommand{\sheetno}[1]{ + \gdef\@sheetno{#1} +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\id} +% The |\id| macro prints the id of an author. The default implementation puts +% the id on a new line in parentheses. +% \begin{macrocode} +\newcommand{\id}[1]{\\\ttfamily\footnotesize(#1)} +% \end{macrocode} +% \end{macro} + +% The default values for most fields are empty. The default university is the +% university of Hamburg. +% \begin{macrocode} +\university[Uni Hamburg]{Universität Hamburg} +\course{} +\group{} +\teacher{} +\sheetno{} +\title{} +% \end{macrocode} + +% \subsubsection{Todos} + +% \begin{macro}{\todomark} +% The |\todomark| is placed in the text when the |\todo| command is used. The +% default implementation draws a purple box with the text "Todo" inside. +% \begin{macrocode} +\newcommand{\todomark}{% + \colorbox{purple}{% + \textnormal\ttfamily\bfseries\color{white}% + TODO% + }% +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\todo} +% The |\todo| macro places the |\todomark| and puts a todo text in a marginpar. +% \begin{macrocode} +\newcommand{\todo}[1][]{% + \ifstrempty{#1}{% + \def\todotext{Todo}% + }{% + \def\todotext{Todo: #1}% + }% + \todomark% + {% + \marginpar{% + \raggedright\normalfont\sffamily\scriptsize\todotext% + }% + }% +} +% \end{macrocode} +% \end{macro} + +% \subsubsection{Tasks} + +% The task mechanism of the \textsf{homework} class implements its own numbering +% mechanism. This is neccessary because the task numbers are not necessarily +% placed at the beginning of the title of a section. +% \begin{macrocode} +\setcounter{secnumdepth}{0} + +\newif\if@tasknumbers +\@tasknumberstrue +% \end{macrocode} + +% \begin{macro}{\task} +% The |\task| command is basically just a wrapper around a section with a +% semi-customizable section title. +% \begin{macrocode} +\newcounter{task} +\newcommand{\task}[2][]{% + \ifstrempty{#1}{% + \stepcounter{task}% + }{% + \setcounter{task}{#1}% + }% + \if@tasknumbers% + \section{Aufgabe \arabic{task}: #2}% + \else% + \section{#2}% + \fi% +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\subtask} +% The equivalent of |\subsection| for the \textsf{homework} class. |\subtask| +% essentially wraps |\subsection| with a semi-customizable title. +% \begin{macrocode} +\newcounter{subtask}[task] +\newcommand{\subtask}[2][]{% + \ifstrempty{#1}{% + \stepcounter{subtask}% + }{% + \setcounter{subtask}{#1}% + }% + \if@tasknumbers% + \subsection{\arabic{task}.\arabic{subtask}. #2}% + \else% + \subsection{#2}% + \fi% +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\subsubtask} +% The equivalent of |\subsubsection| for the \textsf{homework} class. +% |\subsubtask| essentially wraps |\subsection| with a semi-customizable title. +% It probably is not neccessary to use this very often. +% \begin{macrocode} +\newcounter{subsubtask}[subtask] +\newcommand{\subsubtask}[2][]{% + \ifstrempty{#1}{% + \stepcounter{subsubtask}% + }{% + \setcounter{subsubtask}{#1}% + }% + \if@tasknumbers% + \subsubsection{\arabic{task}.\arabic{subtask}.\arabic{subsubtask}. #2}% + \else% + \subsubsection{#2}% + \fi% +} +% \end{macrocode} +% \end{macro} + +% \iffalse %%%%%%%%%%%%%%%%%%% +%%%%%%%%% Page Setup %%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%\fi + +% \subsection{Page Setup} + +% The homework class defines its own header and footer using +% \textsf{scrlayer-scrpage}. The default setup shows the course, sheet number, +% university and date on every page. +% \changes{v1.1}{2017/04/15}{Support Short Headers} +% \begin{macrocode} +\setlength{\headheight}{50pt} +\pagestyle{scrheadings} +\clearpairofpagestyles + +% Header +\ifhomework@shortheader + \ihead{\textbf{\@shortcourse}\\Aufgabenblatt \@sheetno} + \ohead{\textbf{\@shortuniversity}\\\@date} +\else + \ihead{\textbf{\@course}\\Aufgabenblatt \@sheetno} + \ohead{\textbf{\@university}\\\@date} +\fi + +% Footer +\setkomafont{pagefoot}{\textnormal} +\cfoot[Seite \pagemark{} von \pageref{LastPage}]{Seite \pagemark{} von \pageref{LastPage}} + +\newpagestyle{firstpage}[]{% + \ihead{h} + \cfoot{\pagemark{}} +} +% \end{macrocode} + +% \iffalse %%%%%%%%%%%%%%%%%%% +%%%%%%%%%%% Layout %%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%\fi + +% \subsection{Layout} + +% The \textsf{homework} class overrides some font settings and adjusts the +% paragraph spacing to create a more distinct layout. +% \begin{macrocode} +\setlength{\parindent}{0em} +\setlength{\parskip}{5pt} + +\setkomafont{section}{\normalfont\bfseries\Large} +\setkomafont{subsection}{\normalfont\bfseries\large} +\RedeclareSectionCommands[afterskip=.25\baselineskip]{section} +\RedeclareSectionCommands[ + beforeskip=0.5\baselineskip, + afterskip=.125\baselineskip]{subsection} +% \end{macrocode} + +% \begin{macro}{\maketitle} +% The \textsf{homework} class completely redefines the |\maketitle| macro. This +% implementation actually defines the layout of the final title depending on +% which information was specified by the user (group number, a title, \dots). +% +% We differentiate two \emph{states} of the title. If the user does not specify +% a title and does not specify a group the title will be rearranged to not +% display too much empty space. This is implemented via the |\ifextended| +% definition. +% +% \changes{v1.1}{2017/04/15}{Support Short Titles} +% \begin{macrocode} +\renewcommand*{\maketitle}{% + \thispagestyle{plain}% + + \newif\ifextended + \extendedtrue + + \def\homework@university{\@university} + \def\homework@course{\@course} + \ifhomework@shorttitle + \def\homework@university{\@shortuniversity} + \def\homework@course{\@shortcourse} + \else + \def\homework@university{\@university} + \def\homework@course{\@course} + \fi + + % \end{macrocode} + % First we define the different layout parts. The title has six \emph{slots} + % each of which can hold a piece of text: + % \begin{description} + % \item[Top Left] On the top left the course name ist printed in a bold + % font. + % \item[Top Right] On the top right the name of the university is printed + % in a bold font. + % \item[Meta Left] Below the course name a piece of information is + % printed. The contents of this slot depend on the + % specified information and can be either the group + % number or the teacher. + % \item[Meta Right] Similar to meta left but below the university name. + % This slot typically holds the teacher or the date. + % \item[Title Left] Above the actual title there is a row of secondary + % titles. On the left of this row the sheet number is + % printed. + % \item[Title Right] Similarly to title left this slot may contain the + % date. + % \end{description} + % Below the header the actual document title and the author(s) are printed. + % If no |\title| is specified the sheet number becomes the title (|\title| + % however remains empfy). + % \begin{macrocode} + \ifdefempty{\@title}{% + \ifdefempty{\@group}{% + \def\metaleft{\@teacher}% + \def\metaright{\@date}% + \def\titleright{}% + \extendedfalse + }{% + \def\metaleft{Übungsgruppe \@group}% + \def\metaright{\@teacher}% + \def\titleright{\@date}% + }% + \def\titleleft{}% + \def\title{Aufgabenblatt \@sheetno}% + }{% + \ifdefempty{\@group}{% + \def\metaleft{}% + \def\metaright{\@teacher}% + }{% + \def\metaleft{Übungsgruppe \@group}% + \def\metaright{\@teacher}% + }% + \def\titleleft{Aufgabenblatt \@sheetno}% + \def\titleright{\@date}% + \def\title{\@title}% + }% + + % \end{macrocode} + % The following code prints the title with the information specified above. + % Depending on the value of |\ifextended| the title will be longer or + % shorter. + % + % Each field (heading, secondary title, title, author) is put in a separate + % group to avoid interference. + % \begin{macrocode} + + \begingroup% Heading Group + \usekomafont{pageheadfoot}% + \usekomafont{pagehead}% + \setlength{\parskip}{0pt}% + + \textbf{\homework@course} \hfill \textbf{\homework@university}\par% + + \begin{minipage}[t]{\widthof{\metaleft}}% + \metaleft% + \end{minipage}% + \hfill% + \begin{minipage}[t]{\widthof{\metaright}}% + \raggedleft% + \metaright% + \end{minipage}% + \endgroup% + + \ifextended% + \vspace{\baselineskip}% + \fi% + + \begingroup% Secondary Title Group + \Large\bfseries\titleleft\hfill\titleright% + \endgroup% + + \begingroup% Title Group + \begin{center}% + \Huge\textsc{\title}% + \end{center}% + \endgroup% + + \begingroup% Author Group + \setlength{\baselineskip}{2.75\baselineskip}% + \vspace{-\baselineskip}% + \begin{center}% + \begin{tabular}[t]{c}% + \@author% + \end{tabular}% + \end{center}% + \endgroup% +} +% \end{macrocode} +% \end{macro} +% \Finale + +\endinput diff --git a/homework.ins b/homework.ins new file mode 100644 index 0000000..7c97e66 --- /dev/null +++ b/homework.ins @@ -0,0 +1,51 @@ +%% +%% Copyright (C) 2017 by Kim Wittenburg +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. +%% + +\input docstrip.tex +\keepsilent + +\usedir{tex/latex/homework} + +\preamble + +Copyright (C) 2017 by Kim Wittenburg + +This file may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either +version 1.3 of this license or (at your option) any later +version. The latest version of this license is in: + + http://www.latex-project.org/lppl.txt + +and version 1.3 or later is part of all distributions of +LaTeX version 2005/12/01 or later. +\endpreamble + +\generate{\file{homework.cls}{\from{homework.dtx}{class}}} + +\obeyspaces +\Msg{****************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the *} +\Msg{* following file into a directory searched by TeX: *} +\Msg{* *} +\Msg{* homework.cls *} +\Msg{* *} +\Msg{* To produce the documentation run the file *} +\Msg{* homework.dtx through LaTeX. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{****************************************************} + +\endbatchfile