% schulmathematik bundle: package schulma
% Version 1.7
% 16. April 2025
\ProvidesExplPackage{schulma}{2025-04-16}{1.7}{Befehle für die Schulmathematik}

\bool_new:N \g_schulma_icomma_bool
\bool_gset_true:N \g_schulma_icomma_bool

\DeclareOption {ohne-icomma}
  {
    \bool_gset_false:N \g_schulma_icomma_bool
  }

\ProcessOptions \relax

\RequirePackage [intlimits] {mathtools}
\RequirePackage {autoaligne}
\RequirePackage {pgfplots}

\bool_if:NT \g_schulma_icomma_bool
  {
    \RequirePackage {icomma}
  }

\ExplSyntaxOff
\usetikzlibrary{shapes.misc}
\ExplSyntaxOn

\pgfplotsset
  {
    compat = newest ,
    axis~lines = middle ,
    /pgf/number~format/use~comma ,
    every~axis/.append~style =
      {
        font = \small
      },
    ticklabel~style =
      {
        font = \footnotesize ,
        /pgf/number~format/fixed ,
        /pgf/number~format/set~thousands~separator = {\,}
      },
    tick~style = {thick} ,
    scaled~ticks = false ,
    every~axis~plot/.append~style =
      {
        semithick
      }
  }

\NewDocumentEnvironment {Kosy} {o}
  {
    \tl_set:Nn \l_tmpa_tl
      {
        xlabel = {$x$} , ylabel = {$y$} ,
        minor~tick~num = 1 , minor~tick~length = 0pt ,
        grid = both
      }
    \begin {tikzpicture}
    \IfValueTF {#1}
      {
        \begin {axis} [ \l_tmpa_tl , #1 ]
      }
      {
        \begin {axis} [\l_tmpa_tl]
      }
  }
  {
    \end {axis}
    \end {tikzpicture}
  }

\NewDocumentCommand \Rechenkaestchen { O{5mm} m m }
  {
    \begin {tikzpicture}
      \draw [ step = #1 , help~lines ] (0,0) grid (#2,#3) ;
    \end {tikzpicture}
  }

\NewDocumentCommand \LGS {m}
  {
    \ensuremath
      {
        \left |
        \,
        \autoaligne {#1}
        \,
        \right |
      }
  }

\tl_new:N \g_schulma_eulersche_zahl_tl
\tl_new:N \g_schulma_differential_tl

\AtBeginDocument
  {
    \tl_gset:Nx \g_schulma_eulersche_zahl_tl
      {
        \@ifpackageloaded {euler} {e} { \exp_not:N \mathrm {e} }
      }
    \tl_gset:Nx \g_schulma_differential_tl
      {
        \@ifpackageloaded {euler} {d} { \exp_not:N \mathrm {d} }
      }
  }

\NewDocumentCommand \ehoch {m}
  {
    \g_schulma_eulersche_zahl_tl ^ {#1}
  }

\NewDocumentCommand \diff {m}
  {
    \g_schulma_differential_tl
    #1
  }

\NewDocumentCommand \Pkt {o m m}
  {
    \ensuremath
      {
        \IfValueT {#1} {#1}
        \mathopen {} % Zusatzabstand entfernen
        \left( {#2} \, \middle| \, {#3} \right)
      }
  }

\NewDocumentCommand \PktR {o m m m}
  {
    \ensuremath
      {
        \IfValueT {#1} {#1}
        \mathopen {} % Zusatzabstand entfernen
        \left( {#2} \, \middle| \, {#3} \, \middle| \, {#4} \right)
      }
  }

\NewDocumentCommand \Vek {m m m}
  {
    \ensuremath
      {
        \begin {pmatrix}
        #1 \\ #2 \\ #3
        \end {pmatrix}
      }
  }

\NewDocumentCommand \VekBr {m m m}
  {
    \ensuremath
      {
        \begin {pmatrix}
        #1 \\[0,5ex] #2 \\[0,5ex] #3
        \end {pmatrix}
      }
  }

\NewDocumentCommand \GTRY {mo}
  {
    \texttt { Y \textsubscript {#1} }
    \IfValueT {#2} { \texttt {=} \, \ensuremath {#2} }
  }

% Knotentyp zum Setzen von Kreuzen ins Koordinatensystem:
\tikzset
  {
    Kreuz/.style =
      {
        cross~out ,
        draw ,
        minimum~size = 5pt ,
        inner~sep = 0pt ,
        outer~sep = 0pt
      }
  }
