texlive[70901] Master/texmf-dist: didactic (9apr24)

commits+karl at tug.org commits+karl at tug.org
Tue Apr 9 20:47:50 CEST 2024


Revision: 70901
          https://tug.org/svn/texlive?view=revision&revision=70901
Author:   karl
Date:     2024-04-09 20:47:50 +0200 (Tue, 09 Apr 2024)
Log Message:
-----------
didactic (9apr24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/didactic/README.md
    trunk/Master/texmf-dist/doc/latex/didactic/didactic.pdf
    trunk/Master/texmf-dist/source/latex/didactic/didactic.dtx
    trunk/Master/texmf-dist/tex/latex/didactic/didactic.sty

Modified: trunk/Master/texmf-dist/doc/latex/didactic/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/didactic/README.md	2024-04-09 18:47:40 UTC (rev 70900)
+++ trunk/Master/texmf-dist/doc/latex/didactic/README.md	2024-04-09 18:47:50 UTC (rev 70901)
@@ -36,7 +36,7 @@
 
 ## Maintainer
 
-The was authored by Daniel Bosk <daniel+ctan at bosk.se>, who is also the 
+The package was authored by Daniel Bosk <daniel+ctan at bosk.se>, who is also the 
 maintainer.
 
 ## License

Modified: trunk/Master/texmf-dist/doc/latex/didactic/didactic.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/didactic/didactic.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/didactic/didactic.dtx	2024-04-09 18:47:40 UTC (rev 70900)
+++ trunk/Master/texmf-dist/source/latex/didactic/didactic.dtx	2024-04-09 18:47:50 UTC (rev 70901)
@@ -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,23 +983,94 @@
 % \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}
+%
 % \begin{macro}{\ltnote}
 % We provide a few different types of margin notes.
 % 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}
 %

Modified: trunk/Master/texmf-dist/tex/latex/didactic/didactic.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/didactic/didactic.sty	2024-04-09 18:47:40 UTC (rev 70900)
+++ trunk/Master/texmf-dist/tex/latex/didactic/didactic.sty	2024-04-09 18:47:50 UTC (rev 70901)
@@ -22,10 +22,11 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{didactic}
-    [2024/04/07 v1.6 didactic]
+    [2024/04/08 v1.7 didactic]
 \RequirePackage{xparse}
 \RequirePackage{xkeyval}
 \RequirePackage{xstring}
+\RequirePackage{etoolbox}
 \RequirePackage{pythontex}
 \RequirePackage{minted}
 \RequirePackage{babel}
@@ -384,16 +385,39 @@
   }%
 }
 \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}%
+      }}%
+  }
 }
+\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}}
+\NewNoteType{ltnote}{\GetTranslationWarn{Learning theory}}
 \NewDocumentCommand{\lstexample}{omm}{%
   \IfValueTF{#1}
     {\inputminted[escapeinside=||,#1]{#2}{#3}}



More information about the tex-live-commits mailing list.