Debian Codegraph @

texmf-dist/doc/latex/worksheet/worksheet.tex

raw
1 % DocumentClass
2 \documentclass[12pt, a4paper, listof=flat]{scrartcl}
3
4 % Languages
5 \usepackage[ngerman, english]{babel}
6
7 % Graphic Inclusion
8 \usepackage{graphicx}
9
10 % Colors
11 \usepackage{xcolor}
12
13 % define Apple Colors
14 \newcommand*{\maraschino}[1]{\textcolor[RGB]{255, 38, 0}{#1}}
15 \newcommand*{\tangerine}[1]{\textcolor[RGB]{255, 147, 0}{#1}}
16 \newcommand*{\lemon}[1]{\textcolor[RGB]{255, 251, 0}{#1}}
17 \newcommand*{\lime}[1]{\textcolor[RGB]{142, 250, 0}{#1}}
18 \newcommand*{\spring}[1]{\textcolor[RGB]{0, 249, 0}{#1}}
19 \newcommand*{\seafoam}[1]{\textcolor[RGB]{0, 250, 146}{#1}}
20 \newcommand*{\turquoise}[1]{\textcolor[RGB]{0, 253, 255}{#1}}
21 \newcommand*{\aqua}[1]{\textcolor[RGB]{0, 150, 255}{#1}}
22 \newcommand*{\blueberry}[1]{\textcolor[RGB]{4, 52, 155}{#1}}
23 \newcommand*{\grape}[1]{\textcolor[RGB]{148, 55, 155}{#1}}
24 \newcommand*{\magenta}[1]{\textcolor[RGB]{255, 64, 255}{#1}}
25 \newcommand*{\strawberry}[1]{\textcolor[RGB]{255, 47, 146}{#1}}
26 \newcommand*{\gray}[1]{\textcolor[RGB]{127, 127, 127}{#1}}
27
28 % Fonts
29 \usepackage{fontspec}
30 \setsansfont{Helvetica Neue}
31
32 % worksheet
33 \usepackage{worksheet}
34
35 % Filler Texts
36 \def\lipsum{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam dapibus faucibus orci vel commodo. Quisque tristique molestie dolor, eu euismod ligula malesuada ut.}
37 \def\exerciseFillerText{Following this, a certain exercise is described in a sentence. Maybe there is another sentence which is not enough, though. This last sentence should do.}
38
39 % make MiniPage for Source Code
40 \def\sourceCodeMinipage#1{
41 \begin{center}
42 \begin{minipage}{0.9\textwidth}
43 \ttfamily\raggedright
44 #1
45 \end{minipage}
46 \end{center}
47 }
48
49 % define Macros for formatted Source Code
50 \def\sourceCodeBegin#1{\aqua{\textbackslash begin}\{#1\}}
51 \def\sourceCodeEnd#1{\aqua{\textbackslash end}\{#1\}}
52 \def\sourceCodeBeginExercise{\aqua{\textbackslash begin}\{\tangerine{exercise}\}}
53 \def\sourceCodeEndExercise{\aqua{\textbackslash end}\{\tangerine{exercise}\}}
54 \def\sourceCodeScore#1{{\ttfamily\tangerine{\textbackslash score}\{#1\}}}
55 \def\sourceCodeLearningTargets#1{{\ttfamily\tangerine{\textbackslash learningtargets}\{#1\}}}
56 \def\sourceCodeEasy{{\ttfamily\tangerine{\textbackslash easy}}}
57 \def\sourceCodeMedium{{\ttfamily\tangerine{\textbackslash medium}}}
58 \def\sourceCodeHard{{\ttfamily\tangerine{\textbackslash hard}}}
59 \def\sourceCodeOccurrence#1{{\ttfamily\tangerine{\textbackslash occurrence}\{#1\}}}
60 \def\sourceCodeWorksheetTitle#1{{\ttfamily\tangerine{\textbackslash worksheetTitle}\{#1\}}}
61 \def\sourceCodeWorksheetSubTitle#1{{\ttfamily\tangerine{\textbackslash worksheetSubTitle}\{#1\}}}
62 \def\sourceCodeWorksheetMakeTitle{{\ttfamily\tangerine{\textbackslash worksheetMakeTitle}}}
63 \def\sourceCodeWorksheetShowFileName{{\ttfamily\tangerine{\textbackslash worksheetShowFileName}}}
64 \def\sourceCodeWorksheetShowScore{{\ttfamily\tangerine{\textbackslash worksheetShowScore}}}
65 \def\sourceCodeWorksheetShowLearningTargets{{\ttfamily\tangerine{\textbackslash worksheetShowLearningTargets}}}
66 \def\sourceCodeWorksheetShowDifficulty{{\ttfamily\tangerine{\textbackslash worksheetShowDifficulty}}}
67 \def\sourceCodeWorksheetShowOccurrence{{\ttfamily\tangerine{\textbackslash worksheetShowOccurrence}}}
68 \def\sourceCodeWorksheetHideFileName{{\ttfamily\tangerine{\textbackslash worksheetHideFileName}}}
69 \def\sourceCodeWorksheetHideScore{{\ttfamily\tangerine{\textbackslash worksheetHideScore}}}
70 \def\sourceCodeWorksheetHideLearningTargets{{\ttfamily\tangerine{\textbackslash worksheetHideLearningTargets}}}
71 \def\sourceCodeWorksheetHideDifficulty{{\ttfamily\tangerine{\textbackslash worksheetHideDifficulty}}}
72 \def\sourceCodeWorksheetHideOccurrence{{\ttfamily\tangerine{\textbackslash worksheetHideOccurrence}}}
73 \def\sourceCodeWorksheetHideHeader{{\ttfamily\tangerine{\textbackslash worksheetHideHeader}}}
74 \def\sourceCodeWorksheetAuthors#1{{\ttfamily\tangerine{\textbackslash worksheetAuthors}\{#1\}}}
75 \def\sourceCodeWorksheetCourseName#1{{\ttfamily\tangerine{\textbackslash worksheetCourseName}\{#1\}}}
76 \def\sourceCodeWorksheetChangelvFile#1{{\ttfamily\tangerine{\textbackslash worksheetChangelvFile}\{#1\}}}
77 \def\sourceCodeWorksheetNoSFFamilyInHeader{{\ttfamily\tangerine{\textbackslash worksheetNoSFFamilyInHeader}}}
78
79
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 % Document
82
83 % Source Code copied from precompiled PDF - Header - Example
84 % Begin
85 \worksheetChangelvFile{./MySubDirectory/lv.tex}
86 \worksheetAuthors{Ignored Author}
87 \worksheetCourseName{Ignored Header}
88 % End
89
90 \begin{document}
91
92 % hide Header
93 \pagestyle{plain}
94
95 % prevent overfull hboxes
96 \emergencystretch 2em
97
98 % Title Page
99 \begin{titlepage}
100 \sffamily
101 \begin{figure}[t]
102 \centering
103 \includegraphics[width=0.8\textwidth]{./HS-Osna-Logo.png}
104 \end{figure}
105
106 \begin{center}
107 ~\\[6ex]
108 \large{Faculty\\Engineering and Computer Science}\\[10ex]
109 {\Huge{\textbf{Package Documentation}}}\\[10ex]
110 \sffamily\huge{Worksheet}\rmfamily\\[10ex]
111 \end{center}
112
113 \begin{center}
114 \begin{minipage}{0.4\textwidth}
115 \begin{tabbing}
116 \hspace*{5cm}\=\kill
117 Author:\>Benjamin Z\"{o}llner\\
118 \>\footnotesize([email protected])\\[1ex]\normalsize
119 Professor:\>Prof. Dr. Markus Schmidt-Gröttrup\\[1ex]
120 Release:\>\today
121 \end{tabbing}
122 \end{minipage}
123 \end{center}
124 \end{titlepage}
125
126 % Abstract
127 \newpage\section*{Abstract}
128 \input{README.md}\par\addvspace{\topsep}\noindent
129 Every ellipsis ({\ttfamily ...}) in the following examples can be replaced with a string or text of any length.
130
131 \newpage\tableofcontents
132
133 % Exercise Environment
134 \newpage\section{Exercise Environment}
135 An exercise containing minimal information is simply made with:
136
137 \sourceCodeMinipage{
138 \sourceCodeBeginExercise\\
139 ...\\
140 \sourceCodeEndExercise
141 }
142
143 \noindent In the optional argument of exercise, information "Score", "Learning Targets", "Occurrence" and "Difficulty" can be set independently of each other with:
144
145 \begin{center}
146 \sourceCodeScore{...}, \sourceCodeLearningTargets{...}, \sourceCodeOccurrence{...} and\newline
147 \sourceCodeEasy{}, \sourceCodeMedium{} or \sourceCodeHard{}
148 \end{center}
149
150 % Exercise optional Argument Syntax
151 \subsection*{Syntax}
152 Placing a command to set specific exercise information outside of the optional argument of exercise will cause it \emph{to do nothing}. Replace ellipses ({\ttfamily ...}) at will, but even though whitespaces will be ignored, do not add any characters to the optional argument of exercise, \textbf{especially do not add any new-line characters or {\ttfamily\textbackslash par} macros at all costs}.
153
154 \sourceCodeMinipage{
155 \sourceCodeBeginExercise[\sourceCodeScore{...}\sourceCodeLearningTargets{...}\sourceCodeEasy]\\
156 ...\\
157 \sourceCodeEndExercise\\
158 or\\
159 \sourceCodeBeginExercise[\sourceCodeScore{...}\sourceCodeLearningTargets{...}\sourceCodeMedium]\\
160 ...\\
161 \sourceCodeEndExercise\\
162 or\\
163 \sourceCodeBeginExercise[\sourceCodeScore{...}\sourceCodeLearningTargets{...}\sourceCodeHard]\\
164 ...\\
165 \sourceCodeEndExercise
166 }
167 \par\addvspace{\topsep}\noindent
168
169 \noindent Detailed information of an exercise is only shown, if \emph{detailed information is available} and \emph{specific flags are set}. The flags are by default not set. To set these flags use:
170
171 \sourceCodeMinipage{
172 \sourceCodeWorksheetShowFileName\\
173 \sourceCodeWorksheetShowScore\\
174 \sourceCodeWorksheetShowLearningTargets\\
175 \sourceCodeWorksheetShowDifficulty
176 }
177
178 \noindent Deleting these flags is achieved with:
179 \sourceCodeMinipage{
180 \sourceCodeWorksheetHideFileName\\
181 \sourceCodeWorksheetHideScore\\
182 \sourceCodeWorksheetHideLearningTargets\\
183 \sourceCodeWorksheetHideDifficulty
184 }
185
186 % Exercise Example
187 \subsection*{Example:}
188 Including following source code in 4 different *.tex files using {\ttfamily\aqua{\textbackslash input}\{...\}}:\par
189
190 % Show Source Code for both precompiled and finished PDF
191 \noindent "file1.tex"
192 \sourceCodeMinipage{
193 \sourceCodeWorksheetShowScore\\[1ex]
194 \sourceCodeBeginExercise[\sourceCodeScore{10}\sourceCodeEasy]\\
195 This exercise has a maximum score of 10 and easy difficulty level. \exerciseFillerText\\
196 \sourceCodeEndExercise\\[1ex]
197 \sourceCodeWorksheetShowFileName\\
198 \sourceCodeWorksheetShowLearningTargets\\
199 \sourceCodeWorksheetShowDifficulty\\
200 \sourceCodeWorksheetShowOccurrence
201 }
202
203 \noindent "file2.tex"
204 \sourceCodeMinipage{
205 \sourceCodeBeginExercise[\sourceCodeLearningTargets{1, 2, 3}\sourceCodeMedium]\\
206 This exercise satisfies learning targets one, two, three and has medium difficulty level. \exerciseFillerText\\
207 \sourceCodeEndExercise
208 }
209
210 \noindent "file3.tex"
211 \sourceCodeMinipage{
212 \sourceCodeBeginExercise[\sourceCodeOccurrence{Exam WS 2018}\sourceCodeScore{20}]\\
213 This exercise was in an exam in winter semester in 2018, satisfies learning targets 4,5 and has a maximum score of 10 and hard difficulty level. \exerciseFillerText\\
214 \sourceCodeEndExercise\\[1ex]
215 \sourceCodeWorksheetHideFileName
216 }
217
218 \noindent "file4.tex"
219 \sourceCodeMinipage{
220 \sourceCodeBeginExercise[\sourceCodeScore{30}]\\
221 This exercise has a maximum score of 30. \exerciseFillerText\\
222 \sourceCodeEndExercise
223 }
224
225 \pagebreak
226
227 \noindent lead to:
228
229 % Source Code copied from precompiled PDF into 4 Files:
230 % Begin
231 \input{file1.tex}
232 \input{file2.tex}
233 \input{file3.tex}
234 \input{file4.tex}
235 % End
236
237 % Worksheet Title
238 \newpage\section{Worksheet Title}
239 Both, title and subtitle, can be set with:
240 \begin{center}
241 \sourceCodeWorksheetTitle{...} and \sourceCodeWorksheetSubTitle{...}
242 \end{center}
243 The title itself is then displayed with \sourceCodeWorksheetMakeTitle.
244
245 % Worksheet Title Example
246 \subsection*{Example:}
247 Assuming this document's file name would be "\jobname.tex", using this source code
248 \sourceCodeMinipage{
249 \sourceCodeWorksheetTitle{My Title}\\
250 \sourceCodeWorksheetSubTitle{My Subtitle}\\[2ex]
251 \sourceCodeWorksheetMakeTitle\\[2ex]
252 \aqua{\textbackslash noindent} \lipsum%
253 }
254 lead to following title:
255
256 % Source Code copied from precompiled PDF:
257 % Begin
258 \worksheetTitle{My Title}
259 \worksheetSubTitle{My Subtitle}
260
261 \worksheetMakeTitle
262 % End
263
264 \noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam dapibus faucibus orci vel commodo. Quisque tristique molestie dolor, eu euismod ligula malesuada ut.
265
266 % Header
267 \newpage\thispagestyle{headings}\section{Header}
268 Header information can be set with:
269 \begin{center}
270 \sourceCodeWorksheetAuthors{...} and \sourceCodeWorksheetCourseName{...}
271 \end{center}
272 The authors are always placed on the inner side, while the course name is always placed on the outer side. In one-sided documents this would result in placing course name on the page's left side and authors on the page's right side. The default header of "scrlayer-scrpage" package is redefined (plus the default pagestyle is set to "headings") only, if at least authors or at least course name was set before.\par
273 The package worksheet automatically tries to include "./lv.tex" which should define {\ttfamily\textbackslash coursename} and {\ttfamily\textbackslash authors} which are automatically associated as header information. Change the try-to-include file with: \sourceCodeWorksheetChangelvFile{...}.\par
274 If a KOMA document class is selected, worksheet automatically sets the header font family to "Sans Serif". Suppress this behaviour with: \sourceCodeWorksheetNoSFFamilyInHeader.\par
275 See \emph{\ref{cap:dependencies:scrlayerscrpage} Dependencies - scrlayer-scrpage} for further information about controlling presence of the header.
276
277 % Header Examples
278 \subsection*{Examples:}
279 Results of following examples are shown in this page's header. All examples lead to the exact same header.
280
281 % First Header Example
282 \subsubsection*{1. Example}
283 Setting header information manually ("lv.tex" does not exist):
284 \sourceCodeMinipage{
285 \sourceCodeWorksheetAuthors{Example Author}\\
286 \sourceCodeWorksheetCourseName{Example Header}\\[2ex]
287 \sourceCodeBegin{document}...
288 }
289
290 % Second Header Example
291 \subsubsection*{2. Example}
292 Changing the directory path of "lv.tex" ("lv.tex" does exist in "./MySubDirectory/"):
293 \sourceCodeMinipage{
294 \sourceCodeWorksheetChangelvFile{./MySubDirectory/lv.tex}\\[1.5ex]
295 \sourceCodeWorksheetAuthors{Ignored Author}\\
296 \sourceCodeWorksheetCourseName{Ignored Header}\\[1.5ex]
297 \sourceCodeBegin{document}...
298 }
299 \vfil
300 \begin{center}
301 \begin{minipage}[b]{\textwidth}
302 \begin{minipage}[b]{0.5\textwidth}
303 \noindent Content of "MySubDirectory/lv.tex":\par\addvspace{0.5\baselineskip}\noindent
304 {\ttfamily\raggedright \aqua{\textbackslash def}\textbackslash coursename\{Example Header\}\\
305 \aqua{\textbackslash def}\textbackslash authors\{Example Author\}}
306 \end{minipage}%
307 \begin{minipage}[b]{0.5\textwidth}
308 \noindent Also a german version of "MYSubDirectory/lv.tex" is possible:\par\addvspace{0.5\baselineskip}\noindent
309 {\ttfamily\raggedright \aqua{\textbackslash def}\textbackslash lvname\{Example Header\}\\
310 \aqua{\textbackslash def}\textbackslash autoren\{Example Author\}}
311 \end{minipage}
312 \end{minipage}
313 \end{center}
314
315
316 % play it safe to display Example Header on both Pages, if this Section is 2 Pages long
317 \thispagestyle{headings}
318
319 % Babel Languages
320 \newpage\section{Conforming to Babel Languages}
321 This package automatically changes its appearance to a specific language, after a specific language is selected with {\ttfamily\textbackslash selectlanguage\{...\}}. Supported Babel languages are:
322 \begin{center}
323 \textbf{english, french, german and ngerman}
324 \end{center}
325
326 % Babel Languages Example
327 \subsection*{Example:}
328 Defining two different exercises in two different languages:
329
330 % Show Source Code for both precompiled and finished PDF
331 \sourceCodeMinipage{
332 \sourceCodeWorksheetShowScore\\
333 \sourceCodeWorksheetShowLearningTargets\\
334 \sourceCodeWorksheetShowDifficulty\\
335 \sourceCodeWorksheetShowOccurrence\\[1ex]
336 \sourceCodeBeginExercise\spring{\%}\\{}
337 {\small[\sourceCodeScore{10}\sourceCodeEasy\sourceCodeLearningTargets{1, 2, 3}\sourceCodeOccurrence{Exam WS 2018}]}\\
338 This is an exercise written in english and described in a sentence. Maybe there is another sentence which is not enough though. This last sentence should do.\\
339 \sourceCodeEndExercise\\[1ex]
340 \aqua{\textbackslash selectlanguage}\{ngerman\}\\[1ex]
341 \sourceCodeBeginExercise\spring{\%}\\{}
342 {\small[\sourceCodeScore{10}\sourceCodeEasy\sourceCodeLearningTargets{1, 2, 3}\sourceCodeOccurrence{Klausur WS 2018}]}\\
343 Dies ist eine in deutsch verfasste Aufgabe, die mit einem Satz beschrieben wird. Vermutlich reicht dieser eine Satz jedoch nicht aus. Dieser letzte Satz sollte ausreichen.\\
344 \sourceCodeEndExercise\\[1ex]
345 }
346
347 \noindent lead to:
348
349 % Source Code copied from precompiled PDF:
350 % Begin
351 \worksheetShowScore
352 \worksheetShowLearningTargets
353 \worksheetShowDifficulty
354 \worksheetShowOccurrence
355 \begin{exercise}%
356 [\score{10}\easy\learningtargets{1, 2, 3}\occurrence{Exam WS 2018}] This is an exercise written in english and described in a sentence. Maybe there is another sentence which is not enough though. This last sentence should do.
357 \end{exercise}
358 \selectlanguage{ngerman}
359 \begin{exercise}%
360 [\score{10}\easy\learningtargets{1, 2, 3}\occurrence{Klausur WS 2018}] Dies ist eine in deutsch verfasste Aufgabe, die mit einem Satz beschrieben wird. Vermutlich reicht dieser eine Satz jedoch nicht aus. Dieser letzte Satz sollte ausreichen.
361 \end{exercise}
362 % End
363
364 % setting Language back to English
365 \selectlanguage{english}
366
367 % Dependencies
368 \newpage\section{Dependencies}
369 All dependencies are listed in this Section. Compiling this package with \emph{pdflatex} and \emph{xelatex} is guaranteed.
370
371 % Dependencies
372 \subsection*{scrlayer-scrpage}\label{cap:dependencies:scrlayerscrpage}
373 The Package worksheet uses \emph{scrlayer-scrpage} to control header. Use
374 \begin{center}
375 {\ttfamily\textbackslash pagestyle\{plain\}} or {\ttfamily\textbackslash thispagestyle\{plain\}}
376 \end{center}
377 to hide and
378 \begin{center}
379 {\ttfamily\textbackslash pagestyle\{headings\}} or {\ttfamily\textbackslash thispagestyle\{headings\}}
380 \end{center}
381 to show worksheet header. Per default \emph{scrlayer-scrpage's} header is redefined and -- per default -- pagestyle "headings" is selected; suppress all this behaviour by calling \sourceCodeWorksheetHideHeader{} \textbf{before} {\ttfamily\aqua{\textbackslash begin}\{document\}}.\par
382
383 \subsection*{Babel}
384 The package worksheet redefines {\ttfamily\textbackslash selectlanguage\{...\}} keeping the original macro functionality plus checking the selected language's support and changing the internal language if the selected language is supported.
385
386 \end{document}