%%
%% This is file `notesslides.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% notesslides.dtx  (with options: `package')
%% 
\ProvidesExplPackage{notesslides}{2022/05/24}{3.1.0}{notesslides Package}
\RequirePackage{l3keys2e}

\keys_define:nn{notesslides / pkg}{
  topsect         .str_set_x:N  = \c__notesslides_topsect_str,
  defaulttopsect  .str_set_x:N  = \c__notesslides_defaulttopsec_str,
  notes           .bool_set:N   = \c__notesslides_notes_bool ,
  slides          .code:n       = { \bool_set_false:N \c__notesslides_notes_bool },
  sectocframes    .bool_set:N   = \c__notesslides_sectocframes_bool ,
  frameimages     .bool_set:N   = \c__notesslides_frameimages_bool ,
  fiboxed         .bool_set:N   = \c__notesslides_fiboxed_bool ,
  noproblems      .bool_set:N   = \c__notesslides_noproblems_bool,
  unknown         .code:n       = {
    \PassOptionsToClass{\CurrentOption}{stex}
    \PassOptionsToClass{\CurrentOption}{tikzinput}
  }
}
\ProcessKeysOptions{ notesslides / pkg }

\RequirePackage{stex}
\stex_html_backend:T {
  \bool_set_true:N\c__notesslides_notes_bool
}

\newif\ifnotes
\bool_if:NTF \c__notesslides_notes_bool {
  \notestrue
}{
  \notesfalse
}

\str_if_empty:NTF \c__notesslides_topsect_str {
  \str_set_eq:NN \__notesslidestopsect \c__notesslides_defaulttopsec_str
}{
  \str_set_eq:NN \__notesslidestopsect \c__notesslides_topsect_str
}
\PassOptionsToPackage{topsect=\__notesslidestopsect}{document-structure}
\bool_if:NT \c__notesslides_notes_bool {
  \RequirePackage{a4wide}
  \RequirePackage{marginnote}
  \PassOptionsToPackage{usenames,dvipsnames,svgnames}{xcolor}
  \RequirePackage{mdframed}
  \RequirePackage[noxcolor,noamsthm]{beamerarticle}
  \RequirePackage[bookmarks,bookmarksopen,bookmarksnumbered,breaklinks,hidelinks]{hyperref}
}
\RequirePackage{stex-tikzinput}
\RequirePackage{etoolbox}
\RequirePackage{amssymb}
\RequirePackage{amsmath}
\RequirePackage{comment}
\RequirePackage{textcomp}
\RequirePackage{url}
\RequirePackage{graphicx}
\RequirePackage{pgf}
\bool_if:NT \c__notesslides_notes_bool {
  \renewcommand\usetheme[2][]{\usepackage[#1]{beamernotestheme#2}}
}

\NewDocumentCommand \libusetheme {O{} m} {
  \bool_if:NTF \c__notesslides_notes_bool {
    \libusepackage[#1]{beamernotestheme#2}
  }{
  \libusepackage[#1]{beamertheme#2}
  }
}

\newcounter{slide}
\newlength{\slidewidth}\setlength{\slidewidth}{13.5cm}
\newlength{\slideheight}\setlength{\slideheight}{9cm}
\bool_if:NTF \c__notesslides_notes_bool {
  \renewenvironment{note}{\ignorespaces}{}
}{
  \excludecomment{note}
}
\bool_if:NT \c__notesslides_notes_bool {
  \newlength{\slideframewidth}
  \setlength{\slideframewidth}{1.5pt}
  \cs_new_protected:Nn \__notesslides_do_yes_param:Nn {
    \exp_args:Nx \str_if_eq:nnTF { \str_uppercase:n{ #2 } }{ yes }{
      \bool_set_true:N #1
    }{
      \bool_set_false:N #1
    }
  }
  \keys_define:nn{notesslides / frame}{
    label               .str_set_x:N  = \l__notesslides_frame_label_str,
    allowframebreaks    .code:n       = {
      \__notesslides_do_yes_param:Nn \l__notesslides_frame_allowframebreaks_bool { #1 }
    },
    allowdisplaybreaks  .code:n       = {
      \__notesslides_do_yes_param:Nn \l__notesslides_frame_allowdisplaybreaks_bool { #1 }
    },
    fragile             .code:n       = {
      \__notesslides_do_yes_param:Nn \l__notesslides_frame_fragile_bool { #1 }
    },
    shrink              .code:n       = {
      \__notesslides_do_yes_param:Nn \l__notesslides_frame_shrink_bool { #1 }
    },
    squeeze             .code:n       = {
      \__notesslides_do_yes_param:Nn \l__notesslides_frame_squeeze_bool { #1 }
    },
    t                   .code:n       = {
      \__notesslides_do_yes_param:Nn \l__notesslides_frame_t_bool { #1 }
    },
    unknown   .code:n       = {}
  }
  \cs_new_protected:Nn \__notesslides_frame_args:n {
    \str_clear:N \l__notesslides_frame_label_str
    \bool_set_true:N \l__notesslides_frame_allowframebreaks_bool
    \bool_set_true:N \l__notesslides_frame_allowdisplaybreaks_bool
    \bool_set_true:N \l__notesslides_frame_fragile_bool
    \bool_set_true:N \l__notesslides_frame_shrink_bool
    \bool_set_true:N \l__notesslides_frame_squeeze_bool
    \bool_set_true:N \l__notesslides_frame_t_bool
    \keys_set:nn { notesslides / frame }{ #1 }
  }
  \renewenvironment{frame}[1][]{
    \__notesslides_frame_args:n{#1}
    \sffamily
    \stepcounter{slide}
    \def\@currentlabel{\theslide}
    \str_if_empty:NF \l__notesslides_frame_label_str {
      \label{\l__notesslides_frame_label_str}
    }
    \def\itemize@level{outer}
    \def\itemize@outer{outer}
    \def\itemize@inner{inner}
    \renewcommand\newpage{\addtocounter{framenumber}{1}}
    %\newcommand\metakeys@show@keys[2]{\marginnote{{\scriptsize ##2}}}
    \renewenvironment{itemize}{
      \ifx\itemize@level\itemize@outer
        \def\itemize@label{$\rhd$}
      \fi
      \ifx\itemize@level\itemize@inner
        \def\itemize@label{$\scriptstyle\rhd$}
      \fi
      \begin{list}
      {\itemize@label}
      {\setlength{\labelsep}{.3em}
       \setlength{\labelwidth}{.5em}
       \setlength{\leftmargin}{1.5em}
      }
      \edef\itemize@level{\itemize@inner}
    }{
      \end{list}
    }
    \stex_html_backend:TF {
      \begin{stex_annotate_env}{frame}{}\vbox\bgroup
        \mdf@patchamsthm
    }{
      \begin{mdframed}[linewidth=\slideframewidth,skipabove=1ex,skipbelow=1ex,userdefinedwidth=\slidewidth,align=center]\sf
    }
  }{
    \stex_html_backend:TF {
      \miko@slidelabel\egroup\end{stex_annotate_env}
    }{\medskip\miko@slidelabel\end{mdframed}}
  }
  \renewcommand{\frametitle}[1]{
    \stex_document_title:n { #1 }
    {\Large\bf\sf\color{blue}{#1}}\medskip
  }
}
\bool_if:NT \c__notesslides_notes_bool {
  \newcommand\pause{}
}
\bool_if:NTF \c__notesslides_notes_bool {
  \newenvironment{nparagraph}[1][]{\begin{sparagraph}[#1]}{\end{sparagraph}}
}{
  \excludecomment{nparagraph}
}
\bool_if:NTF \c__notesslides_notes_bool {
  \newenvironment{nfragment}[2][]{\begin{sfragment}[#1]{#2}}{\end{sfragment}}
}{
  \excludecomment{nfragment}
}
\bool_if:NTF \c__notesslides_notes_bool {
  \newenvironment{ndefinition}[1][]{\begin{sdefinition}[#1]}{\end{sdefinition}}
}{
  \excludecomment{ndefinition}
}
\bool_if:NTF \c__notesslides_notes_bool {
  \newenvironment{nassertion}[1][]{\begin{sassertion}[#1]}{\end{sassertion}}
}{
  \excludecomment{nassertion}
}
\bool_if:NTF \c__notesslides_notes_bool {
  \newenvironment{nproof}[2][]{\begin{sproof}[#1]{#2}}{\end{sproof}}
}{
  \excludecomment{nproof}
}
\bool_if:NTF \c__notesslides_notes_bool {
  \newenvironment{nexample}[1][]{\begin{sexample}[#1]}{\end{sexample}}
}{
  \excludecomment{nexample}
}
\def\inputref@preskip{\smallskip}
\def\inputref@postskip{\medskip}
\let\orig@inputref\inputref
\def\inputref{\@ifstar\ninputref\orig@inputref}
\newcommand\ninputref[2][]{
  \bool_if:NT \c__notesslides_notes_bool {
    \orig@inputref[#1]{#2}
  }
}
\newlength{\slidelogoheight}

\RequirePackage{graphicx}

\define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}}
\providecommand\mhgraphics[2][]{
  \def\Gin@mhrepos{}\setkeys{Gin}{#1}
  \includegraphics[#1]{\mhpath\Gin@mhrepos{#2}}
}

\bool_if:NTF \c__notesslides_notes_bool {
  \setlength{\slidelogoheight}{.4cm}
}{
  \setlength{\slidelogoheight}{.25cm}
}
\ifcsname slidelogo\endcsname\else
  \newsavebox{\slidelogo}
  \sbox{\slidelogo}{\sTeX}
\fi
\newrobustcmd{\setslidelogo}[2][]{
  \tl_if_empty:nTF{#1}{
    \sbox{\slidelogo}{\includegraphics[height=\slidelogoheight]{#2}}
  }{
    \sbox{\slidelogo}{\mhgraphics[height=\slidelogoheight,mhrepos=#1]{#2}}
  }
}
\def\source{Michael Kohlhase}% customize locally
\newrobustcmd{\setsource}[1]{\def\source{#1}}
\def\copyrightnotice{\footnotesize\copyright :\hspace{.3ex}{\source}}
\newsavebox{\cclogo}
\sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{stex-cc_somerights}}
\newif\ifcchref\cchreffalse
\AtBeginDocument{
  \@ifpackageloaded{hyperref}{\cchreftrue}{\cchreffalse}
}
\def\licensing{
  \ifcchref
    \href{http://creativecommons.org/licenses/by-sa/2.5/}{\usebox{\cclogo}}
  \else
    {\usebox{\cclogo}}
  \fi
}
\newrobustcmd{\setlicensing}[2][]{
  \def\@url{#1}
  \sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{#2}}
  \ifx\@url\@empty
    \def\licensing{{\usebox{\cclogo}}}
  \else
    \def\licensing{
      \ifcchref
      \href{#1}{\usebox{\cclogo}}
      \else
      {\usebox{\cclogo}}
      \fi
    }
  \fi
}
\newrobustcmd\miko@slidelabel{
  \vbox to \slidelogoheight{
    \vss\hbox to \slidewidth
    {\licensing\hfill\copyrightnotice\hfill\arabic{slide}\hfill\usebox{\slidelogo}}
  }
}
\def\Gin@mhrepos{}
\define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}}
\define@key{Gin}{label}{\def\@currentlabel{\arabic{slide}}\label{#1}}
\newrobustcmd\frameimage[2][]{
  \stepcounter{slide}
  \bool_if:NT \c__notesslides_frameimages_bool {
    \def\Gin@ewidth{}\setkeys{Gin}{#1}
    \bool_if:NF \c__notesslides_notes_bool { \vfill }
    \begin{center}
      \bool_if:NTF \c__notesslides_fiboxed_bool {
        \fbox{
          \ifx\Gin@ewidth\@empty
            \ifx\Gin@mhrepos\@empty
              \mhgraphics[width=\slidewidth,#1]{#2}
            \else
              \mhgraphics[width=\slidewidth,#1,mhrepos=\Gin@mhrepos]{#2}
            \fi
          \else% Gin@ewidth empty
            \ifx\Gin@mhrepos\@empty
              \mhgraphics[#1]{#2}
            \else
              \mhgraphics[#1,mhrepos=\Gin@mhrepos]{#2}
            \fi
          \fi% Gin@ewidth empty
        }
      }{
        \ifx\Gin@ewidth\@empty
          \ifx\Gin@mhrepos\@empty
            \mhgraphics[width=\slidewidth,#1]{#2}
          \else
            \mhgraphics[width=\slidewidth,#1,mhrepos=\Gin@mhrepos]{#2}
          \fi
          \ifx\Gin@mhrepos\@empty
            \mhgraphics[#1]{#2}
          \else
            \mhgraphics[#1,mhrepos=\Gin@mhrepos]{#2}
          \fi
        \fi% Gin@ewidth empty
      }
     \end{center}
    \par\strut\hfill{\footnotesize Slide \arabic{slide}}%
    \bool_if:NF \c__notesslides_notes_bool { \vfill }
  }
} % ifmks@sty@frameimages
\sffamily
\AddToHook{begindocument}{
  \definecolor{green}{rgb}{0,.5,0}
  \definecolor{purple}{cmyk}{.3,1,0,.17}
}
\def\defemph#1{{\textcolor{magenta}{#1}}}
\def\symrefemph#1{{\textcolor{cyan}{#1}}}
\def\compemph#1{{\textcolor{blue}{#1}}}
\def\titleemph#1{{\textcolor{blue}{#1}}}
\def\__omtext_lec#1{(\textcolor{green}{#1})}
\pgfdeclareimage[width=.8em]{miko@small@dbend}{stex-dangerous-bend}
\def\smalltextwarning{
  \pgfuseimage{miko@small@dbend}
  \xspace
}
\pgfdeclareimage[width=1.2em]{miko@dbend}{stex-dangerous-bend}
\newrobustcmd\textwarning{
  \raisebox{-.05cm}{\pgfuseimage{miko@dbend}}
  \xspace
}
\pgfdeclareimage[width=2.5em]{miko@big@dbend}{stex-dangerous-bend}
\newrobustcmd\bigtextwarning{
  \raisebox{-.05cm}{\pgfuseimage{miko@big@dbend}}
  \xspace
}
\newrobustcmd\putgraphicsat[3]{
  \begin{picture}(0,0)\put(#1){\includegraphics[#2]{#3}}\end{picture}
}
\newrobustcmd\putat[2]{
  \begin{picture}(0,0)\put(#1){#2}\end{picture}
}
\stex_html_backend:F {
  \bool_if:NT \c__notesslides_sectocframes_bool {
    \str_if_eq:VnTF \__notesslidestopsect{part}{
      \newcounter{chapter}\counterwithin*{section}{chapter}
    }{
      \str_if_eq:VnT\__notesslidestopsect{chapter}{
        \newcounter{chapter}\counterwithin*{section}{chapter}
      }
    }
  }
}
\def\part@prefix{}
\@ifpackageloaded{document-structure}{}{
  \str_case:VnF \__notesslidestopsect {
    {part}{
      \int_set:Nn \l_document_structure_section_level_int {0}
      \def\thesection{\arabic{chapter}.\arabic{section}}
      \def\part@prefix{\arabic{chapter}.}
    }
    {chapter}{
      \int_set:Nn \l_document_structure_section_level_int {1}
      \def\thesection{\arabic{chapter}.\arabic{section}}
      \def\part@prefix{\arabic{chapter}.}
    }
  }{
    \int_set:Nn \l_document_structure_section_level_int {2}
    \def\part@prefix{}
  }
}

\bool_if:NF \c__notesslides_notes_bool { % only in slides
  \renewenvironment{sfragment}[2][]{
    \__document_structure_sfragment_args:n { #1 }
    \int_incr:N \l_document_structure_section_level_int
    \bool_if:NT \c__notesslides_sectocframes_bool {
      \stepcounter{slide}
      \begin{frame}[noframenumbering]
      \vfill\Large\centering
      \red{
        \ifcase\l_document_structure_section_level_int\or
          \stepcounter{part}
          \def\__notesslideslabel{{\omdoc@part@kw}~\Roman{part}}
          \def\currentsectionlevel{\omdoc@part@kw}
        \or
          \stepcounter{chapter}
          \def\__notesslideslabel{{\omdoc@chapter@kw}~\arabic{chapter}}
          \def\currentsectionlevel{\omdoc@chapter@kw}
        \or
          \stepcounter{section}
          \def\__notesslideslabel{\part@prefix\arabic{section}}
          \def\currentsectionlevel{\omdoc@section@kw}
        \or
          \stepcounter{subsection}
          \def\__notesslideslabel{\part@prefix\arabic{section}.\arabic{subsection}}
          \def\currentsectionlevel{\omdoc@subsection@kw}
        \or
          \stepcounter{subsubsection}
          \def\__notesslideslabel{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
          \def\currentsectionlevel{\omdoc@subsubsection@kw}
        \or
          \stepcounter{paragraph}
          \def\__notesslideslabel{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}}
          \def\currentsectionlevel{\omdoc@paragraph@kw}
        \else
          \def\__notesslideslabel{}
          \def\currentsectionlevel{\omdoc@paragraph@kw}
        \fi% end ifcase
        \__notesslideslabel%\sref@label@id\__notesslideslabel
        \quad #2%
      }%
      \vfill%
      \end{frame}%
    }
    \str_if_empty:NF \l__document_structure_sfragment_id_str {
      \stex_ref_new_doc_target:n\l__document_structure_sfragment_id_str
    }
  }{}
}
\def\inserttheorembodyfont{\normalfont}

\AddToHook{begindocument}{ % this does not work for some reasone
  \setbeamertemplate{theorems}[ams style]
}
\bool_if:NT \c__notesslides_notes_bool {
  \renewenvironment{columns}[1][]{%
    \par\noindent%
    \begin{minipage}%
    \slidewidth\centering\leavevmode%
  }{%
    \end{minipage}\par\noindent%
  }%
  \newsavebox\columnbox%
  \renewenvironment<>{column}[2][]{%
    \begin{lrbox}{\columnbox}\begin{minipage}{#2}%
  }{%
    \end{minipage}\end{lrbox}\usebox\columnbox%
  }%
}
\bool_if:NTF \c__notesslides_noproblems_bool {
  \newenvironment{problems}{}{}
}{
  \excludecomment{problems}
}
\gdef\printexcursions{}
\newcommand\excursionref[2]{% label, text
  \bool_if:NT \c__notesslides_notes_bool {
    \begin{sparagraph}[title=Excursion]
      #2 \sref[fallback=the appendix]{#1}.
    \end{sparagraph}
  }
}
\newcommand\activate@excursion[2][]{
  \gappto\printexcursions{\inputref[#1]{#2}}
}
\newcommand\excursion[4][]{% repos, label, path, text
  \bool_if:NT \c__notesslides_notes_bool {
    \activate@excursion[#1]{#3}\excursionref{#2}{#4}
  }
}
\keys_define:nn{notesslides / excursiongroup }{
  id        .str_set_x:N  = \l__notesslides_excursion_id_str,
  intro     .tl_set:N     = \l__notesslides_excursion_intro_tl,
  mhrepos   .str_set_x:N  = \l__notesslides_excursion_mhrepos_str
}
\cs_new_protected:Nn \__notesslides_excursion_args:n {
  \tl_clear:N \l__notesslides_excursion_intro_tl
  \str_clear:N \l__notesslides_excursion_id_str
  \str_clear:N \l__notesslides_excursion_mhrepos_str
  \keys_set:nn {notesslides / excursiongroup }{ #1 }
}
\newcommand\excursiongroup[1][]{
  \__notesslides_excursion_args:n{ #1 }
  \ifdefempty\printexcursions{}% only if there are excursions
  {\begin{note}
    \begin{sfragment}[#1]{Excursions}%
      \ifdefempty\l__notesslides_excursion_intro_tl{}{
        \inputref[\l__notesslides_excursion_mhrepos_str]{
          \l__notesslides_excursion_intro_tl
        }
      }
      \printexcursions%
    \end{sfragment}
  \end{note}}
}
\ifcsname beameritemnestingprefix\endcsname\else\def\beameritemnestingprefix{}\fi
\endinput
%%
%% End of file `notesslides.sty'.
