blob: 61edfdf862552e7af59531305cce1f9e8cba4a29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
%% handin v0.0.3b41 - 2018/04/04
%% The LaTeX package handin - version v0.0.3 (2018/04/04) build 41
%% 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
\ProvidesPackage{handin}[2018/04/04 v0.0.3 Creates a setup that is ideal for handing in hard-science school papers that are divided in exercises.]
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{lastpage}
\usepackage{scrextend}
\def\exerciseNr{0}
\gdef\problem{\@ifnextchar*{\expandafter\@problem\@secondoftwo}{\@problemTOC}}
\gdef\@problemTOC#1{ \addcontentsline{toc}{section}{\@tr{Problem} #1}
\@problem{#1}
}
\newcommand{\@problem}[1]{ \def\exerciseNr{#1}
\begin{addmargin}{-1.5em}
{\normalfont\Large\bfseries \@tr{Problem} #1}
\end{addmargin}
}
\gdef\pproblem{\@ifnextchar*{\expandafter\@pproblem\@secondoftwo}{\@pproblemTOC}}
\gdef\@pproblemTOC#1{ \addcontentsline{toc}{subsection}{\exerciseNr #1}
\@pproblem{#1}
}
\newcommand{\@pproblem}[1]{ \vspace*{1em}
\hspace*{-0.5em}{\normalfont\Large\bfseries\exerciseNr #1)}
}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{bm}
\usepackage{esint}
\usepackage{iflang}
\def\@tr#1{ \ifcsname tr@#1\endcsname%
\csname tr@#1\endcsname%
\else%
#1%
\fi%
}
\newcommand{\set@tr}[2]{ \expandafter\def\csname tr@#1\endcsname{#2}
}
\set@tr{Problem}{Problem}
\set@tr{problem}{problem}
\set@tr{containspages}{Contains \pageref{LastPage} pages, front page included}
\set@tr{pagetext}{Page \thepage~of \pageref{LastPage}}
\IfLanguageName{norsk}{%
\set@tr{Problem}{Oppgave}
\set@tr{problem}{oppgave}
\set@tr{pagetext}{Side \thepage~av \pageref{LastPage}}
\set@tr{containspages}{Inneholder \pageref{LastPage} sider, inkludert forside.}
}{}
\IfLanguageName{german}{%
\set@tr{Problem}{Aufgabe}
\set@tr{problem}{Aufgabe}
\set@tr{containspages}{Enthält \pageref{LastPage} Seiten, inklusive Titelseite}
\set@tr{pagetext}{Seite \thepage~von \pageref{LastPage}}
}{}
\newif\ifshowoff
\showofffalse
\let\ea = \expandafter
\newcommand{\settable}[2][\@nil]{ \ea\def\csname #2\ea\endcsname##1{ \ea\def\csname @#2\endcsname{##1}
\ea\def\csname @#2@noerror\endcsname{##1}
\ea\def\csname isset@#2\endcsname{1}
}
\ea\def\csname ifset@#2\endcsname##1##2{ \ifcsname isset@#2\endcsname%
##1
\else
##2
\fi
}
\ea\def\csname default@#2\endcsname{#1}%
\ea\def\csname @#2@noerror\endcsname{#1}%
\ea\ifx\csname default@#2\endcsname\@nnil
\ea\def\csname default@#2\endcsname{ \textbackslash #2%
{\ea\@latex@warning{\ #2 not given}}
}
\fi
\ea\def\csname @#2\endcsname{ \csname default@#2\endcsname
}
}
\ifshowoff
\@latex@warning{Settable: showing off, no settable is actually set!}
\renewcommand{\settable}[2][\@nil]{ \ea\def\csname #2\endcsname##1{\relax}%
\ea\def\csname @#2\endcsname{}%
\ea\def\csname @#2@noerror\endcsname{}%
\ea\def\csname ifset@#2\endcsname##1##2{##2}
\ea\def\csname default@#2\endcsname{#1}%
\ea\def\csname @#2@noerror\endcsname{#1}%
\ea\def\csname @#2\endcsname{\textbackslash #2}
}
\fi
\settable{title}
\settable{author}
\settable{logo}
\settable{coursename}
\settable{coursetitle}
\settable{institute}
\settable{containspages}
\settable{pagetext}
\setlength\parindent{0pt}
\geometry{paper=a4paper, bottom=3cm, top=3cm, footnotesep=3cm}
\fancyhf{}
\addtolength\headwidth{4em}
\fancyheadoffset{2em}
\pagestyle{fancy}
\let\old@maketitle = \maketitle
\def\maketitle{ \old@maketitle
\thispagestyle{empty}
\clearpage
}
\def\@maketitle{%
\begin{center}
\ifshowoff
\Huge{\textbackslash logo}\\
\Large{\@title} \\[1.5cm]
\else
\ifset@logo{ \includegraphics[scale=1]{\@logo}\\[0.5cm]
\Large{\@title} \\[1.5cm]
}{ \ea\@latex@warning{Use \noexpand\logo{path/to/image} to set a logo on the front page}
\Huge{\@title} \\[1.0cm]
}
\fi
\end{center}
\begin{center}
\textbf{\@coursename - \@coursetitle}\\[1cm]
\textbf{\@author} \\[1cm]
\textbf{\today} \\[3cm]
\end{center}
\begin{center}
\vfill
\ifset@containspages{ \@containspages
}{ \@tr{containspages}
}\\[0.5cm]
\textsc{\@institute}
\end{center}
\rhead{\@author}
\lhead{\@coursename - \@coursetitle}
\ifset@pagetext{ \rfoot{\@pagetext}
}{ \rfoot{\@tr{pagetext}}
}
}
|