Skip to content

Instantly share code, notes, and snippets.

@Romern
Last active August 7, 2018 18:08
Show Gist options
  • Save Romern/49ef5a40be05e6c653b95812101855e5 to your computer and use it in GitHub Desktop.
Save Romern/49ef5a40be05e6c653b95812101855e5 to your computer and use it in GitHub Desktop.
Latex Aufgaben Template slightly modified https://git.rwth-aachen.de/kevin.meder/LaTeX_Templates
\documentclass[fleqn]{solution}
\setgerman % Auskommentieren für Englisch
\setmodule{Beispielfach} % Modulname hier
\setsheetnum{1} % Blattnummer hier
\setgroupnum{G} % Gruppennummer hier
%\setgroupname{TestGruppe} % Gruppennummer hier
%\settutor{Maksim Maximus} % Gruppenleiter hier
\addauthor{Max Mustermann}{123456}
\addauthor{Anton Alliteration}{654321}
\date{\today}
% Nummer der ersten Aufgabe (minus 1)
\setcounter{section}{0}
\begin{document}
\maketitle
\pointtable
\begin{exercise}{Aufgabe mit bepunkteten Teilaufgaben}
\begin{subexercise}[5]{Teilaufgabe mit Titel}
Fubar bar.
\[ \bigplus_{i=1}^n i = \{ \xlongequal{TESTESTEST} \norm{v,e} \seperator \sgn 5 \}\]
Dies ist ein Text.\\\n
Ayy
\begin{subsubexercise}{Etwas}
Unter-Teilaufgaben gehen natürlich auch.
\end{subsubexercise}
\begin{subsubexercise}{}
\end{subsubexercise}
\end{subexercise}
\begin{subexercise}[2]{}
Dieser kleine Satz ist ganze zwei Punkte wert.
\end{subexercise}
\end{exercise}
\begin{exercise}[2.5]{Aufgabe ohne Teilaufgaben}
\end{exercise}
\begin{exercise}[4]{Aufgabe mit unbepunkteten Teilaufgaben}
Der Leser soll die tolle Kopfzeile zur Kenntnis nehmen.
Diese Aufgabe gibt vier Punkte, aber es ist nicht genau gegeben,
wie viele Punkte jede Teilaufgabe gibt.
\begin{subexercise}{}
Bla
\end{subexercise}
\begin{subexercise}{}
Bla bla
\end{subexercise}
\begin{subexercise}{}
Bla bla bla
\end{subexercise}
\end{exercise}
\end{document}
MIT License
Copyright (c) 2017 Nino van der Linden, Kevin Meder
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, subject 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.
% Format solutions for exercise sheets
% Created by Nino van der Linden
% Licensed under MIT License
% https://github.com/ninov/solution-tex
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{solution}[2017/10/15 exercise sheet solution]
\LoadClass{article}
\usepackage{geometry}
\geometry{
a4paper,
total={165mm,252mm},
left=25mm,
top=25mm,
}
\usepackage{ifxetex}
\ifxetex
\usepackage{fontspec}
\else
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\fi
\usepackage{titlesec}
\usepackage{etoolbox}
\usepackage{ifthen}
\usepackage{color}
\usepackage{fancyhdr}
\usepackage{pgfkeys}
\usepackage{amssymb,amsmath,amsthm,amsfonts,mathtools} %common math libs, standard on all PCs
\usepackage{changepage}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{calc}
\usepackage{fp}
\usepackage{xstring}
\usepackage{enumitem}
\usepackage{hhline}
\usepackage{ wasysym }
\usepackage{algorithmicx}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{multicol}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{extarrows}
\usepackage{tikz}
\usetikzlibrary{shapes,shapes.misc,shapes.geometric,arrows,fit,matrix,positioning,automata,patterns, decorations.pathreplacing}
\tikzset
{
leafnode/.style = {rectangle, draw=black, align=center},
treenode/.style = {rounded rectangle, draw=black, align=center}
}
\setlength{\parindent}{0pt}
\setlength{\parskip}{3pt}
\newcommand{\partner}{Partner}
\newcommand{\lSheet}{Sheet}
\newcommand{\lGroup}{Group}
\newcommand{\lGroupname}{Groupname}
\newcommand{\lPage}{Page}
\newcommand{\lPoints}{Points}
\newcommand{\lExercise}{Exercise}
\newcommand{\lOf}{of}
\newcommand{\lPoint}{Point}
\newcommand{\lPointsNom}{Points}
\newcommand{\lTutor}{Tutor}
\newcommand{\setgerman}{
\renewcommand{\partner}{Abgabepartner}
\renewcommand{\lSheet}{Abgabe}
\renewcommand{\lGroup}{Übungsgruppe}
\renewcommand{\lGroupname}{Gruppenname}
\renewcommand{\lPage}{Seite}
\renewcommand{\lPoints}{Punkten}
\renewcommand{\lExercise}{Aufgabe}
\renewcommand{\lOf}{von}
\renewcommand{\lPoint}{Punkt}
\renewcommand{\lPointsNom}{Punkte}
\renewcommand{\lTutor}{Gruppenleiter}
\usepackage[ngerman]{babel}
}
\newcommand{\n}{~\\}
\newcommand{\seperator}{~|~}
\newcommand{\sgn}{\operatorname{sgn}}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\newcommand{\abs}[1]{\left|#1\right|}
\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}
\newcommand{\bigplus}{%
\DOTSB\mathop{\mathpalette\mattos@bigplus\relax}\slimits@
}
\newcommand\mattos@bigplus[2]{%
\vcenter{\hbox{%
\sbox\z@{$#1\sum$}%
\resizebox{!}{0.9\dimexpr\ht\z@+\dp\z@}{\raisebox{\depth}{$\m@th#1+$}}%
}}%
\vphantom{\sum}%
}
\newcommand{\ifempty}[3]{%
\setbox0=\hbox{#1\unskip}\ifdim\wd0=0pt
#2%
\else%
#3%
\fi%
}
\newcommand{\sheetnum}{}
\newcommand{\setsheetnum}[1]{
\renewcommand{\sheetnum}{#1}
}
\newcommand{\module}{}
\newcommand{\setmodule}[1]{
\renewcommand{\module}{#1}
}
\newcommand{\group}{}
\newcommand{\setgroupnum}[1]{
\renewcommand{\group}{\lGroup: & #1}
}
\newcommand{\tutor}{}
\newcommand{\settutor}[1]{
\renewcommand{\tutor}{\lTutor: & #1}
}
\newcommand{\groupname}{}
\newcommand{\setgroupname}[1]{
\renewcommand{\groupname}{\lGroupname: & #1}
}
\newcounter{author}
\newcommand{\addauthor}[2]{%
\csdef{authorName\theauthor}{#1}
\csdef{authorNum\theauthor}{#2}
\stepcounter{author}
}
\newcommand{\getauthorName}[1]{%
\csuse{authorName#1}%
}
\newcommand{\getauthorNum}[1]{%
\csuse{authorNum#1}%
}
\newcommand{\getauthorFull}[1]{%
\getauthorName{#1}~\getauthorNum{#1}%
}
\newcommand{\writee}[1]{
#1
}
\newcounter{ct}
\newcommand{\getauthors}{%
\setcounter{ct}{0}
\whiledo{\value{ct} < \value{author}}%
{%
\writee{&}%
\ifnum \value{ct}=\value{author}{}\else{}\fi%
\getauthorFull{\thect}%
\\%
\stepcounter{ct}%
}
}
\newcommand{\getauthorsShort}{%
\setcounter{ct}{0}
\whiledo{\value{ct} < \value{author}}%
{%
\getauthorNum{\thect}%
\stepcounter{ct}%
\ifnum \value{ct}=\value{author}{}\else{, }\fi%
}
}
\gdef\pointtableSpec{}
\gdef\pointtableHeader{}
\gdef\pointtableValues{}
\newcommand{\pointfield}[1]{%
\begin{flushright}
\hfill\fbox{
~~~~~~\ifempty{#1}{}{/~#1}
}
\end{flushright}
}
\newcounter{subexercises}
%\newcounter{exerciseSumPoints}
%\newcounter{sumPoints}
\FPset\sumPoints{0}
\gdef\sumPointsPlus{}
\newenvironment{exercise}[2][NONE]{
\section{#2}
\ifcsname thefirstExercise\endcsname\else%
\newcounter{firstExercise}%
\setcounter{firstExercise}{\value{section}}%
\fi%
\csdef{exercisePoints\thesection}{#1}%
\setcounter{subexercises}{0}%
\FPset\exerciseSumPoints{0}%
\xdef\exerciseSumPoints{\exerciseSumPoints} % make global
}{%
\xdef\pointfieldContent{}
\ifthenelse{\equal{\csuse{exercisePoints\thesection}}{NONE}}{%
\setcounter{ct}{0}%
\whiledo{\value{ct} < \value{subexercises}}%
{%
\stepcounter{ct}%
\xdef\pointfieldContent{%
\pointfieldContent \csuse{subexercisePoints\thect}%
\ifnum \value{ct}=\value{subexercises}{}\else{+}\fi%
}%
}%
}{%
\xdef\pointfieldContent{\csuse{exercisePoints\thesection}}%
\edef\temp{(exerciseSumPoints) + \csuse{exercisePoints\thesection}}%
\FPeval\exerciseSumPoints{\temp}%
\xdef\exerciseSumPoints{\exerciseSumPoints} % make global
}%
\pointfield{\pointfieldContent}%
\vspace{1cm}
\xdef\pointtableSpec{\pointtableSpec c|}%
\edef\tempA{\thesection &}%
\expandafter\gappto\expandafter\pointtableHeader\expandafter{\tempA}%
\FPifeq{\exerciseSumPoints}{0}%
\edef\tempB{~~~~ / ~~ &}%
\gdef\sumPointsPlus{ +~~~~~}%
\else%
\FPclip\exerciseSumPoints\exerciseSumPoints %
\edef\tempB{~~~~ / \exerciseSumPoints &}%
\FPadd\sumPoints\sumPoints\exerciseSumPoints%
\xdef\sumPoints{\sumPoints} % make global
%\addtocounter{sumPoints}{\value{exerciseSumPoints}}%
\fi%
\expandafter\gappto\expandafter\pointtableValues\expandafter{\tempB}%
}
\newenvironment{subexercise}[2][]{
\subsection{#2}
\stepcounter{subexercises}%
\expandafter\gdef\csname subexercisePoints\arabic{subexercises}\endcsname{#1}%
%\ifempty{#1}{}{\addtocounter{exerciseSumPoints}{\numexpr#1}}
\ifempty{#1}{}{%
\edef\temp{(exerciseSumPoints) + #1}%
\FPeval{\exerciseSumPoints}{\temp}%
\xdef\exerciseSumPoints{\exerciseSumPoints} % make global
}
\adjustwidth{1.75em}{0pt}%
\def\temp{#2}\ifx\temp\empty\vspace{-1.25\baselineskip}\fi%
}{\endadjustwidth}
\newenvironment{subsubexercise}[2][\unskip]{
\subsubsection{#2}
\adjustwidth{1.75em}{0pt}%
\def\temp{#2}\ifx\temp\empty\vspace{-1.25\baselineskip}\fi
}{\endadjustwidth}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\footnotesize \module~(\lSheet~\sheetnum)}
\fancyhead[R]{\footnotesize \getauthorsShort}
\fancyfoot[C]{\thepage}
\renewcommand{\thesubsection}{\alph{subsection}}
\renewcommand{\thesubsubsection}{\roman{subsubsection}}
\newcommand{\colonafter}[1]{\def\temp{#1}\ifx\temp\empty\else~#1:\fi}
\titleformat{\subsection}[runin]{
\normalfont}
{(\thesubsection)}{1pt}
{\bfseries\colonafter}
\titleformat{\subsubsection}[runin]
{\normalfont}
{(\thesubsubsection)}{1pt}
{\bfseries\colonafter}
\titleformat{\section}
{\normalfont\Large\bfseries}
{\lExercise~\thesection:}
{1em}
{\normalfont}
\renewcommand{\maketitle}{
\thispagestyle{plain}
\fancyfoot[C]{\thepage}
{\vspace{4pt}\centering
{\Large \textbf{\module~-~\lSheet~\sheetnum}}\\
\vspace{0.5cm}
\@date
\vspace{0.5cm}
\begin{center}
\begin{tabular}{r r}
\group\\
\groupname\\
\partner:\hspace*{-3.25pt}\getauthors
\tutor\\
\end{tabular}
\end{center}}
}
\newcommand{\todo}[1][]{{\color{red}TODO%
\ifx #1\empty\else: #1\fi%
}}
\newcommand{\pointtable}{
\ifcsname pointtableSpecSaved\endcsname%
\begin{table}[h!]\centering\begin{tabular}{\pointtableSpecSaved}
\pointtableHeaderSaved \\\hline
\pointtableValuesSaved
\end{tabular}\end{table}%
\else
{\color{red}\Large COMPILE AGAIN}%
\ClassWarning{Compile again!}%
\fi%
}
\AtEndDocument{
\makeatletter
\immediate\write\@mainaux{\string\gdef\string\pointtableSpecSaved{\pointtableSpec c}}%
\immediate\write\@mainaux{\string\gdef\string\pointtableHeaderSaved{\pointtableHeader $\Sigma$}}%
\FPclip\sumPoints\sumPoints%
\immediate\write\@mainaux{\string\gdef\string\pointtableValuesSaved{\pointtableValues ~~~~/~\sumPoints\sumPointsPlus}}%
\makeatother
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment