Für Vorlesungen, bitte die Webseite verwenden. https://flavigny.de/lecture
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
7.3KB

  1. \ProvidesClass{lecture}
  2. \LoadClass[a4paper]{book}
  3. \RequirePackage{stmaryrd}
  4. \RequirePackage[utf8]{inputenc}
  5. \RequirePackage[T1]{fontenc}
  6. \RequirePackage{textcomp}
  7. \RequirePackage{babel}
  8. \RequirePackage{amsmath, amssymb, amsthm}
  9. \RequirePackage{mdframed}
  10. \RequirePackage{tikz-cd}
  11. \RequirePackage{geometry}
  12. \RequirePackage{import}
  13. \RequirePackage{pdfpages}
  14. \RequirePackage{transparent}
  15. \RequirePackage{xcolor}
  16. \RequirePackage{array}
  17. \RequirePackage[shortlabels]{enumitem}
  18. \RequirePackage{tikz}
  19. \RequirePackage{pgfplots}
  20. \RequirePackage[pagestyles, nobottomtitles]{titlesec}
  21. \RequirePackage{listings}
  22. \RequirePackage{mathtools}
  23. \RequirePackage{forloop}
  24. \RequirePackage{totcount}
  25. \RequirePackage[hidelinks, unicode]{hyperref} %[unicode, hidelinks]{hyperref}
  26. \RequirePackage{bookmark}
  27. \RequirePackage{wasysym}
  28. \RequirePackage{environ}
  29. \RequirePackage{stackrel}
  30. \RequirePackage{subcaption}
  31. \usetikzlibrary{quotes, angles, math}
  32. \pgfplotsset{
  33. compat=1.15,
  34. default 2d plot/.style={%
  35. grid=both,
  36. minor tick num=4,
  37. grid style={line width=.1pt, draw=gray!10},
  38. major grid style={line width=.2pt,draw=gray!50},
  39. axis lines=middle,
  40. enlargelimits={abs=0.2}
  41. },
  42. }
  43. \geometry{
  44. bottom=35mm
  45. }
  46. %\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
  47. \DeclareOption{uebung}{
  48. \makeatletter
  49. \lhead{\@title}
  50. \rhead{\@author}
  51. \makeatother
  52. }
  53. \ProcessOptions\relax
  54. % PARAGRAPH no indent but skip
  55. %\setlength{\parskip}{3mm}
  56. %\setlength{\parindent}{0mm}
  57. \newtheorem{satz}{Proposition}[chapter]
  58. \newtheorem{theorem}[satz]{Theorem}
  59. \newtheorem{lemma}[satz]{Lemma}
  60. \newtheorem{korollar}[satz]{Corollary}
  61. \theoremstyle{definition}
  62. \newtheorem{definition}[satz]{Definition}
  63. \newtheorem{bsp}[satz]{Example}
  64. \newtheorem{bem}[satz]{Remark}
  65. \newtheorem{aufgabe}[satz]{Exercise}
  66. % enable aufgaben counting
  67. %\regtotcounter{aufgabe}
  68. \newcommand{\N}{\mathbb{N}}
  69. \newcommand{\R}{\mathbb{R}}
  70. \newcommand{\Z}{\mathbb{Z}}
  71. \newcommand{\Q}{\mathbb{Q}}
  72. \newcommand{\C}{\mathbb{C}}
  73. % HEADERS
  74. %\newpagestyle{main}[\small]{
  75. % \setheadrule{.55pt}%
  76. % \sethead[\thepage]% even-left
  77. % []% even-center
  78. % [\thechapter~\chaptertitle]% even-right
  79. % {\thesection~\sectiontitle}% odd-left
  80. % {}% odd-center
  81. % {\thepage}% odd-right
  82. %}
  83. %\pagestyle{main}
  84. \newcommand{\incfig}[1]{%
  85. \def\svgwidth{\columnwidth}
  86. \import{./figures/}{#1.pdf_tex}
  87. }
  88. \pdfsuppresswarningpagegroup=1
  89. % horizontal rule
  90. \newcommand\hr{
  91. \noindent\rule[0.5ex]{\linewidth}{0.5pt}
  92. }
  93. % code listings, define style
  94. \lstdefinestyle{mystyle}{
  95. commentstyle=\color{gray},
  96. keywordstyle=\color{blue},
  97. numberstyle=\tiny\color{gray},
  98. stringstyle=\color{black},
  99. basicstyle=\ttfamily\footnotesize,
  100. breakatwhitespace=false,
  101. breaklines=true,
  102. captionpos=b,
  103. keepspaces=true,
  104. numbers=left,
  105. numbersep=5pt,
  106. showspaces=false,
  107. showstringspaces=false,
  108. showtabs=false,
  109. tabsize=2
  110. }
  111. % activate my colour style
  112. \lstset{style=mystyle}
  113. % better stackrel
  114. \let\oldstackrel\stackrel
  115. \renewcommand{\stackrel}[3][]{%
  116. \oldstackrel[\mathclap{#1}]{\mathclap{#2}}{#3}
  117. }%
  118. % integral d sign
  119. \makeatletter \renewcommand\d[2][]{\ensuremath{%
  120. \,\mathrm{d}^{#1}#2\@ifnextchar^{}{\@ifnextchar\d{}{\,}}}}
  121. \makeatother
  122. % remove page before chapters
  123. \let\cleardoublepage=\clearpage
  124. %josua
  125. \newcommand{\norm}[1]{\left\Vert#1\right\Vert}
  126. % contradiction
  127. \newcommand{\contr}{\text{\Large\lightning}}
  128. % people seem to prefer varepsilon over epsilon
  129. \renewcommand{\epsilon}{\varepsilon}
  130. \ExplSyntaxOn
  131. % S-tackrelcompatible ALIGN environment
  132. % some might also call it the S-uper ALIGN environment
  133. % uses regular expressions to calculate the widest stackrel
  134. % to put additional padding on both sides of relation symbols
  135. \NewEnviron{salign}
  136. {
  137. \begin{align}
  138. \lec_insert_padding:V \BODY
  139. \end{align}
  140. }
  141. % starred version that does no equation numbering
  142. \NewEnviron{salign*}
  143. {
  144. \begin{align*}
  145. \lec_insert_padding:V \BODY
  146. \end{align*}
  147. }
  148. % some helper variables
  149. \tl_new:N \l__lec_text_tl
  150. \seq_new:N \l_lec_stackrels_seq
  151. \int_new:N \l_stackrel_count_int
  152. \int_new:N \l_idx_int
  153. \box_new:N \l_tmp_box
  154. \dim_new:N \l_tmp_dim_a
  155. \dim_new:N \l_tmp_dim_b
  156. \dim_new:N \l_tmp_dim_c
  157. \dim_new:N \l_tmp_dim_needed
  158. % function to insert padding according to widest stackrel
  159. \cs_new_protected:Nn \lec_insert_padding:n
  160. {
  161. \tl_set:Nn \l__lec_text_tl { #1 }
  162. % get all stackrels in this align environment
  163. \regex_extract_all:nnN { \c{stackrel}(\[.*?\])?{(.*?)}{(.*?)} } { #1 } \l_lec_stackrels_seq
  164. % get number of stackrels
  165. \int_set:Nn \l_stackrel_count_int { \seq_count:N \l_lec_stackrels_seq }
  166. \int_set:Nn \l_idx_int { 1 }
  167. \dim_set:Nn \l_tmp_dim_needed { 0pt }
  168. % iterate over stackrels
  169. \int_while_do:nn { \l_idx_int <= \l_stackrel_count_int }
  170. {
  171. % calculate width of text
  172. \hbox_set:Nn \l_tmp_box {$\seq_item:Nn \l_lec_stackrels_seq { \l_idx_int + 1 }$}
  173. \dim_set:Nn \l_tmp_dim_a {\box_wd:N \l_tmp_box}
  174. \hbox_set:Nn \l_tmp_box {$\seq_item:Nn \l_lec_stackrels_seq { \l_idx_int + 2 }$}
  175. \dim_set:Nn \l_tmp_dim_c {\box_wd:N \l_tmp_box}
  176. \dim_set:Nn \l_tmp_dim_a {\dim_max:nn{ \l_tmp_dim_c} {\l_tmp_dim_a}}
  177. % calculate width of relation symbol
  178. \hbox_set:Nn \l_tmp_box {$\seq_item:Nn \l_lec_stackrels_seq { \l_idx_int + 3 }$}
  179. \dim_set:Nn \l_tmp_dim_b {\box_wd:N \l_tmp_box}
  180. % check if 0.5*(a-b) > minimum padding, if yes updated minimum padding
  181. \dim_compare:nNnTF
  182. { 1pt * \dim_ratio:nn { \l_tmp_dim_a - \l_tmp_dim_b } { 2pt } } > { \l_tmp_dim_needed }
  183. { \dim_set:Nn \l_tmp_dim_needed { 1pt * \dim_ratio:nn { \l_tmp_dim_a - \l_tmp_dim_b } { 2pt } } }
  184. { }
  185. % increment list index by three, as every stackrel produces three list entries
  186. \int_incr:N \l_idx_int
  187. \int_incr:N \l_idx_int
  188. \int_incr:N \l_idx_int
  189. \int_incr:N \l_idx_int
  190. }
  191. % replace all relations with align characters (&) and add the needed padding
  192. \regex_replace_all:nnN
  193. { (\c{leq}&|&\c{leq}|\c{geq}&|&\c{geq}|\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}&|>&|&>|<&|&<) }
  194. { \c{kern} \u{l_tmp_dim_needed} \1 \c{kern} \u{l_tmp_dim_needed} }
  195. \l__lec_text_tl
  196. \l__lec_text_tl
  197. }
  198. \cs_generate_variant:Nn \lec_insert_padding:n { V }
  199. \NewEnviron{leftright}
  200. {
  201. \lec_replace_parens:V \BODY
  202. }
  203. % function to replace parens with left right
  204. \cs_new_protected:Nn \lec_replace_parens:n
  205. {
  206. \tl_set:Nn \l__lec_text_tl { #1 }
  207. % replace all parantheses with \left( \right)
  208. \regex_replace_all:nnN { \( } { \c{left}( } \l__lec_text_tl
  209. \regex_replace_all:nnN { \) } { \c{right}) } \l__lec_text_tl
  210. \regex_replace_all:nnN { \[ } { \c{left}[ } \l__lec_text_tl
  211. \regex_replace_all:nnN { \] } { \c{right}] } \l__lec_text_tl
  212. \l__lec_text_tl
  213. }
  214. \cs_generate_variant:Nn \lec_replace_parens:n { V }
  215. \ExplSyntaxOff
  216. % add one equation tag to the current line to otherwise unnumbered environment
  217. \newcommand{\tageq}{\stepcounter{equation}\tag{\theequation}}