%% %% This is file `didactic.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% didactic.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright (C) 2019 by Daniel Bosk %% %% This file may be distributed and/or modified under the conditions of %% the LaTeX Project Public License, either version 1.3c of this license %% or (at your option) any later version. The latest version of this %% license is in: %% %% http://www.latex-project.org/lppl.txt %% %% and version 1.3 or later is part of all distributions of LaTeX version %% 2005/12/01 or later. %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{didactic} [2024/04/08 v1.7 didactic] \RequirePackage{xparse} \RequirePackage{xkeyval} \RequirePackage{xstring} \RequirePackage{etoolbox} \RequirePackage{pythontex} \RequirePackage{minted} \RequirePackage{babel} \RequirePackage{translations} \RequirePackage{amsthm} \RequirePackage{thmtools} \PassOptionsToPackage{unq}{unique} \RequirePackage{unique} \newif\if@didactic@beamer \@ifclassloaded{beamer}{\@didactic@beamertrue}{\@didactic@beamerfalse} \DeclareOptionX{nobeamer}{\@didactic@beamerfalse} \newif\if@didactic@article \@ifclassloaded{beamer}{\@didactic@articlefalse}{\@didactic@articletrue} \newif\if@didactic@beamertheme \@didactic@beamerthemetrue \DeclareOptionX{nobeamertheme}{\@didactic@beamerthemefalse} \DeclareOptionX{noarticle}{\@didactic@articlefalse} \newif\if@didactic@memoir \@ifclassloaded{memoir}{\@didactic@memoirtrue}{\@didactic@memoirfalse} \DeclareOptionX{nomemoir}{\@didactic@memoirfalse} \newif\if@didactic@theorems \@didactic@theoremstrue \DeclareOptionX{notheorems}{\@didactic@theoremsfalse} \newcommand\@didactic@margin@inner{20mm} \newcommand\@didactic@margin@outer{70mm} \newcommand\@didactic@margin@top{25mm} \newcommand\@didactic@margin@bottom{40mm} \DeclareOptionX{inner}[25mm]{\renewcommand\@didactic@margin@inner{#1}} \DeclareOptionX{outer}[65mm]{\renewcommand\@didactic@margin@outer{#1}} \DeclareOptionX{top}[25mm]{\renewcommand\@didactic@margin@top{#1}} \DeclareOptionX{bottom}[40mm]{\renewcommand\@didactic@margin@bottom{#1}} \newcommand\@didactic@marginparmargin{outer} \DeclareOptionX{marginparmargin}{% \renewcommand\@didactic@marginparmargin{#1} \@ifclassloaded{memoir}{% \marginparmargin{#1} \strictpagechecktrue \checkandfixthelayout }{} } \ProcessOptionsX\relax \if@didactic@beamer \if@didactic@beamertheme \usetheme{Berlin} \setbeamertemplate{footline}%{miniframes theme} {% \begin{beamercolorbox}[colsep=1.5pt]{upper separation line foot} \end{beamercolorbox} \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,% leftskip=.3cm,rightskip=.3cm plus1fil]{author in head/foot}% \leavevmode{\usebeamerfont{author in head/foot}\insertshortauthor}% \hfill% {\usebeamerfont{institute in head/foot}% \usebeamercolor[fg]{institute in head/foot}\insertshortinstitute}% \end{beamercolorbox}% \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,% leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}% {\usebeamerfont{title in head/foot}\insertshorttitle}% \hfill% \insertframenumber% \end{beamercolorbox}% \begin{beamercolorbox}[colsep=1.5pt]{lower separation line foot} \end{beamercolorbox} } \setbeamercovered{transparent} \setbeamertemplate{bibliography item}{\relax} \fi \AtBeginSection[]{% \begin{frame} \tableofcontents[currentsection, subsectionstyle=show/show/hide] \end{frame} } \AtBeginSubsection[]{% \begin{frame} \tableofcontents[currentsection, subsectionstyle=show/shaded/hide] \end{frame} } \fi% end \if@didactic@beamer \if@didactic@memoir \RequirePackage{marginfix} \setlrmarginsandblock{\@didactic@margin@inner} {\@didactic@margin@outer} {*} \setulmarginsandblock{\@didactic@margin@top} {\@didactic@margin@bottom} {*} \footnotesinmargin \RequirePackage{ragged2e} \renewcommand{\sidefootform}{\RaggedRight} \renewcommand{\foottextfont}{\footnotesize\RaggedRight} \setmpjustification{\RaggedRight}{\RaggedRight} \setfloatadjustment{marginfigure}{\mpjustification} \setmarginfloatcaptionadjustment{figure}{\captionstyle{\mpjustification}} \sidecapmargin{outer} \setsidecappos{t} \checkandfixthelayout \setsidecaps{\marginparsep}{\marginparwidth} \renewcommand{\sidecapstyle}{% \captionstyle{\RaggedRight} } \RequirePackage[osf,sc]{mathpazo} \RequirePackage[scaled=0.90]{helvet} \RequirePackage[scaled=0.85]{beramono} \setlxvchars\setxlvchars \checkandfixthelayout \nouppercaseheads \@ifpackageloaded{biblatex}{% \ExecuteBibliographyOptions{% autocite=footnote, singletitle=false, %style=verbose, %citestyle=verbose, maxbibnames=99, isbn=false,doi=false,url=false } % from https://tex.stackexchange.com/a/374059/17418 \DeclareCiteCommand{\fullauthorcite} {\usebibmacro{prenote}} {\usedriver {\setcounter{maxnames}{99}% use up to 99 authors \DeclareNameAlias{sortname}{default}} {\thefield{entrytype}}} {\multicitedelim} {\usebibmacro{postnote}} }{} \@ifpackageloaded{csquotes}{% \SetCiteCommand{\footcite} }{} \fi% end \if@didactic@memoir \ProvideDocumentEnvironment{sidecaption}{omo+b}{% #4 \caption{#2\IfValueT{#3}{\label{#3}}} }{\relax} \NewDocumentCommand{\flushscap}{O{\centering}}{% \@ifclassloaded{memoir}{% \ifscapmargleft% \flushleft% \else% \flushright% \fi% }{% #1% }% } \ProvideDocumentCommand{\ProvideSemanticEnv}{m o m o mmmm}{% \@ifundefined{#1}{% \@ifclassloaded{beamer}{% beamer \IfValueTF{#2}{% \ProvideDocumentEnvironment{#1}{o}{% \begin{#2}{\GetTranslationWarn{#3}\IfValueT{##1}{: ##1}} }{% \end{#2} } }{% \ProvideDocumentEnvironment{#1}{o}{% \begin{block}{\GetTranslationWarn{#3}\IfValueT{##1}{: ##1}} }{% \end{block} } } }{% not beamer \IfValueTF{#4}{% \declaretheorem[ name=\GetTranslationWarn{#3}, refname={{\GetTranslationWarn{#5}},{\GetTranslationWarn{#6}}}, Refname={{\GetTranslationWarn{#7}},{\GetTranslationWarn{#8}}}, #4 ]{#1} }{% \declaretheorem[ style=definition, name=\GetTranslationWarn{#3}, refname={{\GetTranslationWarn{#5}},{\GetTranslationWarn{#6}}}, Refname={{\GetTranslationWarn{#7}},{\GetTranslationWarn{#8}}} ]{#1} } } \AtBeginDocument{% \@ifpackageloaded{cleveref}{% \crefname{#1} {\GetTranslationWarn{#5}} {\GetTranslationWarn{#6}} \Crefname{#1} {\GetTranslationWarn{#7}} {\GetTranslationWarn{#8}} }{% \relax } } }{\relax} % \@ifundefined{#1} } % \ProvideSemanticEnv \ProvideSemanticEnv{assumption}[alertblock]{Assumption} {assumption}{assumptions}{Assumption}{Assumptions} \ProvideSemanticEnv{idea}[greenblock]{Idea} {idea}{ideas}{Idea}{Ideas} \ProvideSemanticEnv{question}[orangeblock]{Question} {question}{questions}{Question}{Questions} \ProvideSemanticEnv{exercise}[yellowblock]{Exercise} {exercise}{exercises}{Exercise}{Exercises} \ProvideSemanticEnv{activity}[yellowblock]{Activity} {activity}{activities}{Activity}{Activities} \ProvideSemanticEnv{remark}[alertblock]{Remark}[% numbered=no,style=remark ]{remark}{remarks}{Remark}{Remarks} \ProvideSemanticEnv{summary}[block]{Summary}[% numbered=no,style=remark ]{summary}{summaries}{Summary}{Summaries} \if@didactic@theorems \ProvideSemanticEnv{definition}[block]{Definition} {definition}{definitions}{Definition}{Definitions} \ProvideSemanticEnv{theorem}[block]{Theorem}[% numbered=unless unique,style=theorem ]{theorem}{theorems}{Theorem}{Theorems} \ProvideSemanticEnv{corollary}[block]{Corollary}[% numbered=unless unique,style=theorem ]{corollary}{corollaries}{Corollary}{Corollaries} \ProvideSemanticEnv{lemma}[block]{Lemma}[% numbered=unless unique,style=theorem ]{lemma}{lemmas}{Lemma}{Lemmas} \ProvideSemanticEnv{proof}[block]{Proof}[% numbered=no,style=proof ]{proof}{proofs}{Proof}{Proofs} \ProvideSemanticEnv{solution}[block]{Solution}[% numbered=no,style=proof ]{solution}{solutions}{Solution}{Solutions} \ProvideSemanticEnv{example}[exampleblock]{Example} {example}{examples}{Example}{Examples} \fi \ProvideTranslation{swedish}{Assumption}{Antagande} \ProvideTranslation{swedish}{Assumptions}{Antagandena} \ProvideTranslation{swedish}{assumption}{antagande} \ProvideTranslation{swedish}{assumptions}{antagandena} \ProvideTranslation{swedish}{Idea}{Idé} \ProvideTranslation{swedish}{Ideas}{Idéerna} \ProvideTranslation{swedish}{idea}{idé} \ProvideTranslation{swedish}{ideas}{idéerna} \ProvideTranslation{swedish}{Question}{Fråga} \ProvideTranslation{swedish}{Questions}{Frågor} \ProvideTranslation{swedish}{question}{fråga} \ProvideTranslation{swedish}{questions}{frågor} \ProvideTranslation{swedish}{Exercise}{Övningsuppgift} \ProvideTranslation{swedish}{Exercises}{Övningsuppgifterna} \ProvideTranslation{swedish}{exercise}{övningsuppgift} \ProvideTranslation{swedish}{exercises}{övningsuppgifterna} \ProvideTranslation{swedish}{Activity}{Aktivitet} \ProvideTranslation{swedish}{Activities}{Aktiviteter} \ProvideTranslation{swedish}{activity}{aktivitet} \ProvideTranslation{swedish}{activities}{aktiviteter} \ProvideTranslation{swedish}{Note}{Anmärkning} \ProvideTranslation{swedish}{Notes}{Anmärkningar} \ProvideTranslation{swedish}{note}{anmärkning} \ProvideTranslation{swedish}{notes}{anmärkningar} \ProvideTranslation{swedish}{Remark}{Anmärkning} \ProvideTranslation{swedish}{Remarks}{Anmärkningar} \ProvideTranslation{swedish}{remark}{anmärkning} \ProvideTranslation{swedish}{remarks}{anmärkningar} \ProvideTranslation{swedish}{Summary}{Sammanfattning} \ProvideTranslation{swedish}{Summaries}{Sammanfattningar} \ProvideTranslation{swedish}{summary}{sammanfattning} \ProvideTranslation{swedish}{summaries}{sammanfattningar} \ProvideTranslation{swedish}{definition}{definition} \ProvideTranslation{swedish}{definitions}{definitionerna} \ProvideTranslation{swedish}{Definition}{Definition} \ProvideTranslation{swedish}{Definitions}{Definitionerna} \ProvideTranslation{swedish}{theorem}{sats} \ProvideTranslation{swedish}{theorems}{satserna} \ProvideTranslation{swedish}{Theorem}{Sats} \ProvideTranslation{swedish}{Theorems}{Satserna} \ProvideTranslation{swedish}{corollary}{följdsats} \ProvideTranslation{swedish}{Corollary}{Följdsats} \ProvideTranslation{swedish}{corollaries}{följdsatser} \ProvideTranslation{swedish}{Corollaries}{Följdsatser} \ProvideTranslation{swedish}{lemma}{hjälpsats} \ProvideTranslation{swedish}{lemmas}{hjälpsatserna} \ProvideTranslation{swedish}{Lemma}{Hjälpsats} \ProvideTranslation{swedish}{Lemmas}{Hjälpsatserna} \ProvideTranslation{swedish}{proof}{bevis} \ProvideTranslation{swedish}{Proof}{Bevis} \ProvideTranslation{swedish}{proofs}{bevisen} \ProvideTranslation{swedish}{Proofs}{Bevisen} \ProvideTranslation{swedish}{Solution}{Lösningsförslag} \ProvideTranslation{swedish}{Solutions}{Lösningsförslagen} \ProvideTranslation{swedish}{solution}{lösningsförslag} \ProvideTranslation{swedish}{solutions}{lösningsförslagen} \ProvideTranslation{swedish}{Example}{Exempel} \ProvideTranslation{swedish}{Examples}{Exempelen} \ProvideTranslation{swedish}{example}{exempel} \ProvideTranslation{swedish}{examples}{exempelen} \ProvideDocumentEnvironment{lightblock}{mm}{% \setbeamercolor{block body}{bg=#1!10,fg=black} \setbeamercolor{block title}{bg=#1,fg=black} \setbeamercolor{local structure}{fg=#1} \begin{block}{#2} }{% \end{block} } \ProvideDocumentEnvironment{darkblock}{mm}{% \setbeamercolor{block body}{bg=#1!10,fg=black} \setbeamercolor{block title}{bg=#1,fg=white} \setbeamercolor{local structure}{fg=#1} \begin{block}{#2} }{% \end{block} } \ProvideDocumentEnvironment{blackblock}{m} {\begin{darkblock}{black}{#1}} {\end{darkblock}} \ProvideDocumentEnvironment{whiteblock}{m}{% \setbeamercolor{block body}{bg=white!10,fg=black} \setbeamercolor{block title}{bg=white,fg=black} \setbeamercolor{local structure}{fg=black} \begin{block}{#1} }{% \end{block} } \ProvideDocumentEnvironment{bwblock}{m}{% \setbeamercolor{block body}{bg=white!10,fg=black} \setbeamercolor{block title}{bg=black,fg=white} \setbeamercolor{local structure}{fg=black} \begin{block}{#1} }{% \end{block} } \ProvideDocumentEnvironment{redblock}{m} {\begin{darkblock}{red}{#1}} {\end{darkblock}} \ProvideDocumentEnvironment{blueblock}{m} {\begin{darkblock}{blue}{#1}} {\end{darkblock}} \ProvideDocumentEnvironment{purpleblock}{m} {\begin{darkblock}{purple}{#1}} {\end{darkblock}} \ProvideDocumentEnvironment{greenblock}{m} {\begin{lightblock}{green}{#1}} {\end{lightblock}} \ProvideDocumentEnvironment{yellowblock}{m} {\begin{lightblock}{yellow}{#1}} {\end{lightblock}} \ProvideDocumentEnvironment{orangeblock}{m} {\begin{lightblock}{orange}{#1}} {\end{lightblock}} \NewDocumentCommand{\indentedmarginpar}{+m}{% \@ifclassloaded{memoir}{\strictpagecheck}{\relax}% \marginpar{% \setlength{\parindent}{1.0em}\footnotesize \@afterindentfalse\@afterheading #1 }% } \NewDocumentCommand{\newnotetype}{omm}{% \@ifclassloaded{beamer}{% \NewDocumentCommand{#2}{+m}{\relax} }{% \IfValueTF{#1} {\NewDocumentCommand{#2}{+m}{% \indentedmarginpar{#1{#3:} ##1}% }} {\NewDocumentCommand{#2}{+m}{% \indentedmarginpar{\emph{#3:} ##1}% }}% } } \NewDocumentCommand{\NewNoteType}{omm}{% \newbool{#2} \@ifclassloaded{beamer} {\boolfalse{#2}} {\booltrue{#2}} \expandafter\newcommand\csname #2off\endcsname{\boolfalse{#2}} \expandafter\newcommand\csname #2on\endcsname{\booltrue{#2}} \IfValueTF{#1}{% \expandafter\newcommand\csname #2\endcsname[1]{% \ifbool{#2}{% \indentedmarginpar{#1{#3:} ##1}% }{\relax}% }}{% \expandafter\newcommand\csname #2\endcsname[1]{% \ifbool{#2}{% \indentedmarginpar{\emph{#3:} ##1}% }{\relax}% }}% } \ProvideTranslation{swedish}{Learning theory}{Lärandeteori} \NewNoteType{ltnote}{\GetTranslationWarn{Learning theory}} \NewDocumentCommand{\lstexample}{omm}{% \IfValueTF{#1} {\inputminted[escapeinside=||,#1]{#2}{#3}} {\inputminted[escapeinside=||]{#2}{#3}} } \begin{pycode} import subprocess def run_module(m): result = subprocess.run(["python3", m], capture_output=True) print(result.stdout.decode("utf8").strip()) pytex.add_dependencies(m) def mintedoutput(m, opt): if opt: print(r'\begin{minted}[{}]{{text}}'.format(opt)) else: print(r'\begin{minted}{text}') run_module(m) print(r'\end{minted}') \end{pycode} \NewDocumentCommand{\runpython}{om}{% \setpythontexautoprint{false}% \pyc{run_module("#2")}% \printpythontex[verbatim]% } \RequirePackage{changepage} \newlength{\@didactic@textbytext@oldcolumnwidth} \NewDocumentEnvironment{fullwidth}{+b}{% \setlength{\@didactic@textbytext@oldcolumnwidth}{\columnwidth} \setlength{\columnwidth}{\textwidth+2em+\marginparwidth+\marginparsep} \IfStrEqCase{\@didactic@marginparmargin}{% {inner}{\begin{adjustwidth*}{-\marginparwidth-\marginparsep}{-2em}} {left}{\begin{adjustwidth}{-\marginparwidth-\marginparsep}{-2em}} {outer}{\begin{adjustwidth*}{-2em}{-\marginparwidth-\marginparsep}} {right}{\begin{adjustwidth}{-2em}{-\marginparwidth-\marginparsep}} }[\relax] #1 \IfStrEqCase{\@didactic@marginparmargin}{% {inner}{\end{adjustwidth*}} {left}{\end{adjustwidth}} {outer}{\end{adjustwidth*}} {right}{\end{adjustwidth}} }[\relax] \setlength{\columnwidth}{\@didactic@textbytext@oldcolumnwidth} }{\relax} \NewDocumentCommand{\textbytext}{+m+m}{% \begin{fullwidth} \begin{tabularx}{\columnwidth}{XX} #1 & #2 \end{tabularx} \end{fullwidth} } \RequirePackage{tabularx} \RequirePackage{minted} \NewDocumentCommand{\codebycode}{ommomm}{% \textbytext{% \IfValueTF{#1} {\lstexample[#1]{#2}{#3}} {\lstexample{#2}{#3}}% }{% \IfValueTF{#4} {\lstexample[#4]{#5}{#6}} {\lstexample{#5}{#6}}% }% } \NewDocumentCommand{\runbyrun}{mm}{% \textbytext{\runpython{#1}}{\runpython{#2}}% } \endinput %% %% End of file `didactic.sty'.