diku-dk / su-guides

Guides and guidelines for software development course
14 stars 8 forks source link

`year' undefined in families `header' #3

Closed ploeh closed 1 year ago

ploeh commented 1 year ago

Steps to reproduce

Follow the example in https://github.com/diku-dk/su-guides/blob/main/guides/ReportFormatting.md, but work around #2 by compiling this document intsead:

\documentclass{article}

\usepackage[danish]{su}

\header{%
    assignment={Exercise 1: Introduction to C\#},%
    authors={Donald E. Knuth <\texttt{knuth@stanford.edu}>},%
    shortAuthors={\texttt{knuth}},%
    date={Friday, February 10, 15:00},%
    year={2019}
}

\begin{document}

\maketitle

\end{document}

Expected behaviour

The example compiles.

Actual behaviour

The example doesn't compile, but instead fails with this error message:

! Package xkeyval Error: `year' undefined in families `header'.

See the xkeyval package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.11 }

Possible workaround

One can make the error go away by removing the line year={2019}.

WilliamDue commented 1 year ago

I am sorry but I am unable to replicate this error, might it be that you are using a wrong su.sty file? Since older versions of the su.sty did not have the year keyword?

ploeh commented 1 year ago

Indeed, sorry about the confusion. Based on #1 I received a modified su.sty from a TA via the DIKU SU-e2023 Discord server. Here's the contents of that file:


% Copyright (C) 2020 DIKU
% Copyright (C) 2016 Oleks
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, course to the following conditions:
%
% The above copyright notice and this permission notice shall be included in
% all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
% SOFTWARE.

\ProvidesPackage{su20}

%% Version 1.4

%%%
% Parse options
\newcommand\babelopts{english}
\DeclareOption{danish}{\renewcommand\babelopts{danish}}
\ProcessOptions\relax
%%%

%%%
% Langauge
\PassOptionsToPackage{utf8}{inputenc}
\RequirePackage{inputenc}
\PassOptionsToPackage{\babelopts}{babel}%
\RequirePackage{babel}
%%%

%%%
% Font, Palatino
\PassOptionsToPackage{T1}{fontenc}
\RequirePackage{fontenc}
\RequirePackage{mathpazo}
%%%

%%%
% Mathematics
\RequirePackage{amssymb}
\RequirePackage{amsmath}
\RequirePackage{amsthm}

\everymath{\displaystyle}
%%%

%%%
% LaTeX macro utilities
\RequirePackage{xparse}
%%%

%%%
% Colours
\PassOptionsToPackage{usenames,dvipsnames}{xcolor}
%%%

%%%
% Code
\RequirePackage{alltt}
\RequirePackage{minted}
%%%

%%%
% Graphics
\RequirePackage{graphicx}
%%%

%%%
% Citations
\RequirePackage{cite}
%%%

%%%
% Enumerations
\RequirePackage{paralist} % inparaenum
\RequirePackage{enumitem}
%%%

%%%
% Colours
\RequirePackage{color}
%%%

%%%
% Links and metadata (in PDFs).
\RequirePackage{url}
\PassOptionsToPackage{backref=page}{hyperref} % backrefs in references

% colorlinks does not play well with menukeys, so we'll just hide them instead.
%\PassOptionsToPackage{colorlinks=true}{hyperref} % color, not box the links
\PassOptionsToPackage{hidelinks}{hyperref}

\PassOptionsToPackage{pdftex}{hyperref} % THIS IS PDF!
\RequirePackage{hyperref}
\hypersetup
{
  bookmarksnumbered,
  linkcolor=RoyalBlue,
  anchorcolor=RoyalBlue,
  citecolor=RoyalBlue,
  urlcolor=RoyalBlue,
  pdfstartview={FitV},
  pdfdisplaydoctitle
}
% \hypersetup is used later as well.
%%%

%%%
% Header
\newcommand{\course}{\empty}
\newcommand{\setCourse}[1]{%
    \renewcommand{\course}{#1}%
}
\setCourse{[}

\newcommand{\assignment}{\empty}
\newcommand{\setAssignment}[1]{%
    \renewcommand{\assignment}{#1}\title{#1}\hypersetup{pdftitle={#1}}%
}
\setAssignment{[assignment not setup]}

\newcommand{\staticDate}{\empty}
\newcommand{\setStaticDate}[1]{%
    \renewcommand{\staticDate}{#1}\date{#1}%
}
\setStaticDate{[date not setup..]}

\newcommand{\shortAffiliation}{\empty}
\newcommand{\setShortAffiliation}[1]{%
  \renewcommand{\shortAffiliation}{#1}%
}
\setShortAffiliation{[affiliation not setup..]}

\newcommand{\affiliation}{\empty}
\newcommand{\setAffiliation}[1]{%
  \renewcommand{\affiliation}{#1}%
  \setShortAffiliation{#1}
}
\setAffiliation{[affiliation not set up..]}

\newcommand{\shortAuthors}{\empty}
\newcommand{\setShortAuthors}[1]{%
    \renewcommand{\shortAuthors}{#1}%
}
\setShortAuthors{[short authors not setup..]}

\newcommand{\authors}{\empty}
\newcommand{\setAuthors}[1]{%
    \renewcommand{\authors}{#1}%
    \author{#1}%
    \hypersetup{pdfauthor={#1}}%
  \setShortAuthors{#1}
}
\setAuthors{[authors not setup..]}

\define@key{header}{assignment}{\setAssignment{#1}}
\define@key{header}{date}{\setStaticDate{#1}}
\define@key{header}{course}{\setCourse{#1}}
\define@key{header}{affiliation}{\setAffiliation{#1}}
\define@key{header}{shortAffiliation}{\setShortAffiliation{#1}}
\define@key{header}{authors}{\setAuthors{#1}}
\define@key{header}{shortAuthors}{\setShortAuthors{#1}}
\NewDocumentCommand\header{m}{\setkeys{header}{#1}}
%%%

%%%
% Fancy
\RequirePackage{fancyhdr}
\RequirePackage{lastpage}

\pagestyle{fancy}
\chead{\footnotesize\shortAffiliation\\\ }
\lhead{\footnotesize\course\\\assignment}
\rhead{\footnotesize\staticDate}
\cfoot{\thepage/\pageref*{LastPage}}
\renewcommand{\headrulewidth}{0in}
\renewcommand{\headsep}{40pt}
\setlength{\headheight}{28pt}
\addtolength{\textheight}{-20pt}

\fancypagestyle{first}{%
  \fancyhf{}%
  \cfoot{\thepage/\pageref*{LastPage}}%
}
%%%

%%%
% Captions
\PassOptionsToPackage{hang, small, bf}{caption}
\RequirePackage{caption}
%%%

%%%
% Title
\RenewDocumentCommand\maketitle{}{%
  \begin{center}%
  \LARGE\assignment\\\vspace{0.3in}%
  \Large\course\\%
  \large\affiliation\\\vspace{0.2in}%
  \normalsize\authors\\\vspace{0.2in}%
  \normalsize\staticDate%
  \end{center}%
  \thispagestyle{first}%
}
%%%

%%%
% Checkbox lists
%
% Example:
%   \begin{checkbox}
%     \item This is an unchecked checkbox.
%     \item[checked] This is a checked checkbox.
%   \end{checkbox}
%
% Inspired by: http://tex.stackexchange.com/a/313337
\RequirePackage{enumitem}
\newlist{checkbox}{itemize}{2}
\setlist[checkbox]{label=$\square$}
\RequirePackage{pifont}
\newcommand{\cmark}{\ding{51}}%
\newcommand{\checked}{%
  \rlap{$\square$}{\raisebox{2pt}{\large\hspace{1pt}\cmark}}%
  \hspace{-2.5pt}%
}
%%%

%%%
% C# styling in minted
\setminted[csharp]
{
frame=lines,
framesep=2mm,
baselinestretch=1.2,
%bgcolor=lightgray,
fontsize=\footnotesize,
numbers=left,
%linenos
%
% allows minted to be used with latex math inside code snippets $..$,
% e.g. as comments. Not recommended for languages such as PHP.
mathescape=true,
xrightmargin=25pt, % make frame lines align to text width
}
%%%

%%%
% DIKU Overrides
\setAffiliation{Department of Computer Science \\ University of Copenhagen}
\setShortAffiliation{DIKU}
%%%

%%%
% Software Development 2020
\setCourse{Software Development 2023}
%%%

%%%
% Math wrapper macros.
%
% Examples:
%   $\p{e}$ instead of $\left( e \right)$
%   $\floor{e}$ instead of $\left\lfloor e \right\rfloor$
%   $\ceil{e}$ instead of $\left\lceil e \right\rceil$
%
\NewDocumentCommand\mathWrap{mmm}{\ensuremath{%\mathopen{}\left#1#2\right#3\mathclose{}%
}}
%
\NewDocumentCommand\floor{m}{%
  \mathWrap{\lfloor}{#1}{\rfloor}%
}
%
\NewDocumentCommand\ceil{m}{%
  \mathWrap{\lceil}{#1}{\rceil}%
}
%
\NewDocumentCommand\p{m}{%
  \mathWrap{(}{#1}{)}%
}
%%%

%%%
% TikZ!
\RequirePackage{tikz}
%%%

%%%
% Software Development 2020 Additions
\NewDocumentCommand\inputcsharp{mmm}{%
  \inputminted[firstline=#1,lastline=#2]{csharp}{\dirpath #3.cs}%
}

\RequirePackage{menukeys}
%%%