%% handin v0.1.1b52 - 2018/07/22
%% The LaTeX package handin - version v0.1.1 (2018/07/22) build 52
%% Manual/Documentation for handin.sty
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2018 by Andreas Storvik Strauman
%% -------------------------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% 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.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%% This work has the LPPL maintenance status `author-maintained'.
%% This work consists of all files listed in README.txt
\documentclass[a4paper]{article}
\usepackage[all]{tcolorbox}
\usepackage{needspace}
\usepackage{tabularx}
\usepackage{geometry}
\makeatletter
\def\input@path{{../../docs/}}
\lstdefinestyle{mydocumentation}{style=tcbdocumentation,
  classoffset=0,
  texcsstyle=*\color{blue},
  moretexcs={arrayrulecolor,draw,includegraphics,ifthenelse,isodd,lipsum,path,pgfkeysalso},
  classoffset=1,
  moretexcs={% core
    problem,pproblem,handinsetup,title,author,logo,coursename,coursetitle,institute,containspages,pagetext,currentProblem,currentPartProblem,currentProblemIfNewPage,settable
  },
  texcsstyle=*\color{Definition}\bfseries,
  classoffset=0,% restore default
  }
\newtcolorbox{marker}[1][]{enhanced,
    before skip=2mm,after skip=3mm,
    boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
    colback=yellow!50,
    colframe=yellow!20!black,
    sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
    underlay={%
      \path[fill=tcbcol@back!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
      \path[draw=tcbcol@frame,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
      \path[fill=yellow!50!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=4mm]interior.north west);
      },
    drop fuzzy shadow,#1}
  \def\l@macro#1#2{#1\hfill\newline}
\newcommand\macrotable{\hypersetup{linkcolor=black}\@starttoc{mac}\hypersetup{linkcolor=Definition}}
\newcommand\gh[1]{\href{#1}{https://github.com/#1}}
% --- CHANGELOG TABLE --- %
\newcommand*\l@version[2]{%
  \ifnum \c@tocdepth >\z@
    \addpenalty\@secpenalty
    \addvspace{1.0em \@plus\p@}%
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{}\par
    \endgroup
  \fi}
  \newcommand*\l@change[2]{%
    \addvspace{0.5em \@plus\p@}%
    \leftskip1em--\hspace{0.5em}\begin{minipage}{0.5\textwidth}#1\end{minipage}\hfill%
    \begin{minipage}{0.3\textwidth}#2\end{minipage}\par%
  }

\newcommand\chlogtable{\begin{NoHyper}\@starttoc{chlog}\hypersetup{final}\end{NoHyper}}
\def\newversion#1{\addcontentsline{chlog}{version}{#1}}
\newcommand\change[2][]{\addtocontents{chlog}{\protect\contentsline{change}{#2}{#1}{section.\thepage}}}
% --- /CHANGELOG TABLE --- %

\let\oldTOC\tableofcontents
\renewcommand\tableofcontents{\hypersetup{linkcolor=black}\oldTOC\hypersetup{linkcolor=Definition}}
\reversemarginpar
\def\updated#1{\tcbdocmarginnote{\bfseries{\color{blue}U}#1}}
\def\defnew#1{\tcbdocmarginnote{\bfseries{\color{green}N}#1}}

\let\dac\docAuxCommand
\def\mdac#1{\docAuxCommand{\expandafter\@gobble\string#1}}

\makeatother

\long\def\keyDef#1#2#3#4{\begin{docKey}{#1}{=\meta{#2}}{\meta{default}=#3}#4\end{docKey}}
\long\def\optDef#1#2{\begin{docKey*}{#1}{}{}#2\end{docKey*}}
\tcbset{documentation listing style=mydocumentation}
% Magenta HREF style
\let\oldhref\href
\gdef\href#1#2{{\color{magenta}\oldhref{#1}{#2}}}
\tcbset{documentation listing style=mydocumentation,/tcb/color hyperlink=Definition}
\hypersetup{colorlinks=true}
% Give section some space
\let\oldsection\section
\gdef\section{\needspace{0.3\paperheight}\oldsection}
\let\oldsubsection\subsection
\gdef\subsection{\needspace{0.2\paperheight}\oldsubsection}


\setlength{\parindent}{0pt}
\title{{handin - manual\\ v0.1.1{\\[-0.5em]\footnotesize(build 52)}}}
\author{Andreas Strauman}
\begin{document}
\maketitle
\section*{2 Problem}
I remember when I first started out with LaTeX, as a student, it was very new and challenging just to make a simple nicely typeset document. We've all seen documents that has problem numbering using sections, like I did here. (The header says \textbf{2 Problem}.)\\

This is a package that makes it easy for student to hand in a formatted document in LaTeX. It just creates a couple of commands that typesets the document with nice headers (problem numbers and part problem numbers e.g. \textbf{(1a)} ).\\

If you are a teacher, this package works just as well for creating exercises!\\
 
If you found any bugs or want new functionality, to contribute, view the commented source, get latest version of this package or get in touch with me, you can do all of that at\\\url{https://github.com/Strauman/handin-LaTeX}. If you have questions of functionality, kindly direct them to the community\\ \url{http://tex.stackexchange.com}. The author is active on this site regularly.

\tableofcontents
\clearpage
 \section{Reference}
\filbreak\subsection{Making exercises}
Here are commands related to creating exercises
\begin{docCommand}{problem}{\marg{text}}\addcontentsline{toc}{subsubsection}{\refCom{problem}}

 This command will print out a problem header. For example \dac{problem}\{1\}
 prints a nice big header \textbf{Problem 1} You can do a star (*) after \dac{problem} to
 prevent it from showing in the table of contents
\end{docCommand}
\begin{docCommand}{problem*}{\marg{text}}
 Does the same as \dac{problem}, but does not add the problem to the table of contents
\end{docCommand}
\begin{docCommand}{pproblem}{\marg{text}}\addcontentsline{toc}{subsubsection}{\refCom{pproblem}}
\updated{v0.1.1\\2018/07/22 }
 This command will print out a part problem header based on what problem you are on.
 For example if you already have done \dac{problem}\{1\}, then \dac{pproblem}\{a\}
 prints a nice big header \textbf{(1a)}. Note that the default behaviour is such that if you are on a
 new page, then the part problems are shown with the exercise number in front of it. If not
 it is omitted. If you want to change this behaviour, see \dac{keyRef}\{part problem header\}
\end{docCommand}
\begin{docCommand}{pproblem*}{\marg{text}}
 Does the same as \dac{pproblem}, but does not add the part problem to the table of contents
\end{docCommand}
\filbreak\subsection{Package options}
\keyDef{light}{true/false}{false}{
Pass this option if you don't want to define a different \dac{maketitle} and include
basic math packages.
}
\filbreak\subsection{Package options (\dac{handinsetup})}
 You can do configurations on this package, and probably
 even more to come in later versions!
\begin{docCommand}{handinsetup}{\marg{[key/values]}}\addcontentsline{toc}{subsubsection}{\refCom{handinsetup}}

 Here is a list of the different keys and their meaning
\end{docCommand}
\keyDef{problem header}{macro}{\dac{@tr}\{Problem\}~\dac{currentProblem}}{
This options contains the formatting of the problem header. Use \dac{currentProblem} to access the number of the current exercise, and \dac{@tr}\{Problem\} to access the translation of Problem.\\
Defaults to \dac{@tr}\{Problem\}~\dac{currentProblem}
}
\keyDef{part problem header}{macro}{See below}{
 This defaults to: \dac{currentProblemIfNewPage}\dac{currentPartProblem}).
 See \refCom{currentProblemIfNewPage} and \refCom{currentPartProblem}
}
\keyDef{problem TOC}{macro}{\meta{contents of problem header}}{
 This key decides what is written to the table of contents. It defaults to extract the content in \refKey{problem header}
}
\keyDef{part problem TOC}{macro}{\meta{contents of part problem header}}{
 This key decides what is written to the table of contents. It defaults to \dac{currentPartProblem}
 (which is what the user last sent to \dac{pproblem}).
}
\keyDef{logo width}{number}{0.4}{
 Give as factor (between 0 and 1) of total text width.
 This is a temporary fix for logo not being customisable, and is scheduled to be updated in a later version.
}
\keyDef{title style}{wholepage or small}{wholepage}{
If "wholepage", \dac{maketitle} will produce a full front-page. If "small", \dac{maketitle} will produce a smaller title containing the course name, course title, title, and author.
}
 \subsubsection*{Example} If you don't want to have the exercise number ever in front of the letter, then you'd do
\begin{dispListing}
 \handinsetup{part problem header=\currentPartProblem}
\end{dispListing}
\filbreak\subsection{Page formatting commands}
This package redefines \dac{maketitle}.
Here are some front-page commands. See layout.pdf for where they will appear.
These commands all have to be executed in the preamble (that is after \dac{documentclass} and before \dac{begin}\{document\})\\
The \dac{title} and \dac{author} commands are as per usual,
but are made lasting (not cleared by \dac{maketitle}) with \dac{thetitle} and \dac{theauthor} for use in headers and footers
\begin{docCommand}{title}{\marg{title}}
\end{docCommand}
\begin{docCommand}{author}{\marg{your name}}
\end{docCommand}
\begin{docCommand}{logo}{\marg{path/to/image}}\addcontentsline{toc}{subsubsection}{\refCom{logo}}

 If you want an image below the title, you provide the path to the image here
\end{docCommand}
\begin{docCommand}{coursename}{\marg{text}}\addcontentsline{toc}{subsubsection}{\refCom{coursename}}

\end{docCommand}
\begin{docCommand}{coursetitle}{\marg{text}}\addcontentsline{toc}{subsubsection}{\refCom{coursetitle}}

The front page will show coursename - coursetitle on a "subtitle" format
\end{docCommand}
\begin{docCommand}{institute}{\marg{text}}\addcontentsline{toc}{subsubsection}{\refCom{institute}}

 Shows as text on bottom
\end{docCommand}
\begin{docCommand}{containspages}{\marg{text}}\addcontentsline{toc}{subsubsection}{\refCom{containspages}}

 Here you can set a string that shows on bottom. Default is\\
 \dac{containspages}\{Contains \dac{pageref}\brackets{LastPage\} pages, front page included}
\end{docCommand}
\begin{docCommand}{pagetext}{\marg{string}}\addcontentsline{toc}{subsubsection}{\refCom{pagetext}}

 This is the text that is on the bottom right corner reading "Page x of y". Default is
 \dac{pagetext}\{Page \dac{thepage}~of \dac{pageref}{LastPage\}}
\end{docCommand}
\filbreak\subsection{Languages}
This package supports.
\begin{itemize}
\item English
\item Norwegian
\item German (by \href{https://github.com/africola}{africola})


\end{itemize}
Translations are welcome at \url{https://github.com/Strauman/Handin-LaTeX-template/tree/master/src/languages}.
The current language is set by the \texttt{iflang} package, so you can use e.g. babel:
\begin{dispListing}
\usepackage[german]{babel}
\end{dispListing}
\filbreak\subsection{General reference}
\begin{docCommand}{currentProblem}{}\addcontentsline{toc}{subsubsection}{\refCom{currentProblem}}

Contains the argument of the last call to \dac{problem}
\begin{dispListing}
\pproblem{hello}
\pproblem{world}
\currentPartProblem %<- contains world
\end{dispListing}
\end{docCommand}
\begin{docCommand}{currentPartProblem}{}\addcontentsline{toc}{subsubsection}{\refCom{currentPartProblem}}

 Just as \refCom{currentProblem}, but contains the argument of the last call to \dac{pproblem}
\end{docCommand}
\begin{docCommand}{currentProblemIfNewPage}{}\addcontentsline{toc}{subsubsection}{\refCom{currentProblemIfNewPage}}

If the problem is not defined on the current page, then
The first time \dac{currentProblemIfNewPage} is called on a page,
it expands to the current problem number. If not, it expands to empty.
If the problem is defined on the current page, it also expands to empty.
 This is used in the default key for the \dac{keyRef}\{part problem header\}.
 Here are some examples
\begin{dispListing}
\problem{1}
\currentProblemIfNewPage % <- empty
\end{dispListing}


\begin{dispListing}
\problem{4}
\clearpage
\currentProblemIfNewPage % <- expands to 4
\currentProblemIfNewPage % <- expands to empty
\end{dispListing}
\end{docCommand}
\begin{docCommand}{settable}{\marg{text}}
\begin{dispListing}
 \settable{hello}
\end{dispListing}
 if now \dac{@hello} is called,
  a warning is displayed with
  the text "\dac{hello} not set"
\begin{dispListing}
 \hello{world}
\end{dispListing}
 if now \dac{@hello} is called, it prints "world"
 \dac{@hello@noerror} gives the returning
 content and empty without error if no content set.
\begin{dispListing}
 \ifset@hello{true}{false}
\end{dispListing}
\end{docCommand}
\filbreak\subsection{Macro index reference}

 \addcontentsline{mac}{macro}{\refCom{author}}{}
\addcontentsline{mac}{macro}{\refCom{containspages}}{}
\addcontentsline{mac}{macro}{\refCom{coursename}}{}
\addcontentsline{mac}{macro}{\refCom{coursetitle}}{}
\addcontentsline{mac}{macro}{\refCom{currentPartProblem}}{}
\addcontentsline{mac}{macro}{\refCom{currentProblem}}{}
\addcontentsline{mac}{macro}{\refCom{currentProblemIfNewPage}}{}
\addcontentsline{mac}{macro}{\refCom{handinsetup}}{}
\addcontentsline{mac}{macro}{\refCom{institute}}{}
\addcontentsline{mac}{macro}{\refCom{logo}}{}
\addcontentsline{mac}{macro}{\refCom{pagetext}}{}
\addcontentsline{mac}{macro}{\refCom{pproblem}}{}
\addcontentsline{mac}{macro}{\refCom{pproblem*}}{}
\addcontentsline{mac}{macro}{\refCom{problem}}{}
\addcontentsline{mac}{macro}{\refCom{problem*}}{}
\addcontentsline{mac}{macro}{\refCom{settable}}{}
\addcontentsline{mac}{macro}{\refCom{title}}{}

 \macrotable


% \newgeometry{lmargin=0.7cm}
\section{Changelog}
% Use , 2018/04/01
\newversion{v0.0.2 2018/04/01}
  \change{Problems are now added to the table of contents by default}
\newversion{v0.0.2b34 2018/04/02}
  \change{Updated documentation syntax}
\newversion{v0.0.3b41 2018/04/04}
    \change[\gh{africola}]{German language translation}

\newversion{v0.0.4 2018/04/06}
    \change{Made proper margins for problem headers and part problem headers}
    \change[\gh{koppor}]{Added \texttt{microtype} and Latin Modern font (\texttt{cfr-lm})}


\newversion{v0.1.0 2018/04/10}
    \change{Introduced package options}
    \change[\gh{DanielTrosten}]{New slick, minimalistic, front page}
    \change[\gh{MadsAdrian}]{Added support for \dac{thetitle} and \dac{theauthor}}
    \change[\gh{MadsAdrian}]{Footer bar by default}
    \change{New part problem counting features}
    \change{Misc fixes of margin bugs}
    \change[\gh{MadsAdrian}]{Better file structuring on page style}
\newversion{v0.1.1 2018/07/22}
  \change{Fixed bug where first page after title did not have header and footer.}
  \change{Makes sure \refCom{pproblem} is in horizontal mode, so that the \dac{pproblem} header is placed correctly.}
  \change{Added package option \refKey{light}}
\chlogtable
 \end{document}
