Debian Codegraph @

texmf-dist/source/latex/oststud/hsrstud.dtx

raw
1 % \iffalse meta-comment
2 %
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 % Headers
5
6 %<*package>
7 \NeedsTeXFormat{LaTeX2e}
8 \ProvidesPackage{hsrstud}[2021/08/04 v0.2 HSR-Stud Macros]
9 %</package>
10
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 % Documentation
13 %<*doc>
14 \documentclass[a4paper]{ltxdoc}
15
16 \usepackage{hypdoc}
17
18 %% https://tex.stackexchange.com/questions/95882/avoid-multicol-error-error-saving-partial-page
19 %% \setlength\IndexMin{100pt}
20
21 \usepackage[left=4cm, right=4cm, top=3cm, bottom=3cm]{geometry}
22
23 \usepackage{\jobname}
24
25 \usepackage{fancyvrb}
26 \usepackage{enumitem}
27 \usepackage{framed}
28 \usepackage{booktabs}
29 \usepackage{tikz}
30 \usepackage{xargs}
31 \usepackage{bookmark}
32
33 \usepackage[
34 type={CC},
35 modifier={by-sa},
36 version={4.0},
37 ]{doclicense}
38
39 \CodelineIndex
40 \EnableCrossrefs
41 \RecordChanges
42
43 \makeatletter
44 \newlength\excodewidth
45 \newenvironment{example}{%
46 \leftbar\VerbatimEnvironment%
47 \global\excodewidth=.5\linewidth%
48 \begin{VerbatimOut}{\jobname.vrb}%
49 }{%
50 \end{VerbatimOut}%
51 \noindent%
52 \minipage[c]{\excodewidth}%
53 \vspace{0pt}\input{\jobname.vrb}%
54 \endminipage%
55 \minipage[c]{\dimexpr\linewidth-\excodewidth-2\fboxsep-2\fboxrule-\FrameSep\relax}%
56 \vspace{0pt}\lstinputlisting{\jobname.vrb}%
57 \endminipage%
58 \endleftbar%
59 }
60
61 \newenvironment{hexample}{%
62 \leftbar\VerbatimEnvironment%
63 \begin{VerbatimOut}{\jobname.vrb}%
64 }{%
65 \end{VerbatimOut}%
66 \noindent%
67 \begingroup\centering%
68 \hspace{5pt}%
69 \minipage[t]{\linewidth}%
70 \vspace{0pt}\input{\jobname.vrb}%
71 \endminipage\\
72 \hspace{5pt}%
73 \minipage[t]{\linewidth}%
74 \vspace{0pt}\lstinputlisting{\jobname.vrb}%
75 \endminipage%
76 \endgroup%
77 \endleftbar%
78 }
79
80
81 \makeatother
82
83 \begin{document}
84 \GetFileInfo{\jobname.sty}
85 \title{^^A
86 \texttt{\textcolor{hsr-blue}{hsr}stud} --- HSR-Stud Style and Macros\thanks{^^A
87 This file describes version \fileversion, last revised \filedate.^^A
88 }^^A
89 }
90 \author{Naoki Pross \texttt{<[email protected]>}}
91 \date{Released \filedate}
92 \maketitle
93 \tableofcontents
94
95 \changes{v0.2}{2021/08/05}{Remove legacy code and update notation}
96 \changes{v0.1}{2020/02/16}{Initial draft}
97
98 \section{Purpose of this package}
99 This package is made for the HSR Studenten organization to provide an easy to
100 use interface to give a more consistent look and feel for the works produced by
101 its the members. A secondary objective of this package is to eliminate the
102 \emph{many} dispersed duplicate .tex files that fill the repositories of the
103 HSR-Stud org.
104
105
106 \section{Package Options} \label{sec:options}
107 \begin{description}[align=right]
108 \item[|dontrenew|] Do not renew existing \LaTeX{} commands and
109 environments. This is useful when the package is loaded on a document
110 that is already partially written.
111
112 \item[|arrowvec|] Tells the package to use a vector notation with a small
113 arrow over the variables, as it were handwritten.
114
115 \item[|textvecdiff|] Disables the ``Nabla'' or ``Del'' notation for vector
116 derivatives. Instead the symbols \(\vec{\nabla}, \vec{\nabla}\dotp,
117 \vec{\nabla}\crossp, \nabla^2, \vec{\nabla}^2\) are be replaced with
118 grad, div, curl and div grad.
119 \end{description}
120
121 \section{Summary notation}
122
123 \section{Default Theming}
124 \subsection{Links with \texttt{hyperref}}
125
126 \begin{example}
127 Colors from
128 \cite{bib:hsrcolors} see \\
129 \url{https://intranet.hsr.ch}
130 \end{example}
131
132 \subsection{Source Code with \texttt{listings}}
133
134 \begin{hexample}
135 \begin{lstlisting}[language=C++]
136 int main(int argc, char *argv[], char *envp[]) {
137 std::cout << "hello world" << std::endl;
138 }
139 \end{lstlisting}
140 \end{hexample}
141
142 \section{Mathematics}
143 \subsection{Vectors}
144
145 \begin{macro}{\vec}
146
147 Vectors notation. Aliases: \cs{v}, \cs{vc}. If the option \texttt{arrowvec}
148 described in \S \ref{sec:options} is enabled, the notation with a small
149 arrow over the varible will be used \(\hsrvecarrow{x}\), otherwise the
150 vector is bold \(\hsrvecbold{x}\). Takes one option \marg{letter}. \cs{v}
151 is renamed to \cs{vaccent} and \cs{vec} to \cs{oldvec}.
152
153 \begin{example}
154 \[ \vec{F} = m\vec{a} \]
155 \end{example}
156 \end{macro}
157
158 \begin{macro}{\uvec}
159 Unit vector notation. Alias \cs{uv}. Takes \marg{letter}. It is implemented
160 in terms of \cmd{\vec}, which means that the style is inherited.
161 \begin{example}
162 \[ \uvec{x} = \vec{x}/x \]
163 \end{example}
164 \end{macro}
165
166 \subsubsection{Products}
167 \begin{macro}{\dotp}
168 Dot product between vectors.
169 \begin{example}
170 \[ \vec{u}\dotp\vec{v} \]
171 \end{example}
172 \end{macro}
173
174 \begin{macro}{\crossp}
175 Cross product between vectors.
176 \begin{example}
177 \[ \vec{u}\crossp\vec{v} \]
178 \end{example}
179 \end{macro}
180
181
182 \subsection{Matrices}
183
184 \begin{macro}{\mx}
185 Matrix notation. Takes \marg{letter}.
186
187 \begin{example}
188 \[
189 \mx{J} = \begin{pmatrix}
190 0 & 1 \\
191 1 & 0
192 \end{pmatrix}
193 \]
194 \end{example}
195 \end{macro}
196
197 \subsection{Equalities}
198
199 \begin{macro}{\heq}
200 L'H\^opital limit equality symbol.
201 \begin{hexample}
202 \[
203 \lim_{x\to\infty} \frac{x}{x^2 - 1}
204 \heq \lim_{x\to\infty} \frac{1}{2x}
205 = 0
206 \]
207 \end{hexample}
208 \end{macro}
209
210 \subsection{Derivatives}
211 \subsubsection{Differentials}
212
213 \begin{macro}{\dd}
214 The differential element. It needs a \marg{var} and has the optional
215 argument \oarg{order}.
216 \begin{example}
217 \[ \dd{x} \qquad \dd[4]{x} \]
218 \end{example}
219 \end{macro}
220
221 \begin{macro}{\di}
222 This is the same as \cs{dd} but with a small space in front, it is
223 intended to be used in integrals for a nicer typesetting.
224 \begin{hexample}
225 \begin{align*}
226 I &= \int \vec{J}\dotp\dd{\vec{s}} \\
227 &= \iint \vec{J}\dotp\uvec{n}\di{x}\di{y}
228 \end{align*}
229 \end{hexample}
230 \end{macro}
231
232 \subsubsection{Scalar functions}
233
234 \begin{macro}{\deriv}
235 The derivative has arguments \marg{function}, \marg{var} and the optional
236 argument \oarg{order}.
237 \begin{example}
238 \[
239 \deriv{y}{x} \qquad
240 \deriv[3]{y}{x}
241 \]
242 \end{example}
243 \end{macro}
244
245 %% TODO: add mixed partial derivatives (probably using xparse)
246 \begin{macro}{\pderiv}
247 The partial derivative has arguments \marg{function}, \marg{var} and the
248 optional argument \oarg{order}.
249 \begin{example}
250 \[
251 \pderiv{y}{x} \qquad
252 \pderiv[3]{y}{x}
253 \]
254 \end{example}
255 \end{macro}
256
257 \subsubsection{Vector functions}
258
259 \begin{macro}{\grad}
260 The gradient vector operator.
261 \begin{example}
262 \[ \grad f \]
263 \end{example}
264 \end{macro}
265
266 \begin{macro}{\div}
267 The divergence operator, \cs{div} is renamed to \cs{divsymb}. If the option
268 |donotrenew| is used \cs{divg} is also available.
269 \begin{example}
270 \[ \div \vec{f} \]
271 \end{example}
272 \end{macro}
273
274 \begin{macro}{\curl}
275 The curl operator.
276 \begin{example}
277 \[ \curl \vec{f} \]
278 \end{example}
279 \end{macro}
280
281 \begin{macro}{\laplacian}
282 The laplacian operator.
283 \begin{example}
284 \[
285 \laplacian f
286 \]
287 \end{example}
288 \end{macro}
289
290 \begin{macro}{\vlaplacian}
291 The vector laplacian operator operator.
292 \begin{example}
293 \[
294 \vlaplacian \vec{F}
295 \]
296 \end{example}
297 \end{macro}
298
299
300 \section{Colors}
301 \begin{center}
302 \begin{tikzpicture}
303 \foreach \color/\y in {%
304 hsr-blue/7,
305 hsr-mauve/6,
306 hsr-lakegreen/5,
307 hsr-reed/4,
308 hsr-petrol/3,
309 hsr-basswood/2,
310 hsr-lightgrey/1,
311 hsr-black/0}{
312 \foreach \x/\a in {0/,1/80,2/60,3/40,4/20}{
313 \node[anchor=east] at (-.5,\y) {\texttt{\color}};
314 \fill[color=\color\a] (\x,\y-.25) rectangle ++(1,.5);
315 \node[anchor=west] at (\x,\y) {\texttt{\a}};
316 }
317 }
318 \end{tikzpicture}
319 \end{center}
320
321 \section{License}
322 \doclicenseThis
323
324 \begin{thebibliography}{3}
325 \bibitem{bib:hsrcolors}
326 HSR Intern: Corporate Design / Farben,
327 \textit{Hochschule f\"ur Technik Rapperswil},
328 \url{https://intranet.hsr.ch/Farben.7715.0.html}
329 \end{thebibliography}
330
331 \PrintChanges
332 \PrintIndex
333
334 \DocInput{\jobname.dtx}
335
336 \end{document}
337
338 %</doc>
339 %\fi
340
341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
342 % \appendix
343 % \section{Implementation}
344 % |hsrstud| package implementation with inline documentation
345
346 %\iffalse
347 %<*package>
348 %\fi
349
350 % \subsection{Dependencies}
351 % \begin{macrocode}
352 %% Dependencies ((
353 \RequirePackage{amsmath}
354 \RequirePackage{amssymb}
355 \RequirePackage{bm}
356
357 \RequirePackage{esint}
358 \PassOptionsToPackage{b}{esvect}
359 \RequirePackage{esvect}
360
361 \RequirePackage{xcolor}
362 \RequirePackage{hyperref}
363 \RequirePackage{listings}
364
365 \RequirePackage{iftex}
366 \RequirePackage{kvoptions}
367 %% ))
368 % \end{macrocode}
369
370 % \subsection{Package options}
371 % \begin{macrocode}
372 \SetupKeyvalOptions{
373 family=hsr,
374 prefix=hsr@
375 }
376
377 %% Do not renew LaTeX Macros
378 \DeclareBoolOption[false]{dontrenew}
379
380 %% Vector style
381 \DeclareBoolOption[false]{arrowvec}
382 \DeclareComplementaryOption{boldvec}{arrowvec}
383
384 %% Vector derivative style
385 \DeclareBoolOption[false]{textvecdiff}
386 \DeclareComplementaryOption{delvecdiff}{textvecdiff}
387
388
389 %% Process options
390 \ProcessLocalKeyvalOptions*
391 % \end{macrocode}
392
393
394 % \subsection{Summary notation}
395 % \begin{macrocode}
396 %% TODO: change letters in german
397 \newcommand{\bookref}[1]{\texttt{\textcolor{hsr-mauve}{P.#1}}}
398 \newcommand{\notesref}[1]{\texttt{\textcolor{hsr-blue}{S.#1}}}
399 \newcommand{\lectureref}[1]{\texttt{\textcolor{hsr-lakegreen}{L.#1}}}
400 % \end{macrocode}
401
402 % \subsection{Default theming}
403 % \begin{macrocode}
404 %% Theming for hyperref and listings ((
405 \hypersetup{
406 colorlinks=true,
407 linkcolor=hsr-black,
408 citecolor=hsr-mauve,
409 filecolor=hsr-black,
410 urlcolor=hsr-blue,
411 }
412
413 %% Common listings settings
414 \lstdefinestyle{hsr-base}{
415 belowcaptionskip=\baselineskip,
416 breaklines=true,
417 frame=none,
418 inputencoding=utf8,
419 % margin
420 xleftmargin=\parindent,
421 % numbers
422 numbers=left,
423 numbersep=5pt,
424 numberstyle=\ttfamily\footnotesize\color{hsr-black40},
425 % background
426 backgroundcolor=\color{white},
427 showstringspaces=false,
428 % default language
429 language=[LaTeX]TeX,
430 % break long lines, and show an arrow where the line was broken
431 breaklines=true,
432 postbreak=\mbox{\textcolor{hsr-blue}{$\hookrightarrow$}\space},
433 % font
434 basicstyle=\ttfamily\small,
435 identifierstyle=\color{hsr-black},
436 keywordstyle=\color{hsr-blue},
437 commentstyle=\color{hsr-black40},
438 stringstyle=\color{hsr-mauve80},
439 }
440
441 %% Define missing languages / aliases
442 \lstdefinelanguage{LaTeX}{
443 language=[LaTeX]Tex
444 }
445
446 %% Set style
447 \lstset{style=hsr-base, escapechar=`}
448 %%))
449 % \end{macrocode}
450
451 % \subsection{Mathematics}
452 % \subsubsection{Vectors}
453 % \begin{macrocode}
454 %% Vector ((
455 \newcommand{\hsrvecbold}[1]{\mathbf{\bm{#1}}}
456 \newcommand{\hsrvecarrow}[1]{\vv{\mathrm{#1}}} % from esvect
457
458 \newcommand{\@hsrvecf}[1]{\hsrvecbold{#1}}
459 \ifhsr@arrowvec
460 \renewcommand{\@hsrvecf}[1]{\hsrvecarrow{#1}}
461 \fi
462
463 \newcommand{\vc}{\@hsrvecf}
464 \ifhsr@dontrenew\else
465 % save previous command
466 \newcommand{\vaccent}{\v}
467 \newcommand{\oldvec}{\vec}
468 % redefine
469 \renewcommand{\v}[1]{\@hsrvecf{#1}}
470 \renewcommand{\vec}[1]{\@hsrvecf{#1}}
471 \fi
472 %%))
473
474 %% Unit vector ((
475 \newcommand{\hsruvecbold}[1]{\vec{\hat{#1}}}
476 \newcommand{\hsruvecarrow}[1]{\hat{\mathrm{#1}}}
477 \newcommand{\@hsruvecf}[1]{\hsruvecbold{#1}}
478 \ifhsr@arrowvec
479 \renewcommand{\@hsruvecf}[1]{\hsruvecarrow{#1}}
480 \fi
481
482 \newcommand{\uv}[1]{\@hsruvecf{#1}}
483 \newcommand{\uvec}[1]{\@hsruvecf{#1}}
484 %%))
485
486 %% Products ((
487 \newcommand{\dotp}{\boldsymbol\cdot}
488 \newcommand{\crossp}{\boldsymbol\times}
489 %%))
490 % \end{macrocode}
491
492 % \subsubsection{Matrices and Tensors}
493 % \begin{macrocode}
494 \newcommand{\mx}[1]{\bm{\mathrm{#1}}}
495 % \end{macrocode}
496
497 % \subsubsection{Equalities}
498 % \begin{macrocode}
499 \newcommand{\heq}{\stackrel{\hat{\texttt{H}}}{=}}
500 % \end{macrocode}
501
502 % \subsection{Derivatives}
503 % \subsubsection{Differentials}
504 % \begin{macrocode}
505 \newcommand{\dd}[2][]{\mathrm{d}^{#1} #2}
506 \newcommand{\di}[2][]{\,\dd[#1]{#2}}
507 % \end{macrocode}
508
509 % \subsubsection{Derivatives}
510 % \begin{macrocode}
511 \newcommand{\deriv}[3][]{\frac{\dd[#1]{#2}}{\dd[]{#3^{#1}}}}
512 \newcommand{\pderiv}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
513 % \end{macrocode}
514
515 % \subsubsection{Vector derivatives}
516 % \begin{macrocode}
517 %% Gradient ((
518 \ifhsr@textvecdiff
519 \DeclareMathOperator{\grad}{grad}
520 \else
521 \newcommand{\grad}{\vec{\nabla}}
522 \fi
523 %% ))
524
525 %% Divergence ((
526 \ifhsr@textvecdiff
527 \newcommand{\@hsrdivf}{div}
528 \else
529 \newcommand{\@hsrdivf}{\vec{\nabla}\dotp}
530 \fi
531
532 \DeclareMathOperator{\divg}{\@hsrdivf}
533 \ifhsr@dontrenew\else
534 \let\divsymb=\div
535 \renewcommand{\div}{\operatorname{\@hsrdivf}}
536 \fi
537 %% ))
538
539 %% Curl ((
540 \ifhsr@textvecdiff
541 \DeclareMathOperator{\curl}{curl}
542 \else
543 \DeclareMathOperator{\curl}{\vec{\nabla}\crossp}
544 \fi
545 %% ))
546
547 %% laplacian ((
548 \ifhsr@textvecdiff
549 \DeclareMathOperator{\laplacian}{div grad}
550 \else
551 \DeclareMathOperator{\laplacian}{\nabla^2}
552 \fi
553
554 \ifhsr@textvecdiff
555 \DeclareMathOperator{\vlaplacian}{div grad}
556 \else
557 \DeclareMathOperator{\vlaplacian}{\vec{\nabla}^2}
558 \fi
559 %% ))
560 % \end{macrocode}
561
562 % \subsection{Colors}
563 % \begin{macrocode}
564 \definecolor{hsr-blue}{HTML}{0065A3}
565 \definecolor{hsr-blue80}{HTML}{3384B5}
566 \definecolor{hsr-blue60}{HTML}{66A3C8}
567 \definecolor{hsr-blue40}{HTML}{99C1DA}
568 \definecolor{hsr-blue20}{HTML}{CCE0ED}
569
570 \definecolor{hsr-mauve}{HTML}{6E1C50}
571 \definecolor{hsr-mauve80}{HTML}{8B4973}
572 \definecolor{hsr-mauve60}{HTML}{A87796}
573 \definecolor{hsr-mauve40}{HTML}{C5A4B9}
574 \definecolor{hsr-mauve20}{HTML}{E2D2DC}
575
576 \definecolor{hsr-lakegreen}{HTML}{548C86}
577 \definecolor{hsr-lakegreen80}{HTML}{76A39E}
578 \definecolor{hsr-lakegreen60}{HTML}{98BAB6}
579 \definecolor{hsr-lakegreen40}{HTML}{BBD1CF}
580 \definecolor{hsr-lakegreen20}{HTML}{DDE8E7}
581
582 \definecolor{hsr-reed}{HTML}{7B6951}
583 \definecolor{hsr-reed80}{HTML}{958774}
584 \definecolor{hsr-reed60}{HTML}{B0A597}
585 \definecolor{hsr-reed40}{HTML}{CAC3B9}
586 \definecolor{hsr-reed20}{HTML}{E5E1DC}
587
588 \definecolor{hsr-petrol}{HTML}{00738D}
589 \definecolor{hsr-petrol80}{HTML}{338FA4}
590 \definecolor{hsr-petrol60}{HTML}{66ABBB}
591 \definecolor{hsr-petrol40}{HTML}{99C7D1}
592 \definecolor{hsr-petrol20}{HTML}{CCE3E8}
593
594 \definecolor{hsr-basswood}{HTML}{BABD5D}
595 \definecolor{hsr-basswood80}{HTML}{C8CA7D}
596 \definecolor{hsr-basswood60}{HTML}{D6D79E}
597 \definecolor{hsr-basswood40}{HTML}{E3E5BE}
598 \definecolor{hsr-basswood20}{HTML}{F1F2DF}
599
600 \definecolor{hsr-lightgrey}{HTML}{C6C7C8}
601 \definecolor{hsr-lightgrey80}{HTML}{D1D2D3}
602 \definecolor{hsr-lightgrey60}{HTML}{DDDDDE}
603 \definecolor{hsr-lightgrey40}{HTML}{E8E8E9}
604 \definecolor{hsr-lightgrey20}{HTML}{F4F4F4}
605
606 \definecolor{hsr-black}{HTML}{1A171B}
607 \definecolor{hsr-black80}{HTML}{484549}
608 \definecolor{hsr-black60}{HTML}{767476}
609 \definecolor{hsr-black40}{HTML}{A4A2A4}
610 \definecolor{hsr-black20}{HTML}{D1D1D1}
611 % \end{macrocode}
612
613 % \iffalse
614 % \begin{macrocode}
615 %</package>
616 % \end{macrocode}
617 % \fi
618 %
619 %\Finale