Verified Commit 502c96e7 authored by Sascha Brauer's avatar Sascha Brauer
Browse files

Exercises (homework and inclass)

parent 653b2e3a
%% Document Baseclass and encoding
\LoadClass[11pt, a4paper]{scrartcl}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{lmodern}
%%
%% Package Options
\newif\ifanswer\answerfalse
\newif\ifenglish\englishfalse
\DeclareOption{answers}{\answertrue}
\DeclareOption{english}{\englishtrue}
\ProcessOptions
%%
%% Language Formatting
\ifenglish
\RequirePackage[english]{babel}
\else
\RequirePackage[ngerman]{babel}
\fi
%%
%% General Layout
\RequirePackage[margin=2.5cm]{geometry}
\RequirePackage{hyperref}
\RequirePackage[footsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\clearpairofpagestyles
\makeatletter
\cfoot{\normalfont \ifenglish Page \else Seite \fi\pagemark~\ifenglish of \else von \fi\the\exercise@seiten}
\makeatother
\parindent0em
%%
%% Math
\RequirePackage{amsmath,amsfonts,amssymb,amsthm,mathtools}
\makeatletter
\newtheoremstyle{thmstyle}
{3pt}{3pt}{\itshape}{}{\bfseries}{}{.5em}
{\thmname{#1}\thmnumber{ #2}\thmnote{ \textmd{(#3)}}}
\theoremstyle{thmstyle}
\makeatother
\newcounter{ex}
\setcounter{ex}{0}
\newtheorem{definition}{Definition}[ex]
\newtheorem{lemma}[definition]{Lemma}
\newtheorem{problem}[definition]{Problem}
\ifenglish
\newtheorem{theorem}[definition]{Theorem}
\newtheorem{example}[definition]{Example}
\newtheorem{claim}[definition]{Claim}
\newtheorem{observation}[definition]{Observation}
\else
\newtheorem{theorem}[definition]{Satz}
\newtheorem{example}[definition]{Beispiel}
\newtheorem{claim}[definition]{Behauptung}
\newtheorem{observation}[definition]{Beobachtung}
\fi
\newcommand{\N}{\mathbb{N}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\abs}[1]{\left\vert #1 \right\vert}
\newcommand{\norm}[1]{\left\Vert #1 \right\Vert}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
%%
%% Graphics
\RequirePackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.ai}
\graphicspath{{../figures/converted/}{../figures/others/}{../figures/ai-version-cs/}}
\DeclareGraphicsRule{.ai}{pdf}{*}{}% Handle .ai files as .pdf files.
\RequirePackage{tikz}
\usetikzlibrary{arrows,automata,positioning,decorations.markings,shadows}
%%
%% Exercise specifics
\newif\ifishomework\ishomeworktrue
\newif\ifisinclass\isinclassfalse
\newif\ifnotomitdates\notomitdatestrue
\newif\ifnotomitsummary\notomitsummarytrue
\newif\ifnotomitlogo\notomitlogotrue
\newcommand{\homework}{\ishomeworktrue \isinclassfalse}
\newcommand{\inclass}{\ishomeworkfalse \isinclasstrue}
\newcommand{\generic}{\ishomeworktrue \isinclasstrue}
\newcommand{\omitdates}{\notomitdatesfalse}
\newcommand{\omitsummary}{\notomitsummaryfalse}
\newcommand{\omitlogo}{\notomitlogofalse}
\RequirePackage{framed}
\makeatletter
\renewenvironment{oframed}{
\def\FrameCommand{\hskip\@totalleftmargin\OpenFBox\FrameRule\FrameRule}%
\def\FirstFrameCommand{\OpenFBox\FrameRule\z@}%
\def\MidFrameCommand{\OpenFBox\z@\z@}%
\def\LastFrameCommand{\OpenFBox\z@\FrameRule}%
\MakeFramed {\advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize
\@setminipage \FrameRestore}%
}{\par\unskip\endMakeFramed}
\newcount\exercise@aufgaben
\newcount\exercise@aufgaben@pre
\newcount\exercise@punkte
\newcount\exercise@punkte@pre
\newcount\exercise@seiten
\newenvironment{exercise}[2][]
{
\global\advance\exercise@aufgaben by 1
\refstepcounter{ex}
\par
\vspace{20pt}
\textbf{\ifenglish Exercise \else Aufgabe \fi\theex}
\ifx\\#2\else (#2)\fi
\ifx\\#1\else\global\advance\exercise@punkte by #1 \hspace{\fill}\mbox{}\linebreak[0]\hspace*{\fill} (#1~\ifenglish \ifnum#1=1 Point\else Points\fi\else \ifnum#1=1 Punkt\else Punkte\fi\fi)\fi
}{}
\newcommand{\answer}[1]
{
\ifanswer
\begin{oframed}
\textbf{\ifenglish Solution: \else Lösung: \fi} #1
\end{oframed}
\fi
}
\newcommand{\exercisetlaux}{}
\newcommand{\exercisetl}[1]{\renewcommand{\exercisetlaux}{#1}}
\newcommand{\exercisedateaux}{\today}
\newcommand{\exercisedate}[1]{\renewcommand{\exercisedateaux}{#1}}
\newcommand{\exerciseheader}
{
\begin{minipage}[t][][b]{.33\textwidth}
\footnotesize \exercisetlaux
\end{minipage}
\ifnotomitlogo
\hfill
\begin{minipage}[t][][b]{.32\textwidth}
\begin{center}
\includegraphics[width=1.8cm]{figures/cuk_logo_2019}
\end{center}
\end{minipage}
\fi
\hfill
\begin{minipage}[t][][b]{.33\textwidth}
\begin{flushright}
\small \exercisedateaux
\end{flushright}
\end{minipage}
}
\newcommand{\exerciselectureaux}{}
\newcommand{\exerciselecture}[1]{\renewcommand{\exerciselectureaux}{#1}}
\newcommand{\exercisenumberaux}{}
\newcommand{\exercisenumber}[1]{\renewcommand{\exercisenumberaux}{#1}}
\newcommand{\exercisehandinaux}{}
\newcommand{\exercisehandin}[1]{\renewcommand{\exercisehandinaux}{#1}}
\newcommand{\exerciseinclassaux}{}
\newcommand{\exerciseinclass}[1]{\renewcommand{\exerciseinclassaux}{#1}}
\newcommand{\exercisetitle}
{
\begin{center}
\textbf{\large\exerciselectureaux}
\bigskip
\textbf{\ifishomework \ifisinclass \ifenglish Exercise \else Übungszettel \fi \else \ifenglish Homework \else Heimübung \fi \fi \else \ifenglish In Class Exercise \else Präsenzübung \fi \fi \exercisenumberaux}
\ifnotomitdates
\ifisinclass \textbf{\exerciseinclassaux}\fi
\ifishomework\textbf{\ifenglish Hand In: \else Abgabe: \fi \exercisehandinaux}\fi
\fi
\ifnotomitsummary
\ifenglish
(This exercise sheet contains \the\exercise@aufgaben@pre~\ifnum\the\exercise@aufgaben@pre=1 exercise\else exercises\fi
\ifishomework \ with a total of \the\exercise@punkte@pre~\ifnum\the\exercise@punkte@pre=1 point\else points\fi \fi)
\else
(Dieser Übungszettel besteht aus \the\exercise@aufgaben@pre~\ifnum\the\exercise@aufgaben@pre=1 Aufgabe\else Aufgaben\fi
\ifishomework \ mit insgesamt \the\exercise@punkte@pre~\ifnum\the\exercise@punkte@pre=1 Punkt\else Punkten\fi \fi)
\fi
\fi
\end{center}
}
\AtBeginDocument{
\exercise@aufgaben@pre = \exercise@aufgaben\relax
\exercise@aufgaben = 0
\exercise@punkte@pre = \exercise@punkte\relax
\exercise@punkte = 0
}
\AtEndDocument{
\if@filesw
\immediate\write\@auxout{\string\global\string\exercise@aufgaben = \the\exercise@aufgaben}
\immediate\write\@auxout{\string\global\string\exercise@punkte = \the\exercise@punkte}
\immediate\write\@auxout{\string\global\string\exercise@seiten = \thepage}
\fi
}
\makeatother
%%
\documentclass[answers]{exercise}
%% Optional Argument: answers, english
%% An exercise sheet is either a homework sheet, will be discussed in a tutorial (inclass) or is both (generic)
\homework
% \inclass
% \generic
%%
%% Number of the sheet
\exercisenumber{42}
%% Dated issued
\exercisedate{31. Februar 2015}
%% Period of tutorials (inclass and generic)
\exerciseinclass{31. -- 33. Februar 2015}
%% Deadline for the sheet to be handed in (homework and generic)
\exercisehandin{34. Februar 2015 -- 14:00 Uhr}
%% You can choose to omit dates, the summary sentence or the CuK logo
% \omitdates
% \omitsummary
% \omitlogo
%% Set the content of the top left of the first page
\exercisetl{Universität Paderborn \\ Prof. Dr. Johannes Blömer}
%% Title of the sheet
\exerciselecture{Fast Sichere Verschlüsselungen -- WS 2016/2017}
\begin{document}
\exerciseheader
\exercisetitle
%% An Exercise block has a name for the exercise
%% and an optional number of points awarded for a correct solution
\begin{exercise}[10]{Test}
Testaufgabe
\end{exercise}
%% An Answer command can be used for sketches of solutions
%% Only printed with the [answers] switch!
\answer{
Hier steht eine Lösung
}
%% Furthermore, the class provides:
% \N - natural numbers
% \Z - integers
% \Q - rationals
% \R - reals
% \abs{X} - |X|
% \norm{X} - ||X||
% \argmax and \argmin
% theorem envs: definition, lemma, problem, theorem, example, claim, observation
\begin{definition}
The sky is green.
\end{definition}
\begin{exercise}{Foo}\label{ex1}
\begin{observation}
Water and the sky have the same color.
\end{observation}
\begin{theorem}
\label{l1}
The sea is green.
\end{theorem}
Prove or refute Theorem~\ref{l1}.
\end{exercise}
This is just some test text outside of any environment after Exercise~\ref{ex1}.
Let's try to put an \verb+\answer+ text inside an \verb+exercise+
environment. Here it is \dots
\begin{exercise}[23]{Barbaras Barbarenbar serviert Barbarenbier,
Rhabarberschnaps, Rhabarbereis, Rhabarberbiereis und
Rhabarberschnapseis an Rhabarberbarbaren und
Barbaren-Barbiere}
Wen bedient Barbara in ihrer Barbarenbar?
\answer{Rhabarberbbarbaren und Barbaren-Barbiere}
\end{exercise}
So, now we just fill the page with nonsensical letter combinations
\dots
olghdf bxaqrtuilö.- m,njh
ä,luhrtedqa>@sYFTJHJ,LÖPÜ+ÜBH CSEER BNOLPÖ-ÖÄ
'
++Ü OPNJGHDQAQ
W3ERDFT6UZ89I O0PPÖNJOBHUICF7HZ XDRF5<AWS3Anhtl
ujpäüopzguigzuz8ser6 sae4Q3W3TLÖÖÖÄÜ90Ü+
ÜIOOPUIOFT
HUIDR U7HZSE GT7WA R534Qjh56
6o89öä0ß+uzkopghuhdrz war5wa4237zk89l pä0ß+äß
So, it looks like a rat just ran over my keybord, multiple times. Bad
kitten. Bad, bad kitten \dots
\begin{example}[The Rains of Castamere]
\begin{verbatim}
And who are you,
the proud lord said,
that I must bow so low?
Only a cat of a different coat,
that's all the truth I know.
And so he spoke,
and so he spoke,
that lord of Castamere.
And so he spoke,
and so he spoke,
that lord of Castamere.
A coat of red,
a coat of gold,
a lion still has claws ...
\end{verbatim}
\end{example}
\begin{exercise}[-13]{Recitation}
Recite the story of the Tarbeck Rebellion underlying the song
``The Rains of Castamere.''
\end{exercise}
\end{document}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment