Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

250 lines
6.8KB

  1. \ProvidesClass{lecture}
  2. \LoadClass[a4paper, titlepage]{article}
  3. \RequirePackage[utf8]{inputenc}
  4. \RequirePackage[T1]{fontenc}
  5. \RequirePackage{textcomp}
  6. \RequirePackage[german]{babel}
  7. \RequirePackage{amsmath, amssymb, amsthm}
  8. \RequirePackage{mdframed}
  9. \RequirePackage{fancyhdr}
  10. \RequirePackage{geometry}
  11. \RequirePackage{import}
  12. \RequirePackage{pdfpages}
  13. \RequirePackage{transparent}
  14. \RequirePackage{xcolor}
  15. \RequirePackage{array}
  16. \RequirePackage[shortlabels]{enumitem}
  17. \RequirePackage{tikz}
  18. \RequirePackage{pgfplots}
  19. \RequirePackage[nobottomtitles]{titlesec}
  20. \RequirePackage{listings}
  21. \RequirePackage{mathtools}
  22. \RequirePackage{forloop}
  23. \RequirePackage{totcount}
  24. \RequirePackage{calc}
  25. \RequirePackage{wasysym}
  26. \RequirePackage{environ}
  27. \usetikzlibrary{quotes, angles}
  28. \pgfplotsset{
  29. compat=1.15,
  30. default 2d plot/.style={%
  31. grid=both,
  32. minor tick num=4,
  33. grid style={line width=.1pt, draw=gray!10},
  34. major grid style={line width=.2pt,draw=gray!50},
  35. axis lines=middle,
  36. enlargelimits={abs=0.2}
  37. },
  38. }
  39. \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
  40. \DeclareOption{uebung}{
  41. \makeatletter
  42. \lhead{\@title}
  43. \rhead{\@author}
  44. \makeatother
  45. }
  46. \ProcessOptions\relax
  47. % PAGE GEOMETRY
  48. \geometry{
  49. left=15mm,
  50. right=40mm,
  51. top=20mm,
  52. bottom=20mm
  53. }
  54. % PARAGRAPH no indent but skip
  55. \setlength{\parskip}{3mm}
  56. \setlength{\parindent}{0mm}
  57. \theoremstyle{definition}
  58. \newmdtheoremenv{satz}{Satz}[section]
  59. \newmdtheoremenv{lemma}[satz]{Lemma}
  60. \newmdtheoremenv{korrolar}[satz]{Korrolar}
  61. \newmdtheoremenv{definition}[satz]{Definition}
  62. \newtheorem{bsp}[satz]{Beispiel}
  63. \newtheorem{bem}[satz]{Bemerkung}
  64. \newtheorem{aufgabe}{Aufgabe}
  65. % enable aufgaben counting
  66. \regtotcounter{aufgabe}
  67. % temporary calculation counter
  68. \newcounter{var}
  69. \newcommand{\N}{\mathbb{N}}
  70. \newcommand{\R}{\mathbb{R}}
  71. \newcommand{\Z}{\mathbb{Z}}
  72. \newcommand{\Q}{\mathbb{Q}}
  73. \newcommand{\C}{\mathbb{C}}
  74. % HEADERS
  75. \pagestyle{fancy}
  76. \newcommand{\incfig}[1]{%
  77. \def\svgwidth{\columnwidth}
  78. \import{./figures/}{#1.pdf_tex}
  79. }
  80. \pdfsuppresswarningpagegroup=1
  81. % horizontal rule
  82. \newcommand\hr{
  83. \noindent\rule[0.5ex]{\linewidth}{0.5pt}
  84. }
  85. % punkte tabelle
  86. \newcommand{\punkte}[1][1]{
  87. \newcounter{k}
  88. \setcounter{k}{#1}
  89. \@punkten{\value{k}}{\totvalue{aufgabe}}
  90. \setcounter{k}{#1-1}
  91. \setcounter{aufgabe}{\value{k}}
  92. \vspace{5mm}
  93. }
  94. \def\@punkten#1#2{
  95. \newcounter{n}
  96. % create a temporary calculation counter
  97. \setcounter{var}{#2-#1+1}
  98. \begin{tabular}{|c|*{\value{var}}{m{1cm}|}m{1cm}|@{}m{0cm}@{}}
  99. \hline
  100. Aufgabe
  101. \forloop{n}{#1}{\not{\value{n} > #2}}{
  102. & \centering A\then
  103. }
  104. & \centering $\sum$ & \\[5mm] \hline
  105. Punkte
  106. \forloop{n}{#1}{\not{\value{n} > #2}}{
  107. &
  108. }
  109. & & \\[5mm] \hline
  110. \end{tabular}
  111. }
  112. % code listings, define style
  113. \lstdefinestyle{mystyle}{
  114. commentstyle=\color{gray},
  115. keywordstyle=\color{blue},
  116. numberstyle=\tiny\color{gray},
  117. stringstyle=\color{black},
  118. basicstyle=\ttfamily\footnotesize,
  119. breakatwhitespace=false,
  120. breaklines=true,
  121. captionpos=b,
  122. keepspaces=true,
  123. numbers=left,
  124. numbersep=5pt,
  125. showspaces=false,
  126. showstringspaces=false,
  127. showtabs=false,
  128. tabsize=2
  129. }
  130. % activate my colour style
  131. \lstset{style=mystyle}
  132. % better stackrel
  133. \let\oldstackrel\stackrel
  134. \renewcommand{\stackrel}[2]{%
  135. \oldstackrel{\mathclap{#1}}{#2}
  136. }%
  137. % integral d sign
  138. \makeatletter \renewcommand\d[2][]{\ensuremath{%
  139. \,\mathrm{d}^{#1}#2\@ifnextchar^{}{\@ifnextchar\d{}{\,}}}}
  140. \makeatother
  141. % contradiction
  142. \newcommand{\contr}{\text{\Large\lightning}}
  143. % disjoint unions: provides cupdot and bigcupdot
  144. \makeatletter
  145. \def\moverlay{\mathpalette\mov@rlay}
  146. \def\mov@rlay#1#2{\leavevmode\vtop{%
  147. \baselineskip\z@skip \lineskiplimit-\maxdimen
  148. \ialign{\hfil$\m@th#1##$\hfil\cr#2\crcr}}}
  149. \newcommand{\charfusion}[3][\mathord]{
  150. #1{\ifx#1\mathop\vphantom{#2}\fi
  151. \mathpalette\mov@rlay{#2\cr#3}
  152. }
  153. \ifx#1\mathop\expandafter\displaylimits\fi}
  154. \makeatother
  155. \newcommand{\cupdot}{\charfusion[\mathbin]{\cup}{\cdot}}
  156. \newcommand{\bigcupdot}{\charfusion[\mathop]{\bigcup}{\cdot}}
  157. \ExplSyntaxOn
  158. % S-tackrelcompatible ALIGN environment
  159. % some might also call it the S-uper ALIGN environment
  160. % uses regular expressions to calculate the widest stackrel
  161. % to put additional padding on both sides of relation symbols
  162. \NewEnviron{salign}
  163. {
  164. \begin{align}
  165. \lec_insert_padding:V \BODY
  166. \end{align}
  167. }
  168. % starred version that does no equation numbering
  169. \NewEnviron{salign*}
  170. {
  171. \begin{align*}
  172. \lec_insert_padding:V \BODY
  173. \end{align*}
  174. }
  175. % some helper variables
  176. \tl_new:N \l__lec_text_tl
  177. \seq_new:N \l_lec_stackrels_seq
  178. \int_new:N \l_stackrel_count_int
  179. \int_new:N \l_idx_int
  180. \box_new:N \l_tmp_box
  181. \dim_new:N \l_tmp_dim_a
  182. \dim_new:N \l_tmp_dim_b
  183. \dim_new:N \l_tmp_dim_needed
  184. % function to insert padding according to widest stackrel
  185. \cs_new_protected:Nn \lec_insert_padding:n
  186. {
  187. \tl_set:Nn \l__lec_text_tl { #1 }
  188. % get all stackrels in this align environment
  189. \regex_extract_all:nnN { \c{stackrel}{(.*?)}{(.*?)} } { #1 } \l_lec_stackrels_seq
  190. % get number of stackrels
  191. \int_set:Nn \l_stackrel_count_int { \seq_count:N \l_lec_stackrels_seq }
  192. \int_set:Nn \l_idx_int { 1 }
  193. \dim_set:Nn \l_tmp_dim_needed { 0pt }
  194. % iterate over stackrels
  195. \int_while_do:nn { \l_idx_int <= \l_stackrel_count_int }
  196. {
  197. % calculate width of text
  198. \hbox_set:Nn \l_tmp_box {$\seq_item:Nn \l_lec_stackrels_seq { \l_idx_int + 1 }$}
  199. \dim_set:Nn \l_tmp_dim_a {\box_wd:N \l_tmp_box}
  200. % calculate width of relation symbol
  201. \hbox_set:Nn \l_tmp_box {$\seq_item:Nn \l_lec_stackrels_seq { \l_idx_int + 2 }$}
  202. \dim_set:Nn \l_tmp_dim_b {\box_wd:N \l_tmp_box}
  203. % check if 0.5*(a-b) > minimum padding, if yes updated minimum padding
  204. \dim_compare:nNnTF
  205. { 1pt * \dim_ratio:nn { \l_tmp_dim_a - \l_tmp_dim_b } { 2pt } } > { \l_tmp_dim_needed }
  206. { \dim_set:Nn \l_tmp_dim_needed { 1pt * \dim_ratio:nn { \l_tmp_dim_a - \l_tmp_dim_b } { 2pt } } }
  207. { }
  208. \quad
  209. % increment list index by three, as every stackrel produces three list entries
  210. \int_incr:N \l_idx_int
  211. \int_incr:N \l_idx_int
  212. \int_incr:N \l_idx_int
  213. }
  214. % replace all relations with align characters (&) and add the needed padding
  215. \regex_replace_all:nnN
  216. { (\c{iff}&|&\c{iff}|\c{impliedby}&|&\c{impliedby}|\c{implies}&|&\c{implies}|\c{approx}&|&\c{approx}|\c{equiv}&|&\c{equiv}|=&|&=|\c{le}&|&\c{le}|\c{ge}&|&\c{ge}|&\c{stackrel}{.*?}{.*?}|\c{stackrel}{.*?}{.*?}&|&\c{neq}|\c{neq}&) }
  217. { \c{kern} \u{l_tmp_dim_needed} \1 \c{kern} \u{l_tmp_dim_needed} }
  218. \l__lec_text_tl
  219. \l__lec_text_tl
  220. }
  221. \cs_generate_variant:Nn \lec_insert_padding:n { V }
  222. \ExplSyntaxOff