diff options
author | Norbert Preining <norbert@preining.info> | 2024-04-10 03:00:55 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-04-10 03:00:55 +0000 |
commit | f58130da9ab2f6181b0b2ca4e02895b11d902e20 (patch) | |
tree | 3e7d142983aab069b10f920bb36a95b9fb1af620 /macros/latex/contrib/didactic | |
parent | eb49829734b61c8d5a80ff94393e6c28739ee969 (diff) |
CTAN sync 202404100300
Diffstat (limited to 'macros/latex/contrib/didactic')
-rw-r--r-- | macros/latex/contrib/didactic/README.md | 2 | ||||
-rw-r--r-- | macros/latex/contrib/didactic/didactic.dtx | 103 | ||||
-rw-r--r-- | macros/latex/contrib/didactic/didactic.pdf | bin | 264041 -> 268125 bytes |
3 files changed, 95 insertions, 10 deletions
diff --git a/macros/latex/contrib/didactic/README.md b/macros/latex/contrib/didactic/README.md index f55168d205..da63a9ab36 100644 --- a/macros/latex/contrib/didactic/README.md +++ b/macros/latex/contrib/didactic/README.md @@ -36,7 +36,7 @@ located in `didactic.pdf`. ## Maintainer -The was authored by Daniel Bosk <daniel+ctan@bosk.se>, who is also the +The package was authored by Daniel Bosk <daniel+ctan@bosk.se>, who is also the maintainer. ## License diff --git a/macros/latex/contrib/didactic/didactic.dtx b/macros/latex/contrib/didactic/didactic.dtx index 5429b8bf61..a11b78ebc2 100644 --- a/macros/latex/contrib/didactic/didactic.dtx +++ b/macros/latex/contrib/didactic/didactic.dtx @@ -22,11 +22,12 @@ %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{didactic} %<*package> - [2024/04/07 v1.6 didactic] + [2024/04/08 v1.7 didactic] %</package> %<package>\RequirePackage{xparse} %<package>\RequirePackage{xkeyval} %<package>\RequirePackage{xstring} +%<package>\RequirePackage{etoolbox} %<package>\RequirePackage{pythontex} %<package>\RequirePackage{minted} %<package>\RequirePackage{babel} @@ -90,6 +91,9 @@ % Adds |fullwidth| environment, handles margins better. % Adds |sidecaption| environment and |\flushscap| command. % } +% \changes{v1.7}{2024/04/08}{% +% Adds |\NewNoteType| that improves |\newnotetype| with toggles. +% } % % \GetFileInfo{didactic.dtx} % @@ -273,6 +277,16 @@ % \bfnote{This is a bold note.} % \ltnote{Another example of a learning theory note.} % +% \DescribeMacro{\NewNoteType} +% We also have |\NewNoteType| which is almost synonymous to |\newnotetype|. +% The difference is that |\NewNoteType| doesn't take a command as argument, but +% just a name: +% |\NewNoteType{ltnote}{Learning theory}| instead. +% Then we also get |\ltnoteoff| to turn off the note and |\ltnoteon| to turn it +% back on. +% +% Notes are off by default in |beamer|, but on by default otherwise. +% % \StopEventually{} % % \section{Implementation} @@ -969,13 +983,84 @@ % \titlenote{this is the text} % \begin{macrocode} \NewDocumentCommand{\newnotetype}{omm}{% - \IfValueTF{#1} - {\NewDocumentCommand{#2}{+m}{% - \indentedmarginpar{#1{#3:} ##1}% - }} - {\NewDocumentCommand{#2}{+m}{% - \indentedmarginpar{\emph{#3:} ##1}% - }}% + \@ifclassloaded{beamer}{% + \NewDocumentCommand{#2}{+m}{\relax} + }{% + \IfValueTF{#1} + {\NewDocumentCommand{#2}{+m}{% + \indentedmarginpar{#1{#3:} ##1}% + }} + {\NewDocumentCommand{#2}{+m}{% + \indentedmarginpar{\emph{#3:} ##1}% + }}% + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NewNoteType} +% It can also be useful to be able to turn the notes off. +% For instance, we might want notes to appear in one version, but not in +% others. +% Then we'd like a switch to simply turn them off. +% Also, we don't want these notes to appear in |beamer|, so we define them to +% be off by default in that case. +% +% However, to achieve this, we must change the behaviour when creating new +% notes: we need the name, not the |\command| as an argument. +% This is why we have the |\NewNoteType| command. +% +% \ltnote{This is a note with a title, using the note defined by the package.} +% We can use it like this: +% |\NewNoteType{lt}{Learning theory}| +% \NewNoteType{lt}{Learning theory} +% This creates a new note type |\lt|. +% |\lt{This is a note}| yields the note on the side. +% \lt{This is a note} +% +% We can also turn the notes off and on with |\ltoff| and |\lton|. +% \ltoff +% \lt{This is another note while off.} +% \lton +% \lt{This is another note while on, we didn't see the one we used while off.} +% \ltnote{This is a note with a title, using the note defined by the package.} +% +% Let's look at the implementation. +% We first create a new boolean for the note type. +% This will keep track of whether the note type is on or off, should be typeset +% in the margin or if it does nothing. +% As mentioned above, we want to turn the notes off by default in |beamer|. +% \begin{macrocode} +\NewDocumentCommand{\NewNoteType}{omm}{% + \newbool{#2} + \@ifclassloaded{beamer} + {\boolfalse{#2}} + {\booltrue{#2}} +% \end{macrocode} +% Then we create the commands to turn the notes off and on. +% These must be created with |\expandafter\newcommand| to get the name of the +% note type. +% (|\NewDocumentCommand| can't accept names constructed with |\csname|.) +% \begin{macrocode} + \expandafter\newcommand\csname #2off\endcsname{\boolfalse{#2}} + \expandafter\newcommand\csname #2on\endcsname{\booltrue{#2}} +% \end{macrocode} +% We define the command differently depending on whether we want a custom +% formatting for the title of not. +% Same as before, we must use |\expandafter\newcommand| to construct these +% commands. +% \begin{macrocode} + \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}% + }}% } % \end{macrocode} % \end{macro} @@ -985,7 +1070,7 @@ % That way we can also include translations for them. % \begin{macrocode} \ProvideTranslation{swedish}{Learning theory}{Lärandeteori} -\newnotetype{\ltnote}{\GetTranslationWarn{Learning theory}} +\NewNoteType{ltnote}{\GetTranslationWarn{Learning theory}} % \end{macrocode} % \end{macro} % diff --git a/macros/latex/contrib/didactic/didactic.pdf b/macros/latex/contrib/didactic/didactic.pdf Binary files differindex 3c219334ad..3a53a9029a 100644 --- a/macros/latex/contrib/didactic/didactic.pdf +++ b/macros/latex/contrib/didactic/didactic.pdf |