texlive[64383] Master/texmf-dist: stex (14sep22)

commits+karl at tug.org commits+karl at tug.org
Wed Sep 14 21:58:16 CEST 2022


Revision: 64383
          http://tug.org/svn/texlive?view=revision&revision=64383
Author:   karl
Date:     2022-09-14 21:58:16 +0200 (Wed, 14 Sep 2022)
Log Message:
-----------
stex (14sep22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/stex/Makefile
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-document-structure.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-features.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-hwexam.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-mathhub.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-problem.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-proofs.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-references.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-symbols.tex
    trunk/Master/texmf-dist/doc/latex/stex/stex-doc.pdf
    trunk/Master/texmf-dist/doc/latex/stex/stex-doc.tex
    trunk/Master/texmf-dist/doc/latex/stex/stex-docheader.tex
    trunk/Master/texmf-dist/doc/latex/stex/stex-manual.pdf
    trunk/Master/texmf-dist/doc/latex/stex/stex-manual.tex
    trunk/Master/texmf-dist/doc/latex/stex/stex-tutorial.tex
    trunk/Master/texmf-dist/source/latex/stex/extensions/document-structure.dtx
    trunk/Master/texmf-dist/source/latex/stex/extensions/hwexam.dtx
    trunk/Master/texmf-dist/source/latex/stex/extensions/notesslides.dtx
    trunk/Master/texmf-dist/source/latex/stex/extensions/problem.dtx
    trunk/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-basics.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-features.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-inheritance.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-mathhub.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-metatheory.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-modules.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-others.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-proofs.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-references.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-statements.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-symbols.dtx
    trunk/Master/texmf-dist/source/latex/stex/stex/stex-terms.dtx
    trunk/Master/texmf-dist/tex/latex/stex/document-structure.sty
    trunk/Master/texmf-dist/tex/latex/stex/etc/beamerthemesTeX.sty
    trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-pdflatex.cfg
    trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-rustex.cfg
    trunk/Master/texmf-dist/tex/latex/stex/etc/stexthm.sty
    trunk/Master/texmf-dist/tex/latex/stex/hwexam.sty
    trunk/Master/texmf-dist/tex/latex/stex/ldf/problem-ngerman.ldf
    trunk/Master/texmf-dist/tex/latex/stex/notesslides.cls
    trunk/Master/texmf-dist/tex/latex/stex/notesslides.sty
    trunk/Master/texmf-dist/tex/latex/stex/problem.sty
    trunk/Master/texmf-dist/tex/latex/stex/stex-tikzinput.sty
    trunk/Master/texmf-dist/tex/latex/stex/stex.cls
    trunk/Master/texmf-dist/tex/latex/stex/stex.sty
    trunk/Master/texmf-dist/tex/latex/stex/tikzinput.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/stex/img/
    trunk/Master/texmf-dist/doc/latex/stex/img/vsc1.png
    trunk/Master/texmf-dist/doc/latex/stex/img/vsc2.png
    trunk/Master/texmf-dist/doc/latex/stex/img/vsc3.png
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-idesetup.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-mathhubsetup.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-notesslides.tex
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-setup.tex
    trunk/Master/texmf-dist/doc/latex/stex/stex-ide.pdf
    trunk/Master/texmf-dist/doc/latex/stex/stex-ide.tex
    trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-tex4ht.cfg

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/latex/stex/packages/stex-slides.tex
    trunk/Master/texmf-dist/tex/latex/stex/etc/beamernotesthemesTeX.sty

Modified: trunk/Master/texmf-dist/doc/latex/stex/Makefile
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/Makefile	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/Makefile	2022-09-14 19:58:16 UTC (rev 64383)
@@ -2,7 +2,7 @@
 SPATH = $(STY:%=../source/%)
 DTX =  $(shell ls $(SPATH:%=%/*.dtx))
 INS =  $(shell ls $(SPATH:%=%/*.ins))
-DOC = stex-doc.pdf stex-manual.pdf
+DOC = stex-doc.pdf stex-manual.pdf stex-ide.pdf
 TEXDIR = ../tex
 TEXINPUTS = $(TEXDIR)//:
 

Added: trunk/Master/texmf-dist/doc/latex/stex/img/vsc1.png
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/stex/img/vsc1.png
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/img/vsc1.png	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/img/vsc1.png	2022-09-14 19:58:16 UTC (rev 64383)

Property changes on: trunk/Master/texmf-dist/doc/latex/stex/img/vsc1.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/stex/img/vsc2.png
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/stex/img/vsc2.png
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/img/vsc2.png	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/img/vsc2.png	2022-09-14 19:58:16 UTC (rev 64383)

Property changes on: trunk/Master/texmf-dist/doc/latex/stex/img/vsc2.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/stex/img/vsc3.png
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/stex/img/vsc3.png
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/img/vsc3.png	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/img/vsc3.png	2022-09-14 19:58:16 UTC (rev 64383)

Property changes on: trunk/Master/texmf-dist/doc/latex/stex/img/vsc3.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-document-structure.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-document-structure.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-document-structure.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,3 +1,4 @@
+\begin{sfragment}[id=sec:ds:intro]{Introduction}
 The \pkg{document-structure} package supplies an infrastructure for writing {\omdoc} documents in {\LaTeX}.
 This includes a simple structure sharing mechanism for \sTeX that allows to to move from
 a copy-and-paste document development model to a copy-and-reference model, which
@@ -17,7 +18,9 @@
  DAG models of documents allow to replace the ``Copy and Paste'' in the source document
  with a label-and-reference model where document are shared in the document source and the
  formatter does the copying during document formatting/presentation.
+\end{sfragment}
 
+\begin{sfragment}{Package Options}
 The \pkg{document-structure} package accepts the following options:
 \begin{center}
   \begin{tabular}{|l|p{10cm}|}\hline
@@ -26,7 +29,9 @@
     \meta{sect} is \texttt{section}\\\hline 
   \end{tabular}
 \end{center}
+\end{sfragment}
 
+\begin{sfragment}{Document Fragments}
 \begin{environment}{sfragment}
   The structure of the document is given by nested |sfragment| environments. In the
   {\LaTeX} route, the |sfragment| environment is flexibly mapped to sectioning commands,
@@ -36,8 +41,8 @@
   sfragment. The optional metadata argument has the keys |id| for an identifier,
   |creators| and |contributors| for the Dublin Core metadata~\cite{DCMI:dmt03}. The option
   |short| allows to give a short title for the generated section. If the title contains
-  semantic macros, they need to be protected by |\protect|\ednote{MK: still?}, and we need
-  to give the |loadmodules| key it needs no value. For instance we would have
+  semantic macros, we need to give the |loadmodules| key (it needs no value). For instance
+  we would have
 \begin{latexcode}
 \begin{smodule}{foo}
   \symdef{bar}{B^a_r}
@@ -90,9 +95,8 @@
   the introductory remarks become a ``chapter'' instead of a ``part''.
 \item The inner one groups the frontmatter\footnote{We shied away from redefining the
     |frontmatter| to induce a blindfragment, but this may be the ``right'' way to go in
-    the future.} and makes the preface of the book a section-level construct.\ednote{MK:
-    We need a substitute for the ``Note that here the |display=flow| on the |sfragment|
-    environment prevents numbering as is traditional for prefaces.''}
+    the future.} and makes the preface of the book a section-level construct. The
+  |frontmatter| environment also suppresses numbering as is traditional for prefaces.
 \end{itemize}
 \end{environment}
 
@@ -110,11 +114,13 @@
   will\ldots'' in an |sfragment| environment, where we do not know which sectioning level we
   will end up.
 \end{function}
+\end{sfragment}  
 
+\begin{sfragment}{Ending Documents Prematurely}
 \begin{function}{\prematurestop,\afterprematurestop}
   For prematurely stopping the formatting of a document, \sTeX provides the
   |\prematurestop| macro. It can be used everywhere in a document and ignores all input
-  after that -- backing out of the |sfragment| environment as needed. After that -- and
+  after that -- backing out of the |sfragment| environments as needed. After that -- and
   before the implicit |\end{document}| it calls the internal |\afterprematurestop|, which
   can be customized to do additional cleanup or e.g. print the bibliography.
 
@@ -132,7 +138,12 @@
 re-usable) by using variables (actually token registers) |courseAcronym| and |courseTitle|
 instead of the text itself. The variables can then be set in the \sTeX preamble of the
 course notes file.
-  
+\end{sfragment}
+
+\begin{sfragment}{Global Document Variables}
+  To make document fragments more reusable, we sometimes want to make the content depend
+  on the context. We use \defemph{document variables} for that.
+
 \begin{function}{\setSGvar,\useSGvar}
   |\setSGvar{|\meta{vname}|}{|\meta{text}|}| to set the global variable \meta{vname} to
   \meta{text} and |\useSGvar{|\meta{vname}|}| to reference it.
@@ -144,6 +155,7 @@
   variable \meta{vname}, only if (after expansion) it is equal to \meta{val}, the
   conditional text \meta{ctext} is formatted.
 \end{function}
+\end{sfragment}
 
 %%% Local Variables:
 %%% mode: latex

Modified: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-features.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-features.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-features.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -144,8 +144,16 @@
 be  a \symname{monoid} on $\Int$ ...
         }
 
-        We will return to these two example later, when we also know
-        how to handle the \emph{axioms} of a monoid.
+
+We will return to these two example later, when we also know how to handle the
+\emph{axioms} of a monoid.
+
+\begin{environment}{usestructure}
+  The |usestructure{<struct>}| environment is used in multilingual settings as a parallel
+  to the |mathstructure|. It opens a group and then issues a
+  |\usemodule{.../<struct>-structure}| that gives the body access to all the semantic
+  macros in the referenced structure. 
+\end{environment}
 \end{smodule}
 \end{sfragment}
 

Modified: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-hwexam.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-hwexam.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-hwexam.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,15 +1,29 @@
-
+\begin{sfragment}{Introduction}
 The \pkg{hwexam} package and class supplies an infrastructure that allows to format
 nice-looking assignment sheets by simply including problems from problem files marked up
-with the \pkg{roblem} package.  It is designed to be compatible with |problems.sty|, and
+with the \pkg{problem} package.  It is designed to be compatible with |problems.sty|, and
 inherits some of the functionality.
+\end{sfragment}
 
+\begin{sfragment}{Package Options}
 \begin{variable}{solutions,notes,hints,gnotes,pts,min}
-  The \pkg{wexam} package and class take the options |solutions|, |notes|, |hints|,
+  The \pkg{hwexam} package and class take the options |solutions|, |notes|, |hints|,
   |gnotes|, |pts|, |min|, and |boxed| that are just passed on to the \pkg{problems}
   package (cf. its documentation for a description of the intended behavior).
 \end{variable}
 
+Furthermore, the \pkg{hwexam} package takes the option
+\DescribeMacro{multiple}|multiple| that allows to combine multiple assignment sheets
+into a compound document (the assignment sheets are treated as section, there is a table
+of contents, etc.).
+
+Finally, there is the option \DescribeMacro{test}|test| that modifies the behavior to
+facilitate formatting tests. Only in |test| mode, the macros |\testspace|,
+|\testnewpage|, and |\testemptypage| have an effect: they generate space for the
+students to solve the given problems. Thus they can be left in the {\LaTeX} source. 
+\end{sfragment}
+
+\begin{sfragment}{Assignments}
 This package supplies the \DescribeEnv{assignment}|assignment| environment that groups
 problems into assignment sheets. It takes an optional KeyVal argument with the keys
 \DescribeMacro{number}|number| (for the assignment number; if none is given, 1 is
@@ -19,23 +33,22 @@
 assignment type; e.g. ``quiz'', or ``homework''), \DescribeMacro{given}|given| (for the
 date the assignment was given), and \DescribeMacro{due}|due| (for the date the
 assignment is due).
+\end{sfragment}
 
-Furthermore, the \pkg{hwexam} package takes the option
-\DescribeMacro{multiple}|multiple| that allows to combine multiple assignment sheets
-into a compound document (the assignment sheets are treated as section, there is a table
-of contents, etc.).
+\begin{sfragment}{Including Assignments}
+\begin{function}{\inputassignment}
+  The |\inputassignment| macro can be used to input an assignment from another file. It
+  takes an optional KeyVal argument and a second argument which is a path to the file
+  containing the problem (the macro assumes that there is only one |assignment|
+  environment in the included file).  The keys |number|, |title|, |type|, |given|, and
+  |due| are just as for the |assignment| environment and (if given) overwrite the ones
+  specified in the |assignment| environment in the included file.
+\end{function}
+\end{sfragment}
 
-Finally, there is the option \DescribeMacro{test}|test| that modifies the behavior to
-facilitate formatting tests. Only in |test| mode, the macros |\testspace|,
-|\testnewpage|, and |\testemptypage| have an effect: they generate space for the
-students to solve the given problems. Thus they can be left in the {\LaTeX} source. 
+\begin{sfragment}{Typesetting Exams}
 
-\DescribeMacro{\testspace}|\testspace| takes an argument that expands to a dimension,
-and leaves vertical space accordingly. \DescribeMacro{\testnewpage}|\testnewpage| makes
-a new page in |test| mode, and \DescribeMacro{\testemptypage}|\testemptypage| generates
-an empty page with the cautionary message that this page was intentionally left empty.
-
-Finally, the \DescribeEnv{testheading}|\testheading| takes an optional keyword argument
+The \DescribeEnv{testheading}|\testheading| takes an optional keyword argument
 where the keys \DescribeMacro{duration}|duration| specifies a string that specifies the
 duration of the test, \DescribeMacro{min}|min| specifies the equivalent in number of
 minutes, and \DescribeMacro{reqpts}|reqpts| the points that are required for a perfect
@@ -68,17 +81,12 @@
 \end{center}
 \ednote{MK: The first three ``problems'' come from the stex examples above, how do we get rid
   of this?}
+\end{sfragment}
 
-\begin{function}{\inputassignment}
-  The |\inputassignment| macro can be used to input an assignment from another file. It
-  takes an optional KeyVal argument and a second argument which is a path to the file
-  containing the problem (the macro assumes that there is only one |assignment|
-  environment in the included file).  The keys |number|, |title|, |type|, |given|, and
-  |due| are just as for the |assignment| environment and (if given) overwrite the ones
-  specified in the |assignment| environment in the included file.
-\end{function}
-
 %%% Local Variables:
 %%% mode: latex
 %%% TeX-master: "../stex-manual"
 %%% End:
+
+%  LocalWords:  hwexam solutions,notes,hints,gnotes,pts,min gnotes testemptypage reqpts
+%  LocalWords:  inputassignment reqpts hour,min 60,reqpts

Added: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-idesetup.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-idesetup.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-idesetup.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -0,0 +1,61 @@
+\begin{sfragment}{Setting up the \sTeX IDE}
+  
+    The \sTeX IDE consists of two components using the 
+    \emph{Language Server Protocol (LSP)}: A \emph{client}
+    in the form of a VSCode extension, and a \emph{server}
+    included in the \mmt system. Installing the extension will
+    open up a setup routine that will guide you through the rest.
+  
+    \begin{sfragment}{The \sTeX VSCode Extension}
+  
+      If you have not already, you should first install the VSCode editor 
+      available at \url{https://code.visualstudio.com/}.
+  
+      Next, open VSCode and install the \sTeX extension by clicking on
+      the \emph{extensions} menu on the very left of the VSCode window
+      and searching for ``sTeX'' in the 
+      \emph{``Search Extensions in Marketplace''} field, as in
+      \autoref{fig:install}, and clicking the \emph{Install}-button
+      of the \sTeX extension by KWARC.
+  
+      \begin{figure}
+        \begin{center}
+          \includegraphics[width=0.6\textwidth]{img/vsc1.png}
+        \end{center}
+        \caption{Installing the \sTeX extension for VSCode}\label{fig:install}
+      \end{figure}
+  
+    \end{sfragment}
+  
+    \begin{sfragment}{Setting up \mmt}
+  
+      Next, open any directory (\texttt{File $\to$ Open Folder...}) that contains
+      a \verb|.tex|-file, and a setup window as in \autoref{fig:setup} 
+      will pop up. Clik on the highlighted link `\emph{here}' and download
+      the latest version of the \texttt{MMT.jar} file (at least version 23.0.0)
+      anywhere you like. Then click the \emph{``Browse...''}-button
+      and select your freshly downloaded \texttt{MMT.jar}.
+  
+      If you have already set a system variable for your MathHub-directory,
+      you are now done and can click \emph{``Finish''}. If you have not,
+      you can now also enter a directory path in the lower text field,
+      and the VSCode extension will attempt to globally set one up
+      for you, depending on your operating system.
+  
+      \begin{figure}
+        \begin{center}
+          \includegraphics[width=\textwidth]{img/vsc2.png}
+        \end{center}
+        \caption{\sTeX Setup Routine}\label{fig:setup}
+      \end{figure}
+
+      Once you click \emph{``Finish''}, the client will connect
+      to \url{https://stexmmt.mathhub.info/:sTeX}, query for
+      available archives, download the core libraries required
+      for all (or most) semantic services (\texttt{MMT/urtheories}
+      and \texttt{sTeX/meta-inf}) and set up \RusTeX for you 
+      automatically.
+  
+    \end{sfragment}
+  
+  \end{sfragment}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-idesetup.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-mathhub.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-mathhub.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-mathhub.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,4 +1,4 @@
-\begin{sfragment}{The Local MathHub-Directory}
+\begin{sfragment}[id=sec:localmh]{The Local MathHub-Directory}
     \stexcode"\usemodule", \stexcode"\importmodule", 
     \stexcode"\inputref" etc. allow for 
     including content modularly without having to specify absolute

Added: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-mathhubsetup.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-mathhubsetup.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-mathhubsetup.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -0,0 +1,25 @@
+  \begin{sfragment}{Setting your MathHub Directory}
+    One of \sTeX's features is a proper \emph{module system}
+    of interconnected document snippets for mathematical
+    content. Analogously to \emph{object-oriented programming},
+    it allows for ``object-oriented mathematics'' via individual
+    combinable and, importantly, \emph{reusable} modules, developed
+    collaboratively.
+
+    To make use of such modules, the \sTeX system needs to be told
+    where to find them. There are several ways to do so (see
+    \sref[file=stex-mathhub]{sec:localmh}[in=../stex-manual,
+        title={\href{\basedocurl/stex-manual.pdf}{the \sTeX{}3 Manual}}]),
+    but the most convenient way to do so is via a system variable.
+
+    To do so, create a directory \texttt{MathHub} somewhere on
+    your local file system and set the environment
+    variable \texttt{MATHHUB} to the file path to that directory.
+
+    In linux, you can do so by writing 
+    \begin{lstlisting}[language=bash]
+        export MATHHUB="/path/to/your/MathHub"
+    \end{lstlisting}
+    in your \verb|~/.profile| (for all shells) or \verb|~/.bashrc|
+    (for the bash terminal only) file.
+  \end{sfragment}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-mathhubsetup.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-notesslides.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-notesslides.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-notesslides.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -0,0 +1,243 @@
+\begin{sfragment}{Introduction}
+  The \pkg{notesslides} document class is derived from |beamer.cls|~\cite{beamerclass:on},
+it adds a ``notes version'' for course notes that is more suited to printing than the one
+supplied by |beamer.cls|.
+
+The \pkg{notesslides} class takes the notion of a slide frame from Till Tantau's excellent
+\pkg{beamer} class and adapts its notion of frames for use in the \sTeX and \omdoc. To
+support semantic course notes, it extends the notion of mixing frames and explanatory
+text, but rather than treating the frames as images (or integrating their contents into
+the flowing text), the \pkg{notesslides} package displays the slides as such in the course
+notes to give students a visual anchor into the slide presentation in the course (and to
+distinguish the different writing styles in slides and course notes).
+
+In practice we want to generate two documents from the same source: the slides for
+presentation in the lecture and the course notes as a narrative document for home
+study. To achieve this, the \pkg{notesslides} class has two modes: \emph{slides mode} and
+\emph{notes mode} which are determined by the package option. 
+\end{sfragment}
+
+\begin{sfragment}{Package Options}
+  The \pkg{notesslides} class takes a variety of class options:
+
+  \begin{variable}{slides,notes} The options |slides| and |notes| switch between slides
+    mode and notes mode (see \sref{sec:user:notesslides}).
+  \end{variable}
+
+  \begin{variable}{sectocframes} If the option |sectocframes| is given, then for the
+    |sfragment|s, special frames with the |sfragment| title (and number) are generated.
+  \end{variable}
+
+  \begin{variable}{frameimages,fiboxed}
+    If the option |frameimages| is set, then slide mode also shows the
+    |\frameimage|-generated frames (see \sref{sec:user:frameimage}). If also the |fiboxed|
+    option is given, the slides are surrounded by a box.
+  \end{variable}
+\end{sfragment}
+
+\begin{sfragment}[id=sec:user:notesslides]{Notes and Slides}
+
+\begin{environment}{frame}
+  Slides are represented with the |frame| environment just like in the \pkg{beamer} class,
+  see~\cite{Tantau:ugbc} for details.
+\end{environment}
+
+\begin{environment}{note}
+  The \pkg{notesslides} class adds the |note| environment for encapsulating the course
+  note fragments.
+\end{environment}
+  
+\begin{dangerbox}
+  Note that it is essential to start and end the |notes| environment at the start of the
+  line -- in particular, there may not be leading blanks -- else {\LaTeX} becomes confused
+  and throws error messages that are difficult to decipher.
+\end{dangerbox}
+
+By interleaving the |frame| and |note| environments, we can build course notes as shown
+here:
+
+\begin{latexcode}
+\ifnotes\maketitle\else
+\frame[noframenumbering]\maketitle\fi
+
+\begin{note}
+  We start this course with ...
+\end{note}
+
+\begin{frame}
+  \frametitle{The first slide}
+  ...
+\end{frame}
+\begin{note}
+  ... and more explanatory text
+\end{note}
+
+\begin{frame}
+  \frametitle{The second slide}
+  ...
+\end{frame}
+...
+\end{latexcode}
+
+\begin{function}{\ifnotes}
+  Note the use of the |\ifnotes| conditional, which allows different treatment between
+  |notes| and |slides| mode -- manually setting |\notestrue| or |\notesfalse| is strongly
+  discouraged however.
+\end{function}
+ 
+\begin{dangerbox}
+  We need to give the title frame the |noframenumbering| option so that the frame
+  numbering is kept in sync between the slides and the course notes.
+\end{dangerbox}
+
+\begin{dangerbox}
+  The \pkg{beamer} class recommends not to use the |allowframebreaks| option on frames
+  (even though it is very convenient). This holds even more in the |notesslides| case: At
+  least in conjunction with |\newpage|, frame numbering behaves funnily (we have tried to
+  fix this, but who knows).
+\end{dangerbox}
+\end{sfragment}
+
+\begin{function}{\inputref*}
+  If we want to transclude a the contents of a file as a note, we can use a new variant
+  |\inputref*| of the |\inputref| macro: |\inputref*{foo}| is equivalent to
+  |\begin{note}\inputref{foo}\end{note}|.
+\end{function}
+
+\begin{environment}{nparagraph, nparagraph, ndefinition, nexample, nsproof, nassertion}
+  There are some environments that tend to occur at the top-level of |note|
+  environments. We make convenience versions of these: e.g. the |nparagraph| environment
+  is just an |sparagraph| inside a |note| environment (but looks nicer in the source,
+  since it avoids one level of source indenting). Similarly, we have the |nfragment|,
+  |ndefinition|, |nexample|, |nsproof|, and |nassertion| environments.
+\end{environment}
+
+\begin{sfragment}{Customizing Header and Footer Lines}
+  The \pkg{notesslides} package and class comes with a simple default theme named
+  \pkg{sTeX} that provided by the \pkg{beamterthemesTeX}. It is assumed as the default
+  theme for \sTeX-based notes and slides.
+  The result in |notes| mode (which is like the |slides| version except that the slide
+  hight is variable) is
+  
+  \includegraphics[width=.95\textwidth]{\libfolder{img/notes-frame}}
+  
+The footer line can be customized. In particular the logos. 
+
+\begin{function} {\setslidelogo}
+  The default logo provided by the \pkg{notesslides} package is the {\sTeX} logo it can be
+  customized using |\setslidelogo{|\meta{logo name}|}|.
+\end{function}
+
+\begin{function}{\setsource}
+  The default footer line of the \pkg{notesslides} package mentions copyright and
+  licensing. In \pkg{notesslides} |\source| stores the author's name as the copyright
+  holder. By default it is the author's name as defined in the |\author| macro in the
+  preamble.  |\setsource{|\meta{name}|}| can change the writer's name.
+\end{function}
+
+\begin{function}{\setlicensing}
+  For licensing, we use the Creative Commons Attribuition-ShareAlike license by default to
+  strengthen the public domain. If package |hyperref| is loaded, then we can attach a
+  hyperlink to the license logo. |\setlicensing[|\meta{url}|]{|\meta{logo name}|}| is used
+  for customization, where \meta{url} is optional.
+\end{function}
+\end{sfragment}
+
+\begin{sfragment}[id=sec:user:frameimages]{Frame Images}
+ Sometimes, we want to integrate slides as images after all -- e.g. because we already
+have a PowerPoint presentation, to which we want to add \sTeX notes.
+
+\begin{function}{\frameimage,\mhframeimage}
+  In this case we can use |\frameimage[|\meta{opt}|]{|\meta{path}|}|, where \meta{opt} are
+  the options of |\includegraphics| from the \pkg{graphicx} package~\cite{CarRah:tpp99}
+  and \meta{path} is the file path (extension can be left off like in
+  |\includegraphics|). We have added the |label| key that allows to give a frame label
+  that can be referenced like a regular |beamer| frame.
+
+The |\mhframeimage| macro is a variant of |\frameimage| with repository support. Instead
+of writing
+\begin{latexcode}
+\frameimage{\MathHub{fooMH/bar/source/baz/foobar}}
+\end{latexcode}
+  we can simply write (assuming that |\MathHub| is defined as above)
+\begin{latexcode}
+\mhframeimage[fooMH/bar]{baz/foobar}
+\end{latexcode}
+  Note that the |\mhframeimage| form is more semantic, which allows more advanced document
+management features in \textsf{MathHub}.
+\end{function}
+
+If |baz/foobar| is the ``current module'', i.e. if we are on the \textsf{MathHub} path
+\ldots|MathHub/fooMH/bar|\ldots, then stating the repository in the first optional
+argument is redundant, so we can just use
+\begin{latexcode}
+\mhframeimage{baz/foobar}
+\end{latexcode}
+\end{sfragment}
+
+\begin{function}{\textwarning}
+  The |\textwarning| macro generates a warning sign: \textwarning
+\end{function}
+
+\begin{sfragment}[id=sec:user:excursions]{Excursions}
+In course notes, we sometimes want to point to an ``excursion'' -- material that is either
+presupposed or tangential to the course at the moment -- e.g. in an appendix. The typical
+setup is the following:
+
+\begin{latexcode}
+\excursion{founif}{../fragments/founif.en}
+  {We will cover first-order unification in}
+...
+\begin{appendix}\printexcursions\end{appendix}
+\end{latexcode}
+
+It generates a paragraph that references the excursion whose source is in the file
+|../fragments/founif.en.tex| and automatically books the file for the |\printexcursions|
+command that is used here to put it into the appendix. We will look at the mechanics now. 
+
+\begin{function}{\excursion}
+  The |\excursion{|\meta{ref}|}{|\meta{path}|}{|\meta{text}|}| is syntactic sugar for
+
+\begin{latexcode}
+\begin{nparagraph}[title=Excursion]
+  \activateexcursion{founif}{../ex/founif}
+  We will cover first-order unification in \sref{founif}.
+\end{nparagraph}
+\end{latexcode}
+\end{function}
+
+\begin{function}{\activateexcursion,\printexcursion,\excursionref}
+  Here |\activateexcursion{|\meta{path}|}| augments the |\printexcursions| macro by a call
+  |\inputref{|\meta{path}|}|. In this way, the |\printexcursions| macro (usually in the
+  appendix) will collect up all excursions that are specified in the main text.
+
+  Sometimes, we want to reference -- in an excursion -- part of another. We can use
+  |\excursionref{|\meta{label}|}| for that.
+\end{function}
+
+\begin{function}{\excursiongroup}
+  Finally, we usually want to put the excursions into an |sfragment| environment and add
+  an introduction, therefore we provide the a variant of the |\printexcursions| macro:
+  |\excursiongroup[id=|\meta{id}|,intro=|\meta{path}|]| is equivalent to
+\begin{latexcode}
+\begin{note}
+\begin{sfragment}[id=<id>]{Excursions}
+  \inputref{<path>}
+  \printexcursions
+\end{sfragment}
+\end{note}
+\end{latexcode}
+\end{function}
+\end{sfragment}
+
+\begin{dangerbox}
+  When option |book| which uses |\pagestyle{headings}| is given and semantic macros are
+  given in the |sfragment| titles, then they sometimes are not defined by the time the
+  heading is formatted. Need to look into how the headings are made. This is a problem of
+  the underlying \pkg{document-structure} package.
+\end{dangerbox}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: "../stex-manual"
+%%% End:


Property changes on: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-notesslides.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-problem.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-problem.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-problem.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,4 +1,5 @@
-The \pkg{problem} package supplies an infrastructure that allows specify problem.  Problems
+\begin{sfragment}{Introduction}
+  The \pkg{problem} package supplies an infrastructure that allows specify problem.  Problems
 are text fragments that come with auxiliary functions: hints, notes, and
 solutions\footnote{for the moment multiple choice problems are not supported, but may
   well be in a future version}. Furthermore, we can specify how long the solution to a
@@ -7,7 +8,11 @@
 
 Finally, the \pkg{problem} package facilitates the management of problems in small files,
 so that problems can be re-used in multiple environment. 
+\end{sfragment}
 
+
+\begin{sfragment}{Problems and Solutions}
+  
 \begin{function}{solutions,notes,hints,gnotes,pts,min,boxed,test}
   The \pkg{problem} package takes the options |solutions| (should solutions be output?),
   |notes| (should the problem notes be presented?), |hints| (do we give the hints?),
@@ -43,7 +48,7 @@
     \begin{exnote}
       Justify your answer
     \end{exnote}
-\begin{solution}[for=elefants,height=3cm]
+\begin{solution}[for=elefants]
   Four, two in the front seats, and two in the back.
   \begin{gnote}
     if they do not give the justification deduct 5 pts
@@ -66,7 +71,7 @@
 \begin{environment}{hint,exnote,gnote}
   The |hint| and |exnote| environments can be used in a |problem| environment to give
   hints and to make notes that elaborate certain aspects of the problem.  The |gnote|
-  (grading notes) environment can be used to document situtations that may arise in
+  (grading notes) environment can be used to document situations that may arise in
   grading.
 \end{environment}
 
@@ -80,7 +85,22 @@
   Also, sometimes, we want content (e.g. in an exam with master solutions) conditional on
   whether solutions are shown. This can be done with the |\ifsolutions| conditional.
 \end{function}
+\end{sfragment}
 
+\begin{sfragment}{Markup for Added-Value Services}
+
+\begin{sparagraph}
+  The |problem| package is all about specifying the meaning of the various moving parts of
+  practice/exam problems. The motivation for the additional markup is that we can base
+  added-value services from these, for instance auto-grading and immediate feedback.
+
+  The simplest example of this are multiple-choice problems, where the |problem| package
+  allows to annotate answer options with the intended values and possibly feedback that
+  can be delivered to the users in an interactive setting. In this section we will give
+  some infrastructure for these, we expect that this will grow over time. 
+\end{sparagraph}
+
+\begin{sfragment}{Multiple Choice Blocks}
 \begin{environment}{mcb}
   Multiple choice blocks can be formatted using the |mcb| environment, in which single
   choices are marked up with |\mcc| macro.
@@ -96,9 +116,9 @@
   \item |feedback| for a short feedback text given to the student.
   \end{itemize}
 \end{function}
+What we see when this is formatted to PDF depends on the context. In solutions mode (we
+start the solutions in the code fragment below) we get
 
-If we start the solutions, then we get
-
 \stexexample{%
 \startsolutions
 \begin{sproblem}[title=Functions,name=functions1]
@@ -111,8 +131,8 @@
   \end{mcb}
 \end{sproblem}
 }
-without solutions (that is what the students see during the exam/quiz)\ednote{MK: that did
-not work!}
+
+In ``exam mode'' where disable solutions (here via |\stopsolutions|)
 \stexexample{%
 \stopsolutions
 \begin{sproblem}[title=Functions,name=functions1]
@@ -125,7 +145,44 @@
   \end{mcb}
 \end{sproblem}
 }
+we get the questions without solutions (that is what the students see during the
+exam/quiz).
+\end{sfragment}
 
+\begin{sfragment}{Filling-In Concrete Solutions}
+The next simplest situation, where we can implement auto-grading is the case where we
+have fill-in-the-blanks 
+
+\begin{function}{\fillinsol}
+  The |\fillinsol| macro takes\Ednote{for now; more to come} an a single argument, which
+  contains a concrete solution (i.e. a number, a string, \ldots), which generates a
+  fill-in-box in test mode:
+\stexexample{%
+  \stopsolutions 
+  \begin{sproblem}[id=elefants.fillin,title=Fitting Elefants]
+    How many Elefants can you fit into a Volkswagen beetle? \fillinsol{4}
+\end{sproblem}}
+ and the actual solution in solutions mode:   
+\end{function}
+\stexexample{%
+  \begin{sproblem}[id=elefants.fillin,title=Fitting Elefants]
+    How many Elefants can you fit into a Volkswagen beetle? \fillinsol{4}
+  \end{sproblem}}
+If we do not want to leak information about the solution by the size of the blank we can
+also give |\fillinsol| an optional argument with a size: |\fillinsol[3cm]{12}| makes a box
+ three cm wide. 
+
+ Obviously, the required argument of |\fillinsol| can be used for auto-grading. For
+ concrete data like numbers, this is immediate, for more complex data like strings ``soft
+ comparisons'' might be in order. \ednote{For the moment we only assume a single concrete
+   value as correct. In the future we will almost certainly want to extend the
+   functionality to multiple answer classes that allow different feedback like im
+   MCQ. This still needs a bit of design. Also we want to make the formatting of the
+   answer in solutions/test mode configurable.}
+\end{sfragment}
+\end{sfragment}
+
+\begin{sfragment}{Including Problems}
 \begin{function}{\includeproblem}
   The |\includeproblem| macro can be used to include a problem from another file. It takes
   an optional KeyVal argument and a second argument which is a path to the file containing
@@ -144,8 +201,32 @@
 distribution of time and reward to parts of a problem, if the |pts| and |pts| options are
 set. This allows to give students hints about the estimated time and the points to be
 awarded.
+\end{sfragment}
 
+\begin{sfragment}{Testing and Spacing}
+The |problem| package is often used by the |hwexam| package, which is used to create
+homework assignments and exams. Both of these have a ``test mode'' (invoked by the
+package option |test|), where certain information --master solutions or feedback -- is
+not shown in the presentation.
+
+\DescribeMacro{\testspace}|\testspace| takes an argument that expands to a dimension, and
+leaves vertical space accordingly. Specific instances exist:
+\DescribeMacro{\testsmallspace}|\testsmallspace|,
+\DescribeMacro{\testsmallspace}|\testsmallspace|,
+\DescribeMacro{\testsmallspace}|\testsmallspace| give small (1cm), medium (2cm), and big (3cm)
+vertical space.
+
+\DescribeMacro{\testnewpage}|\testnewpage| makes a new page in |test| mode, and
+\DescribeMacro{\testemptypage}|\testemptypage| generates an empty page with the cautionary
+message that this page was intentionally left empty.
+\end{sfragment}
+
 %%% Local Variables:
 %%% mode: latex
 %%% TeX-master: "../stex-manual"
 %%% End:
+
+%  LocalWords:  solutions,notes,hints,gnotes,pts,min,boxed,test gnotes elefants,pts gnote
+%  LocalWords:  2,title exnote hint,exnote,gnote ifsolutions mcb keyvals Ttext Ftext
+%  LocalWords:  Functions,name F,feedback Nooooooooo,feedback 2,title includeproblem
+%  LocalWords:  elefants.fillin,title

Modified: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-proofs.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-proofs.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-proofs.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,100 +1,308 @@
+\begin{sfragment}{Proofs}
+
 The \pkg{stex-proof} package supplies macros and environment that allow to annotate the
 structure of mathematical proofs in \sTeX document. This structure can be used by MKM
 systems for added-value services, either directly from the \sTeX sources, or after
 translation.
 
-We will go over the general intuition by way of a running example: 
+Its central component is the |sproof|-environment, whose body consists
+of:
+\begin{itemize}
+  \item \emph{subproofs} via the |subproof|-environment,
+  \item \emph{proof steps} via the |\spfstep|, |\eqstep|
+    |\assumption|, and |\conclude| macros, and
+  \item \emph{comments}, via normal text without special markup.
+\end{itemize}
 
+|sproof|, |subproof| and the various proof step macros take the following
+optional arguments:
+\begin{itemize}
+  \item[|id|] (\meta{string}) for referencing,
+  \item[|method|] (\meta{string}) the proof method (e.g. contradiction, induction,...)
+  \item[|term|] (\meta{token list}) the (ideally semantically-marked up)
+    proposition that is derived/proven by this proof/subproof/proof step.
+\end{itemize}
+Additionally, they take one mandatory argument for the document text
+to be annotated, or (in the case of the environments)
+as an introductory description of the proof itself. Since
+the latter often contains the |term| to be derived
+as text, alternatively to providing it as 
+an optional argument, the mandatory argument can use the
+|\yield|-macro to mark it up in the text.
+
+The |sproof| and |subproof| environments additionally take
+two optional arguments:
+\begin{itemize}
+  \item[|for|] the symbol identifier/name corresponding to the |sassertion|
+    to be proven. This too subsumes |\yield| and the |term|-argument.
+  \item[|hide|] In the pdf, this only shows the mandatory argument text
+    and hides the body of the environment. In the HTML (as served by \mmt),
+    the bodies of all |proof| and |subproof| environments are \emph{collapsible},
+    and |hide| collapses the body by default.
+\end{itemize}
+
+\begin{smodule}{sproofs}
+  \symdef{coprime}[args=2]{#1 \comp\bot #2}
+  \symdef{realroot}[args=1]{\sqrt{#1}}
+  \symdecl{irrational}[args=1]
+  \symdecl{rational}[args=1]
+  \symdef{eq}[args=2]{#1 \comp= #2}
+  \symdef{ratfrac}[args=2,prec=1]{\frac{#1}{#2}}
+  \symdef{intpow}[args=2,prec=-1]{{#1}^{#2}}
+  \symdef{ratpow}[args=2]{{#1}^{#2}}
+  \symdef{inset}[args=ai]{#1\comp\in#2}{##1\comp,##2}
+  \symdef{Int}{\comp{\mathbb Z}}
+  \symdef{PosInt}{\comp{{\mathbb Z}^+}}
+  \symdef{inttimes}[args=2]{#1 #2}
+  \symdef{divides}[args=2]{#1\comp\|#2}
+
+  \vardef{vara}{\comp a}
+  \vardef{varb}{\comp b}
+  \vardef{varc}{\comp c}
+
+  \def\contradiction{}
+
 \begin{latexcode}
-\begin{sproof}[id=simple-proof]
+  \begin{sassertion}[type=theorem,name=sqrt2irr]
+    \conclusion{\irrational{$\arg{\realroot{2}}$ is \comp{irrational}}}.
+\end{sassertion}
+
+\begin{sproof}[for=sqrt2irr,method=contradiction]{By contradiction}
+    \assumption{Assume \yield{\rational{$\arg{\realroot{2}}$ is 
+      \comp{rational}}}}
+    \begin{subproof}[method=straightforward]{Then 
+        \yield{$\eq{\ratfrac{\intpow{\vara}{2}}{\intpow{\varb}2}}{2}$ 
+        for some $\inset{\vara,\varb}\PosInt$ with 
+        \coprime{$\arg{\vara},\arg{\varb}$ \comp{coprime}}}}
+        \assumption{By assumption, \yield{there are 
+        $\inset{\vara,\varb}\PosInt $ with 
+        $\realroot{2}=\ratfrac{\vara}{\varb}$}}
+        \spfstep{wlog, we can assume \coprime{$\arg{\vara},\arg{\varb}$ 
+        to be \comp{coprime}}}
+            % a comment:
+            If not, reduce the fraction until numerator and denominator 
+            are coprime, and let the resulting components be 
+            $\vara $ and $\varb $
+        \spfstep{Then \yield{$\eq{\intpow{\ratfrac{\vara}{\varb}}2}2$}}
+        \eqstep{\ratfrac{\intpow{\vara}2}{\intpow{\varb}2}}
+    \end{subproof}
+    \begin{subproof}[term=\divides{2}{\vara},method=straightforward]{
+        Then $\vara $ is even}
+        \spfstep{Multiplying the equation by $\intpow{\varb}2$ yields 
+        $\yield{\eq{\intpow{\vara}2}{\inttimes{2}{\intpow{\varb}2}}}$}
+        \spfstep[term=\divides{2}{\intpow{\vara}2}]{Hence 
+        $\intpow{\vara}2$ is even}
+        \conclude[term=\divides{2}{\vara}]{Hence $\vara $ is even as well}
+        % another comment:
+        Hint: Think about the prime factorizations of $\vara $ and 
+        $\intpow{\vara}2$
+    \end{subproof}
+    \begin{subproof}[term=\divides{2}{\varb},method=straightforward,]{
+        Then $\varb $ is also even}
+        \spfstep{Since $\vara $ is even, we have \yield{some $\varc $ 
+          such that $\eq{\inttimes{2}{\varc}}{\vara}$}}
+        \spfstep{Plugging into the above, we get 
+          \yield{$\eq{\intpow{\inttimes{2}{\vara}}2}
+            {\inttimes{2}{\intpow{\varb}2}}$}}
+        \eqstep{\inttimes{4}{\intpow{\vara}2}}
+        \spfstep{Dividing both sides by $2$ yields 
+          \yield{$\eq{\intpow{\varb}2}{\inttimes{2}{\intpow{\vara}2}}$}}
+        \spfstep[term=\divides{2}{\intpow{\varb}2}]{Hence 
+          $\intpow{\varb}2$ is even}
+        \conclude[term=\divides{2}{\varb}]{Hence $\varb $ is even}
+        % one more comment:
+        By the same argument as above
+    \end{subproof}
+    \conclude[term=\contradiction]{Contradiction to $\vara,\varb $ being 
+    \symname{coprime}.}
+\end{sproof}
+\end{latexcode}
+
+which will produce:
+
+\begin{mdframed}
+\begin{sassertion}[type=theorem,name=sqrt2irr]
+  \conclusion{\irrational{$\arg{\realroot2}$ is \comp{irrational}}}.
+\end{sassertion}
+
+\begin{sproof}[for=sqrt2irr,method=contradiction]{By contradiction}
+  \assumption{Assume \yield{\rational{$\arg{\realroot2}$ is \comp{rational}}}}
+  \begin{subproof}[method=straightforward]%
+      {Then \yield{$\eq{\ratfrac{\intpow \vara2}{\intpow \varb2}}{2}$ for some $\inset{\vara,\varb}\PosInt$ with \coprime{$\arg \vara,\arg \varb$ \comp{coprime}}}}
+      \assumption{By assumption, \yield{there are $\inset{\vara,\varb}\PosInt$ with $\realroot2=\ratfrac\vara\varb$}}
+      \spfstep{wlog, we can assume \coprime{$\arg{\vara},\arg{\varb}$ to be \comp{coprime}}}
+          If not, reduce the fraction until numerator and denominator are 
+          coprime, and let the resulting components be $\vara$ and $\varb$
+      \spfstep{Then \yield{$\eq{\intpow{\ratfrac\vara\varb}2}2$}}
+      \eqstep{\ratfrac{\intpow\vara2}{\intpow\varb2}}
+  \end{subproof}
+  \begin{subproof}[term=\divides{2}{\vara},method=straightforward]{Then $\vara$ is even}
+      \spfstep{Multiplying the equation by $\intpow\varb2$ yields $\yield{\eq{\intpow\vara2}{\inttimes2{\intpow\varb2}}}$}
+      \spfstep[term=\divides{2}{\intpow\vara2}]{Hence $\intpow\vara2$ is even}
+      \conclude[term=\divides{2}{\vara}]{Hence $\vara$ is even as well}
+      Hint: Think about the prime factorizations of $\vara$ and $\intpow\vara2$
+  \end{subproof}
+  \begin{subproof}[term=\divides{2}{\varb},method=straightforward]{Then $\varb$ is also even}
+      \spfstep{Since $\vara$ is even, we have \yield{some $\varc$ such that $\eq{\inttimes2\varc}{\vara}$}}
+      \spfstep{Plugging into the above, we get \yield{$\eq{\intpow{\inttimes2\vara}2}{\inttimes2{\intpow\varb2}}$}}
+      \eqstep{\inttimes4{\intpow\vara2}}
+      \spfstep{Dividing both sides by $2$ yields \yield{$\eq{\intpow\varb2}{\inttimes2{\intpow\vara2}}$}}
+      \spfstep[term=\divides{2}{\intpow\varb2}]{Hence $\intpow\varb2$ is even}
+      \conclude[term=\divides{2}{\varb}]{Hence $\varb$ is even}
+      By the same argument as above
+  \end{subproof}
+  \conclude[term=\contradiction]{Contradiction to $\vara,\varb$ being \symname{coprime}.}
+\end{sproof}
+\end{mdframed}
+
+If we mark all subproofs with |hide|, we will obtain the following
+instead:
+
+\begin{mdframed}
+  \begin{sassertion}[type=theorem,name=sqrt2irr]
+    \conclusion{\irrational{$\arg{\realroot2}$ is \comp{irrational}}}.
+  \end{sassertion}
+  
+  \begin{sproof}[for=sqrt2irr,method=contradiction]{By contradiction}
+    \assumption{Assume \yield{\rational{$\arg{\realroot2}$ is \comp{rational}}}}
+    \begin{subproof}[hide,method=straightforward]%
+        {Then \yield{$\eq{\ratfrac{\intpow \vara2}{\intpow \varb2}}{2}$ for some $\inset{\vara,\varb}\PosInt$ with \coprime{$\arg \vara,\arg \varb$ \comp{coprime}}}}
+        \assumption{By assumption, \yield{there are $\inset{\vara,\varb}\PosInt$ with $\realroot2=\ratfrac\vara\varb$}}
+        \spfstep{wlog, we can assume \coprime{$\arg{\vara},\arg{\varb}$ to be \comp{coprime}}}
+            If not, reduce the fraction until numerator and denominator are 
+            coprime, and let the resulting components be $\vara$ and $\varb$
+        \spfstep{Then \yield{$\eq{\intpow{\ratfrac\vara\varb}2}2$}}
+        \eqstep{\ratfrac{\intpow\vara2}{\intpow\varb2}}
+    \end{subproof}
+    \begin{subproof}[hide,term=\divides{2}{\vara},method=straightforward]{Then $\vara$ is even}
+        \spfstep{Multiplying the equation by $\intpow\varb2$ yields $\yield{\eq{\intpow\vara2}{\inttimes2{\intpow\varb2}}}$}
+        \spfstep[term=\divides{2}{\intpow\vara2}]{Hence $\intpow\vara2$ is even}
+        \conclude[term=\divides{2}{\vara}]{Hence $\vara$ is even as well}
+        Hint: Think about the prime factorizations of $\vara$ and $\intpow\vara2$
+    \end{subproof}
+    \begin{subproof}[hide,term=\divides{2}{\varb},method=straightforward,]{Then $\varb$ is also even}
+        \spfstep{Since $\vara$ is even, we have \yield{some $\varc$ such that $\eq{\inttimes2\varc}{\vara}$}}
+        \spfstep{Plugging into the above, we get \yield{$\eq{\intpow{\inttimes2\vara}2}{\inttimes2{\intpow\varb2}}$}}
+        \eqstep{\inttimes4{\intpow\vara2}}
+        \spfstep{Dividing both sides by $2$ yields \yield{$\eq{\intpow\varb2}{\inttimes2{\intpow\vara2}}$}}
+        \spfstep[term=\divides{2}{\intpow\varb2}]{Hence $\intpow\varb2$ is even}
+        \conclude[term=\divides{2}{\varb}]{Hence $\varb$ is even}
+        By the same argument as above
+    \end{subproof}
+    \conclude[term=\contradiction]{Contradiction to $\vara,\varb$ being \symname{coprime}.}
+  \end{sproof}
+  \end{mdframed}
+
+  However, the hidden subproofs will still be shown in the HTML,
+  only in an expandable section which is collapsed by default.
+
+
+The above style of writing proofs is usually called \emph{structured proofs}.
+They have a huge advantage over the traditional purely prosaic style,
+in that (as the name suggests) the actual \emph{structure} of the proof
+is made explicit, which almost always makes it considerably more 
+comprehensible. We, among many others, encourage the general use of 
+structured proofs.
+
+Alas, most proofs are not written in this style, and we would
+do users a disservice by insisting on this style. For that reason,
+the |spfblock| environment turns all subproofs and proof step
+macros into presentationally neutral \emph{inline} annotations,
+as in the induction step of the following example:
+
+\begin{latexcode}
+\begin{sproof}[id=simple-proof,method=induction]
    {We prove that $\sum_{i=1}^n{2i-1}=n^{2}$ by induction over $n$}
-  \begin{spfcases}{For the induction we have to consider three cases:}
-   \begin{spfcase}{$n=1$}
-    \begin{spfstep}[type=inline] then we compute $1=1^2$\end{spfstep}
-   \end{spfcase}
-   \begin{spfcase}{$n=2$}
-      \begin{spfcomment}[type=inline]
+  For the induction we have to consider three cases: % <- a comment
+   \begin{subproof}{$n=1$}
+    \spfstep*{then we compute $1=1^2$}
+   \end{subproof}
+   \begin{subproof}{$n=2$}
         This case is not really necessary, but we do it for the
         fun of it (and to get more intuition).
-      \end{spfcomment}
-      \begin{spfstep}[type=inline] We compute $1+3=2^{2}=4$.\end{spfstep}
-   \end{spfcase}
-   \begin{spfcase}{$n>1$}
-      \begin{spfstep}[type=assumption,id=ind-hyp]
+      \spfstep*{We compute $1+3=2^{2}=4$.}
+   \end{subproof}
+   \begin{subproof}{$n>1$}\begin{spfblock}
+      \assumption[id=ind-hyp]{
         Now, we assume that the assertion is true for a certain $k\geq 1$,
-        i.e. $\sum_{i=1}^k{(2i-1)}=k^{2}$.
-      \end{spfstep}
-      \begin{spfcomment}
+        i.e. \yield{$\sum_{i=1}^k{(2i-1)}=k^{2}$}.
+      }
+      
         We have to show that we can derive the assertion for $n=k+1$ from
         this assumption, i.e. $\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$.
-      \end{spfcomment}
-      \begin{spfstep}
-        We obtain $\sum_{i=1}^{k+1}{2i-1}=\sum_{i=1}^k{2i-1}+2(k+1)-1$
-        \spfjust[method=arith:split-sum]{by splitting the sum}.
-      \end{spfstep}
-      \begin{spfstep}
-        Thus we have $\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1$
-        \spfjust[method=fertilize]{by inductive hypothesis}.
-      \end{spfstep}
-      \begin{spfstep}[type=conclusion]
-        We can \spfjust[method=simplify]{simplify} the right-hand side to
+
+      \spfstep{
+        We obtain $\yield{\sum_{i=1}^{k+1}{2i-1}=
+          \sum_{i=1}^k{2i-1}+2(k+1)-1}$
+        \spfjust{by \splitsum{\comp{splitting the sum}
+        \arg*{$\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$}}}.
+      }
+      \spfstep{
+        Thus we have $\yield{\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1}$
+        \spfjust{by \symname{induction-hypothesis}}.
+      }
+      \conclude{
+        We can \spfjust{\simplification{\comp{simplify} the right-hand side
+        \arg*{k^2+2k+1}}} to
         ${k+1}^2$, which proves the assertion.
-      \end{spfstep}
-   \end{spfcase}
-    \begin{spfstep}[type=conclusion]
+      }
+   \end{spfblock}\end{subproof}
+    \conclude{
       We have considered all the cases, so we have proven the assertion.
-    \end{spfstep}
-  \end{spfcases}
+    }
 \end{sproof}
 \end{latexcode}
 
+
+\symdecl{splitsum}[args=1]
+\symdecl{inducthypothesis}[name=induction-hypothesis]
+\symdecl{simplification}[args=1]
+
 This yields the following result: 
 
 \begin{mdframed}
-  \begin{sproof}[id=simple-proof]
-  {We prove that $\sum_{i=1}^n{2i-1}=n^{2}$ by induction over $n$}
-  \begin{spfcases}{For the induction we have to consider the following cases:}
-    \begin{spfcase}{$n=1$}
-      \begin{spfstep}[type=inline] then we compute $1=1^2$\end{spfstep}
-    \end{spfcase}
-    \begin{spfcase}{$n=2$}
-      \begin{spfcomment}[type=inline]
-         This case is not really necessary, but we do it for the fun
-         of it (and to get more intuition).
-      \end{spfcomment}
-      \begin{spfstep}[type=inline]
-         We compute $1+3=2^{2}=4$
-      \end{spfstep}
-    \end{spfcase}
-    \begin{spfcase}{$n>1$}
-      \begin{spfstep}[type=hypothesis,id=ind-hyp]
-        Now, we assume that the assertion is true for a certain $k\geq 1$, i.e.
-        $\sum_{i=1}^k{(2i-1)}=k^{2}$.
-      \end{spfstep}
-      \begin{spfcomment}
-        We have to show that we can derive the assertion for $n=k+1$ from this
-        assumption, i.e.  $\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$.
-      \end{spfcomment}
-      \begin{spfstep}[id=splitit]
-        We obtain $\sum_{i=1}^{k+1}{(2i-1)}=\sum_{i=1}^k{(2i-1)}+2(k+1)-1$
-       \spfjust[method=arith:split-sum]{by splitting the sum}.
-     \end{spfstep}
-     \begin{spfstep}[id=byindhyp]
-       Thus we have $\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1$
-       \spfjust[method=fertilize]{by \premise[ind-hyp]{inductive hypothesis}}.
-     \end{spfstep}
-     \begin{spfstep}[type=conclusion]
-       We can \spfjust[method=simplify-eq]{simplify the \justarg[rhs]{right-hand side}} to
-       $(k+1)^2$, which proves the assertion.
-     \end{spfstep}
-   \end{spfcase}
-   \begin{spfstep}[type=conclusion]
-     We have considered all the cases, so we have proven the assertion.
-   \end{spfstep}
-  \end{spfcases}
-\end{sproof}
+  \begin{sproof}[id=simple-proof,method=induction]
+    {We prove that $\sum_{i=1}^n{2i-1}=n^{2}$ by induction over $n$}
+   For the induction we have to consider three cases: % <- a comment
+    \begin{subproof}{$n=1$}
+     \spfstep*{then we compute $1=1^2$}
+    \end{subproof}
+    \begin{subproof}{$n=2$}
+         This case is not really necessary, but we do it for the
+         fun of it (and to get more intuition).
+       \spfstep*{We compute $1+3=2^{2}=4$.}
+    \end{subproof}
+    \begin{subproof}{$n>1$}\begin{spfblock}
+       \assumption[id=ind-hyp]{
+         Now, we assume that the assertion is true for a certain $k\geq 1$,
+         i.e. \yield{$\sum_{i=1}^k{(2i-1)}=k^{2}$}.
+       }
+       
+         We have to show that we can derive the assertion for $n=k+1$ from
+         this assumption, i.e. $\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$.
+ 
+       \spfstep{
+         We obtain $\yield{\sum_{i=1}^{k+1}{2i-1}=\sum_{i=1}^k{2i-1}+2(k+1)-1}$
+         \spfjust{by \splitsum{\comp{splitting the sum}\arg*{$\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$}}}.
+       }
+       \spfstep{
+         Thus we have $\yield{\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1}$
+         \spfjust{by \symname{induction-hypothesis}}.
+       }
+       \conclude{
+         We can \spfjust{\simplification{\comp{simplify} the right-hand side
+         \arg*{k^2+2k+1}}} to
+         ${k+1}^2$, which proves the assertion.
+       }
+    \end{spfblock}\end{subproof}
+     \conclude{
+       We have considered all the cases, so we have proven the assertion.
+     }
+ \end{sproof}
 \end{mdframed}
 
+\end{smodule}
+
 \begin{environment}{sproof}
   The |sproof| environment is the main container for proofs. It takes an optional |KeyVal|
   argument that allows to specify the |id| (identifier) and |for| (for which assertion is
@@ -114,44 +322,33 @@
   the proof.
 \end{function}
 
-\begin{environment}{spfstep}
-  Regular proof steps are marked up with the |step| environment, which takes an optional
+\begin{function}{\spfstep}
+  Regular proof steps are marked up with the |\spfstep| macro, which takes an optional
   |KeyVal| argument for annotations. A proof step usually contains a local assertion
   (the text of the step) together with some kind of evidence that this can be derived
   from already established assertions.
-\end{environment}
+\end{function}
 
+\begin{function}{\yield}
+  See above
+\end{function}
+
 \begin{function}{\spfjust}
   This evidence is marked up with the |\spfjust| macro in the \pkg{stex-proofs}
   package. This environment totally invisible to the formatted result; it wraps the text
-  in the proof step that corresponds to the evidence. The environment takes an optional
-  |KeyVal| argument, which can have the |method| key, whose value is the name of a proof
-  method (this will only need to mean something to the application that consumes the
-  semantic annotations). Furthermore, the justification can contain ``premises''
-  (specifications to assertions that were used justify the step) and ``arguments''
-  (other information taken into account by the proof method).
+  in the proof step that corresponds to the evidence (ideally, a
+  semantically marked-up term).
 \end{function}
 
-\begin{function}{\premise}
-  The |\premise| macro allows to mark up part of the text as reference to an assertion
-  that is used in the argumentation. In the running example we have used the |\premise|
-  macro to identify the inductive hypothesis.
+\begin{function}{\assumption}
+  The |\assumption| macro allows to mark up a (justified) assumption.
 \end{function}
 
 \begin{function}{\justarg}
-  The |\justarg| macro is very similar to |\premise| with the difference that it is used
-  to mark up arguments to the proof method. Therefore the content of the first argument
-  is interpreted as a mathematical object rather than as an identifier as in the case of
-  |\premise|. In our example, we specified that the simplification should take place on
-  the right hand side of the equation. Other examples include proof methods that
-  instantiate. Here we would indicate the substituted object in a |\justarg| macro.
 \end{function}
 
-Note that both |\premise| and |\justarg| can be used with an empty second argument to
-mark up premises and arguments that are not explicitly mentioned in the text.
-
 \begin{environment}{subproof}
-  The |spfcases| environment is used to mark up a subproof. This environment takes an
+  The |subproof| environment is used to mark up a subproof. This environment takes an
   optional |KeyVal| argument for semantic annotations and a second argument that allows
   to specify an introductory comment (just like in the |proof| environment). The
   |method| key can be used to give the name of the proof method
@@ -158,34 +355,6 @@
   executed to make this subproof.
 \end{environment}
 
-\begin{environment}{spfcases}
-  The |spfcases| environment is used to mark up a proof by cases. Technically it is a
-  variant of the |subproof| where the |method| is |by-cases|. Its contents are |spfcase|
-  environments that mark up the cases one by one.
-\end{environment}
-
-\begin{environment}{spfcase}
-  The content of a |spfcases| environment are a sequence of case proofs marked up in the
-  |spfcase| environment, which takes an optional |KeyVal| argument for semantic
-  annotations. The second argument is used to specify the the description of the case
-  under consideration. The content of a |spfcase| environment is the same as that of a
-  |sproof|, i.e. |spfstep|s, |spfcomment|s, and |spfcases| environments.
-\end{environment}
-
-\begin{function}{\spfcasesketch}
-  |\spfcasesketch| is a variant of the |spfcase| environment that takes the same
-  arguments, but instead of the |spfstep|s in the body uses a third argument for a proof
-  sketch.
-\end{function}
-
-\begin{environment}{spfcomment}
-  The |spfcomment| environment is much like a |step|, only that it does not have an
-  object-level assertion of its own. Rather than asserting some fact that is relevant
-  for the proof, it is used to explain where the proof is going, what we are attempting
-  to to, or what we have achieved so far. As such, it cannot be the target of a
-  |\premise|.
-\end{environment}
-
 \begin{function}{\sproofend}
   Traditionally, the end of a mathematical proof is marked with a little box at the end of
   the last line of the proof (if there is space and on the end of the next line if there
@@ -205,6 +374,7 @@
 wastes space (especially, if a proof ends in a case analysis which will supply its own
 proof end marker). To suppress it locally, just set |proofend={}| in them or use use
 |\sProofEndSymbol{}|.
+\end{sfragment}
 
 %%% Local Variables:
 %%% mode: latex
@@ -211,4 +381,7 @@
 %%% TeX-master: "../stex-manual"
 %%% End:
 
-%  LocalWords:  hypothesis,id geq splitit arith:split-sum byindhyp rhs proofend
+%  LocalWords:  hypothesis,id geq splitit arith:split-sum byindhyp rhs proofend eqstep
+%  LocalWords:  sproofs coprime ratfrac 2,prec intpow ratpow inttimes varb varc sqrt2irr
+%  LocalWords:  theorem,name sqrt2irr,method wlog hide,method hide,term spfblock splitsum
+%  LocalWords:  simple-proof,method inducthypothesis

Modified: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-references.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-references.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-references.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,7 +1,91 @@
-\begin{sfragment}[id=sec.references]{Referencing Symbols and Statements}
-\textcolor{red}{TODO: references documentation}
-\end{sfragment}
+If we take features like \stexcode"\inputref" and \stexcode"\mhinput" 
+(and the \stexcode"sfragment"-environment, see 
+\sref[file=stex-document-structure]{sec:ds:intro}[in=../stex-manual,title={the \sTeX{}3 manual}]) seriously,
+and build large documents modularly from individually compiling documents for sections, chapters
+and so on, cross-referencing becomes an interesting problem.
 
+Say, we have a document |main.tex|, which \stexcode"\inputref"s a section
+|section1.tex|, which references a definition with label |some_definition| in
+|section2.tex| (subsequently also inputted in |main.tex|).
+Then the numbering of the definition will depend on the \emph{document context}
+in which the document fragment |section2.tex| occurs - in |section2.tex| itself
+(as a standalone document), it might be \emph{Definition 1}, in |main.tex| it might
+be \emph{Definition 3.1}, and in |section1.tex|, the definition \emph{does not even occur}, so
+it needs to be referenced by some other text.
+
+What we would want in that instance is an equivalent of \stexcode"\autoref", that takes
+the document context into account to yield something like \emph{Definition 1}, \emph{Definition 3.1}
+or ``\emph{Definition 1 in the section on Foo}'' respectively.
+
+The \stexcode"\sref" command attempts to do precisely that. Unlike plain \stexcode"\ref", \stexcode"\autoref"
+etc., \stexcode"\sref" refers to not just a \emph{label}, but instead a pair consisting of a \emph{label}
+and the \emph{document} in whose context we want to refer to it. Conversely, every \emph{document} 
+(i.e. standalone compilable |.tex|-file) keeps track of the ``names'' (\emph{Definition 3.1} etc.) for every
+label as determined in the context of the document, and stores them in a dedicated file |\jobname.sref|.
+Additionally, every document has a ``\emph{reference name}'' (e.g. ``\emph{the section on Foo}'').
+This allows us to refer to ``label $x$ in document $D$'' to yield ``\emph{Definition 1 in the section on Foo}''.
+And of course, \sTeX can decide based on the current document to either refer to the label by its
+``full name'' or directly as e.g. \emph{Definition 3.1} depending on whether the label occurs in
+the current document anyway (and link to it accordingly).
+
+\paragraph{} For that to work, we need to supply (up to) three pieces
+of information:
+\begin{itemize}
+    \item The \emph{label} of the reference target (e.g. |some_definition|),
+    \item (optionally) the \emph{file}/document containing the reference target
+        (e.g. |section2|).
+        This is not strictly necessary, but allows for additional disambiguation
+        between possibly duplicate labels across files, and
+    \item (optionally) the document context, in which we want to
+        refer to the reference target (e.g. |main|).
+\end{itemize}
+Additionally, the document in which we want to reference a label needs
+a title for external references.
+
+
+\begin{function}{\sref}
+    \begin{syntax} \cs{sref}|[archive=|\meta{archive1}|,file=|\meta{file}|]|%
+        \Arg{label}|[archive=|\meta{archive2}|,in=|\meta{document-context}|,title=|\meta{title}|]| \end{syntax}
+    This command references \meta{label} (declared in \meta{file} in \meta{archive1}).
+    If the object (section, figure, etc.) with that label occurs ultimately
+    in the same document, \cs{sref} will ignore the second set of optional arguments
+    and simply defer to \cs{autoref} if that command exists, or \cs{ref} if the \pkg{hyperref}
+    package is not included.
+
+    If the referenced object does \emph{not} occur in the current document however,
+    \cs{sref} will refer to it by the object's name as it occurs in
+    the file \meta{document-context} in \meta{archive2}.
+
+For example, the reference to the \stexcode"sfragment"-environment above
+will appear as ``subsection 7.2.1 (Introduction) in the \sTeX{}3 manual''
+if you are reading this in the package documentation for |stex-references|
+directly, but as a linked ``subsection 7.2.1'' in the full documentation
+or manual. This is achieved using 
+
+\stexcode"\sref[file=stex-document-structure]{sec:ds:intro}[in=../stex-manual,title={the \sTeX{}3 manual}]".
+
+\end{function}
+
+For a further example, the following:
+\begin{center}
+    \sref[file=../stex-doc]{part:extends}[in=../stex-doc,title={the full \sTeX{}3 documentation}]
+\end{center}
+will say ``Part III'' (and link accordingly) in the full documentation,
+and ``Part III (Extensions) in the full \sTeX{}3 documentation''
+everywhere else. This is achieved using
+
+\stexcode"\sref[file=../stex-doc]{part:extends}[in=../stex-doc,title={the full \sTeX{}3 documentation}]".
+
+\begin{function}{\extref}
+    \begin{syntax} \cs{sref}|[archive=|\meta{archive1}|,file=|\meta{file}|]|%
+        \Arg{label}|{archive=|\meta{archive2}|,in=|\meta{document-context}|,title=|\meta{title}|}| \end{syntax}
+    The \cs{extref}-command behaves exactly like \cs{sref}, but takes
+    \emph{required} the document context argument and will always use it
+    for generating the document text, regardless of whether the label
+    occurs in the current document.
+\end{function}
+
+
 %%% Local Variables:
 %%% mode: latex
 %%% TeX-master: "../stex-manual"

Added: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-setup.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-setup.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-setup.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -0,0 +1,34 @@
+\begin{sfragment}{Setting up the \sTeX Package}
+
+    \begin{sfragment}[id=sec.minimal-setup]{Minimal Setup for the \sTeX Package}
+        In the best of all worlds, there is no setup, as you already have a new version of
+        {\TeX}Live on your system as a {\LaTeX} enthusiast. If not now is the time to
+        install it; see \cite{TeXLive:on}. You can usually update {\TeX}Live via a package
+        manager or the {\TeX}Live manager \textbf{tlmgr}.
+        \sTeX requires a \TeX{} kernel newer than February 2022. 
+
+        Alternatively, you can install \sTeX from CTAN, the Comprehensive {\TeX} Archive
+        Network; see \cite{stexCTAN:on} for details. We
+        assume you have the \sTeX package in at least version 3.2 (September 2022).
+    \end{sfragment}
+
+    \begin{sfragment}[id=sec.git-setup]{GIT-based Setup for the \sTeX Development Version}
+        If you want use the latest and greatest \sTeX packages
+        that have not even been released to CTAN, 
+        then you can directly clone them from the \sTeX development
+        repository \cite{sTeX:github:on} by the following command-line instructions: 
+        \begin{lstlisting}[language=bash]
+        cd <stexdir>
+        git clone https://github.com/slatex/sTeX.git
+        \end{lstlisting}
+        and keep it updated by pulling updates via \lstinline|git pull| in the cloned \sTeX
+        directory.
+        Make sure to either clone the \sTeX repository into a local texmf-tree or to update your \lstinline|TEXINPUTS| environment variable, e.g. by placing the following line in your \lstinline|.bashrc|:
+        \begin{lstlisting}[language=bash]
+        export TEXINPUTS="$(TEXINPUTS):<sTeXDIR>//:"
+        \end{lstlisting}       
+    \end{sfragment}
+
+    \input{packages/stex-mathhubsetup}
+    
+\end{sfragment}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-setup.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Deleted: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-slides.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-slides.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-slides.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,212 +0,0 @@
-The \pkg{notesslides} document class is derived from |beamer.cls|~\cite{beamerclass:on},
-it adds a ``notes version'' for course notes that is more suited to printing than the one
-supplied by |beamer.cls|.
-
-The \pkg{notesslides} class takes the notion of a slide frame from Till Tantau's excellent
-\pkg{beamer} class and adapts its notion of frames for use in the \sTeX and \omdoc. To
-support semantic course notes, it extends the notion of mixing frames and explanatory
-text, but rather than treating the frames as images (or integrating their contents into
-the flowing text), the \pkg{notesslides} package displays the slides as such in the course
-notes to give students a visual anchor into the slide presentation in the course (and to
-distinguish the different writing styles in slides and course notes).
-
-In practice we want to generate two documents from the same source: the slides for
-presentation in the lecture and the course notes as a narrative document for home
-study. To achieve this, the \pkg{notesslides} class has two modes: \emph{slides mode} and
-\emph{notes mode} which are determined by the package option. 
-
-
-\begin{variable}{slides,notes,sectocframes,frameimages,fiboxed}
-  The \pkg{notesslides} class takes a variety of class options: 
-  \begin{itemize}
-  \item The options |slides| and |notes| switch between slides mode and notes mode (see
-    Section~\ref{sec:user:notesslides}).
-  \item If the option |sectocframes| is given, then for the |sfragment|s, special frames
-    with the |sfragment| title (and number) are generated.
-  \item If the option |frameimages| is set, then slide mode also shows the
-    |\frameimage|-generated frames (see section~\ref{sec:user:frameimage}). If also the
-    |fiboxed| option is given, the slides are surrounded by a box.
-  \end{itemize}
-\end{variable}
-
-\begin{environment}{frame,note}
-  Slides are represented with the |frame| environment just like in the \pkg{beamer} class,
-  see~\cite{Tantau:ugbc} for details. The \pkg{notesslides} class adds the |note|
-  environment for encapsulating the course note fragments.\footnote{MK: it would be very
-    nice, if we did not need this environment, and this should be possible in principle,
-    but not without intensive LaTeX trickery. Hints to the author are welcome.}
-\end{environment}
-  
-\begin{dangerbox}
-  Note that it is essential to start and end the |notes| environment at the start of the
-  line -- in particular, there may not be leading blanks -- else {\LaTeX} becomes confused
-  and throws error messages that are difficult to decipher.
-\end{dangerbox}
-
-By interleaving the |frame| and |note| environments, we can build course notes as shown
-here:
-
-\begin{latexcode}
-\ifnotes\maketitle\else
-\frame[noframenumbering]\maketitle\fi
-
-\begin{note}
-  We start this course with ...
-\end{note}
-
-\begin{frame}
-  \frametitle{The first slide}
-  ...
-\end{frame}
-\begin{note}
-  ... and more explanatory text
-\end{note}
-
-\begin{frame}
-  \frametitle{The second slide}
-  ...
-\end{frame}
-...
-\end{latexcode}
-
-\begin{function}{\ifnotes}
-  Note the use of the |\ifnotes| conditional, which allows different treatment between
-  |notes| and |slides| mode -- manually setting |\notestrue| or |\notesfalse| is strongly
-  discouraged however.
-\end{function}
- 
-\begin{dangerbox}
-  We need to give the title frame the |noframenumbering| option so that the frame
-  numbering is kept in sync between the slides and the course notes.
-\end{dangerbox}
-
-\begin{dangerbox}
-  The \pkg{beamer} class recommends not to use the |allowframebreaks| option on frames
-  (even though it is very convenient). This holds even more in the |notesslides| case: At
-  least in conjunction with |\newpage|, frame numbering behaves funnily (we have tried to
-  fix this, but who knows).
-\end{dangerbox}
-
-\begin{function}{\inputref*}
-  If we want to transclude a the contents of a file as a note, we can use a new variant
-  |\inputref*| of the |\inputref| macro: |\inputref*{foo}| is equivalent to
-  |\begin{note}\inputref{foo}\end{note}|.
-\end{function}
-
-\begin{environment}{nparagraph, nparagraph, ndefinition, nexample, nsproof, nassertion}
-  There are some environments that tend to occur at the top-level of |note|
-  environments. We make convenience versions of these: e.g. the |nparagraph| environment
-  is just an |sparagraph| inside a |note| environment (but looks nicer in the source,
-  since it avoids one level of source indenting). Similarly, we have the |nfragment|,
-  |ndefinition|, |nexample|, |nsproof|, and |nassertion| environments.
-\end{environment}
-
-\begin{function} {\setslidelogo}
-  The default logo provided by the \pkg{notesslides} package is the {\sTeX} logo it can be
-  customized using |\setslidelogo{|\meta{logo name}|}|.
-\end{function}
-
-\begin{function}{\setsource}
-  The default footer line of the \pkg{notesslides} package mentions copyright and
-  licensing. In the \pkg{beamer} class, |\source| stores the author's name as the
-  copyright holder . By default it is \emph{Michael Kohlhase} in the \pkg{notesslides}
-  package since he is the main user and designer of this
-  package. |\setsource{|\meta{name}|}| can change the writer's name.
-\end{function}
-
-\begin{function}{\setlicensing}
-  For licensing, we use the Creative Commons Attribuition-ShareAlike license by default to
-  strengthen the public domain. If package |hyperref| is loaded, then we can attach a
-  hyperlink to the license logo. |\setlicensing[|\meta{url}|]{|\meta{logo name}|}| is used
-  for customization, where \meta{url} is optional.
-\end{function}
-
-Sometimes, we want to integrate slides as images after all -- e.g. because we already
-have a PowerPoint presentation, to which we want to add \sTeX notes.
-
-\begin{function}{\frameimage,\mhframeimage}
-  In this case we can use |\frameimage[|\meta{opt}|]{|\meta{path}|}|, where \meta{opt} are
-  the options of |\includegraphics| from the \pkg{graphicx} package~\cite{CarRah:tpp99}
-  and \meta{path} is the file path (extension can be left off like in
-  |\includegraphics|). We have added the |label| key that allows to give a frame label
-  that can be referenced like a regular |beamer| frame.
-
-The |\mhframeimage| macro is a variant of |\frameimage| with repository support. Instead
-of writing
-\begin{latexcode}
-\frameimage{\MathHub{fooMH/bar/source/baz/foobar}}
-\end{latexcode}
-  we can simply write (assuming that |\MathHub| is defined as above)
-\begin{latexcode}
-\mhframeimage[fooMH/bar]{baz/foobar}
-\end{latexcode}
-  Note that the |\mhframeimage| form is more semantic, which allows more advanced document
-management features in \textsf{MathHub}.
-\end{function}
-
-If |baz/foobar| is the ``current module'', i.e. if we are on the \textsf{MathHub} path
-\ldots|MathHub/fooMH/bar|\ldots, then stating the repository in the first optional
-argument is redundant, so we can just use
-\begin{latexcode}
-\mhframeimage{baz/foobar}
-\end{latexcode}
-
-\begin{function}{\textwarning}
-  The |\textwarning| macro generates a warning sign: \textwarning
-\end{function}
-
-In course notes, we sometimes want to point to an ``excursion'' -- material that is either
-presupposed or tangential to the course at the moment -- e.g. in an appendix. The typical
-setup is the following:
-
-\begin{latexcode}
-\excursion{founif}{../ex/founif}{We will cover first-order unification in}
-...
-\begin{appendix}\printexcursions\end{appendix}
-\end{latexcode}
-
-\begin{function}{\excursion}
-  The |\excursion{|\meta{ref}|}{|\meta{path}|}{|\meta{text}|}| is syntactic sugar for
-
-\begin{latexcode}
-\begin{nparagraph}[title=Excursion]
-  \activateexcursion{founif}{../ex/founif}
-  We will cover first-order unification in \sref{founif}.
-\end{nparagraph}
-\end{latexcode}
-\end{function}
-
-\begin{function}{\activateexcursion,\printexcursion,\excursionref}
-  Here |\activateexcursion{|\meta{path}|}| augments the |\printexcursions| macro by a call
-  |\inputref{|\meta{path}|}|. In this way, the |\printexcursions| macro (usually in the
-  appendix) will collect up all excursions that are specified in the main text.
-
-  Sometimes, we want to reference -- in an excursion -- part of another. We can use
-  |\excursionref{|\meta{label}|}| for that.
-\end{function}
-
-\begin{function}{\excursiongroup}
-  Finally, we usually want to put the excursions into an |sfragment| environment and add
-  an introduction, therefore we provide the a variant of the |\printexcursions| macro:
-  |\excursiongroup[id=|\meta{id}|,intro=|\meta{path}|]| is equivalent to
-\begin{latexcode}
-\begin{note}
-\begin{sfragment}[id=<id>]{Excursions}
-  \inputref{<path>}
-  \printexcursions
-\end{sfragment}
-\end{note}
-\end{latexcode}
-\end{function}
-
-\begin{dangerbox}
-  When option |book| which uses |\pagestyle{headings}| is given and semantic macros are
-  given in the |sfragment| titles, then they sometimes are not defined by the time the
-  heading is formatted. Need to look into how the headings are made. This is a problem of
-  the underlying \pkg{document-structure} package.
-\end{dangerbox}
-
-%%% Local Variables:
-%%% mode: latex
-%%% TeX-master: "../stex-manual"
-%%% End:

Modified: trunk/Master/texmf-dist/doc/latex/stex/packages/stex-symbols.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/packages/stex-symbols.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/packages/stex-symbols.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -413,9 +413,9 @@
 which precedences are higher than which other precedences when used in conjunction.
 \begin{variable}{\infprec,\neginfprec}
   It is occasionally useful to have ``infinitely'' high or low precedences to enforce or
-  forbid automated bracketing entirely -- for those purposes, \stexcode"\infprec" and
-  \stexcode"\neginfprec" exist (which are implemented as the maximal and minimal integer
-  values accordingly).
+  forbid automated bracketing entirely, e.g. for bracket-like notations such as intervals
+  -- for those purposes, \stexcode"\infprec" and \stexcode"\neginfprec" exist (which are
+  implemented as the maximal and minimal integer values accordingly).g
 \end{variable}
 
 \begin{dangerbox}
@@ -499,7 +499,7 @@
 \vardef{varx}[name=x,type=\Nat]{\comp{x}}
 
 Given a function $\varf!:\funtype{\Nat}{\Nat}$, 
-by $\addition{\varf!,\varn}$ we mean the function
+by $\addition{\varf!,\varn}$ we mean the function\rustexBREAK
 $\fun{\varx}{\varf{\addition{\varx,\varn}}}$
 }
 

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

Modified: trunk/Master/texmf-dist/doc/latex/stex/stex-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/stex-doc.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/stex-doc.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,4 +1,7 @@
-\def\bibfolder#1{../lib/bib/#1}
+\def\libfolder#1{../lib/#1}
+\newif\ifinidedoc\inidedocfalse
+\newif\ifinfulldoc\inidedocfalse
+
 \input{stex-docheader}
 \infulldoctrue
 
@@ -9,8 +12,6 @@
 }
 \ExplSyntaxOff
 
-\expandafter\newif\csname if at infulldoc\expandafter\endcsname\csname @infulldoctrue\endcsname
-
 \begin{document}
 	\title{
 		The {\stex{3}} Package Collection
@@ -185,7 +186,7 @@
 \OmitDocInput{../source/stex/stex-others.dtx}
 \DocInput{../source/stex/stex-metatheory.dtx}
 
-\part{Extensions}\label{part:extensions}
+\part{Extensions}\label{part:extensions}\slabel{part:extends}
 
 \DocInput{../source/extensions/tikzinput.dtx}
 \DocInput{../source/extensions/document-structure.dtx}

Modified: trunk/Master/texmf-dist/doc/latex/stex/stex-docheader.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/stex-docheader.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/stex-docheader.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,4 +1,5 @@
 \RequirePackage{paralist}
+\ifcsname libfolder\endcsname\else\def\libfolder#1{../lib/#1}\fi
 \documentclass[full,kernel]{l3doc}
 \usepackage[dvipsnames]{xcolor}
 \usepackage[utf8]{inputenc}
@@ -7,15 +8,14 @@
 \RequirePackage{tikzinput}
 \usetikzlibrary{fit}
 
-% \usepackage[debug=all,lang=en, mathhub=./tests]{stex}
-\usepackage[lang=en, mathhub=./tests]{stex}
-\usepackage{url,array,float,textcomp}
+\usepackage[lang=en, mathhub=./tests,debug=sref]{stex}
+\usepackage{url,array,float}
 \usepackage[show]{ed}
 \usepackage[hyperref=auto,style=alphabetic]{biblatex}
-\addbibresource{\bibfolder{kwarcpubs.bib}}
-\addbibresource{\bibfolder{extpubs.bib}}
-\addbibresource{\bibfolder{kwarccrossrefs.bib}}
-\addbibresource{\bibfolder{extcrossrefs.bib}}
+\addbibresource{\libfolder{bib/kwarcpubs.bib}}
+\addbibresource{\libfolder{bib/extpubs.bib}}
+\addbibresource{\libfolder{bib/kwarccrossrefs.bib}}
+\addbibresource{\libfolder{bib/extcrossrefs.bib}}
 \usepackage{amssymb}
 \usepackage{amsfonts}
 \usepackage{xspace}
@@ -50,7 +50,9 @@
       \\symbolname,\\binarysymbol,\\newbinarysymbol,\\addition,
       \\summation,\\ascendingchain,\\quantforall,\\set,\\funtype,
       \\Nat,\\successor,\\multiplication,\\Int,\\zero,\\uminus,
-      \\intmonoid
+      \\intmonoid,\\divides,\\intpow,\\ratfrac,\\ratpow,\\inttimes,
+      \\inset,\\eq,\\rational,\\irrational,\\coprime,\\PosInt,
+      \\realroot
   },	
   classoffset=2,keywordstyle=\color{blue},morekeywords={
     \\symdecl,\\symdef,\\notation,\\vardef,\\varseq,\\instantiate,
@@ -64,11 +66,11 @@
   classoffset=4,keywordstyle=\color{Purple},morekeywords={
     \\definiendum,\\definame,\\symref,\\symname,\\comp,
     \\compemph,\\definiens,\\svar,\\infprec,\\neginfprec,\\ellipses,
-    \\Symname,\\arg
+    \\Symname,\\arg,\\yield,\\assumption,\\spfstep,\\eqstep,\\conclude
   },
   classoffset=5,keywordstyle=\color{magenta},morekeywords={
     smodule,sdefinition,sassertion,sparagraph,sexample,
-    sproof,subproof,spfcases,spfcase,spfstep,spfcomment,
+    sproof,subproof,spfcases,spfcase,spfstep,spfcomment,spfblock,
     \\spfidea,\\spfsketch,\\spfcasesketch,\\sproofend,
     \\spfjust,\\premise,\\justarg,
     copymodule,interpretmodule,mathstructure,sexample
@@ -88,57 +90,12 @@
   },
   classoffset=8,keywordstyle=\color{red},morekeywords={
     frame,note
+  },
+  classoffset=9,keywordstyle=\color{gray},morekeywords={
+    \\vara,\\varb,\\varc
   }
 }
 
-%\lstdefinestyle{mylatex}{	
-%	keywordstyle=\color{BurntOrange}
-%}
-%\lstdefinelanguage{mylatex}{
-%	emphstyle=\underbar,
-%	alsodigit={:},
-%	%alsoletter={_},
-%	alsoletter={\\}
-%	sensitive=true,
-%	classoffset=0,keywordstyle=\bfseries,
-%	morekeywords={\\begin,\\end,\\ExplSyntaxOn,\\ExplSyntaxOff},	
-%	classoffset=1,keywordstyle=\color{blue},
-%	morekeywords={
-%		\\symdecl,
-%		\\symdef,
-%		\\notation,
-%		\\abbrdef,
-%		\\importmodule,
-%		\\usemodule,
-%		\\STEXwithbrackets,
-%		\\symref
-%	},
-%	classoffset=2,keywordstyle=\color{Purple},
-%	morekeywords={
-%		\\stex_path_from_string:Nn,
-%		\\stex_path_to_string:NN,
-%		\\stex_path_to_string:N,
-%		\\stex_require_repository:n,
-%		\\stex_modules_current_namespace:,
-%		\\stex_debug:n,
-%		\\stex_set_current_repository:n,
-%		\\stex_file_in_smsmode:nn,
-%		\\stex_get_symbol:n,
-%	},
-%	classoffset=3,keywordstyle=\color{SkyBlue},
-%	morekeywords={
-%		\\l_stex_module_ns_str,
-%		\\g_stex_currentfile_seq,
-%		\\l_stex_current_module_prop,
-%		\\l_stex_get_symbol_uri_str,
-%	}
-%	classoffset=0,
-%%^^A	morecomment=[l][\color{Gray}]{//},
-%%^^A	morecomment=[s][\color{Gray}]{/*}{*/},
-%	morecomment=[s][\color{Green}]{$}{$},,
-%	morecomment=[s][\color{OliveGreen}]{\\[}{\\]},
-%^^A  morestring=[b][\color{Purple}]\$,
-%}
 \lstnewenvironment{latexcode}[1][]{\lstset{language=sTeX,#1}}{}
 
 \def\stexcode{\lstinline[language=sTeX]}
@@ -183,28 +140,6 @@
   outer arc=4pt
 }
 
-
-%\newtcolorbox{exampleborderbox}{
-%  enhanced,
-%  left=0pt,
-%  title={Example \the\example at counter},
-%  right=0pt,
-%  top=8pt,
-%  bottom=8pt,
-%  colback=white,
-%  colframe=blue,
-%  width=\textwidth,
-%  enlarge left by=0mm,
-%  boxsep=5pt,
-%  fontupper=\small,
-%  arc=4pt,
-%  outer arc=4pt,
-%  leftupper=1.5cm,
-%  fonttitle=\bfseries,
-%  coltitle=blue,
-%  boxed title style={empty,size=minimal,toprule=0pt,top=1pt,left=3mm,overlay={}},
-%}
-
 \newenvironment{example at border}
 {
   \global\advance\example at counter by 1
@@ -262,7 +197,7 @@
     Output:
     
     \begin{stextest at output}
-      \input{stextest.tex}
+      \csname @ @ input\endcsname{stextest.tex}
     \end{stextest at output}
   \end{example at border}
 }
@@ -371,7 +306,7 @@
 \def\atwintoo#1#2#3{{#1 #2 #3}\atwin{#1}{#2}{#3}}
 \def\cT{\mathcal{T}}\def\cD{\mathcal{D}}
 
-\def\fileversion{3.1}
+\def\fileversion{3.2}
 \def\filedate{\today}
 
 \RequirePackage{pdfcomment}
@@ -446,4 +381,4 @@
 \end{mdframed}\end{remarkbox}\endlist
 }
 
-\usepackage{rustex}
+\usepackage{rustex}
\ No newline at end of file

Added: trunk/Master/texmf-dist/doc/latex/stex/stex-ide.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/stex/stex-ide.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/stex-ide.pdf	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/stex-ide.pdf	2022-09-14 19:58:16 UTC (rev 64383)

Property changes on: trunk/Master/texmf-dist/doc/latex/stex/stex-ide.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/stex/stex-ide.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/stex-ide.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/stex/stex-ide.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -0,0 +1,155 @@
+\ifcsname ifinfulldoc\endcsname\else
+    \expandafter\newif\csname ifinfulldoc\endcsname\infulldocfalse
+\fi
+\ifcsname ifinidedoc\endcsname\else
+    \expandafter\newif\csname ifinidedoc\endcsname\inidedoctrue
+\fi
+
+\ifinidedoc
+\input{stex-docheader}
+
+
+\begin{document}
+
+	\title{
+		The {\stex} VSCode IDE
+		\thanks{Version {\fileversion} (last revised {\filedate})}
+ 	}
+	\author{Michael Kohlhase, Dennis Müller\\
+		FAU Erlangen-Nürnberg\\
+		\url{http://kwarc.info/}
+	}
+	\pagenumbering{roman}
+	\maketitle
+
+  This is the user manual for the \sTeX Plugin for VSCode, available at
+  \url{https://marketplace.visualstudio.com/items?itemName=kwarc.stexide}.
+  For the manual for the \sTeX package itself, see \href{\basedocurl/stex-manual.pdf}{the \sTeX{}3 Manual}.
+	
+	\makeatletter
+		\renewcommand\part{%
+    		\clearpage
+  			\thispagestyle{plain}%
+  			\@tempswafalse
+  			\null\vfil
+  			\secdef\@part\@spart%
+  		}
+		\newcounter{chapter}
+		\numberwithin{section}{chapter}
+		\renewcommand\thechapter{\@arabic\c at chapter}
+		\renewcommand\thesection{\thechapter.\@arabic\c at section}
+		\newcommand*\chaptermark[1]{}
+		\setcounter{secnumdepth}{2}
+		\newcommand\@chapapp{\chaptername}
+		%\newcommand\chaptername{Chapter}
+  		\def\ps at headings{%
+    		\let\@oddfoot\@empty
+    		\def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
+    		\let\@mkboth\markboth
+    		\def\chaptermark##1{%
+      			\markright{\MakeUppercase{%
+        			\ifnum \c at secnumdepth >\m at ne
+            			\@chapapp\ \thechapter. \ %
+        			\fi
+        		##1}}%
+        	}%
+        }
+		\newcommand\chapter{\clearpage
+			\thispagestyle{plain}%
+			\global\@topnum\z@
+			\@afterindentfalse
+			\secdef\@chapter\@schapter%
+		}
+		\def\@chapter[#1]#2{\refstepcounter{chapter}%
+			\typeout{\@chapapp\space\thechapter.}%
+			\addcontentsline{toc}{chapter}%
+				{\protect\numberline{\thechapter}#1}%
+			\chaptermark{#1}%
+			\addtocontents{lof}{\protect\addvspace{10\p@}}%
+			\addtocontents{lot}{\protect\addvspace{10\p@}}%
+			\@makechapterhead{#2}%
+			\@afterheading%
+		}
+		\def\@makechapterhead#1{%
+			\vspace*{50\p@}%
+			{\parindent \z@ \raggedright \normalfont
+				\huge\bfseries \@chapapp\space \thechapter
+				\par\nobreak
+				\vskip 20\p@
+				\interlinepenalty\@M
+				\Huge \bfseries #1\par\nobreak
+				\vskip 40\p@
+			}%
+		}
+\newcommand*\l at chapter[2]{%
+  \ifnum \c at tocdepth >\m at ne
+    \addpenalty{-\@highpenalty}%
+    \vskip 1.0em \@plus\p@
+    \setlength\@tempdima{1.5em}%
+    \begingroup
+      \parindent \z@ \rightskip \@pnumwidth
+      \parfillskip -\@pnumwidth
+      \leavevmode \bfseries
+      \advance\leftskip\@tempdima
+      \hskip -\leftskip
+      #1\nobreak\hfil
+      \nobreak\hb at xt@\@pnumwidth{\hss #2%
+                                 \kern-\p@\kern\p@}\par
+      \penalty\@highpenalty
+    \endgroup
+  \fi}
+\renewcommand*\l at section{\@dottedtocline{1}{1.5em}{2.8em}}
+\renewcommand*\l at subsection{\@dottedtocline{2}{3.8em}{3.2em}}
+\renewcommand*\l at subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}
+\def\partname{Part}
+\def\toclevel at part{-1}
+\def\maketitle{\chapter{\@title}}
+\let\thanks\@gobble
+\let\DelayPrintIndex\PrintIndex
+\let\PrintIndex\@empty
+\providecommand*{\hexnum}[1]{\text{\texttt{\char`\"}#1}}
+\makeatother
+
+\ExplSyntaxOn
+\int_set:Nn \l_document_structure_section_level_int {1}
+\ExplSyntaxOff
+
+\clearpage
+
+{%
+  \def\\{:}% fix "newlines" in the ToC
+  \tableofcontents
+}
+
+\clearpage
+\pagenumbering{arabic}
+
+\long\def\ignore#1{}
+	
+\input{packages/stex-setup}
+\input{packages/stex-idesetup}
+
+\fi
+
+
+
+
+\ifinidedoc
+\newpage 
+\printbibliography
+\end{document}
+\fi
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
+
+%  LocalWords:  stex-docheader infulldoctrue l at subsubsection toclevel at part ExplSyntaxOff
+%  LocalWords:  l_document_structure_section_level_int dangerbox mmtbox omdoc OBJref lmh
+%  LocalWords:  own:fifom MueRabRot:rslffml20 sec.stexarchives stex-mathhub ngerman a,b
+%  LocalWords:  Metatheory sec.customhighlight sproof stexthm xspace stexpatchmodule
+%  LocalWords:  stexpatchexample stexpatchparagraph sexampleid amsthm sassertiontitle
+%  LocalWords:  sdefinitiontitle compemph varemph srefsymuri stex-hwexam TeXLive:on tlmgr
+%  LocalWords:  stexls:on,stexls-vscode-plugin:on


Property changes on: trunk/Master/texmf-dist/doc/latex/stex/stex-ide.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/stex/stex-manual.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/stex/stex-manual.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/stex-manual.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/stex-manual.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,19 +1,15 @@
-\makeatletter
-\ifcsname if at infulldoc\endcsname\else
-    \expandafter\newif\csname if at infulldoc\endcsname\@infulldocfalse
+
+\ifcsname ifinfulldoc\endcsname\else
+    \expandafter\newif\csname ifinfulldoc\endcsname\infulldocfalse
 \fi
-\makeatother
+\ifcsname ifinidedoc\endcsname\else
+    \expandafter\newif\csname ifinidedoc\endcsname\inidedocfalse
+\fi
 
-\csname if at infulldoc\endcsname\else
+\ifinfulldoc\else
+  \input{stex-docheader}
 
-\def\bibfolder#1{../lib/bib/#1}
-
-\input{stex-docheader}
-
-\infulldoctrue
-
 \begin{document}
-  \csname if at infulldoc\endcsname\else
 	\title{
 		The {\stex{3}} Manual
 		\thanks{Version {\fileversion} (last revised {\filedate})}
@@ -192,82 +188,55 @@
 \end{itemize}
 
 \end{sfragment}
-
-\begin{sfragment}{Quickstart}
   
-  \begin{sfragment}{Setup}
-      There are two ways of using \sTeX: as a 
-      \begin{enumerate}
-      \item way of writing {\LaTeX} more modularly (object-oriented Math) for creating PDF
-        documents or
-      \item foundation for authoring active documents in HTML5 instrumented with knowledge
-        management services. 
-      \end{enumerate}
-      Both are legitimate and useful. The first requires a significantly smaller
-      tool-chain, so we describe it first. The second requires a much more substantial
-      (and experimental) toolchain of knowledge management systems. Both workflows profit
-      from an integrated development environment (IDE), which (also) automates setup as
-      far as possible (see \sref{sec.sTeX-IDE}). 
+\begin{sfragment}{Setup}
+    There are two ways of using \sTeX: as a 
+    \begin{enumerate}
+    \item way of writing {\LaTeX} more modularly (object-oriented Math) for creating PDF
+      documents or
+    \item foundation for authoring active documents in HTML5 instrumented with knowledge
+      management services. 
+    \end{enumerate}
+    Both are legitimate and useful. The first requires a significantly smaller
+    tool-chain, so we describe it first. The second requires a much more substantial
+    toolchain of knowledge management systems. 
+    
+    Luckily, the \sTeX-IDE will take care of much of the setup required
+    for the full toolchain, if you are willing to use it.
 
-      \begin{sfragment}[id=sec.minimal-setup]{Minimal Setup for the PDF-only Workflow}
-        In the best of all worlds, there is no setup, as you already have a new version of
-        {\TeX}Live on your system as a {\LaTeX} enthusiast. If not now is the time to
-        install it; see \cite{TeXLive:on}. You can usually update {\TeX}Live via a package
-        manager or the {\TeX}Live manager \textbf{tlmgr}.
+    \input{packages/stex-setup}
 
-        Alternatively, you can install \sTeX from CTAN, the Comprehensive {\TeX} Archive
-        Network; see \cite{stexCTAN:on} for details.
-      \end{sfragment}
+    \input{packages/stex-idesetup}
 
-      \begin{sfragment}[id=sec.git-setup]{GIT-based Setup for the \sTeX Development Version}
-        If you want use the latest and greatest \sTeX packages
-        that have not even been released to CTAN, 
-        then you can directly clone them from the \sTeX development
-        repository \cite{sTeX:github:on} by the following command-line instructions: 
-\begin{lstlisting}[language=bash]
-  cd <stexdir>
-  git clone https://github.com/slatex/sTeX.git
-\end{lstlisting}
-       and keep it updated by pulling updates via \lstinline|git pull| in the cloned \sTeX
-       directory.
-       Then update your \lstinline|TEXINPUTS| environment variable, e.g. by placing the following line in your \lstinline|.bashrc|:
-\begin{lstlisting}[language=bash]
-export TEXINPUTS="$(TEXINPUTS):<sTeXDIR>//:"
-\end{lstlisting}       
-      \end{sfragment}
+    \begin{sfragment}{Manual Setup}
 
-      \begin{sfragment}[id=sec.stex-archives]{\sTeX Archives (Manual Setup)}
-        Writing semantically annotated \sTeX becomes much easier, if we can use
-        well-designed libraries of already annotated content. \sTeX provides such
-        libraries as \sTeX archives -- i.e. GIT repositories at
-        \url{https://gl.mathhub.info} -- most prominently the SMGLoM libraries at
-        \url{https://gl.mathhub.info/smglom}.
+      In lieu of using the \sTeX IDE, we can do the following:
 
-        To do so, we set up a \textbf{local MathHub} by creating a MathHub directory
-        \lstinline|<mhdir>|. Every \sTeX archive as an \textbf{archive path}
-        \lstinline|<apath>| and a name \lstinline|<archive>|. We can clone the \sTeX
-        archive by the following command-line instructions: 
+    \begin{sfragment}[id=sec.stex-archives]{\sTeX Archives (Manual Setup)}
+      Writing semantically annotated \sTeX becomes much easier, if we can use
+      well-designed libraries of already annotated content. \sTeX provides such
+      libraries as \sTeX archives -- i.e. GIT repositories at
+      \url{https://gl.mathhub.info} -- most prominently the SMGLoM libraries at
+      \url{https://gl.mathhub.info/smglom}.
+
+      To do so, we set up a \textbf{local MathHub} by creating a MathHub directory
+      \lstinline|<mhdir>|. Every \sTeX archive as an \textbf{archive path}
+      \lstinline|<apath>| and a name \lstinline|<archive>|. We can clone the \sTeX
+      archive by the following command-line instructions: 
 \begin{lstlisting}[language=bash]
-  cd <mhdir>/<apath>
-  git clone https://gl.mathhub.info/smglom/<archive>.git
+cd <mhdir>/<apath>
+git clone https://gl.mathhub.info/smglom/<archive>.git
 \end{lstlisting}
-        Note that \sTeX archives often depend on other archives, thus you should be
-        prepared to clone these as well -- e.g. if \texttt{pdflatex} reports missing
-        files.  
-        To make sure that \sTeX too knows where to find its archives, we need to set a global
-        system variable |MATHHUB|, that points to your local |MathHub|-directory (see
-        \sref{sec.stexarchives}).
+      Note that \sTeX archives often depend on other archives, thus you should be
+      prepared to clone these as well -- e.g. if \texttt{pdflatex} reports missing
+      files.  
+      To make sure that \sTeX too knows where to find its archives, we need to set a global
+      system variable |MATHHUB|, that points to your local |MathHub|-directory (see
+      \sref{sec.stexarchives}).
 \begin{lstlisting}[language=bash]
-export MATHHUB="<mhdir>''
+export MATHHUB="<mhdir>"
 \end{lstlisting}
-      \end{sfragment}
-      
-      \begin{sfragment}[id=sec.sTeX-IDE]{The \sTeX IDE}
-        We are currently working on an \sTeX IDE as an \sTeX plugin for |VScode|;
-        see~\cite{sTeX-IDE:on}. It will feature a setup procedure that automates the setup
-        described above (and below). For additional functionality see the (now obsolete)
-        plugin for \sTeX1 \cite{stexls:on,stexls-vscode-plugin:on}.
-      \end{sfragment}
+    \end{sfragment}
     
   \begin{sfragment}{Manual Setup for Active Documents and Knowledge Management Services}
       Foregoing on the \sTeX IDE, we will need several additional (on top of the minimal
@@ -301,11 +270,15 @@
       \end{itemize}
     \end{sfragment}
   \end{sfragment}
+\end{sfragment}
 
-  \input{stex-tutorial}
-
+\begin{sfragment}[id=sec.sTeX-IDE]{The \sTeX IDE}
+  \input{stex-ide}
 \end{sfragment}
 
+\input{stex-tutorial}
+
+
 \begin{sfragment}{Creating \sTeX Content}
 
   \input{packages/stex-basics}
@@ -453,7 +426,6 @@
 \begin{sfragment}{\sTeX Statements}
   \input{packages/stex-statements}
   \input{packages/stex-proofs}
-\end{sfragment}
 
 \begin{sfragment}[id=sec.customhighlight]{Highlighting and Presentation Customizations}
 
@@ -538,7 +510,7 @@
 \begin{latexcode}
 \protected\def\symrefemph at uri#1#2{
   \pdftooltip{
-    \srefsymuri{#2}{\symrefemph{#1}}
+    \symrefemph{#1}
   }{
     URI:~\detokenize{#2}
   }
@@ -548,6 +520,10 @@
   other three commands).
 \end{function}
 \end{sfragment}
+\end{sfragment}
+\begin{sfragment}[id=sec.references]{Cross References}
+  \input{packages/stex-references}
+\end{sfragment}
 
 \begin{sfragment}{Additional Packages}
   \begin{sfragment}{Tikzinput: Treating TIKZ code as images}
@@ -557,7 +533,7 @@
     \input{packages/stex-document-structure}
   \end{sfragment}
   \begin{sfragment}{Slides and Course Notes}
-    \input{packages/stex-slides}
+    \input{packages/stex-notesslides}
   \end{sfragment}
   \begin{sfragment}{Representing Problems and Solutions}
     \input{packages/stex-problem}
@@ -567,7 +543,7 @@
   \end{sfragment}
 \end{sfragment}
 
-\csname if at infulldoc\endcsname\else
+\ifinfulldoc\else
 \newpage 
 \printbibliography
 \end{document}

Modified: trunk/Master/texmf-dist/doc/latex/stex/stex-tutorial.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stex/stex-tutorial.tex	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/doc/latex/stex/stex-tutorial.tex	2022-09-14 19:58:16 UTC (rev 64383)
@@ -21,7 +21,7 @@
             \symdef{geometricSeries}[name=geometric-series]{\comp{S}}
 
             \begin{sdefinition}[for=geometricSeries]
-                The \definame{geometricSeries} is the \symname{?series}
+                The \definame{geometricSeries} is the \symname{series}
                 \[\defeq{\geometricSeries}{\definiens{
                     \infinitesum{\svar{n}}{1}{
                         \realdivide[frac]{1}{

Modified: trunk/Master/texmf-dist/source/latex/stex/extensions/document-structure.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/extensions/document-structure.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/extensions/document-structure.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -9,7 +9,7 @@
 %
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -42,14 +42,14 @@
 %
 % \tableofcontents
 % 
+% \begin{documentation}\label{pkg:documentstructure:doc}
+% \begin{sfragment}{The User Interface}
 % \input{../../doc/packages/stex-document-structure}
+% \end{sfragment}
+% \end{documentation}
+%
 % \fi
 %
-%
-% \begin{documentation}\label{pkg:documentstructure:doc}
-%
-% \end{documentation}
-%
 % \begin{implementation}\label{pkg:documentstructure:impl}
 %
 % \begin{sfragment}{document-structure.sty Implementation}
@@ -57,7 +57,7 @@
 %    \begin{macrocode}
 %<*package>
 %<@@=document_structure>
-\ProvidesExplPackage{document-structure}{2022/05/24}{3.1.0}{Modular Document Structure}
+\ProvidesExplPackage{document-structure}{2022/09/14}{3.2.0}{Modular Document Structure}
 \RequirePackage{l3keys2e}
 %    \end{macrocode}
 %
@@ -72,7 +72,7 @@
 
 \keys_define:nn{ document-structure }{
   class       .str_set_x:N  = \c_document_structure_class_str,
-  topsect     .str_set_x:N  = \c_document_structure_topsect_str,,
+  topsect     .str_set_x:N  = \c_document_structure_topsect_str,
   unknown     .code:n       = {
     \PassOptionsToClass{\CurrentOption}{stex}
     \PassOptionsToClass{\CurrentOption}{tikzinput}
@@ -98,7 +98,7 @@
 \AddToHook{begindocument}{
 	\ltx at ifpackageloaded{babel}{
     \clist_set:Nx \l_tmpa_clist {\bbl at loaded}
-    \clist_if_in:NnT \l_tmpa_clist {ngerman}{
+    \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{
       \makeatletter\input{document-structure-ngerman.ldf}\makeatother
     }
   }{}
@@ -223,7 +223,6 @@
   srccite       .tl_set:N    = \l_@@_sfragment_srccite_tl,
   type          .tl_set:N    = \l_@@_sfragment_type_tl,
   short         .tl_set:N    = \l_@@_sfragment_short_tl,
-  display       .tl_set:N    = \l_@@_sfragment_display_tl,
   intro         .tl_set:N    = \l_@@_sfragment_intro_tl,
   imports       .tl_set:N    = \l_@@_sfragment_imports_tl,
   loadmodules   .bool_set:N  = \l_@@_sfragment_loadmodules_bool
@@ -236,7 +235,6 @@
   \tl_clear:N \l_@@_sfragment_srccite_tl
   \tl_clear:N \l_@@_sfragment_type_tl
   \tl_clear:N \l_@@_sfragment_short_tl
-  \tl_clear:N \l_@@_sfragment_display_tl
   \tl_clear:N \l_@@_sfragment_imports_tl
   \tl_clear:N \l_@@_sfragment_intro_tl
   \bool_set_false:N \l_@@_sfragment_loadmodules_bool

Modified: trunk/Master/texmf-dist/source/latex/stex/extensions/hwexam.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/extensions/hwexam.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/extensions/hwexam.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % \iffalse
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -32,8 +32,10 @@
 %    \url{http://kwarc.info/kohlhase}}
 % \maketitle
 %
-%\ifinfulldoc\else
-%\begin{abstract}
+% \begin{documentation}
+%\ifinfulldoc\else 
+% 
+%\begin{abstract}{}
 %  The |hwexam| package and class allows individual course assignment sheets and compound
 %  assignment documents using problem files marked up with the |problem| package.
 % 
@@ -43,12 +45,11 @@
 % \end{abstract}
 %
 % \tableofcontents
-% 
+% \begin{sfragment}{The User Intterface}
 % \input{../../doc/packages/stex-hwexam}
+% \end{sfragment}
 % \fi
 %
-% \begin{documentation}
-% 
 % \end{documentation}
 %
 %\begin{implementation}
@@ -63,13 +64,14 @@
 %
 %    \begin{macrocode}
 %<*package>
-\ProvidesExplPackage{hwexam}{2022/05/24}{3.1.0}{homework assignments and exams}
+\ProvidesExplPackage{hwexam}{2022/09/14}{3.2.0}{homework assignments and exams}
 \RequirePackage{l3keys2e}
 
 \newif\iftest\testfalse
-\DeclareOption{test}{\testtrue}
+\DeclareOption{test}{\testtrue\PassOptionsToPackage{\CurrentOption}{problem}}
 \newif\ifmultiple\multiplefalse
 \DeclareOption{multiple}{\multipletrue}
+\DeclareOption{lang}{\PassOptionsToPackage{\CurrentOption}{problem}}
 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{problem}}
 \ProcessOptions
 %    \end{macrocode}
@@ -86,9 +88,8 @@
 \newcommand\hwexam at assignment@kw{Assignment}
 \newcommand\hwexam at given@kw{Given}
 \newcommand\hwexam at due@kw{Due}
-\newcommand\hwexam at testemptypage@kw{This~page~was~intentionally~left~
-	blank~for~extra~space}
-	\def\hwexam at minutes@kw{minutes}
+\newcommand\hwexam at testemptypage@kw{This~page~was~intentionally~left~blank~for~extra~space}
+\newcommand\hwexam at minutes@kw{minutes}
 \newcommand\correction at probs@kw{prob.}
 \newcommand\correction at pts@kw{total}
 \newcommand\correction at reached@kw{reached}
@@ -104,16 +105,16 @@
 	\ltx at ifpackageloaded{babel}{
 		\makeatletter
 		\clist_set:Nx \l_tmpa_clist {\bbl at loaded}
-		\clist_if_in:NnT \l_tmpa_clist {ngerman}{
+		\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{
 		  \input{hwexam-ngerman.ldf}
 		}
-		\clist_if_in:NnT \l_tmpa_clist {finnish}{
+		\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{
 		  \input{hwexam-finnish.ldf}
 		}
-		\clist_if_in:NnT \l_tmpa_clist {french}{
+		\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{
 		  \input{hwexam-french.ldf}
 		}
-		\clist_if_in:NnT \l_tmpa_clist {russian}{
+		\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{
 		  \input{hwexam-russian.ldf}
 		}
 		\makeatother
@@ -265,7 +266,7 @@
 	}{
 		\global\setcounter{assignment}{\int_use:N\l_@@_assign_number_int}
 	}
-	\setcounter{problem}{0}
+	\setcounter{sproblem}{0}
 	\renewcommand\prob at label[1]{\assignment at number.##1}
 	\def\current at section@level{\document at hwexamtype}
 	%\sref at label@id{\document at hwexamtype \thesection}
@@ -416,24 +417,6 @@
 %    \end{macrocode}
 % \end{macro}
 % 
-% \begin{macro}{\testspace}
-%    \begin{macrocode}
-\newcommand\testspace[1]{\iftest\vspace*{#1}\fi}
-%    \end{macrocode}
-% \end{macro}
-% 
-% \begin{macro}{\testnewpage}
-%    \begin{macrocode}
-\newcommand\testnewpage{\iftest\newpage\fi}
-%    \end{macrocode}
-% \end{macro}
-% 
-% \begin{macro}{\testemptypage}
-%    \begin{macrocode}
-\newcommand\testemptypage[1][]{\iftest\begin{center}\hwexam at testemptypage@kw\end{center}\vfill\eject\else\fi}
-%    \end{macrocode}
-% \end{macro}
-% 
 % \begin{macro}{\@problem}
 %   This macro acts on a problem's record in the |*.aux| file. Here we redefine it (it was
 %   defined to do nothing in |problem.sty|) to  generate the correction table. 

Modified: trunk/Master/texmf-dist/source/latex/stex/extensions/notesslides.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/extensions/notesslides.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/extensions/notesslides.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -11,9 +11,8 @@
 % \iffalse
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
-
 \begin{document}
   \DocInput{\jobname.dtx}
 \end{document}
@@ -54,7 +53,9 @@
 %  see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the
 % \href{\basedocurl/stex.pdf}{full \sTeX documentation}.
 %
-% \input{../../doc/packages/stex-slides}
+% \begin{sfragment}{The User Interface}
+% \input{../../doc/packages/stex-notesslides}
+% \end{sfragment}
 % \fi
 %
 % \begin{documentation}\label{pkg:notesslides:doc}
@@ -76,7 +77,7 @@
 %    \begin{macrocode}
 %<*cls>
 %<@@=notesslides>
-\ProvidesExplClass{notesslides}{2022/05/24}{3.1.0}{notesslides Class}
+\ProvidesExplClass{notesslides}{2022/09/14}{3.2.0}{notesslides Class}
 \RequirePackage{l3keys2e}
 
 \keys_define:nn{notesslides / cls}{
@@ -121,7 +122,7 @@
 % now we do the same for the |notesslides| package. 
 %    \begin{macrocode}
 %<*package>
-\ProvidesExplPackage{notesslides}{2022/05/24}{3.1.0}{notesslides Package}
+\ProvidesExplPackage{notesslides}{2022/09/14}{3.2.0}{notesslides Package}
 \RequirePackage{l3keys2e}
 
 \keys_define:nn{notesslides / pkg}{
@@ -208,35 +209,23 @@
   \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}
+\RequirePackage{bookmark}
 %    \end{macrocode}
 % 
 % \subsection{Notes and Slides}\label{sec:impl:noteslides}
 %
 % For the lecture notes cases, we also provide the |\usetheme| macro that would otherwise
-% come from the the |beamer| class. While the latter loads
-% |beamertheme|\meta{theme}{.sty}, the notes version loads
-% |beamernotestheme|\meta{theme}|.sty|.\ednote{MK: This is not ideal, but I am not sure
-% that I want to be able to provide the full theme functionality there.}
+% come from the the |beamer| class.
 %    \begin{macrocode}
 \bool_if:NT \c_@@_notes_bool {
-  \renewcommand\usetheme[2][]{\usepackage[#1]{beamernotestheme#2}}
+  \renewcommand\usetheme[2][]{\usepackage[#1]{beamertheme#2}}
 }
-
-
 \NewDocumentCommand \libusetheme {O{} m} {
-  \bool_if:NTF \c_@@_notes_bool {
-    \libusepackage[#1]{beamernotestheme#2}
-  }{
   \libusepackage[#1]{beamertheme#2}
-  }
 }
 
 %    \end{macrocode}
@@ -485,8 +474,6 @@
   \includegraphics[#1]{\mhpath\Gin at mhrepos{#2}}
 }
 
-
-
 \bool_if:NTF \c_@@_notes_bool {
   \setlength{\slidelogoheight}{.4cm}
 }{
@@ -506,10 +493,26 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\author}
+%   In notes mode, we redefine the |\author| macro so that it does not  disregard the
+%   optional argument (as \pkg{beamerarticle} does). We want to use it to set the source
+%   later. 
+%    \begin{macrocode}
+\bool_if:NT \c_@@_notes_bool {
+  \def\author{\@dblarg\ns at author}
+  \long\def\ns at author[#1]#2{%
+    \def\c_@@_shortauthor{#1}%
+    \def\@author{#2}
+  }
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\setsource}
-% |\source| stores the writer's name. By default it is {\it Michael Kohlhase} since he is the main user and designer of this package. |\setsource{|\meta{name}|}| can change the writer's name.
+%   |\source| stores the writer's name. By default it is {\it Michael Kohlhase} since he
+%   is the main user and designer of this package. |\setsource{|\meta{name}|}| can change
+%   the writer's name.
 %    \begin{macrocode}
-\def\source{Michael Kohlhase}% customize locally
 \newrobustcmd{\setsource}[1]{\def\source{#1}}
 %    \end{macrocode}
 % \end{macro}
@@ -521,7 +524,13 @@
 %   logo. |\setlicensing[|\meta{url}|]{|\meta{logo name}|}| is used for customization,
 %   where ||\meta{url}|| is optional.
 %    \begin{macrocode}
-\def\copyrightnotice{\footnotesize\copyright :\hspace{.3ex}{\source}}
+\def\copyrightnotice{%
+  \footnotesize\copyright :\hspace{.3ex}%
+  \ifcsname source\endcsname\source\else%
+  \ifcsname c_@@_shortauthor\endcsname\c_@@_shortauthor\else%
+  \PackageWarning{notesslides}{Author/Source~undefined~in~copyright~notice}%
+  ?source/author?\fi%
+  \fi}
 \newsavebox{\cclogo}
 \sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{stex-cc_somerights}}
 \newif\ifcchref\cchreffalse
@@ -617,69 +626,6 @@
 %    \end{macrocode}
 % \end{macro}
 % 
-% \subsection{Colors and Highlighting}\label{sec:impl:highlighting}
-%
-% We first specify sans serif fonts as the default. 
-%
-%    \begin{macrocode}
-\sffamily
-%    \end{macrocode}
-%
-% Now, we set up an infrastructure for highlighting phrases in slides. Note that we use
-% content-oriented macros for highlighting rather than directly using color markup. 
-% The first thing to to is to adapt the green so that it is dark enough for most beamers
-%    \begin{macrocode}
-\AddToHook{begindocument}{
-  \definecolor{green}{rgb}{0,.5,0}
-  \definecolor{purple}{cmyk}{.3,1,0,.17}
-}
-%    \end{macrocode}
-%
-% We customize the |\defemph|, |\symrefemph|, |\compemph|, and |\titleemph| macros with
-% colors. Furthermore we customize the |\__omtextlec| macro for the appearance of line end
-% comments in |\lec|.
-%
-%    \begin{macrocode}
-% \def\STpresent#1{\textcolor{blue}{#1}}
-\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})}
-%    \end{macrocode}
-%
-% I like to use the dangerous bend symbol for warnings, so we provide it here.
-% \begin{macro}{\textwarning}
-%   as the macro can be used quite often we put it into a box register, so that it is only
-%   loaded once. 
-%    \begin{macrocode}
-\pgfdeclareimage[width=.8em]{miko at small@dbend}{stex-dangerous-bend}
-\def\smalltextwarning{
-  \pgfuseimage{miko at small@dbend}
-  \xspace
-}
-\pgfdeclareimage[width=1.2em]{miko at dbend}{stex-dangerous-bend}
-\newrobustcmd\textwarning{
-  \raisebox{-.05cm}{\pgfuseimage{miko at dbend}}
-  \xspace
-}
-\pgfdeclareimage[width=2.5em]{miko at big@dbend}{stex-dangerous-bend}
-\newrobustcmd\bigtextwarning{
-  \raisebox{-.05cm}{\pgfuseimage{miko at big@dbend}}
-  \xspace
-}
-%    \end{macrocode}
-% \end{macro}
-% 
-%    \begin{macrocode}
-\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}
-}
-%    \end{macrocode}
-%
 % \subsection{Sectioning}
 %
 % If the |sectocframes| option is set, then we make section frames. We first define
@@ -744,33 +690,48 @@
         \ifcase\l_document_structure_section_level_int\or
           \stepcounter{part}
           \def\@@label{{\omdoc at part@kw}~\Roman{part}}
+          \addcontentsline{toc}{part}{\protect\numberline{\thepart}#2}
+          \pdfbookmark[0]{\thepart\ #2}{part.\thepart}
           \def\currentsectionlevel{\omdoc at part@kw}
         \or
           \stepcounter{chapter}
           \def\@@label{{\omdoc at chapter@kw}~\arabic{chapter}}
+          \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#2}
+          \pdfbookmark[1]{\thechapter\ #2}{chapter.\cs_if_exist:cT{thepart}\thepart.\thechapter}
           \def\currentsectionlevel{\omdoc at chapter@kw}
         \or
           \stepcounter{section}
           \def\@@label{\part at prefix\arabic{section}}
+          \addcontentsline{toc}{section}{\protect\numberline{\thesection}#2}
+          \pdfbookmark[2]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection\ #2}
+          {section.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection}
           \def\currentsectionlevel{\omdoc at section@kw}
         \or
           \stepcounter{subsection}
           \def\@@label{\part at prefix\arabic{section}.\arabic{subsection}}
+          \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#2}
+          \pdfbookmark[3]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection\ #2}
+          {subsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection}
           \def\currentsectionlevel{\omdoc at subsection@kw}
         \or
           \stepcounter{subsubsection}
           \def\@@label{\part at prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
+          \addcontentsline{toc}{subsubsection}{\protect\numberline{\thesubsubsection}#2}
+          \pdfbookmark[4]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection\ #2}
+          {subsubsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection}
           \def\currentsectionlevel{\omdoc at subsubsection@kw}
         \or
           \stepcounter{paragraph}
           \def\@@label{\part at prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}}
+          \addcontentsline{toc}{paragraph}{\protect\numberline{\theparagraph}#2}
+          \pdfbookmark[5]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection.\theparagraph\ #2}
+          {paragraph.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection.\theparagraph}
           \def\currentsectionlevel{\omdoc at paragraph@kw}
         \else
           \def\@@label{}
           \def\currentsectionlevel{\omdoc at paragraph@kw}
         \fi% end ifcase
-        \@@label%\sref at label@id\@@label
-        \quad #2%
+        \@@label\quad #2%
       }%
       \vfill%
       \end{frame}%

Modified: trunk/Master/texmf-dist/source/latex/stex/extensions/problem.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/extensions/problem.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/extensions/problem.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % \iffalse
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 \RequirePackage[hints,solutions,notes]{problem}
 
@@ -32,6 +32,7 @@
 % \maketitle
 %
 % \ifinfulldoc\else
+% \begin{documentation}
 % \begin{abstract}
 % This is the documentation for the \pkg{problem} package.
 % For a more high-level introduction, 
@@ -44,12 +45,13 @@
 % \end{abstract}
 %
 % \tableofcontents
-%
-% \input{../../doc/packages/stex-problem}
+% \begin{sfragment}{User Interface}
+%   \input{../../doc/packages/stex-problem}
+% \ednote{MK: the input does not work! it includes the commented stuff as well. }
+% \end{sfragment}
+% \end{documentation}
 % \fi
 %
-% \begin{documentation}
-% \end{documentation}
 % \begin{implementation}
 %
 % \section{The Implementation}\label{sec:implementation}
@@ -63,8 +65,9 @@
 %    \begin{macrocode}
 %<*package>
 %<@@=problems>
-\ProvidesExplPackage{problem}{2022/05/24}{3.1.0}{Semantic Markup for Problems}
-\RequirePackage{l3keys2e,stex}
+\ProvidesExplPackage{problem}{2022/09/14}{3.2.0}{Semantic Markup for Problems}
+\RequirePackage{l3keys2e}
+\RequirePackage{amssymb}% for \Box
 
 \keys_define:nn { problem / pkg }{
   notes     .default:n    = { true },
@@ -81,7 +84,11 @@
   min       .bool_set:N   = \c_@@_min_bool,
   boxed     .default:n    = { true },
   boxed     .bool_set:N   = \c_@@_boxed_bool,
-  unknown   .code:n       = {}
+  test     .default:n    = { true },
+  test     .bool_set:N   = \c_@@_test_bool,
+  unknown     .code:n       = {
+    \PassOptionsToPackage{\CurrentOption}{stex}
+  }
 }
 \newif\ifsolutions
 
@@ -91,6 +98,7 @@
 }{
   \solutionsfalse
 }
+\RequirePackage{stex}
 %    \end{macrocode}
 %
 % Then we make sure that the necessary packages are loaded (in the right versions).
@@ -117,6 +125,8 @@
 \def\prob at gnote@kw{Grading}
 \def\prob at pt@kw{pt}
 \def\prob at min@kw{min}
+\def\prob at correct@kw{Correct}
+\def\prob at wrong@kw{Wrong}
 %    \end{macrocode}
 % \end{macro}
 % 
@@ -126,16 +136,16 @@
   \ltx at ifpackageloaded{babel}{
       \makeatletter
       \clist_set:Nx \l_tmpa_clist {\bbl at loaded}
-      \clist_if_in:NnT \l_tmpa_clist {ngerman}{
+      \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{
         \input{problem-ngerman.ldf}
       }
-      \clist_if_in:NnT \l_tmpa_clist {finnish}{
+      \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{
         \input{problem-finnish.ldf}
       }
-      \clist_if_in:NnT \l_tmpa_clist {french}{
+      \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{
         \input{problem-french.ldf}
       }
-      \clist_if_in:NnT \l_tmpa_clist {russian}{
+      \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{
         \input{problem-russian.ldf}
       }
       \makeatother
@@ -178,8 +188,10 @@
 % Then we set up a counter for problems.
 % \begin{macro}{\numberproblemsin}
 %    \begin{macrocode}
-\newcounter{problem}[section]
-\newcommand\numberproblemsin[1]{\@addtoreset{problem}{#1}}
+\newcounter{sproblem}[section]
+\newcommand\numberproblemsin[1]{\@addtoreset{sproblem}{#1}}
+\def\theplainsproblem{\arabic{sproblem}}
+\def\thesproblem{\thesection.\theplainsproblem}
 %    \end{macrocode}
 % \end{macro}
 % 
@@ -200,10 +212,11 @@
     \int_if_exist:NTF \l_@@_prob_refnum_int {
       \prob at label{\int_use:N \l_@@_prob_refnum_int }
     }{
-        \prob at label\theproblem
+        \prob at label\theplainsproblem
     }
   }
 }
+\def\sproblemautorefname{\prob at problem@kw}
 %    \end{macrocode}
 % \end{macro}
 % 
@@ -216,10 +229,10 @@
   \tl_if_exist:NTF \l_@@_inclprob_title_tl {
     #2 \l_@@_inclprob_title_tl #3
   }{
-    \tl_if_exist:NTF \l_@@_prob_title_tl {
+    \tl_if_empty:NTF \l_@@_prob_title_tl {
+      #1
+    }{
       #2 \l_@@_prob_title_tl #3
-    }{
-      #1
     }
   }
 }
@@ -248,7 +261,7 @@
 \newenvironment{sproblem}[1][]{
   \_@@_prob_args:n{#1}%\sref at target%
   \@in at omtexttrue% we are in a statement (for inline definitions)
-  \stepcounter{problem}\record at problem
+  \refstepcounter{sproblem}\record at problem
   \def\current at section@level{\prob at problem@kw}
 
   \str_if_empty:NT \l_@@_prob_name_str {
@@ -315,7 +328,7 @@
     }
   }
   \stex_ref_new_doc_target:n \sproblemid
-  \stex_smsmode_do:
+  \stex_if_smsmode:TF \stex_smsmode_do: \ignorespacesandpars
 }{
   \__stex_modules_end_module:
   \stex_if_smsmode:F{
@@ -408,35 +421,18 @@
 %    \begin{macrocode}
 \keys_define:nn { problem / solution }{
   id            .str_set_x:N  = \l_@@_solution_id_str ,
-  for           .tl_set:N     = \l_@@_solution_for_tl ,
-  height        .dim_set:N    = \l_@@_solution_height_dim ,
-  creators      .clist_set:N  = \l_@@_solution_creators_clist ,
-  contributors  .clist_set:N  = \l_@@_solution_contributors_clist ,
-  srccite       .tl_set:N     = \l_@@_solution_srccite_tl
+  for           .str_set_x:N  = \l_@@_solution_for_str ,
+  type          .str_set_x:N  = \l_@@_solution_type_str ,
+  title         .tl_set:N     = \l_@@_solution_title_tl
 }
 \cs_new_protected:Nn \_@@_solution_args:n {
   \str_clear:N \l_@@_solution_id_str
-  \tl_clear:N \l_@@_solution_for_tl
-  \tl_clear:N \l_@@_solution_srccite_tl
-  \clist_clear:N \l_@@_solution_creators_clist
-  \clist_clear:N \l_@@_solution_contributors_clist
-  \dim_zero:N \l_@@_solution_height_dim
+  \str_clear:N \l_@@_solution_type_str
+  \str_clear:N \l_@@_solution_for_str
+  \tl_clear:N \l_@@_solution_title_tl
   \keys_set:nn { problem / solution }{ #1 }
 }
 %    \end{macrocode}
-% the next step is to define a helper macro that does what is needed to start a solution. 
-%    \begin{macrocode}
-\newcommand\@startsolution[1][]{
-  \_@@_solution_args:n { #1 }
-  \@in at omtexttrue% we are in a statement.
-  \bool_if:NF \c_@@_boxed_bool { \hrule }
-  \smallskip\noindent
-  {\textbf\prob at solution@kw :\enspace}
-  \begin{small}
-  \def\current at section@level{\prob at solution@kw}
-  \ignorespacesandpars
-}
-%    \end{macrocode}
 %
 % \begin{macro}{\startsolutions}
 % for the |\startsolutions| macro we use the |\specialcomment| macro from the |comment|
@@ -445,14 +441,20 @@
 %    \begin{macrocode}
 \box_new:N \l_@@_solution_box
 \newenvironment{solution}[1][]{
+  \_@@_solution_args:n{#1}
   \stex_html_backend:TF{
     \stex_if_do_html:T{
       \begin{stex_annotate_env}{solution}{}
+        \str_if_empty:NF \l_@@_solution_type_str {
+          \par\noindent
+          \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{}
+        }
+        \noindent\textbf{Solution\tl_if_empty:NF\l_@@_solution_title_tl{~(\l_@@_solution_title_tl)}: }~
     }
   }{
     \setbox\l_@@_solution_box\vbox\bgroup
       \par\smallskip\hrule\smallskip
-      \noindent\textbf{Solution:}~
+      \noindent\textbf{Solution\tl_if_empty:NF\l_@@_solution_title_tl{~(\l_@@_solution_title_tl)}: }~
   }
 }{
   \stex_html_backend:TF{
@@ -463,6 +465,7 @@
     \smallskip\hrule
     \egroup
     \bool_if:NT \c_@@_solutions_bool {
+      \strut\par\noindent 
       \box\l_@@_solution_box
     }
   }
@@ -470,6 +473,7 @@
 
 \newcommand\startsolutions{
   \bool_set_true:N \c_@@_solutions_bool
+  \solutionstrue
 %  \specialcomment{solution}{\@startsolution}{
 %    \bool_if:NF \c_@@_boxed_bool {
 %      \hrule\medskip
@@ -485,19 +489,10 @@
 % 
 % \begin{macro}{\stopsolutions}
 %    \begin{macrocode}
-\newcommand\stopsolutions{\bool_set_false:N \c_@@_solutions_bool}%\excludecomment{solution}}
+\newcommand\stopsolutions{\bool_set_false:N \c_@@_solutions_bool \solutionsfalse}%\excludecomment{solution}}
 %    \end{macrocode}
 % \end{macro}
-% 
-% so it only remains to start/stop solutions depending on what option was specified.
 %
-%    \begin{macrocode}
-\ifsolutions
-  \startsolutions
-\else
-  \stopsolutions
-\fi
-%    \end{macrocode}
 %
 % \begin{environment}{exnote}
 %    \begin{macrocode}
@@ -550,8 +545,10 @@
 }
 %    \end{macrocode}
 % \end{environment}
+%
+% \subsection{Markup for Added Value Services}\label{sec:impl:avs}
 % 
-% \subsection{Multiple Choice Blocks}\label{sec:impl:mcq}
+% \subsubsection{Multiple Choice Blocks}\label{sec:impl:mcq}
 %
 % \begin{environment}{mcb}
 %   \ednote{MK: maybe import something better here from a dedicated MC package}
@@ -579,8 +576,8 @@
   T         .bool_set:N   = \l_@@_mcc_t_bool ,
   F         .default:n    = { false } ,
   F         .bool_set:N   = \l_@@_mcc_f_bool ,
-  Ttext     .tl_set:N     = \l_@@_mcc_Ttext_str ,
-  Ftext     .tl_set:N     = \l_@@_mcc_Ftext_str
+  Ttext     .tl_set:N     = \l_@@_mcc_Ttext_tl ,
+  Ftext     .tl_set:N     = \l_@@_mcc_Ftext_tl
 }
 \cs_new_protected:Nn \l_@@_mcc_args:n {
   \str_clear:N \l_@@_mcc_id_str
@@ -596,12 +593,12 @@
 %
 % \begin{macro}{\mcc}
 %    \begin{macrocode}
-\def\mccTrueText{\textbf{(true)~}}
-\def\mccFalseText{\textbf{(false)~}}
+\def\mccTrueText{\textbf{\prob at correct@kw!~}}
+\def\mccFalseText{\textbf{\prob at wrong@kw!~}}
 \newcommand\mcc[2][]{
   \l_@@_mcc_args:n{ #1 }
   \item[$\Box$] #2
-  \ifsolutions
+  \bool_if:NT \c_@@_solutions_bool{
     \\
     \bool_if:NT \l_@@_mcc_t_bool {
       \tl_if_empty:NTF\l_@@_mcc_Ttext_tl\mccTrueText\l_@@_mcc_Ttext_tl
@@ -610,13 +607,27 @@
       \tl_if_empty:NTF\l_@@_mcc_Ttext_tl\mccFalseText\l_@@_mcc_Ftext_tl
     }
     \tl_if_empty:NF \l_@@_mcc_feedback_tl {
-      \emph{(\l_@@_mcc_feedback_tl)}
+      \emph{\l_@@_mcc_feedback_tl}
     }
-  \fi
+  }
 } %solutions
 %    \end{macrocode}
 % \end{macro}
+%
+% \subsubsection{Filling in Concrete Solutions}
 % 
+% \begin{macro}{\includeproblem}
+%   This is embarrasingly simple, but can grow over time. 
+%    \begin{macrocode}
+\newcommand\fillinsol[2][]{%
+  \def\@test{#1}
+  \quad%
+  \ifsolutions\textcolor{red}{#1!}\else%
+  \fbox{\ifx\@test\@empty\phantom{\huge{21}}\else\hspace{#1}\fi}%
+  \fi}
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{Including Problems}\label{sec:impl:includeproblem}
 %
 % \begin{macro}{\includeproblem}
@@ -780,15 +791,45 @@
 %</package>
 %    \end{macrocode}
 % \end{macro}
+%
+% \subsection{Testing and Spacing}
+%
+% \begin{macro}{\testspace}
+%    \begin{macrocode}
+\newcommand\testspace[1]{\bool_if:NT \c_@@_boxed_bool {\vspace*{#1}}}
+%    \end{macrocode}
+% \end{macro}
+% 
+% \begin{macro}{\testnewpage}
+%    \begin{macrocode}
+\newcommand\testnewpage{\bool_if:NT \c_@@_boxed_bool  {\newpage}}
+%    \end{macrocode}
+% \end{macro}
+% 
+% \begin{macro}{\testemptypage}
+%    \begin{macrocode}
+\newcommand\testemptypage[1][]{%
+\bool_if:NT \c_@@_boxed_bool {\begin{center}\hwexam at testemptypage@kw\end{center}\vfill\eject\else}}
+%    \end{macrocode}
+% \end{macro}
+% 
+% \begin{macro}{\test*space}
+%    \begin{macrocode}
+\newcommand\testsmallspace{\testspace{1cm}}
+\newcommand\testmedspace{\testspace{2cm}}
+\newcommand\testbigspace{\testspace{3cm}}
+%    \end{macrocode}
+% \end{macro}
+%
 % \end{implementation}
 % \ifinfulldoc\else\printbibliography\fi
 \endinput
-% LocalWords:  GPL structuresharing STR dtx pts keyval xcomment CPERL DefKeyVal iffalse
 %%% Local Variables: 
 %%% mode: doctex
 %%% TeX-master: t
 %%% End: 
 % \fi
+% LocalWords:  GPL structuresharing STR dtx pts keyval xcomment CPERL DefKeyVal iffalse 
 % LocalWords:  RequirePackage Semiverbatim DefEnvironment OptionalKeyVals soln texttt baz
 % LocalWords:  exnote DefConstructor inclprob NeedsTeXFormat omd.sty textbackslash exfig
 %  LocalWords:  stopsolution fileversion filedate maketitle setcounter tocdepth newpage

Modified: trunk/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -67,7 +67,7 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\ProvidesExplPackage{tikzinput}{2022/05/24}{3.1.0}{tikzinput package}
+\ProvidesExplPackage{tikzinput}{2022/09/14}{3.2.0}{tikzinput package}
 \RequirePackage{l3keys2e}
 
 \keys_define:nn { tikzinput } {
@@ -130,7 +130,7 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\ProvidesExplPackage{stex-tikzinput}{2022/05/24}{3.1.0}{stex-tikzinput}
+\ProvidesExplPackage{stex-tikzinput}{2022/09/14}{3.2.0}{stex-tikzinput}
 \RequirePackage{stex}
 \RequirePackage{tikzinput}
 
@@ -207,5 +207,14 @@
 %
 % \PrintIndex
 
-%  LocalWords:  bibfolder jobname.dtx tikzinput.dtx usetikzlibrary Gin at ewidth Gin at eheight
-%  LocalWords:  resizebox ctikzinput mhtikzinput Gin at mhrepos mhpath
+% \endinput
+% Local Variables:
+% mode: doctex
+% TeX-master: t
+% End:
+
+%  LocalWords:  libfolder jobname.dtx tikzinput.dtx usetikzlibrary Gin at ewidth Gin at eheight
+%  LocalWords:  ctikzinput mhpath pgfkeys at spdef pgfutil at empty 1 at atcode catcode l_tmpa_str
+%  LocalWords:  pgfutil at InputIfFileExists libusetikzlibrary msg_error:nnn notinarchive
+%  LocalWords:  seq_clear:N seq_set_eq:NN l_tmpa_seq c_stex_mathhub_seq seq_set_split:NnV
+%  LocalWords:  l_tmpb_seq seq_if_empty_p:N tikzlibrary seq_put_right:No seq_pop_left:NN

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-basics.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-basics.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-basics.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -150,7 +150,7 @@
 %%%%%%%%%%%%%   basics.dtx   %%%%%%%%%%%%%
 
 \RequirePackage{expl3,l3keys2e}
-\ProvidesExplClass{stex}{2022/05/24}{3.1.0}{sTeX document class}
+\ProvidesExplClass{stex}{2022/09/14}{3.2.0}{sTeX document class}
 
 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{stex}}
 \ProcessOptions
@@ -198,7 +198,7 @@
 %%%%%%%%%%%%%   basics.dtx   %%%%%%%%%%%%%
 
 \RequirePackage{expl3,l3keys2e,ltxcmds}
-\ProvidesExplPackage{stex}{2022/05/24}{3.1.0}{sTeX package}
+\ProvidesExplPackage{stex}{2022/09/14}{3.2.0}{sTeX package}
 
 \bool_if_exist:NF \c_stex_document_class_bool {
   \bool_set_false:N \c_stex_document_class_bool
@@ -205,7 +205,7 @@
   \RequirePackage{standalone}
 }
 
-\message{^^J*~This~is~sTeX~version~3.1.0~*^^J}
+\message{^^J*~This~is~sTeX~version~3.2.0~*^^J}
 
 %\RequirePackage{morewrites}
 %\RequirePackage{amsmath}
@@ -287,7 +287,7 @@
     \msg_redirect_module:nnn{ stex }{ none }{ term }
 }{
   \clist_map_inline:Nn \c_stex_debug_clist {
-    \msg_redirect_name:nnn{ stex }{ debug / ##1 }{ term }
+    \msg_redirect_name:nnn{ stex }{ debug / #1 }{ term }
   }
 }
 
@@ -367,14 +367,26 @@
 %  the \latexml-implementations resort to perl bindings.
 %
 %    \begin{macrocode}
+\ifcsname if at rustex\endcsname\else
+  \expandafter\newif\csname if at rustex\endcsname
+  \@rustexfalse
+\fi
+\ifcsname if at latexml\endcsname\else
+  \expandafter\newif\csname if at latexml\endcsname
+  \@latexmlfalse
+\fi
 \tl_if_exist:NF\stex at backend{
-  \ifcsname if at rustex\endcsname
+  \if at rustex
     \def\stex at backend{rustex}
   \else
-    \ifcsname if at latexml\endcsname
+    \if at latexml
       \def\stex at backend{latexml}
     \else
-      \def\stex at backend{pdflatex}
+      \cs_if_exist:NTF\HCode{
+        \def\stex at backend{tex4ht}
+      }{
+        \def\stex at backend{pdflatex}
+      }
     \fi
   \fi
 }
@@ -482,6 +494,7 @@
     }
   }
 }
+
 %    \end{macrocode}
 %
 % \subsection{Persistence}

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-features.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-features.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-features.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -385,6 +385,9 @@
       { \l_stex_import_ns_str } { \l_stex_import_archive_str } 
       { \l_stex_import_path_str } { \l_stex_import_name_str }
   }
+  \exp_args:Nx \stex_add_import_to_current_module:n{
+    \l_stex_import_ns_str ? \l_stex_import_name_str
+  }
   
   \seq_map_inline:Nn \l_@@_copymodule_modules_seq {
     \seq_map_inline:cn {c_stex_module_##1_constants}{
@@ -594,8 +597,12 @@
   \str_clear:N \l_@@_name_str
   \keys_set:nn { stex / features / structure } { #1 }
 }
-
 \NewDocumentEnvironment{mathstructure}{m O{}}{
+  \begin{mathstructure_inner}{#1}[#2]
+    \stex_smsmode_do:
+    \ignorespacesandpars
+  }{\end{mathstructure_inner}}
+\NewDocumentEnvironment{mathstructure_inner}{m O{}}{
   \_@@_structure_args:n { #2 }
   \str_if_empty:NT \l_@@_name_str {
     \str_set:Nx \l_@@_name_str { #1 }
@@ -617,7 +624,6 @@
   \exp_args:Nnnx
   \begin{structural_feature_module}{ structure }
     { \l_@@_name_str }{}
-  \stex_smsmode_do:
 }{
   \end{structural_feature_module}
   \_stex_reset_up_to_module:n \l_stex_last_feature_str
@@ -696,7 +702,8 @@
   \seq_map_inline:Nn \l_stex_all_modules_seq {
     \prop_if_exist:cT {c_stex_module_##1_structures} {
       \prop_map_inline:cn {c_stex_module_##1_structures} {
-        \str_if_eq:eeT { \l_tmpa_str }{ \str_range:nnn {##1?####1}{-\l_tmpa_int}{-1}}{
+        \exp_args:No \str_if_eq:nnT \l_tmpa_str {####1}{
+        %\str_if_eq:eeT { \l_tmpa_str }{ \str_range:nnn {##1?####1}{-\l_tmpa_int}{-1}}{
           \prop_map_break:n{\seq_map_break:n{
             \tl_set:Nn \l_tmpa_tl {
               \str_set:Nn \l_stex_get_structure_str {##1?####1}
@@ -716,6 +723,12 @@
 % \begin{macro}{\instantiate}
 %    \begin{macrocode}
 
+\NewDocumentEnvironment{usestructure}{m}{
+  \stex_get_structure:n {#1}
+  \exp_args:Nnx \stex_debug:nn{features}{using~structure:~\l_stex_get_structure_module_str}
+  \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str
+}{}
+
 \keys_define:nn { stex / instantiate } {
   name        .str_set_x:N  = \l_@@_name_str
 }
@@ -724,6 +737,37 @@
   \keys_set:nn { stex / instantiate } { #1 }
 }
 
+\NewDocumentEnvironment{extstructure}{m m O{}}{
+  \begin{mathstructure_inner}{#1}[#3]
+    \seq_set_split:Nnn\_@@_extstructure_imports_seq,{#2}
+    \seq_map_inline:Nn\_@@_extstructure_imports_seq {
+      \stex_get_structure:n {##1}
+      \exp_args:Nnx \stex_debug:nn{features}{importing~structure:~\l_stex_get_structure_module_str{}~into~\l_stex_current_module_str}
+      \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str
+      \stex_if_smsmode:F {
+        \stex_annotate_invisible:nnn 
+          {import} {\l_stex_get_structure_module_str} {}
+      }
+      \exp_args:Nx \stex_add_import_to_current_module:n {
+        \l_stex_get_structure_module_str
+      }
+      \exp_args:Nx \stex_add_to_current_module:n {
+        \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str
+      }
+    }
+    \stex_smsmode_do:
+    \ignorespacesandpars
+}{
+  \end{mathstructure_inner}
+}
+
+\NewDocumentEnvironment{extstructure*}{m m O{}}{
+  % TODO
+  \begin{extstructure}{#1}{#2}[#3]
+}{
+  \end{extstructure}
+}
+
 \NewDocumentCommand \instantiate {m O{} m m O{}}{
   \begingroup
     \stex_get_structure:n {#3}
@@ -775,7 +819,8 @@
           name   = \l_tmpa_str ,
           args   = \prop_item:cn {l_stex_symdecl_##1_prop}{args} ,
           arity  = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} ,
-          assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs}
+          assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} ,
+          argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}}
         }
         \seq_clear:c {l_stex_symdecl_\l_stex_current_module_str?\l_tmpa_str _notations}
       }
@@ -872,7 +917,7 @@
 }
 
 \cs_new_protected:Nn \_@@_symbolorvar_from_string:n {
-  \prop_if_exist:cTF {l_stex_variable_#1 _prop}{
+  \prop_if_exist:cTF {l_stex_symdecl_var://#1 _prop}{
     \bool_set_true:N \l_stex_symbol_or_var_bool
     \str_set:Nn \l_stex_get_symbol_uri_str { #1 }
   }{
@@ -935,12 +980,12 @@
           \bool_if:NTF \l_stex_symbol_or_var_bool {
             \exp_args:Nxx \str_if_eq:nnF 
               {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}}
-              {\prop_item:cn{l_stex_variable_\l_stex_get_symbol_uri_str _prop}{args}}{
+              {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}}{
               \msg_error:nnxxxx{stex}{error/incompatible}
                 {\l_@@_dom_str}
                 {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}}
                 {\l_stex_get_symbol_uri_str}
-                {\prop_item:cn{l_stex_variable_\l_stex_get_symbol_uri_str _prop}{args}}
+                {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}}
             }
             \prop_put:Nxx \l_tmpa_prop {\seq_item:Nn \l_tmpb_seq 1} {\stex_invoke_variable:n {\l_stex_get_symbol_uri_str}}
           }{
@@ -974,11 +1019,12 @@
         }
 
         \exp_args:NNx \tl_gput_right:Nn \g_@@_aftergroup_tl {
-          \prop_set_from_keyval:cn { l_stex_variable_ \l_tmpa_str _prop}{
+          \prop_set_from_keyval:cn { l_stex_symdecl_ var://\l_tmpa_str _prop}{
             name   = \l_tmpa_str ,
             args   = \prop_item:cn {l_stex_symdecl_##1_prop}{args} ,
             arity  = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} ,
-            assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs}
+            assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} ,
+            argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}} ,
           }
           \cs_set_eq:cc {stex_var_notation_\l_tmpa_str _cs}
             {g_@@_tmpa_\l_tmpa_str _cs}

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-inheritance.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-inheritance.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-inheritance.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -240,7 +240,9 @@
     sexample,
     sassertion,
     sparagraph,
-    mathstructure
+    mathstructure,
+    extstructure,
+    extstructure*
   }
 }
 %    \end{macrocode}
@@ -643,14 +645,11 @@
   \stex_debug:nn{modules}{Importing~module:~
     \l_stex_import_ns_str ? \l_stex_import_name_str
   }
-  \stex_import_require_module:nnnn 
-  { \l_stex_import_ns_str } { \l_stex_import_archive_str } 
-  { \l_stex_import_path_str } { \l_stex_import_name_str }
   \stex_if_smsmode:F {
     \stex_annotate_invisible:nnn 
       {import} {\l_stex_import_ns_str ? \l_stex_import_name_str} {}
   }
-  \exp_args:Nx \stex_add_to_current_module:n {
+  \stex_execute_in_module:x {
     \stex_import_require_module:nnnn 
     { \l_stex_import_ns_str } { \l_stex_import_archive_str } 
     { \l_stex_import_path_str } { \l_stex_import_name_str }

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-mathhub.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-mathhub.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-mathhub.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -245,6 +245,7 @@
 % \begin{macro}{\stex_path_from_string:Nn}
 %    \begin{macrocode}
 \cs_new_protected:Nn \stex_path_from_string:Nn {
+  \stex_debug:nn{files}{#2}
   \str_set:Nx \l_tmpa_str { #2 }
   \str_if_empty:NTF \l_tmpa_str {
     \seq_clear:N #1
@@ -260,6 +261,7 @@
     }
     \stex_path_canonicalize:N #1
   }
+  \stex_debug:nn{files}{Yields: \stex_path_to_string:N#1}
 }
 
 %    \end{macrocode}
@@ -438,6 +440,7 @@
   }
   \seq_gset_eq:NN\g_stex_currentfile_seq\g_stex_currentfile_seq
   \exp_args:NNo\seq_gpush:Nn\g_@@_stack\g_stex_currentfile_seq
+  \stex_get_document_uri:
 }
 %    \end{macrocode}
 % \end{macro}
@@ -454,6 +457,7 @@
     \seq_get:NN\g_@@_stack\l_tmpa_seq
     \seq_gset_eq:NN\g_stex_currentfile_seq\l_tmpa_seq
   }
+  \stex_get_document_uri:
 }
 %    \end{macrocode}
 % \end{macro}
@@ -462,7 +466,11 @@
 %
 %    \begin{macrocode}
 \AddToHook{file/before}{
-  \stex_filestack_push:n{\CurrentFilePath/\CurrentFile}
+  \tl_if_empty:NTF\CurrentFilePath{
+    \stex_filestack_push:n{\CurrentFile}
+  }{
+    \stex_filestack_push:n{\CurrentFilePath/\CurrentFile}
+  }
 }
 \AddToHook{file/after}{
   \stex_filestack_pop:
@@ -483,6 +491,7 @@
     \begingroup\escapechar=-1\catcode`\\=12
     \exp_args:Nx\stex_kpsewhich:n{-expand-var~\c_percent_str MATHHUB\c_percent_str}
     \exp_args:NNx\str_replace_all:Nnn\l_stex_kpsewhich_return_str{\c_backslash_str}/
+    \exp_args:NNx\str_if_eq:onT\l_stex_kpsewhich_return_str{\c_percent_str MATHHUB\c_percent_str}{\str_clear:N\l_stex_kpsewhich_return_str}
     \exp_args:Nnx\use:nn{\endgroup}{\str_set:Nn\exp_not:N\l_stex_kpsewhich_return_str{\l_stex_kpsewhich_return_str}}
   }{
     \stex_kpsewhich:n{-var-value~MATHHUB}
@@ -498,15 +507,15 @@
     }{
       \stex_kpsewhich:n{-var-value~HOME}
     }
-    \ior_open:NnT \l_tmpa_ior{\l_stex_kpsewhich_return_str / .stex / mathhub.path}{
+    \ior_open:NnT \g_tmpa_ior{\l_stex_kpsewhich_return_str / .stex / mathhub.path}{
       \begingroup\escapechar=-1\catcode`\\=12
-      \ior_str_get:NN \l_tmpa_ior \l_tmpa_str
+      \ior_str_get:NN \g_tmpa_ior \l_tmpa_str
       \sys_if_platform_windows:T{
         \exp_args:NNx\str_replace_all:Nnn\l_tmpa_str{\c_backslash_str}/
       }
       \str_gset_eq:NN \c_stex_mathhub_str\l_tmpa_str
       \endgroup
-      \ior_close:N \l_tmpa_ior
+      \ior_close:N \g_tmpa_ior
     }
   }
   \str_if_empty:NTF\c_stex_mathhub_str{

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-metatheory.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-metatheory.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-metatheory.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-modules.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-modules.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-modules.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -857,7 +857,21 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{environment}{mmtinterface}
 %    \begin{macrocode}
+\NewDocumentEnvironment { mmtinterface } { O{} m m } {
+  \begin{smodule}[#1]{#3}
+    \str_set:Nx \l_stex_module_mmtfor_str {#2}
+    \MMTinclude{#2}
+    \stex_reactivate_macro:N \mmtdecl
+    \stex_reactivate_macro:N \mmtdef
+}{
+  \end{smodule}
+}
+%    \end{macrocode}
+% \end{environment}
+%
+%    \begin{macrocode}
 %</package>
 %    \end{macrocode}
 %

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-others.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-others.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-others.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -97,6 +97,8 @@
     \exp_args:Nx \stex_set_current_repository:n { \l_tmpa_str }
   }
 }
+
+\stex_get_document_uri:
 %    \end{macrocode}
 %
 %

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-proofs.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-proofs.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-proofs.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -87,7 +87,9 @@
   title       .tl_set:N     = \spftitle,
   continues   .tl_set:N     = \l_@@_spf_continues_tl,
   functions   .tl_set:N     = \l_@@_spf_functions_tl,
-  method      .tl_set:N     = \l_@@_spf_method_tl
+  term        .tl_set:N     = \l_@@_spf_term_tl,
+  method      .tl_set:N     = \l_@@_spf_method_tl,
+  hide        .bool_set:N   = \l_@@_spf_hide_bool  
 }
 \cs_new_protected:Nn \_@@_spf_args:n {
 	\str_clear:N \spfid
@@ -97,11 +99,13 @@
 	\str_clear:N \spftype
 	\tl_clear:N \spftitle
 	\tl_clear:N \l_@@_spf_continues_tl
+	\tl_clear:N \l_@@_spf_term_tl
 	\tl_clear:N \l_@@_spf_functions_tl
 	\tl_clear:N \l_@@_spf_method_tl
-  \bool_set_false:N \l_@@_inc_counter_bool
+  \bool_set_false:N \l_@@_spf_hide_bool
 	\keys_set:nn { stex / spf }{ #1 }
 }
+\bool_set_true:N \l_@@_inc_counter_bool
 %    \end{macrocode}
 %
 % \begin{macro}{\c_@@_flow_str}
@@ -275,168 +279,145 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{spfeq}
-%   This is very similar to |\spfsketch|, but uses a computation array\ednote{This should
-%   really be more like a tabular with an ensuremath in it. or invoke text on the last
-%   column}\ednote{document above}
+% \begin{macro}{\_@@_maybe_comment:,\_@@_maybe_comment_end:,\_@@_start_comment:}
 %    \begin{macrocode}
-\newenvironment{spfeq}[2][]{
-  \_@@_spf_args:n{#1}
-  \let \premise \stex_proof_premise:
-  \stex_if_smsmode:TF {
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }{
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l_@@_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
-        }
-      }
-    }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{spfeq}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
-    }
+\bool_set_false:N \l_@@_in_spfblock_bool
 
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_clear:N \l_tmpa_tl
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \tl_if_exist:cT {_@@_spfeq_##1_start:}{
-        \tl_set:Nn \l_tmpa_tl {\use:c{_@@_spfeq_##1_start:}}
-      }
-      \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} {
-        \tl_set:Nn \l_tmpa_tl {\use:n{}}
-      }
-    }
-    \tl_if_empty:NTF \l_tmpa_tl {
-      \_@@_spfeq_start:
-    }{
-      \l_tmpa_tl
-    }{~#2}
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-    \begin{displaymath}\begin{array}{rcll}
+\cs_new_protected:Nn \_@@_maybe_comment: {
+  \bool_if:NF \l_@@_in_spfblock_bool {
+    \par \setbox \l_tmpa_box \vbox \bgroup \everypar{\_@@_start_comment:}
   }
-  \stex_smsmode_do:
-}{
-  \stex_if_smsmode:F {
-    \end{array}\end{displaymath}
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_clear:N \l_tmpa_tl
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \tl_if_exist:cT {_@@_spfeq_##1_end:}{
-        \tl_set:Nn \l_tmpa_tl {\use:c{_@@_spfeq_##1_end:}}
-      }
-    }
-    \tl_if_empty:NTF \l_tmpa_tl {
-      \_@@_spfeq_end:
-    }{
-      \l_tmpa_tl
-    }
-    \end{stex_annotate_env}
-  }
 }
-
-\cs_new_protected:Nn \_@@_spfeq_start: {
-  \titleemph{
-    \tl_if_empty:NTF \spftitle {
-      \spf at proof@kw
-    }{
-      \spftitle
-    }
-  }:
+\cs_new_protected:Nn \_@@_maybe_comment_end: {
+  \bool_if:NF \l_@@_in_spfblock_bool { \egroup }
 }
-\cs_new_protected:Nn \_@@_spfeq_end: {\sproofend}
-
-\newcommand\stexpatchspfeq[3][] {
-    \str_set:Nx \l_tmpa_str{ #1 }
-    \str_if_empty:NTF \l_tmpa_str {
-      \tl_set:Nn \_@@_spfeq_start: { #2 }
-      \tl_set:Nn \_@@_spfeq_end: { #3 }
-    }{
-      \exp_after:wN \tl_set:Nn \csname _@@_spfeq_#1_start:\endcsname{ #2 }
-      \exp_after:wN \tl_set:Nn \csname _@@_spfeq_#1_end:\endcsname{ #3 }
-    }
+\cs_new_protected:Nn \_@@_start_comment: {
+  \csname @ @ par\endcsname\egroup\item[]\bgroup\stexcommentfont
 }
 
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\stexcommentfont}
+%    \begin{macrocode}
+\cs_new_protected:Npn \stexcommentfont {
+  \small\itshape
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{environment}{sproof}
 %    In this environment, we initialize the proof depth counter |\count10| to 10, and set
 %    up the description environment that will take the proof steps. At the end of the
 %    proof, we position the proof end into the last line.
 %    \begin{macrocode}
-\newenvironment{sproof}[2][]{
-  \let \premise \stex_proof_premise:
+\cs_new_protected:Nn \_@@_start_env:nnn {
+  \seq_clear:N \l_tmpa_seq
+  \clist_map_inline:Nn \l_@@_spf_for_clist {
+    \tl_if_empty:nF{ ##1 }{
+      \stex_get_symbol:n { ##1 }
+      \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
+        \l_stex_get_symbol_uri_str
+      }
+    }
+  }
+  \exp_args:Nnnx
+  \begin{stex_annotate_env}{#1}{\seq_use:Nn \l_tmpa_seq {,}}
+  \str_if_empty:NF \spftype {
+    \stex_annotate_invisible:nnn{type}{\spftype}{}
+  }
+  #3 {~\stex_annotate:nnn{spftitle}{}{#2}}
+  \str_if_empty:NF \spfid {
+    \stex_ref_new_doc_target:n \spfid
+  }
+  \begin{stex_annotate_env}{spfbody}{\bool_if:NTF \l_@@_spf_hide_bool {false}{true}}
+  \bool_if:NT \l_@@_spf_hide_bool{
+    \stex_html_backend:F{\setbox\l_tmpa_box\vbox\bgroup}
+  }
+  \begin{list}{}{
+    \setlength\topsep{0pt}
+    \setlength\parsep{0pt}
+    \setlength\rightmargin{0pt}
+    
+  }\_@@_maybe_comment:
+}
+\cs_new_protected:Nn \_@@_end_env:n {
+  \stex_if_smsmode:F{
+    \_@@_maybe_comment_end:
+    \end{list}  
+    \bool_if:NT \l_@@_spf_hide_bool{
+      \stex_html_backend:F{\egroup}
+    }
+    \clist_set:No \l_tmpa_clist \spftype
+    #1
+    \end{stex_annotate_env}
+    \end{stex_annotate_env}
+  }
+}
+\NewDocumentEnvironment{sproof}{s O{} m}{
   \intarray_gzero:N \l_@@_counter_intarray
   \intarray_gset:Nnn \l_@@_counter_intarray 1 1
-  \_@@_spf_args:n{#1}
+  \stex_reactivate_macro:N \yield
+  \stex_reactivate_macro:N \eqstep
+  \stex_reactivate_macro:N \assumption
+  \stex_reactivate_macro:N \conclude
+  \stex_reactivate_macro:N \spfstep
+  \_@@_spf_args:n{#2}
   \stex_if_smsmode:TF {
     \str_if_empty:NF \spfid {
       \stex_ref_new_doc_target:n \spfid
     }
   }{
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l_@@_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
+    \_@@_start_env:nnn{sproof}{#3}{
+      \clist_set:No \l_tmpa_clist \spftype
+      \tl_clear:N \l_tmpa_tl
+      \clist_map_inline:Nn \l_tmpa_clist {
+        \tl_if_exist:cT {_@@_sproof_##1_start:}{
+          \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_start:}}
         }
+        \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} {
+          \tl_set:Nn \l_tmpa_tl {\use:n{}}
+        }
       }
+      \tl_if_empty:NTF \l_tmpa_tl {
+        \_@@_sproof_start:
+      }{
+        \l_tmpa_tl
+      }
     }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{sproof}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
+  }
+  \stex_smsmode_do:
+}{\_@@_end_env:n{
+  \tl_clear:N \l_tmpa_tl
+  \clist_map_inline:Nn \l_tmpa_clist {
+    \tl_if_exist:cT {_@@_sproof_##1_end:}{
+      \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_end:}}
     }
-
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_clear:N \l_tmpa_tl
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \tl_if_exist:cT {_@@_sproof_##1_start:}{
-        \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_start:}}
-      }
-      \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} {
-        \tl_set:Nn \l_tmpa_tl {\use:n{}}
-      }
-    }
-    \tl_if_empty:NTF \l_tmpa_tl {
-      \_@@_sproof_start:
-    }{
-      \l_tmpa_tl
-    }{~#2}
+  }
+  \tl_if_empty:NTF \l_tmpa_tl {
+    \_@@_sproof_end:
+  }{
+    \l_tmpa_tl
+  }
+}}
+\NewDocumentEnvironment{subproof}{s O{} m}{
+  \_@@_spf_args:n{#2}
+  \stex_if_smsmode:TF {
     \str_if_empty:NF \spfid {
       \stex_ref_new_doc_target:n \spfid
     }
-    \begin{description}
+  }{
+    \_@@_start_env:nnn{subproof}{\item[\sproofnumber]\ignorespacesandpars #3}{}
   }
+  \_@@_add_counter:
   \stex_smsmode_do:
-}{
-  \stex_if_smsmode:F{
-    \end{description}
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_clear:N \l_tmpa_tl
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \tl_if_exist:cT {_@@_sproof_##1_end:}{
-        \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_end:}}
-      }
-    }
-    \tl_if_empty:NTF \l_tmpa_tl {
-      \_@@_sproof_end:
-    }{
-      \l_tmpa_tl
-    }
-    \end{stex_annotate_env}
+}{\_@@_remove_counter:\_@@_end_env:n{}  
+  \bool_if:NT \l_@@_inc_counter_bool {
+    \_@@_inc_counter:
   }
+  \aftergroup\_@@_maybe_comment:
 }
+\AddToHook{env/subproof/before}{\_@@_maybe_comment_end:}
 
 \cs_new_protected:Nn \_@@_sproof_start: {
   \par\noindent\titleemph{
@@ -461,290 +442,103 @@
 }
 %    \end{macrocode}
 % \end{environment}
-% 
-% \begin{macro}{\spfidea}
+%
+% \begin{macro}{\pstep,\conclude,\assumption,\have,\eqstep}
 %    \begin{macrocode}
-\newcommand\spfidea[2][]{
-  \_@@_spf_args:n{#1}
-  \titleemph{
-    \tl_if_empty:NTF \spftype {Proof~Idea}{
-      \spftype
-    }:
-  }~#2
-  \sproofend
+
+\keys_define:nn { stex / spfsteps } {
+  id          .str_set_x:N  = \spfstepid,
+  for         .clist_set:N  = \l_@@_spf_for_clist ,
+  type        .str_set_x:N  = \spftype,
+  title       .tl_set:N     = \spftitle,
+  method      .tl_set:N     = \l_@@_spf_method_tl,
+  term        .tl_set:N     = \l_@@_spf_term_tl
 }
-%    \end{macrocode}
-% \end{macro}
-%
-% The next two environments (proof steps) and comments, are mostly semantical, they take
-% |KeyVal| arguments that specify their semantic role. In draft mode, they read these
-% values and show them. If the surrounding proof had |display=flow|, then no new |\item| is
-% generated, otherwise it is. In any case, the proof step number (at the current level) is
-% incremented.
-% \begin{environment}{spfstep}
-%    \begin{macrocode}
-\newenvironment{spfstep}[1][]{
-  \_@@_spf_args:n{#1}
-  \stex_if_smsmode:TF {
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }{
-    \@in at omtexttrue
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_set:Nn \l_tmpa_tl {
-      \item[\sproofnumber]
-      \bool_set_true:N \l_@@_inc_counter_bool
-    }
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} {
-        \tl_clear:N \l_tmpa_tl
+\cs_new_protected:Nn \_@@_spfstep_args:n {
+	\str_clear:N \spfstepid
+	\clist_clear:N \l_@@_spf_for_clist
+	\str_clear:N \spftype
+	\tl_clear:N \l_@@_spf_method_tl
+	\tl_clear:N \l_@@_spf_term_tl
+  %\bool_set_false:N \l_@@_inc_counter_bool
+	\keys_set:nn { stex / spfsteps }{ #1 }
+}
+
+\cs_new_protected:Nn \_@@_make_step_macro:Nnnnn {
+  \NewDocumentCommand #1 {s O{} +m} {
+    \_@@_maybe_comment_end:
+
+    \_@@_spfstep_args:n{##2}
+    \stex_annotate:nnn{spfstep}{#2}{ 
+      \tl_if_empty:NF \l_@@_spf_term_tl {
+        \stex_annotate_invisible:nnn{spfyield}{}{$\l_@@_spf_term_tl$}
       }
-    }
-    \l_tmpa_tl
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l_@@_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
-        }
+      \bool_if:NTF \l_@@_in_spfblock_bool {
+        #4
+      }{
+        \item[\IfBooleanTF ##1 {}{#3}]
       }
+      \ignorespacesandpars ##3
     }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{spfstep}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
-    }
-    \tl_if_empty:NF \spftitle {
-      {(\titleemph{\spftitle})\enspace}
-    }
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
+    \bool_if:NF \l_@@_in_spfblock_bool { \IfBooleanTF ##1 {}{ #5 } }
+    \_@@_maybe_comment:
   }
-  \stex_smsmode_do:
-  \ignorespacesandpars
-}{
-  \bool_if:NT \l_@@_inc_counter_bool {
-    \_@@_inc_counter:
-  }
-  \stex_if_smsmode:F {
-    \end{stex_annotate_env}
-  }
+  \stex_deactivate_macro:Nn #1 {sproof~environments}
 }
-%    \end{macrocode}
-% \end{environment}
-%
-% \begin{environment}{spfcomment}
-%    \begin{macrocode}
-\newenvironment{spfcomment}[1][]{
-  \_@@_spf_args:n{#1}
-  \clist_set:No \l_tmpa_clist \spftype
-  \tl_set:Nn \l_tmpa_tl {
-    \item[\sproofnumber]
-    \bool_set_true:N \l_@@_inc_counter_bool
+
+\_@@_make_step_macro:Nnnnn \assumption {assumption} \sproofnumber {} \_@@_inc_counter:
+\_@@_make_step_macro:Nnnnn \conclude {conclusion} {$\Rightarrow$} {} {}
+\_@@_make_step_macro:Nnnnn \spfstep {} \sproofnumber {} \_@@_inc_counter:
+
+\NewDocumentCommand \eqstep {s m}{
+  \_@@_maybe_comment_end:
+  \bool_if:NTF \l_@@_in_spfblock_bool {
+    $=$
+  }{
+    \item[$=$]
   }
-  \clist_map_inline:Nn \l_tmpa_clist {
-    \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} {
-      \tl_clear:N \l_tmpa_tl
-    }
-  }
-  \l_tmpa_tl
-}{
-  \bool_if:NT \l_@@_inc_counter_bool {
-    \_@@_inc_counter:
-  }
+  $\stex_annotate:nnn{spfstep}{eq}{ #2 }$
+  \_@@_maybe_comment:
 }
-%    \end{macrocode}
-% \end{environment}
-%
-% The next two environments also take a |KeyVal| argument, but also a regular one, which
-% contains a start text. Both environments start a new numbered proof level.
-%
-% \begin{environment}{subproof}
-%   In the |subproof| environment, a new (lower-level) proproofof environment is started.
-%    \begin{macrocode}
-\newenvironment{subproof}[2][]{
-  \_@@_spf_args:n{#1}
-  \stex_if_smsmode:TF{
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }{
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l_@@_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
-        }
-      }
-    }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{subproof}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
-    }
+\stex_deactivate_macro:Nn \eqstep {sproof~environments}
 
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_set:Nn \l_tmpa_tl {
-      \item[\sproofnumber]
-      \bool_set_true:N \l_@@_inc_counter_bool
-    }
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} {
-        \tl_clear:N \l_tmpa_tl
-      }
-    }
-    \l_tmpa_tl
-    \tl_if_empty:NF \spftitle {
-      {(\titleemph{\spftitle})\enspace}
-    }
-    {~#2}
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }
-  \_@@_add_counter:
-  \stex_smsmode_do:
-}{
-  \_@@_remove_counter:
-  \bool_if:NT \l_@@_inc_counter_bool {
-    \_@@_inc_counter:
-  }
-  \stex_if_smsmode:F{
-    \end{stex_annotate_env}
-  }
+\NewDocumentCommand \yield {+m}{
+  \stex_annotate:nnn{spfyield}{}{ #1 }
 }
-%    \end{macrocode}
-% \end{environment}
-%
-% \begin{environment}{spfcases}
-%   In the |pfcases| environment, the start text is displayed as the first comment of the
-%   proof.
-%    \begin{macrocode}
-\newenvironment{spfcases}[2][]{
-  \tl_if_empty:nTF{#1}{
-    \begin{subproof}[method=by-cases]{#2}
-  }{
-    \begin{subproof}[#1,method=by-cases]{#2}
-  }
+\stex_deactivate_macro:Nn \yield {sproof~environments}
+
+\NewDocumentEnvironment{spfblock}{}{
+  \item[]
+  \bool_set_true:N \l_@@_in_spfblock_bool
 }{
-  \end{subproof}
+  \aftergroup\_@@_maybe_comment:
 }
+\AddToHook{env/spfblock/before}{\_@@_maybe_comment_end:}
+
 %    \end{macrocode}
-% \end{environment}
+% \end{macro}
 %
-% \begin{environment}{spfcase}
-%    In the |pfcase| environment, the start text is displayed specification of the case
-%    after the |\item|
+% 
+% \begin{macro}{\spfidea}
 %    \begin{macrocode}
-\newenvironment{spfcase}[2][]{
+\NewDocumentCommand\spfidea{O{} +m}{
   \_@@_spf_args:n{#1}
-  \stex_if_smsmode:TF {
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }{
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l_@@_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
-        }
-      }
-    }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{spfcase}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
-    }
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_set:Nn \l_tmpa_tl {
-      \item[\sproofnumber]
-      \bool_set_true:N \l_@@_inc_counter_bool
-    }
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} {
-        \tl_clear:N \l_tmpa_tl
-      }
-    }
-    \l_tmpa_tl
-    \tl_if_empty:nF{#2}{
-      \titleemph{#2}:~
-    }
-  }
-  \_@@_add_counter:
-  \stex_smsmode_do:
-}{
-  \_@@_remove_counter:
-  \bool_if:NT \l_@@_inc_counter_bool {
-    \_@@_inc_counter:
-  }
-  \stex_if_smsmode:F{
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_set:Nn \l_tmpa_tl{\sproofend}
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} {
-        \tl_clear:N \l_tmpa_tl
-      }
-    }
-    \l_tmpa_tl
-    \end{stex_annotate_env}
-  }
+  \titleemph{
+    \tl_if_empty:NTF \spftype {Proof~Idea}{
+      \spftype
+    }:
+  }~#2
+  \sproofend
 }
 %    \end{macrocode}
-% \end{environment}
+% \end{macro}
 %
-% \begin{environment}{spfcase}
-%    similar to |spfcase|, takes a third argument. 
 %    \begin{macrocode}
-\newcommand\spfcasesketch[3][]{
-  \begin{spfcase}[#1]{#2}#3\end{spfcase}
+\newcommand\spfjust[1]{
+  #1
 }
-%    \end{macrocode}
-% \end{environment}
-%
-% \subsection{Justifications}
-%
-% We define the actions that are undertaken, when the keys for justifications are
-% encountered. Here this is very simple, we just define an internal macro with the value,
-% so that we can use it later.
-%    \begin{macrocode}
-\keys_define:nn { stex / just }{
-  id        .str_set_x:N  = \l_@@_just_id_str,
-  method    .tl_set:N     = \l_@@_just_method_tl,
-  premises  .tl_set:N     = \l_@@_just_premises_tl,
-  args      .tl_set:N     = \l_@@_just_args_tl
-}
-%    \end{macrocode}
-%
-% The next three environments and macros are purely semantic, so we ignore the keyval
-% arguments for now and only display the content.\ednote{need to do something about the
-% premise in draft mode.}
-%
-% \begin{macro}{\spfjust}
-%    \begin{macrocode}
-\newcommand\spfjust[1][]{}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\premise}
-%    \begin{macrocode}
-\newcommand\stex_proof_premise:[2][]{#2}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\justarg}
-% the |\justarg| macro is purely semantic, so we ignore the keyval arguments for now and
-% only display the content.
-%    \begin{macrocode}
-\newcommand\justarg[2][]{#2}
 %</package>
 %    \end{macrocode}
-% \end{macro}
 % \end{implementation}
 % \Finale
 % \ifinfulldoc\else\printbibliography\fi

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-references.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-references.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-references.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -47,22 +47,11 @@
 %
 % \section{Macros and Environments}\label{pkg:sref:doc:macros}
 %
-% \begin{function}{\STEXreftitle}
-%    \begin{syntax} \cs{STEXreftitle}\Arg{some title} \end{syntax}
 %
-%    Sets the title of the current document to \meta{some title}.
-%    A reference to the current document from \emph{some other}
-%    document will then be displayed accordingly. e.g.
-%    if |\STEXreftitle{foo book}| is called, then referencing 
-%    Definition 3.5 in this document in another document will display
-%    |Definition 3.5 in foo book|.
-% \end{function}
-%
 % \begin{function}{\stex_get_document_uri:}
-%   Computes the current document uri from the current archive's
-%   |narr|-field and its location relative to the archive's 
-%   |source|-directory. Reference targets are computed from
-%   this URI and the reference-id.
+%   Computes the current document uri from the current archive's |narr|-field and its
+%   location relative to the archive's |source|-directory. Reference targets are computed
+%   from this URI and the reference-id.
 %
 %   \begin{variable}{\l_stex_current_docns_str}
 %      Stores its result in |\l_stex_current_docns_str|
@@ -70,11 +59,9 @@
 % \end{function}
 %
 % \begin{function}{\stex_get_document_url:}
-%   Computes the current URL from the current archive's
-%   |docurl|-field and its location relative to the archive's 
-%   |source|-directory. Reference targets are computed from
-%   this URL and the reference-id, if this document is only included
-%   in SMS mode.
+%   Computes the current URL from the current archive's |docurl|-field and its location
+%   relative to the archive's |source|-directory. Reference targets are computed from this
+%   URL and the reference-id, if this document is only included in SMS mode.
 %
 %   \begin{variable}{\l_stex_current_docurl_str}
 %      Stores its result in |\l_stex_current_docurl_str|
@@ -132,7 +119,7 @@
 %    \begin{macrocode}
 %<*package>
 
-%%%%%%%%%%%%%   references.dtx   %%%%%%%%%%%%%
+%%%%%%%%%%%%%   stex-references.dtx   %%%%%%%%%%%%%
 
 %<@@=stex_refs>
 %    \end{macrocode}
@@ -140,7 +127,15 @@
 % Warnings and error messages
 %
 %    \begin{macrocode}
-
+\msg_new:nnn{stex}{error/extrefmissing}{
+  Missing~in~or~cite~value~for~\detokenize{\extref}!
+}
+\msg_new:nnn{stex}{warning/smsmissing}{
+  .sref~file~#1~doesn't~exist!
+}
+\msg_new:nnn{stex}{warning/smslabelmissing}{
+  No~label~#2~in~.sref~file~#1!
+}
 %    \end{macrocode}
 %
 % References are stored in the file |\jobname.sref|, to enable
@@ -147,24 +142,15 @@
 % cross-referencing external documents.
 %
 %    \begin{macrocode}
-%\iow_new:N \c_@@_refs_iow
+\iow_new:N \c_@@_refs_iow
 \AtBeginDocument{
-%  \iow_open:Nn \c_@@_refs_iow {\jobname.sref}
+  \iow_open:Nn \c_@@_refs_iow {\jobname.sref}
 }
 \AtEndDocument{
-%  \iow_close:N \c_@@_refs_iow
+  \iow_close:N \c_@@_refs_iow
 }
 %    \end{macrocode}
 %
-% \begin{macro}{\STEXreftitle}
-%    \begin{macrocode}
-\str_set:Nn \g_@@_title_tl {Unnamed~Document}
-
-\NewDocumentCommand \STEXreftitle { m } {
-  \tl_gset:Nx \g_@@_title_tl { #1 }
-}
-%    \end{macrocode}
-% \end{macro}
 %
 % \subsection{Document URIs and URLs}
 %
@@ -208,13 +194,14 @@
     }
   
     \seq_if_empty:NTF \l_tmpa_seq {
-      \str_set_eq:NN \l_stex_current_docns_str \l_tmpa_str
+      \str_gset_eq:NN \l_stex_current_docns_str \l_tmpa_str
     }{
-      \str_set:Nx \l_stex_current_docns_str { 
+      \str_gset:Nx \l_stex_current_docns_str { 
         \l_tmpa_str/\stex_path_to_string:N \l_tmpa_seq
       }
     }
   }
+  %\stex_get_document_url:
 }
 %    \end{macrocode}
 % \end{macro}
@@ -281,6 +268,8 @@
 % @currentlabel -> number
 % @currentlabelname -> title
 % @currentHref -> name.number <- id of some kind
+% @currentcounter <- name/id
+% \#autorefname <- "Section"
 % \theH# -> \arabic{section}
 % \the#  -> number
 % \hyper at makecurrent{#}
@@ -287,36 +276,63 @@
 \int_new:N \l_@@_unnamed_counter_int
 %    \end{macrocode}
 %
+% Restoring references from |.sref|-files
+%
+% \begin{macro}{\STEXInternalSrefRestoreTarget}
+%    \begin{macrocode}
+\cs_new_protected:Npn \STEXInternalSrefRestoreTarget #1#2#3#4#5 {}
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \begin{macro}{\stex_ref_new_doc_target:n}
 %    \begin{macrocode}
+\seq_new:N \g_stex_ref_files_seq
+
 \cs_new_protected:Nn \stex_ref_new_doc_target:n {
-  \stex_get_document_uri:
+  %\stex_get_document_uri:
   \str_clear:N \l_@@_curr_label_str
   \str_set:Nx \l_tmpa_str { #1 }
   \str_if_empty:NT \l_tmpa_str {
-    \int_incr:N \l_@@_unnamed_counter_int
+    \int_gincr:N \l_@@_unnamed_counter_int
     \str_set:Nx \l_tmpa_str {REF\int_use:N \l_@@_unnamed_counter_int}
   }
   \str_set:Nx \l_@@_curr_label_str {
     \l_stex_current_docns_str?\l_tmpa_str
   }
-  \seq_if_exist:cF{g_@@_labels_\l_tmpa_str _seq}{
-    \seq_new:c {g_@@_labels_\l_tmpa_str _seq}
-  }
-  \seq_if_in:coF{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str {
-    \seq_gput_right:co{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str
-  }
+
+  \exp_args:Noo \STEXInternalAuxAddDocRef\l_stex_current_docns_str\l_tmpa_str
+  
+  %\seq_if_exist:cF{g_@@_labels_\l_tmpa_str _seq}{
+  %  \seq_new:c {g_@@_labels_\l_tmpa_str _seq}
+  %}
+  %\seq_if_in:coF{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str {
+  %  \seq_gput_right:co{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str
+  %}
+
+
   \stex_if_smsmode:TF {
-    \stex_get_document_url:
-    \str_gset_eq:cN {sref_url_\l_@@_curr_label_str _str}\l_stex_current_docurl_str
-    \str_gset_eq:cN {sref_\l_@@_curr_label_str _type}\c_@@_url_str
+    %\stex_get_document_url:
+    %\str_gset_eq:cN {sref_url_\l_@@_curr_label_str _str}\l_stex_current_docurl_str
+    %\str_gset_eq:cN {sref_\l_@@_curr_label_str _type}\c_@@_url_str
   }{
-    %\iow_now:Nx \c_@@_refs_iow { \l_tmpa_str~=~\expandafter\unexpanded\expandafter{\@currentlabel}~in~\exp_args:No\unexpanded\g_@@_title_tl,}
+    \iow_now:Nx \c_@@_refs_iow {
+      \STEXInternalSrefRestoreTarget
+        {\l_stex_current_docns_str}
+        {\l_tmpa_str}
+        {\@currentcounter}
+        {\@currentlabel}
+        {\tl_if_exist:NT\@currentlabelname{\exp_args:No\unexpanded\@currentlabelname}}
+    }
+    %\iow_now:Nx \c_@@_refs_iow { 
+    %  {\l_stex_current_docns_str?\l_tmpa_str}~=~{{\use:c{\@currentcounter autorefname}~\@currentlabel}~(\@currentlabelname)~in~\exp_args:No\unexpanded\g_@@_title_tl},}
+    \stex_debug:nn{sref}{New~label~\l_@@_curr_label_str~at~\use:c{\use:c{@currentcounter}autorefname}}
     \exp_args:Nx\label{sref_\l_@@_curr_label_str}
-    \immediate\write\@auxout{\stexauxadddocref{\l_stex_current_docns_str}{\l_tmpa_str}}
-    \str_gset:cx {sref_\l_@@_curr_label_str _type}\c_@@_ref_str
+    \immediate\write\@auxout{\STEXInternalAuxAddDocRef{\l_stex_current_docns_str}{\l_tmpa_str}}
+    %\str_gset:cx {sref_\l_@@_curr_label_str _type}\c_@@_ref_str
   }
 }
+\NewDocumentCommand \slabel {m} {\stex_ref_new_doc_target:n {#1}}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -323,15 +339,27 @@
 % The following is used to set the necessary macros in the |.aux|-file.
 %
 %    \begin{macrocode}
-\cs_new_protected:Npn \stexauxadddocref #1 #2 {
-  \str_set:Nn \l_tmpa_str {#1?#2}
-  \str_gset_eq:cN{sref_#1?#2_type}\c_@@_ref_str
-  \seq_if_exist:cF{g_@@_labels_#2_seq}{
-    \seq_new:c {g_@@_labels_#2_seq}
+\cs_new_protected:Npn \STEXInternalAuxAddDocRef #1 #2 {
+  \exp_args:NNx \seq_if_in:NnTF \g_stex_ref_files_seq {\detokenize{#1}} {
+    \exp_args:Nnx \seq_if_in:cnF{g_stex_ref_ #1 _seq}{\detokenize{#2}}{
+      \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}}
+    }
+  }{
+      \exp_args:NNx \seq_gput_right:Nn \g_stex_ref_files_seq {\detokenize{#1}}
+      %\seq_if_exist:cF{g_stex_ref_ #1 _seq}{
+        \seq_new:c{g_stex_ref_ #1 _seq} % <- seq_new throws errors??
+      %}
+      \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}}
   }
-  \seq_if_in:coF{g_@@_labels_#2_seq}\l_tmpa_str {
-    \seq_gput_right:co{g_@@_labels_#2_seq}\l_tmpa_str
-  }
+  
+  %\str_set:Nn \l_tmpa_str {#1?#2}
+  %\str_gset_eq:cN{sref_#1?#2_type}\c_@@_ref_str
+  %\seq_if_exist:cF{g_@@_labels_#2_seq}{
+  %  \seq_new:c {g_@@_labels_#2_seq}
+  %}
+  %\seq_if_in:coF{g_@@_labels_#2_seq}\l_tmpa_str {
+  %  \seq_gput_right:co{g_@@_labels_#2_seq}\l_tmpa_str
+  %}
 }
 %    \end{macrocode}
 % To avoid resetting the same macros when the |.aux|-file is read
@@ -339,7 +367,7 @@
 %
 %    \begin{macrocode}
 \AtEndDocument{
-  \def\stexauxadddocref#1 #2 {}{}
+  \def\STEXInternalAuxAddDocRef#1 #2 {}{}
 }
 %    \end{macrocode}
 %
@@ -346,22 +374,23 @@
 % \begin{macro}{\stex_ref_new_sym_target:n}
 %    \begin{macrocode}
 \cs_new_protected:Nn \stex_ref_new_sym_target:n {
-  \stex_if_smsmode:TF {
-    \str_if_exist:cF{sref_sym_#1_type}{
-      \stex_get_document_url:
-      \str_gset_eq:cN {sref_sym_url_#1_str}\l_stex_current_docurl_str
-      \str_gset_eq:cN {sref_sym_#1_type}\c_@@_url_str
-    }
-  }{
-    \str_if_empty:NF \l_@@_curr_label_str {
-      \str_gset_eq:cN {sref_sym_#1_label_str}\l_@@_curr_label_str
-      \immediate\write\@auxout{
-        \exp_not:N\expandafter\def\exp_not:N\csname \exp_not:N\detokenize{sref_sym_#1_label_str}\exp_not:N\endcsname{
-            \l_@@_curr_label_str
-          }
-      }
-    }
-  }
+
+%  \stex_if_smsmode:TF {
+%    \str_if_exist:cF{sref_sym_#1_type}{
+%      \stex_get_document_url:
+%      \str_gset_eq:cN {sref_sym_url_#1_str}\l_stex_current_docurl_str
+%      \str_gset_eq:cN {sref_sym_#1_type}\c_@@_url_str
+%    }
+%  }{
+%    \str_if_empty:NF \l_@@_curr_label_str {
+%      \str_gset_eq:cN {sref_sym_#1_label_str}\l_@@_curr_label_str
+%      \immediate\write\@auxout{
+%        \exp_not:N\expandafter\def\exp_not:N\csname \exp_not:N\detokenize{sref_sym_#1_label_str}\exp_not:N\endcsname{
+%            \l_@@_curr_label_str
+%          }
+%      }
+%    }
+%  }
 }
 %    \end{macrocode}
 % \end{macro}
@@ -368,93 +397,284 @@
 %
 % \subsection{Using References}
 %
-%    \begin{macrocode}
-\str_new:N \l_@@_indocument_str
-%    \end{macrocode}
-%
 % \begin{macro}{\sref}
 % Optional arguments:
 %    \begin{macrocode}
 
-\keys_define:nn { stex / sref } {
-  linktext      .tl_set:N  = \l_@@_linktext_tl ,
-  fallback      .tl_set:N  = \l_@@_fallback_tl ,
-  pre           .tl_set:N  = \l_@@_pre_tl ,
-  post          .tl_set:N  = \l_@@_post_tl ,
+\keys_define:nn { stex / sref / 1 } {
+  archive   .str_set_x:N  = \l_@@_repo_str,
+  file      .str_set_x:N  = \l_@@_file_str,
+  % TODO get rid of this
+  fallback  .code:n = {},
+  pre       .code:n = {},
+  post      .code:n = {}
 }
-\cs_new_protected:Nn \_@@_args:n {
-  \tl_clear:N \l_@@_linktext_tl
-  \tl_clear:N \l_@@_fallback_tl
-  \tl_clear:N \l_@@_pre_tl
-  \tl_clear:N \l_@@_post_tl
+\cs_new_protected:Nn \_@@_args_i:n {
   \str_clear:N \l_@@_repo_str
-  \keys_set:nn { stex / sref } { #1 }
+  \str_clear:N \l_@@_file_str
+  \keys_set:nn { stex / sref / 1 } { #1 }
 }
+\keys_define:nn { stex / sref / 2 } {
+  in      .str_set_x:N  = \l_@@_in_str,
+  archive    .str_set_x:N  = \l_@@_repob_str,
+  title    .tl_set:N  = \l_@@_title_tl
+}
+\cs_new_protected:Nn \_@@_args_ii:n {
+  \str_clear:N \l_@@_in_str
+  \tl_clear:N \l_@@_title_tl
+  \str_clear:N \l_@@_repob_str
+  \keys_set:nn { stex / sref / 2 } { #1 }
+}
 %    \end{macrocode}
 % The actual macro:
 %    \begin{macrocode}
-\NewDocumentCommand \sref { O{} m}{
-  \_@@_args:n { #1 }
-  \str_if_empty:NTF \l_@@_indocument_str {
-    \str_set:Nx \l_tmpa_str { #2 }
-    \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str
-    \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} = 1 {
-      \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{
-        \seq_get_left:cNF {g_@@_labels_\l_tmpa_str _seq} \l_tmpa_str {
-          \str_clear:N \l_tmpa_str
+\NewDocumentCommand \sref { O{} m O{}}{
+  \_@@_args_i:n{#1}
+  \_@@_args_ii:n{#3}
+  \str_clear:N \l_@@_uri_str
+  \_@@_find_uri:n{#2}
+  \_@@_do_sref:n{#2}
+}
+\NewDocumentCommand \extref { O{} m m}{
+  \_@@_args_i:n{#1}
+  \_@@_args_ii:n{#3}
+  \str_if_empty:NT \l_@@_in_str {
+    \msg_error:nn{stex}{error/extrefmissing}
+  }
+  \str_clear:N \l_@@_uri_str
+  \_@@_find_uri:n{#2}
+  \_@@_do_sref_in:n{#2}
+}
+
+\cs_new_protected:Nn \_@@_find_uri:n {
+  \stex_debug:nn{sref}{File:~\l_@@_file_str^^JRepo:\l_@@_repo_str}
+  \str_if_empty:NTF \l_@@_file_str {
+    \stex_debug:nn{sref}{Empty.~Checking~current~file~for~#1}
+    \seq_if_exist:cT{g_stex_ref_\l_stex_current_docns_str _seq}{
+      \seq_map_inline:cn{g_stex_ref_\l_stex_current_docns_str _seq}{
+        \str_if_eq:nnT{#1}{##1}{
+          \str_set_eq:NN \l_@@_uri_str \l_stex_current_docns_str
+          \stex_debug:nn{sref}{Found.}
+          \seq_map_break:
         }
-      }{
-        \str_clear:N \l_tmpa_str
       }
-    }{
-      \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str
-      \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str
-      \int_set:Nn \l_tmpa_int { \exp_args:Ne \str_count:n {\l_tmpb_str?\l_tmpa_str} }
-      \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{
-        \str_set_eq:NN \l_tmpc_str \l_tmpa_str
-        \str_clear:N \l_tmpa_str
-        \seq_map_inline:cn {g_@@_labels_\l_tmpc_str _seq} {
-          \str_if_eq:eeT { \l_tmpb_str?\l_tmpc_str }{
-            \str_range:nnn { ##1 }{ -\l_tmpa_int}{ -1 } 
-          }{
-            \seq_map_break:n {
-              \str_set:Nn \l_tmpa_str { ##1 }
-            }
+    }
+    \str_if_empty:NT \l_@@_uri_str {
+      \stex_debug:nn{sref}{Checking~other~files}
+      \seq_map_inline:Nn \g_stex_ref_files_seq {
+        \stex_debug:nn{sref}{##1...}
+        \seq_map_inline:cn{g_stex_ref_##1_seq}{
+          \str_if_eq:nnT{#1}{####1}{
+            \stex_debug:nn{sref}{Found~##1}
+            \str_set:Nn \l_@@_uri_str {##1}
+            \seq_map_break:n{\seq_map_break:}
           }
         }
+      }
+    }
+  }{
+    \str_if_empty:NTF \l_@@_repo_str {
+      \prop_if_exist:NTF \l_stex_current_repository_prop {
+        \prop_get:NnN \l_stex_current_repository_prop { ns } \l_@@_uri_str
+        \str_set:Nx \l_@@_uri_str {\l_@@_uri_str / \l_@@_file_str}
+        \stex_path_from_string:Nn \l_tmpb_seq \l_@@_uri_str
+        \str_set:Nx \l_@@_uri_str {\stex_path_to_string:N \l_tmpb_seq}
       }{
-        \str_clear:N \l_tmpa_str
+        \stex_path_from_string:Nn \l_tmpb_seq {
+          \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l_@@_file_str
+        }
+        \str_set:Nx \l_@@_uri_str {file:/\stex_path_to_string:N \l_tmpb_seq}
       }
+    }{
+      \stex_require_repository:n \l_@@_repo_str
+      \prop_get:cnN { c_stex_mathhub_\l_@@_repo_str _manifest_prop } { ns } \l_@@_uri_str
+      \str_set:Nx \l_@@_uri_str {\l_@@_uri_str / \l_@@_file_str}
+      \stex_path_from_string:Nn \l_tmpb_seq \l_@@_uri_str
+      \str_set:Nx \l_@@_uri_str {\stex_path_to_string:N \l_tmpb_seq}
     }
-    \str_if_empty:NTF \l_tmpa_str {
-      \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl
+  }
+}
+
+\cs_new_protected:Nn \_@@_do_autoref:n{
+  \cs_if_exist:cTF{autoref}{
+     \exp_args:Nx\autoref{sref_#1}
+   }{
+     \exp_args:Nx\ref{sref_#1}
+   }
+}
+
+\cs_new_protected:Nn \_@@_do_sref:n {
+  \str_if_empty:NTF \l_@@_uri_str {
+    \str_if_empty:NTF \l_@@_in_str {
+      \stex_debug:nn{sref}{autoref~on~#1}
+      \_@@_do_autoref:n{#1}
     }{
-      \str_if_eq:cNTF {sref_\l_tmpa_str _type} \c_@@_ref_str {
-        \tl_if_empty:NTF \l_@@_linktext_tl {
-          \cs_if_exist:cTF{autoref}{
-            \l_@@_pre_tl\exp_args:Nx\autoref{sref_\l_tmpa_str}\l_@@_post_tl
-          }{
-            \l_@@_pre_tl\exp_args:Nx\ref{sref_\l_tmpa_str}\l_@@_post_tl
-          }
+      \stex_debug:nn{sref}{srefin~on~#1}
+      \_@@_do_sref_in:n{#1}
+    }
+  }{
+    \exp_args:NNo \seq_if_in:NnTF \g_stex_ref_files_seq \l_@@_uri_str {
+      \exp_args:Nnx \seq_if_in:cnTF{g_stex_ref_\l_@@_uri_str _seq}{\detokenize{#1}}{
+        \stex_debug:nn{sref}{Reference~found~in~ref~files;~autoref~on~#1}
+        \_@@_do_autoref:n{\l_@@_uri_str?#1}
+      }{
+        \str_if_empty:NTF \l_@@_in_str {
+          \stex_debug:nn{sref}{in~empty;~autoref~on~#1}
+          \_@@_do_autoref:n{#1}
         }{
-          \ltx at ifpackageloaded{hyperref}{
-            \hyperref[sref_\l_tmpa_str]\l_@@_linktext_tl
-          }{
-            \l_@@_linktext_tl
-          }
+          \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1}
+          \_@@_do_sref_in:n{#1}
         }
+      }
+    }{
+      \str_if_empty:NTF \l_@@_in_str {
+        \stex_debug:nn{sref}{in~empty;~autoref~on~#1}
+        \_@@_do_autoref:n{#1}
       }{
-        \ltx at ifpackageloaded{hyperref}{
-          \href{\use:c{sref_url_\l_tmpa_str _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl}
-        }{
-          \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl
+        \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1}
+        \_@@_do_sref_in:n{#1}
+      }
+    }
+  }
+}
+
+\cs_new_protected:Nn \_@@_restore_target:nnnnn {
+  \str_if_empty:NTF \l_@@_uri_str {
+    \exp_args:No \str_if_eq:nnT \l_@@_id_str {#2}{
+      \tl_set:Nn \l_@@_return_tl {
+        \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~
+        \tl_if_empty:nTF\l_@@_title_tl{
+          ???
+        }\l_@@_title_tl
+      }
+    }
+  }{
+    \stex_debug:nn{sref}{\l_@@_uri_str{}~ == ~ #1 ~ ?}
+    \exp_args:No \str_if_eq:nnT \l_@@_uri_str {#1}{
+      \stex_debug:nn{sref}{\l_@@_id_str~ == ~ #2 ~ ?}
+      \exp_args:No \str_if_eq:nnT \l_@@_id_str {#2}{
+        \stex_debug:nn{sref}{success!}
+        \tl_set:Nn \l_@@_return_tl {
+          \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~
+          \tl_if_empty:nTF\l_@@_title_tl{
+            ???
+          }\l_@@_title_tl
         }
+        \endinput
       }
     }
-  }{
-    % TODO
   }
 }
+
+\cs_new_protected:Nn \_@@_do_sref_in:n {
+  \stex_debug:nn{sref}{In: \l_@@_in_str^^JRepo:\l_@@_repo_str}
+  \stex_debug:nn{sref}{URI: \l_@@_uri_str?#1}
+  %\msg_warning:nnn{stex}{warning/smsmissing}{<filename>}
+  \begingroup\catcode13=9\relax\catcode10=9\relax
+    \str_if_empty:NTF \l_@@_repob_str {
+      \prop_if_exist:NTF \l_stex_current_repository_prop {
+        \str_set:Nx \l_tmpa_str {
+          \c_stex_mathhub_str /
+          \prop_item:Nn \l_stex_current_repository_prop { id }
+          / source / \l_@@_in_str .sref
+        }
+      }{
+        \str_set:Nx \l_tmpa_str {
+          \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l_@@_in_str . sref
+        }
+      }
+    }{
+      \str_set:Nx \l_tmpa_str {
+        \c_stex_mathhub_str / \l_@@_repob_str 
+        / source / \l_@@_in_str . sref
+      }
+    }
+    \stex_path_from_string:Nn \l_tmpb_seq \l_tmpa_str
+    \stex_path_to_string:NN \l_tmpb_seq \l_tmpa_str
+    \stex_debug:nn{sref}{File: \l_tmpa_str}
+    \exp_args:No \IfFileExists \l_tmpa_str {
+      \tl_clear:N \l_@@_return_tl
+      \str_set:Nn \l_@@_id_str {#1}
+      \let\STEXInternalSrefRestoreTarget\_@@_restore_target:nnnnn
+      \use:c{@ @ input}{\l_tmpa_str}
+      \exp_args:No \tl_if_empty:nTF \l_@@_return_tl {
+        \exp_args:Nnno \msg_warning:nnnn{stex}{warning/smslabelmissing}\l_tmpa_str{#1}
+        \_@@_do_autoref:n{
+          \str_if_empty:NF\l_@@_uri_str{\l_@@_uri_str?}#1
+        }
+      }{
+        \l_@@_return_tl
+      }
+    }{
+      \exp_args:Nnno \msg_warning:nnn{stex}{warning/smsmissing}\l_tmpa_str
+      \_@@_do_autoref:n{
+        \str_if_empty:NF\l_@@_uri_str{\l_@@_uri_str?}#1
+      }
+    }
+  \endgroup
+}
+
+ % \_@@_args:n { #1 }
+ % \str_if_empty:NTF \l_@@_indocument_str {
+ %   \str_set:Nx \l_tmpa_str { #2 }
+ %   \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str
+ %   \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} = 1 {
+ %     \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{
+ %       \seq_get_left:cNF {g_@@_labels_\l_tmpa_str _seq} \l_tmpa_str {
+ %         \str_clear:N \l_tmpa_str
+ %       }
+ %     }{
+ %       \str_clear:N \l_tmpa_str
+ %     }
+ %   }{
+ %     \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str
+ %     \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str
+ %    \int_set:Nn \l_tmpa_int { \exp_args:Ne \str_count:n {\l_tmpb_str?\l_tmpa_str} }
+ %     \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{
+ %       \str_set_eq:NN \l_tmpc_str \l_tmpa_str
+ %       \str_clear:N \l_tmpa_str
+ %       \seq_map_inline:cn {g_@@_labels_\l_tmpc_str _seq} {
+ %         \str_if_eq:eeT { \l_tmpb_str?\l_tmpc_str }{
+ %           \str_range:nnn { ##1 }{ -\l_tmpa_int}{ -1 } 
+ %         }{
+ %           \seq_map_break:n {
+ %             \str_set:Nn \l_tmpa_str { ##1 }
+ %           }
+ %         }
+ %       }
+ %     }{
+ %       \str_clear:N \l_tmpa_str
+ %     }
+ %   }
+ %   \str_if_empty:NTF \l_tmpa_str {
+ %     \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl
+ %   }{
+ %     \str_if_eq:cNTF {sref_\l_tmpa_str _type} \c_@@_ref_str {
+ %       \tl_if_empty:NTF \l_@@_linktext_tl {
+ %         \cs_if_exist:cTF{autoref}{
+ %           \l_@@_pre_tl\exp_args:Nx\autoref{sref_\l_tmpa_str}\l_@@_post_tl
+ %         }{
+ %           \l_@@_pre_tl\exp_args:Nx\ref{sref_\l_tmpa_str}\l_@@_post_tl
+ %         }
+ %       }{
+ %         \ltx at ifpackageloaded{hyperref}{
+ %           \hyperref[sref_\l_tmpa_str]\l_@@_linktext_tl
+ %         }{
+ %           \l_@@_linktext_tl
+ %         }
+ %       }
+ %     }{
+ %       \ltx at ifpackageloaded{hyperref}{
+ %         \href{\use:c{sref_url_\l_tmpa_str _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl}
+ %       }{
+ %         \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl
+ %       }
+ %     }
+ %   }
+ % }{
+    % TODO
+ % }
+%}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -466,44 +686,45 @@
 }
 
 \cs_new_protected:Nn \_@@_sym_aux:nn {
-  \str_if_exist:cTF {sref_sym_#2 _label_str }{
-    \sref[#1]{\use:c{sref_sym_#2 _label_str}}
-  }{
-    \_@@_args:n { #1 }
-    \str_if_empty:NTF \l_@@_indocument_str {
-      \tl_if_exist:cTF{sref_sym_#2 _type}{
-        % doc uri in \l_tmpb_str
-        \str_set:Nx \l_tmpa_str {\use:c{sref_sym_#2 _type}}
-        \str_if_eq:NNTF \l_tmpa_str \c_@@_ref_str {
-          % reference
-          \tl_if_empty:NTF \l_@@_linktext_tl {
-            \cs_if_exist:cTF{autoref}{
-              \l_@@_pre_tl\autoref{sref_sym_#2}\l_@@_post_tl
-            }{
-              \l_@@_pre_tl\ref{sref_sym_#2}\l_@@_post_tl
-            }
-          }{
-            \ltx at ifpackageloaded{hyperref}{
-              \hyperref[sref_sym_#2]\l_@@_linktext_tl
-            }{
-              \l_@@_linktext_tl
-            }
-          }
-        }{
-          % URL
-          \ltx at ifpackageloaded{hyperref}{
-            \href{\use:c{sref_sym_url_#2 _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl}
-          }{
-            \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl
-          }
-        }
-      }{
-        \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl
-      }
-    }{
-      % TODO
-    }
-  }
+
+%  \str_if_exist:cTF {sref_sym_#2 _label_str }{
+%    \sref[#1]{\use:c{sref_sym_#2 _label_str}}
+%  }{
+%    \_@@_args:n { #1 }
+%    \str_if_empty:NTF \l_@@_indocument_str {
+%      \tl_if_exist:cTF{sref_sym_#2 _type}{
+%        % doc uri in \l_tmpb_str
+%        \str_set:Nx \l_tmpa_str {\use:c{sref_sym_#2 _type}}
+%        \str_if_eq:NNTF \l_tmpa_str \c_@@_ref_str {
+%          % reference
+%          \tl_if_empty:NTF \l_@@_linktext_tl {
+%            \cs_if_exist:cTF{autoref}{
+%              \l_@@_pre_tl\autoref{sref_sym_#2}\l_@@_post_tl
+%            }{
+%              \l_@@_pre_tl\ref{sref_sym_#2}\l_@@_post_tl
+%            }
+%          }{
+%            \ltx at ifpackageloaded{hyperref}{
+%              \hyperref[sref_sym_#2]\l_@@_linktext_tl
+%            }{
+%              \l_@@_linktext_tl
+%            }
+%          }
+%        }{
+%          % URL
+%          \ltx at ifpackageloaded{hyperref}{
+%            \href{\use:c{sref_sym_url_#2 _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl}
+%          }{
+%            \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl
+%          }
+%        }
+%      }{
+%        \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl
+%      }
+%    }{
+%      % TODO
+%    }
+%  }
 }
 %    \end{macrocode}
 % \end{macro}
@@ -510,8 +731,8 @@
 %
 % \begin{macro}{\srefsymuri}
 %    \begin{macrocode}
-\cs_new_protected:Npn \srefsymuri #1 #2 {
-  \_@@_sym_aux:nn{linktext={#2}}{#1}
+\cs_new_protected:Npn \srefsymuri #1 #2 { % TODO
+  #2%\_@@_sym_aux:nn{linktext={#2}}{#1}
 }
 %    \end{macrocode}
 % \end{macro}

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-statements.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-statements.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-statements.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -365,6 +365,7 @@
       }
     }
     \clist_set_from_seq:NN \l_@@_sdefinition_for_clist \l_tmpb_seq
+    \ifvmode\noindent\fi
     \exp_args:Nnx
     \stex_annotate:nnn{definition}{\seq_use:Nn \l_tmpb_seq {,}}{
       \str_if_empty:NF \sdefinitiontype {
@@ -542,6 +543,7 @@
         }
       }
     }
+    \ifvmode\noindent\fi
     \exp_args:Nnx
     \stex_annotate:nnn{assertion}{\seq_use:Nn \l_tmpb_seq {,}}{
       \str_if_empty:NF \sassertiontype {
@@ -705,6 +707,7 @@
         }
       }
     }
+    \ifvmode\noindent\fi
     \exp_args:Nnx
     \stex_annotate:nnn{example}{\seq_use:Nn \l_tmpb_seq {,}}{
       \str_if_empty:NF \sexampletype {
@@ -926,6 +929,7 @@
         }
       }
     }
+    \ifvmode\noindent\fi
     \exp_args:Nnx
     \stex_annotate:nnn{paragraph}{\seq_use:Nn \l_tmpb_seq {,}}{
       \str_if_empty:NF \sparagraphtype {

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-symbols.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-symbols.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-symbols.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -60,9 +60,6 @@
 %         passed on to \mmt for semantic services.
 %     \item |def|: An (ideally semantic) term, representing a \emph{definiens}. Not used by \sTeX, but
 %         passed on to \mmt for semantic services.
-%     \item |local|: A boolean (by default false). If set, this declaration
-%         will not be added to the module content, i.e. importing
-%         the current module will not make this declaration available.
 %     \item |args|: Specifies the ``signature'' of the semantic macro.
 %       Can be either an integer $0 \leq n \leq 9$, or a (more precise)
 %       sequence of the following characters:
@@ -92,7 +89,6 @@
 %     \item |name| (string),
 %     \item |module| (string),
 %     \item |notations| (sequence of strings; initially empty),
-%     \item |local| (boolean),
 %     \item |type| (token list),
 %     \item |args| (string of |i|s, |a|s and |b|s),
 %     \item |arity| (integer string),
@@ -204,15 +200,14 @@
 %    \begin{macrocode}
 \keys_define:nn { stex / symdecl } {
   name        .str_set_x:N  = \l_stex_symdecl_name_str ,
-  local       .bool_set:N   = \l_stex_symdecl_local_bool ,
   args        .str_set_x:N  = \l_stex_symdecl_args_str ,
   type        .tl_set:N     = \l_stex_symdecl_type_tl ,
   deprecate   .str_set_x:N  = \l_stex_symdecl_deprecate_str ,
   align       .str_set:N    = \l_stex_symdecl_align_str , % TODO(?)
   gfc         .str_set:N    = \l_stex_symdecl_gfc_str , % TODO(?)
-  specializes .str_set:N    = \l_stex_symdecl_specializes_str , % TODO(?)
   def         .tl_set:N     = \l_stex_symdecl_definiens_tl ,
   reorder     .str_set_x:N  = \l_stex_symdecl_reorder_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
   assoc       .choices:nn   = 
       {bin,binl,binr,pre,conj,pwconj}
       {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}
@@ -229,6 +224,7 @@
   \bool_set_false:N \l_stex_symdecl_local_bool
   \tl_clear:N \l_stex_symdecl_type_tl
   \tl_clear:N \l_stex_symdecl_definiens_tl
+  \clist_clear:N \l_stex_symdecl_argnames_clist
   
   \keys_set:nn { stex / symdecl } { #1 }
 }
@@ -324,6 +320,7 @@
       }{##1}
     }
   }
+
   \bool_if:NTF \l_tmpa_bool {
     % possibly numeric
     \str_if_empty:NTF \l_stex_symdecl_args_str {
@@ -351,6 +348,19 @@
     \prop_put:Nnx \l_tmpa_prop { defined }{ true }
   }
 
+  % argnames
+
+  \clist_clear:N \l_tmpa_clist
+  \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} {
+    \clist_if_empty:NTF \l_stex_symdecl_argnames_clist {
+      \clist_put_right:Nn \l_tmpa_clist {##1}
+    }{
+      \clist_pop:NN \l_stex_symdecl_argnames_clist \l_tmpa_tl
+      \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl}
+    }
+  }
+  \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,}
+
   % semantic macro
 
   \bool_if:NT \l_stex_symdecl_make_macro_bool {
@@ -396,7 +406,7 @@
     _prop 
   } {
     \bool_if:NTF \l_stex_symdecl_local_bool \stex_do_up_to_module:x \stex_execute_in_module:x {
-      \_@@_restore_symbol:nnnnnnn
+      \_@@_restore_symbol:nnnnnnnn
         {\l_stex_symdecl_name_str}
         { \prop_item:Nn \l_tmpa_prop {args} }
         { \prop_item:Nn \l_tmpa_prop {arity} }
@@ -404,10 +414,11 @@
         { \prop_item:Nn \l_tmpa_prop {defined} }
         {\bool_if:NT \l_stex_symdecl_make_macro_bool {#1} }
         {\l_stex_current_module_str}
+        { \prop_item:Nn \l_tmpa_prop {argnames} }
     }
   }
 }
-\cs_new_protected:Nn \_@@_restore_symbol:nnnnnnn {
+\cs_new_protected:Nn \_@@_restore_symbol:nnnnnnnn {
   \prop_clear:N \l_tmpa_prop
   \prop_put:Nnn \l_tmpa_prop { module } { #7 }
   \prop_put:Nnn \l_tmpa_prop { name } { #1}
@@ -415,6 +426,7 @@
   \prop_put:Nnn \l_tmpa_prop { arity } { #3 }
   \prop_put:Nnn \l_tmpa_prop { assocs } { #4 }
   \prop_put:Nnn \l_tmpa_prop { defined } { #5 }
+  \prop_put:Nnn \l_tmpa_prop { argnames } { #8 }
   \tl_if_empty:nF{#6}{
     \tl_set:cx{#6}{\stex_invoke_symbol:n{\detokenize{#7 ? #1}}}
   }
@@ -435,6 +447,7 @@
 \cs_new_protected:Nn \_stex_textsymdecl_args:n {
   \str_clear:N \l_@@_name_str
   \tl_clear:N \l_@@_type_tl
+  \clist_clear:N \l_stex_symdecl_argnames_clist
   \keys_set:nn { stex / textsymdecl } { #1 }
 }
 
@@ -450,12 +463,12 @@
   \stex_execute_in_module:n{
     \cs_set_nopar:cpn{#1name}{
       \ifvmode\hbox_unpack:N\c_empty_box\fi
-      \hbox{#3}\xspace
+      \ifmmode\hbox{#3}\else#3\fi\xspace
     }
     \cs_set_nopar:cpn{#1}{
       \ifmmode\csname#1-sym\expandafter\endcsname\else
       \ifvmode\hbox_unpack:N\c_empty_box\fi
-      \symref{#1-sym}{\hbox{#3}}\expandafter\xspace
+      \symref{#1-sym}{#3}\expandafter\xspace
       \fi
     }
   }
@@ -594,12 +607,13 @@
 %    \begin{macrocode}
 \keys_define:nn { stex / notation } {
 %  lang    .tl_set_x:N  = \l_@@_lang_str ,
-  variant .tl_set_x:N  = \l_@@_variant_str ,
-  prec    .str_set_x:N = \l_@@_prec_str ,
-  op      .tl_set:N    = \l_@@_op_tl ,
-  primary .bool_set:N  = \l_@@_primary_bool ,
-  primary .default:n   = {true} ,
-  unknown .code:n      = \str_set:Nx 
+  variant .tl_set_x:N   = \l_@@_variant_str ,
+  prec    .str_set_x:N  = \l_@@_prec_str ,
+  op      .tl_set:N     = \l_@@_op_tl ,
+  primary .bool_set:N   = \l_@@_primary_bool ,
+  primary .default:n    = {true} ,
+  hints    .str_set_x:N = \l_@@_hints_str,
+  unknown .code:n       = \str_set:Nx 
       \l_@@_variant_str \l_keys_key_str
 }
 
@@ -607,6 +621,7 @@
 %  \str_clear:N \l_@@_lang_str
   \str_clear:N \l_@@_variant_str
   \str_clear:N \l_@@_prec_str
+  \str_clear:N \l_@@_hints_str
   \tl_clear:N \l_@@_op_tl
   \bool_set_false:N \l_@@_primary_bool
   
@@ -677,7 +692,7 @@
           \exp_args:NNNo \exp_args:NNno \seq_set_split:Nnn 
             \l_tmpa_seq {\tl_to_str:n{x} } { \l_tmpa_str }
           \seq_map_inline:Nn \l_tmpa_seq {
-            \seq_put_right:Nn \l_tmpb_seq { ##1 }
+            \seq_put_right:Nn \l_@@_precedences_seq { ##1 }
           }
         }
       }{
@@ -824,11 +839,12 @@
 
   \seq_pop_left:NN \l_@@_remaining_precs_seq \l_tmpa_str
   \tl_put_right:Nx \l_stex_notation_dummyargs_tl { {
-    \STEXInternalTermMathAssocArgiiii
-      { #1\int_use:N \l_@@_currarg_int }
+    \STEXInternalTermMathAssocArgiiiii
+      { \int_use:N \l_@@_currarg_int }
       { \l_tmpa_str }
       { ####\int_use:N \l_@@_currarg_int }
       { \l_tmpa_cs {####1} {####2} }
+      {#1}
   } }
   \_@@_arguments:
 }
@@ -1036,7 +1052,6 @@
 %    \begin{macrocode}
 \keys_define:nn { stex / symdef } {
   name    .str_set_x:N = \l_stex_symdecl_name_str ,
-  local   .bool_set:N  = \l_stex_symdecl_local_bool ,
   args    .str_set_x:N = \l_stex_symdecl_args_str ,
   type    .tl_set:N    = \l_stex_symdecl_type_tl ,
   def     .tl_set:N    = \l_stex_symdecl_definiens_tl ,
@@ -1045,6 +1060,7 @@
  % lang    .str_set_x:N = \l_@@_lang_str ,
   variant .str_set_x:N = \l_@@_variant_str ,
   prec    .str_set_x:N = \l_@@_prec_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
   assoc   .choices:nn  = 
       {bin,binl,binr,pre,conj,pwconj}
       {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}},
@@ -1060,6 +1076,7 @@
   \bool_set_false:N \l_stex_symdecl_local_bool
   \tl_clear:N \l_stex_symdecl_type_tl
   \tl_clear:N \l_stex_symdecl_definiens_tl
+  \clist_clear:N \l_stex_symdecl_argnames_clist
  % \str_clear:N \l_@@_lang_str
   \str_clear:N \l_@@_variant_str
   \str_clear:N \l_@@_prec_str
@@ -1086,6 +1103,70 @@
     { \l_@@_prec_str}
 }
 \stex_deactivate_macro:Nn \symdef {module~environments}
+
+\keys_define:nn { stex / mmtdef } {
+  name    .str_set_x:N = \l_stex_symdecl_name_str ,
+  args    .str_set_x:N = \l_stex_symdecl_args_str ,
+  reorder .str_set_x:N = \l_stex_symdecl_reorder_str ,
+  op      .tl_set:N    = \l_@@_op_tl ,
+ % lang    .str_set_x:N = \l_@@_lang_str ,
+  variant .str_set_x:N = \l_@@_variant_str ,
+  prec    .str_set_x:N = \l_@@_prec_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
+  assoc   .choices:nn  = 
+      {bin,binl,binr,pre,conj,pwconj}
+      {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}},
+  unknown .code:n      = \str_set:Nx 
+      \l_@@_variant_str \l_keys_key_str
+}
+\cs_new_protected:Nn \_stex_mmtdef_args:n {
+  \str_clear:N \l_stex_symdecl_name_str
+  \str_clear:N \l_stex_symdecl_args_str
+  \str_clear:N \l_stex_symdecl_assoctype_str
+  \str_clear:N \l_stex_symdecl_reorder_str
+  \bool_set_false:N \l_stex_symdecl_local_bool
+  \clist_clear:N \l_stex_symdecl_argnames_clist
+ % \str_clear:N \l_@@_lang_str
+  \str_clear:N \l_@@_variant_str
+  \str_clear:N \l_@@_prec_str
+  \tl_clear:N \l_@@_op_tl
+  
+  \keys_set:nn { stex / mmtdef } { #1 }
+}
+
+\NewDocumentCommand \mmtdef {m O{} }{
+  \_stex_mmtdef_args:n{ #2 }
+  \bool_set_true:N \l_stex_symdecl_make_macro_bool
+  \str_if_empty:NT \l_stex_symdecl_name_str {
+    \str_set:Nx \l_stex_symdecl_name_str { #1 }
+  }
+  %\tl_set:Nx \l_stex_symdecl_definiens_tl {
+  %  \stex_annotate:nnn{ OMID }{
+  %    \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str 
+  %  }{}
+  %}
+  \stex_symdecl_do:n { #1 }
+  \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_current_module_str ? \l_stex_symdecl_name_str
+    }{},
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str 
+    }{}
+  }
+  \tl_set:Nn \l_stex_notation_after_do_tl {
+    \_@@_final:
+    \stex_smsmode_do:\ignorespacesandpars
+  }
+  \str_set:Nx \l_stex_get_symbol_uri_str {
+    \l_stex_current_module_str ? \l_stex_symdecl_name_str
+  }
+  \exp_args:Nx \stex_notation_do:nnnnn
+    { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } }
+    { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } }
+    { \l_@@_variant_str }
+    { \l_@@_prec_str}
+}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1102,6 +1183,7 @@
   op      .tl_set:N     = \l_@@_op_tl ,
   prec    .str_set_x:N  = \l_@@_prec_str ,
   reorder .str_set_x:N  = \l_@@_reorder_str ,
+  argnames    .clist_set:N  = \l_@@_argnames_clist ,
   assoc   .choices:nn   = 
       {bin,binl,binr,pre,conj,pwconj}
       {\str_set:Nx \l_@@_assoctype_str {\l_keys_choice_tl}},
@@ -1120,6 +1202,7 @@
   \tl_clear:N \l_@@_type_tl
   \tl_clear:N \l_@@_def_tl
   \tl_clear:N \l_@@_op_tl
+  \clist_clear:N \l_@@_argnames_clist
 
   \keys_set:nn { stex / vardef } { #1 }
 }
@@ -1176,8 +1259,22 @@
   \prop_put:Nnx \l_tmpa_prop { assocs } { \int_use:N \l_tmpb_int }
   \tl_set:cx { #1 }{ \stex_invoke_variable:n { \l_@@_name_str } }
 
-  \prop_set_eq:cN { l_stex_variable_\l_@@_name_str _prop} \l_tmpa_prop
+  % argnames
 
+  \clist_clear:N \l_tmpa_clist
+  \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} {
+    \clist_if_empty:NTF \l_@@_argnames_clist {
+      \clist_put_right:Nn \l_tmpa_clist {##1}
+    }{
+      \clist_pop:NN \l_@@_argnames_clist \l_tmpa_tl
+      \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl}
+    }
+  }
+  \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,}
+
+
+  \prop_set_eq:cN { l_stex_symdecl_var://\l_@@_name_str _prop} \l_tmpa_prop
+
   \tl_if_empty:NF \l_@@_op_tl {
     \cs_set:cpx {
       stex_var_op_notation_ \l_@@_name_str _cs
@@ -1352,6 +1449,17 @@
 
   \cs_generate_from_arg_count:cNnn {stex_varseq_\l_@@_name_str _cs}
     \cs_set:Npn  {\int_use:N \l_@@_args_int} { #5 }
+
+  % argnames
+
+  \clist_clear:N \l_tmpa_clist
+  \int_step_inline:nn {\l_@@_args_int} {
+      \clist_put_right:Nn \l_tmpa_clist {##1}
+  }
+  \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,}
+
+
+
   
   \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l_@@_name_str _cs}}
   \int_step_inline:nn \l_@@_args_int {
@@ -1399,6 +1507,8 @@
     \expandafter\meaning\csname stex_varseq_\l_@@_name_str _cs\endcsname\\~\\
     \prop_to_keyval:N \l_tmpa_prop
   }
+  \prop_set_eq:cN {l_stex_symdecl_varseq://\l_@@_name_str _prop}\l_tmpa_prop
+  
   \stex_if_do_html:T{\stex_annotate_invisible:nnn{varseq}{\l_@@_name_str}{
     \tl_if_empty:NF \l_@@_type_tl {
       \stex_annotate:nnn {type}{}{$\l_@@_type_tl$}
@@ -1428,10 +1538,63 @@
 
   }}
 
-  \prop_set_eq:cN {stex_varseq_\l_@@_name_str _prop}\l_tmpa_prop
   \ignorespacesandpars
 }
 
+
+\keys_define:nn { stex / mmtdecl } {
+  name        .str_set_x:N  = \l_stex_symdecl_name_str ,
+  args        .str_set_x:N  = \l_stex_symdecl_args_str ,
+  deprecate   .str_set_x:N  = \l_stex_symdecl_deprecate_str ,
+  reorder     .str_set_x:N  = \l_stex_symdecl_reorder_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
+  assoc       .choices:nn   = 
+      {bin,binl,binr,pre,conj,pwconj}
+      {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}
+}
+
+\cs_new_protected:Nn \_stex_mmtdecl_args:n {
+  \str_clear:N \l_stex_symdecl_name_str
+  \str_clear:N \l_stex_symdecl_args_str
+  \str_clear:N \l_stex_symdecl_deprecate_str
+  \str_clear:N \l_stex_symdecl_reorder_str
+  \str_clear:N \l_stex_symdecl_assoctype_str
+  \bool_set_false:N \l_stex_symdecl_local_bool
+  \clist_clear:N \l_stex_symdecl_argnames_clist
+  
+  \keys_set:nn { stex / symdecl } { #1 }
+}
+
+\NewDocumentCommand \mmtdecl { s m O{}} {
+  \_stex_mmtdecl_args:n{#3}
+  \IfBooleanTF #1 {
+    \bool_set_false:N \l_stex_symdecl_make_macro_bool
+  } {
+    \bool_set_true:N \l_stex_symdecl_make_macro_bool
+  }
+  \str_if_empty:NT \l_stex_symdecl_name_str {
+    \str_set:Nx \l_stex_symdecl_name_str { #1 }
+  }
+  %\tl_set:Nx \l_stex_symdecl_definiens_tl {
+  %  \stex_annotate:nnn{ OMID }{
+  %    \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str 
+  %  }{}
+  %}
+  \stex_symdecl_do:n{#2}
+  \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_current_module_str ? \l_stex_symdecl_name_str
+    }{},
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str 
+    }{}
+  }
+  \stex_smsmode_do:
+}
+
+\stex_deactivate_macro:Nn \mmtdecl {mmtinterface~environments}
+\stex_deactivate_macro:Nn \mmtdef {mmtinterface~environments}
+
 %    \end{macrocode}
 %
 %    \begin{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/stex/stex/stex-terms.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/stex/stex/stex-terms.dtx	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/source/latex/stex/stex/stex-terms.dtx	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -89,8 +89,8 @@
 % with (downwards) argument precedence \meta{prec}.
 % \end{function}
 %
-% \begin{function}{\STEXInternalTermMathAssocArgiiii}
-%   \begin{syntax} \cs{stex_term_arg:nnn}\meta{int}\meta{prec}\meta{notation}\meta{body} \end{syntax}
+% \begin{function}{\STEXInternalTermMathAssocArgiiiii}
+%   \begin{syntax} \cs{stex_term_arg:nnn}\meta{int}\meta{prec}\meta{notation}\meta{type}\meta{body} \end{syntax}
 % Annotates \meta{body} as the \meta{int}th (associative) \emph{sequence} argument
 % (as comma-separated list of terms) of the current |OMA| or |OMBIND|,
 % with (downwards) argument precedence \meta{prec} and associative
@@ -267,8 +267,10 @@
     \def\comp{\_comp}
     \str_set:Nn \STEXInternalCurrentSymbolStr { #1 }
     \bool_set_false:N \l_stex_allow_semantic_bool
-    \_stex_term_oms:nnn {#1}{#1 \c_hash_str CUSTOM-}{
-      \comp{ #2 }
+    \stex_mathml_intent:nn{#1}{
+      \_stex_term_oms:nnn {#1}{#1 \c_hash_str CUSTOM-}{
+        \comp{ #2 }
+      }
     }
   }{
     \_stex_reset:N \comp
@@ -382,6 +384,8 @@
 }
 
 \prop_new:N \l_@@_custom_args_prop
+\clist_new:N \l_stex_argnames_seq
+\seq_new:N \l_@@_tmp_seq
 
 \cs_new_protected:Nn\_@@_custom_comp:n{\bool_set_false:N \l_stex_allow_semantic_bool\_comp{#1}\bool_set_true:N \l_stex_allow_semantic_bool}
 
@@ -394,23 +398,47 @@
     \prop_get:cnN {
       l_stex_symdecl_#1 _prop
     }{ args } \l_tmpa_str
+    \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq {
+      \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames}
+    }
     \prop_put:Nno \l_@@_custom_args_prop {args} \l_tmpa_str
     \tl_set:Nn \arg { \_@@_arg: }
     \str_if_empty:NTF \l_tmpa_str {
-      \_stex_term_oms:nnn {#1}{#1\c_hash_str CUSTOM-}{\ignorespaces#2}
+      \stex_mathml_intent:nn{#1}{
+        \_stex_term_oms:nnn {#1}{#1\c_hash_str CUSTOM-}{\ignorespaces#2}
+      }
     }{
-      \str_if_in:NnTF \l_tmpa_str b {
-        \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
+      \seq_clear:N \l_@@_tmp_seq
+      \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{
+        \tl_set:Nx \l_@@_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}}
+        \bool_lazy_or:nnT{
+          \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}}
+        }{
+          \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}}
+        }{
+          \tl_put_right:Nn \l_@@_tmp_tl +
+        }
+        \seq_put_right:No \l_@@_tmp_seq \l_@@_tmp_tl
+      }
+      \stex_mathml_intent:nn{
+        #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }](
+          \seq_use:Nn \l_@@_tmp_seq ,
+        )
       }{
-        \str_if_in:NnTF \l_tmpa_str B {
+        \str_if_in:NnTF \l_tmpa_str b {
           \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
         }{
-          \_stex_term_oma:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
+          \str_if_in:NnTF \l_tmpa_str B {
+            \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
+          }{
+            \_stex_term_oma:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
+          }
         }
       }
     }
     % TODO check that all arguments exist
   }{
+    \_stex_reset:N \l_stex_argnames_seq
     \_stex_reset:N \STEXInternalCurrentSymbolStr
     \_stex_reset:N \arg
     \_stex_reset:N \comp
@@ -452,15 +480,21 @@
     }
   }
   \exp_args:NNx \prop_put:Nnn \l_@@_custom_args_prop {\int_use:N \l_tmpa_int} {\ignorespaces#3}
-  \bool_set_true:N \l_stex_allow_semantic_bool
-  \IfBooleanTF#1{
-    \stex_annotate_invisible:n { %TODO
+  \bool_if:NTF \l_stex_allow_semantic_bool \use_i:nn {
+    \bool_set_true:N \l_stex_allow_semantic_bool  
+    \use:nn
+  }
+  {
+  \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{
+    \IfBooleanTF#1{
+      \stex_annotate_invisible:n { %TODO
+        \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3}
+      }
+    }{ %TODO
       \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3}
     }
-  }{ %TODO
-    \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3}
-  }
-  \bool_set_false:N \l_stex_allow_semantic_bool
+  }}
+  {\bool_set_false:N \l_stex_allow_semantic_bool}
 }
 
 
@@ -473,7 +507,9 @@
 \cs_new_protected:Npn \STEXInternalTermMathArgiii #1#2#3 {
   \exp_args:Nnx \use:nn
     { \int_set:Nn \l_@@_downprec { #2 } 
+      \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{
         \_stex_term_arg:nn { #1 }{ #3 }
+      }
     }
     { \int_set:Nn \exp_not:N \l_@@_downprec { \int_use:N \l_@@_downprec } }
 }
@@ -480,28 +516,28 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\STEXInternalTermMathAssocArgiiii}
+% \begin{macro}{\STEXInternalTermMathAssocArgiiiii}
 %    \begin{macrocode}
-\cs_new_protected:Npn \STEXInternalTermMathAssocArgiiii #1#2#3#4 {
+\cs_new_protected:Npn \STEXInternalTermMathAssocArgiiiii #1#2#3#4#5 {
   \cs_set:Npn \l_tmpa_cs ##1 ##2 { #4 }
-  \tl_set:Nn \l_tmpb_tl {\STEXInternalTermMathArgiii{#1}{#2}}
+  \tl_set:Nn \l_tmpb_tl {\STEXInternalTermMathArgiii{#5#1}{#2}}
   \tl_if_empty:nTF { #3 }{
-    \STEXInternalTermMathArgiii{#1}{#2}{}
+    \STEXInternalTermMathArgiii{#5#1}{#2}{}
   }{
     \exp_args:Nx \tl_if_empty:nTF { \tl_tail:n{ #3 }}{
       \expandafter\if\expandafter\relax\noexpand#3
-        \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_maybe_sequence:Nn#3{#1}}
+        \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_maybe_sequence:Nnn#3{#1}{#5}}
       \else
-        \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_simple:nn{#1}{#3}}
+        \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_simple:nnn{#1}{#3}{#5}}
       \fi
       \l_tmpa_tl
     }{
-      \_@@_math_assoc_arg_simple:nn{#1}{#3}
+      \_@@_math_assoc_arg_simple:nnn{#1}{#3}{#5}
     }
   }
 }
 
-\cs_new_protected:Nn \_@@_math_assoc_arg_maybe_sequence:Nn {
+\cs_new_protected:Nn \_@@_math_assoc_arg_maybe_sequence:Nnn {
   \str_set:Nx \l_tmpa_str { \cs_argument_spec:N #1 }
   \str_if_empty:NTF \l_tmpa_str {
     \exp_args:Nx \cs_if_eq:NNTF {
@@ -509,7 +545,7 @@
     } \stex_invoke_sequence:n {
       \tl_set:Nx \l_tmpa_tl {\tl_tail:N #1}
       \str_set:Nx \l_tmpa_str {\exp_after:wN \use:n \l_tmpa_tl}
-      \tl_set:Nx \l_tmpa_tl {\prop_item:cn {stex_varseq_\l_tmpa_str _prop}{notation}}
+      \tl_set:Nx \l_tmpa_tl {\prop_item:cn {l_stex_symdecl_varseq://\l_tmpa_str _prop}{notation}}
       \exp_args:NNo \seq_set_from_clist:Nn \l_tmpa_seq \l_tmpa_tl
       \tl_set:Nx \l_tmpa_tl {{\exp_not:N \exp_not:n{
         \exp_not:n{\exp_args:Nnx \use:nn} {
@@ -525,7 +561,7 @@
           }
         }
       }}}
-      \exp_args:Nno \use:nn {\seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq} \l_tmpa_tl
+      \exp_args:Nno \use:n {\seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq} \l_tmpa_tl
       \seq_reverse:N \l_tmpa_seq
       \seq_pop:NN \l_tmpa_seq \l_tmpa_tl
       \seq_map_inline:Nn \l_tmpa_seq {
@@ -541,28 +577,38 @@
       }
       \exp_args:No\l_tmpb_tl\l_tmpa_tl
     }{
-      \_@@_math_assoc_arg_simple:nn{#2} { #1 }
+      \_@@_math_assoc_arg_simple:nnn{#2} { #1 }{#3}
     }
   } {
-    \_@@_math_assoc_arg_simple:nn{#2} { #1 }
+    \_@@_math_assoc_arg_simple:nnn{#2} { #1 }{#3}
   }
 
 }
 
-\cs_new_protected:Nn \_@@_math_assoc_arg_simple:nn {
+\cs_new_protected:Nn \_@@_math_assoc_arg_simple:nnn {
   \clist_set:Nn \l_tmpa_clist{ #2 }
   \int_compare:nNnTF { \clist_count:N \l_tmpa_clist } < 2 {
-    \tl_set:Nn \l_tmpa_tl { \_stex_term_arg:nn{A#1}{ #2 } }
+    \tl_set:Nn \l_tmpa_tl { 
+      \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{
+        \_stex_term_arg:nn{A#3#1}{ #2 } }
+    }
   }{
     \clist_reverse:N \l_tmpa_clist
     \clist_pop:NN \l_tmpa_clist \l_tmpa_tl
-    \tl_set:Nx \l_tmpa_tl { \_stex_term_arg:nn{A#1}{
-      \exp_args:No \exp_not:n \l_tmpa_tl
+    \tl_set:Nx \l_tmpa_tl { 
+      \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{
+        \_stex_term_arg:nn{A#3#1}{
+        \exp_args:No \exp_not:n \l_tmpa_tl
+      }
     }}
     \clist_map_inline:Nn \l_tmpa_clist {
       \exp_args:NNNo \exp_args:NNo \tl_set:No \l_tmpa_tl {
         \exp_args:Nno 
-        \l_tmpa_cs { \_stex_term_arg:nn{A#1}{##1} } \l_tmpa_tl 
+        \l_tmpa_cs { 
+          \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{
+            \_stex_term_arg:nn{A#3#1}{##1} 
+          }
+        } \l_tmpa_tl 
       }
     }
   }
@@ -679,7 +725,9 @@
 
 \cs_new_protected:Npn \STEXInternalTermMathOMSiiii #1#2#3#4 {
   \_@@_maybe_brackets:nn { #3 }{ 
-    \_stex_term_oms:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    \stex_mathml_intent:nn{#1} {
+      \_stex_term_oms:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    }
   }
 }
 %    \end{macrocode}
@@ -704,9 +752,36 @@
 }
 
 \cs_new_protected:Npn \STEXInternalTermMathOMAiiii #1#2#3#4 {
+  \exp_args:Nnx \use:nn {
+    \seq_clear:N \l_@@_tmp_seq
+    \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{
+    \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq {
+      \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames}
+    }
+    \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{
+      \tl_set:Nx \l_@@_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}}
+      \bool_lazy_or:nnT{
+        \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}}
+      }{
+        \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}}
+      }{
+        \tl_put_right:Nn \l_@@_tmp_tl +
+      }
+      \seq_put_right:No \l_@@_tmp_seq \l_@@_tmp_tl
+    }
+  }
   \_@@_maybe_brackets:nn { #3 }{ 
-    \_stex_term_oma:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    \stex_mathml_intent:nn{
+      #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }](
+        \seq_use:Nn \l_@@_tmp_seq ,
+      )
+    }{
+      \_stex_term_oma:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    }
   }
+  }{
+    \_stex_reset:N \l_stex_argnames_seq
+  }
 }
 %    \end{macrocode}
 % \end{macro}
@@ -720,9 +795,36 @@
 }
 
 \cs_new_protected:Npn \STEXInternalTermMathOMBiiii #1#2#3#4 {
+  \exp_args:Nnx \use:nn {
+    \seq_clear:N \l_@@_tmp_seq
+    \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{
+    \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq {
+      \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames}
+    }
+    \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{
+      \tl_set:Nx \l_@@_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}}
+      \bool_lazy_or:nnT{
+        \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}}
+      }{
+        \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}}
+      }{
+        \tl_put_right:Nn \l_@@_tmp_tl +
+      }
+      \seq_put_right:No \l_@@_tmp_seq \l_@@_tmp_tl
+    }
+  }
   \_@@_maybe_brackets:nn { #3 }{ 
-    \_stex_term_ombind:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    \stex_mathml_intent:nn{
+      #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }](
+        \seq_use:Nn \l_@@_tmp_seq ,
+      )
+    }{
+      \_stex_term_ombind:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    }
   }
+  }{
+    \_stex_reset:N \l_stex_argnames_seq
+  }
 }
 %    \end{macrocode}
 % \end{macro}
@@ -990,7 +1092,7 @@
       \_stex_reset:N \STEXInternalCurrentSymbolStr
     }
   }{
-    \int_compare:nNnTF {\prop_item:cn {l_stex_variable_#1_prop}{arity}} = 0{
+    \int_compare:nNnTF {\prop_item:cn {l_stex_symdecl_var://#1_prop}{arity}} = 0{
       \_@@_invoke_math_ii:n {#1}
     }{
       \msg_error:nnxx{stex}{error/noop}{variable~#1}{}
@@ -1024,7 +1126,7 @@
     \prop_clear:N \l__stex_terms_custom_args_prop
     \prop_put:Nnn \l__stex_terms_custom_args_prop {currnum} {1}
     \prop_get:cnN {
-      l_stex_variable_#1 _prop
+      l_stex_symdecl_var://#1 _prop
     }{ args } \l_tmpa_str
     \prop_put:Nno \l__stex_terms_custom_args_prop {args} \l_tmpa_str
     \tl_set:Nn \arg { \__stex_terms_arg: }
@@ -1063,7 +1165,7 @@
       \exp_args:Nnx \use:nn {
         \def\comp{\_varcomp}
         \str_set:Nn \STEXInternalCurrentSymbolStr {varseq://#1}
-        \prop_item:cn{stex_varseq_#1_prop}{notation}
+        \prop_item:cn{l_stex_symdecl_varseq://#1_prop}{notation}
       }{
         \_stex_reset:N \comp
         \_stex_reset:N \STEXInternalCurrentSymbolStr

Modified: trunk/Master/texmf-dist/tex/latex/stex/document-structure.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/document-structure.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/document-structure.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -6,12 +6,12 @@
 %%
 %% document-structure.dtx  (with options: `package')
 %% 
-\ProvidesExplPackage{document-structure}{2022/05/24}{3.1.0}{Modular Document Structure}
+\ProvidesExplPackage{document-structure}{2022/09/14}{3.2.0}{Modular Document Structure}
 \RequirePackage{l3keys2e}
 
 \keys_define:nn{ document-structure }{
   class       .str_set_x:N  = \c_document_structure_class_str,
-  topsect     .str_set_x:N  = \c_document_structure_topsect_str,,
+  topsect     .str_set_x:N  = \c_document_structure_topsect_str,
   unknown     .code:n       = {
     \PassOptionsToClass{\CurrentOption}{stex}
     \PassOptionsToClass{\CurrentOption}{tikzinput}
@@ -30,7 +30,7 @@
 \AddToHook{begindocument}{
 \ltx at ifpackageloaded{babel}{
     \clist_set:Nx \l_tmpa_clist {\bbl at loaded}
-    \clist_if_in:NnT \l_tmpa_clist {ngerman}{
+    \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{
       \makeatletter\input{document-structure-ngerman.ldf}\makeatother
     }
   }{}
@@ -98,7 +98,6 @@
   srccite       .tl_set:N    = \l__document_structure_sfragment_srccite_tl,
   type          .tl_set:N    = \l__document_structure_sfragment_type_tl,
   short         .tl_set:N    = \l__document_structure_sfragment_short_tl,
-  display       .tl_set:N    = \l__document_structure_sfragment_display_tl,
   intro         .tl_set:N    = \l__document_structure_sfragment_intro_tl,
   imports       .tl_set:N    = \l__document_structure_sfragment_imports_tl,
   loadmodules   .bool_set:N  = \l__document_structure_sfragment_loadmodules_bool
@@ -111,7 +110,6 @@
   \tl_clear:N \l__document_structure_sfragment_srccite_tl
   \tl_clear:N \l__document_structure_sfragment_type_tl
   \tl_clear:N \l__document_structure_sfragment_short_tl
-  \tl_clear:N \l__document_structure_sfragment_display_tl
   \tl_clear:N \l__document_structure_sfragment_imports_tl
   \tl_clear:N \l__document_structure_sfragment_intro_tl
   \bool_set_false:N \l__document_structure_sfragment_loadmodules_bool

Deleted: trunk/Master/texmf-dist/tex/latex/stex/etc/beamernotesthemesTeX.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/etc/beamernotesthemesTeX.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/etc/beamernotesthemesTeX.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,14 +0,0 @@
-% Beamer sTeX notes theme;
-% Copyright (c) 2022 Michael Kohlhase <michael.kohlhase at fau.de>.
-\ProvidesPackage{beamernotestheme-sTeX}
-\typeout{Beamer sTeX notes theme}
-\setbeamertemplate{theorem begin}
-{%
-  \inserttheoremheadfont
-  \inserttheoremname
-  \inserttheoremnumber
-  \ifx \inserttheoremaddition \empty \else\ (\inserttheoremaddition)\fi
-  \inserttheorempunctuation\xspace
-  \inserttheorembodyfont
-}
-\setbeamertemplate{theorem end}{}

Modified: trunk/Master/texmf-dist/tex/latex/stex/etc/beamerthemesTeX.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/etc/beamerthemesTeX.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/etc/beamerthemesTeX.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,25 +1,58 @@
 % Beamer sTeX slide theme;
 % Copyright (c) 20 Michael Kohlhase <michael.kohlhase at fau.de>.
-\ProvidesPackage{beamertheme-sTeX}
+\ProvidesPackage{beamerthemesTeX}
 \typeout{Beamer sTeX theme}
 \RequirePackage{xspace}
+\RequirePackage{xcolor}
+\RequirePackage{stex}
 
-% General appearance  of theorems, like "ams style", but without the block env. 
-\setbeamertemplate{theorem begin}
-{%
-  \inserttheoremheadfont
-  \inserttheoremname
-  \inserttheoremnumber
-  \ifx \inserttheoremaddition \empty \else\ (\inserttheoremaddition)\fi
-  \inserttheorempunctuation\xspace
-  \inserttheorembodyfont
+\ExplSyntaxOn
+\protected\def\stexbeamerthm#1#2#3#4#5#6#7#8{
+  \newcounter{#1}
+  \tl_if_empty:nF{#4}{
+    \tl_set:cn{the#1}{
+      \use:c{the#4}.\arabic{#1}
+    }
+  }
+  \tl_set:cn{#1autorefname}{#6}
+
+  \newenvironment{#1}{
+    \ifhmode\par\fi
+
+    \tl_if_empty:nF{#5}{
+      \setcounter{#1}{\value{#5}}
+      \stepcounter{#5}
+    }
+    \refstepcounter{#1}
+    \noindent#7{
+      #6~\use:c{the#1}
+      \tl_if_empty:cF{s#2title}{
+        {}~(\csname s#2title\endcsname)
+      }.
+    }
+    #8
+  }{\par}
+  \csname stexpatch#2\endcsname[#3]{\begin{#1}}{\end{#1}}
 }
-\setbeamertemplate{theorem end}{}
+\ExplSyntaxOff
 
+\stexbeamerthm{theorem}{assertion}{theorem}{section}{}{Theorem}\textbf\itshape
+\stexbeamerthm{observation}{assertion}{observation}{section}{theorem}{Observation}\textbf\itshape
+\stexbeamerthm{corollary}{assertion}{corollary}{section}{theorem}{Corollary}\textbf\itshape
+\stexbeamerthm{lemma}{assertion}{lemma}{section}{theorem}{Lemma}\textbf\itshape
+\stexbeamerthm{axiom}{assertion}{axiom}{section}{theorem}{Axiom}\textbf\itshape
+\stexbeamerthm{remark}{assertion}{remark}{section}{theorem}{Remark}\emph{}
+\stexpatchparagraph[remark]{\begin{remark}}{\end{remark}}
+\stexbeamerthm{example}{example}{}{section}{theorem}{Example}\textbf{}
+\stexbeamerthm{definition}{definition}{}{section}{theorem}{Definition}\textbf{}
+
+
 % THEME
 \mode
 <presentation>
 
+\sffamily
+
 \ifcsname slidelogo\endcsname\else
   \newsavebox\slidelogo
   \sbox\slidelogo{\sTeX}
@@ -64,3 +97,42 @@
 \setlength\leftmarginii{1em}
 \setlength\leftmarginiii{1em}
 \providecommand{\vstretch}[1]{\vspace*{\stretch{#1}}}
+
+%% set the colors for sTeX content highlighting
+
+\def\compemph#1{\ifcsname textcolor\endcsname\textcolor{SteelBlue}{#1}\else#1\fi}
+\def\symrefemph#1{\ifcsname textcolor\endcsname\textcolor{SteelBlue}{#1}\else#1\fi}
+\def\defemph#1{\ifcsname textcolor\endcsname\textcolor{magenta}{#1}\else\textbf{#1}\fi}
+\def\varemph#1{\ifcsname textcolor\endcsname\textcolor{gray}{#1}\else#1\fi}
+\def\titleemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{#1}\else\textbf{#1}\fi}
+
+%% set PDF tooltips
+\RequirePackage{pdfcomment}
+\protected\def\compemph at uri#1#2{%
+  \pdftooltip{%
+    \srefsymuri{#2}{\compemph{#1}}%
+  }{%
+    URI:~\detokenize{#2}%
+  }%
+}
+\protected\def\symrefemph at uri#1#2{%
+  \pdftooltip{%
+    \srefsymuri{#2}{\symrefemph{#1}}%
+  }{%
+    URI:~\detokenize{#2}%
+  }%
+}
+\protected\def\defemph at uri#1#2{%
+  \pdftooltip{%
+    \defemph{#1}%
+  }{%
+    URI:~\detokenize{#2}%
+  }%
+}
+\protected\def\varemph at uri#1#2{%
+  \pdftooltip{%
+    \varemph{#1}%
+  }{%
+    Variable~\detokenize{#2}%
+  }%
+}
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-pdflatex.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-pdflatex.cfg	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-pdflatex.cfg	2022-09-14 19:58:16 UTC (rev 64383)
@@ -1,6 +1,8 @@
 \tl_const:Nx \c_stex_html_emptyarg_tl {~}
 
 \cs_new_protected:Nn \stex_annotate:nnn {#3}
+\cs_new_protected:Nn \stex_mathml_intent:nn { #2 }
+\cs_new_protected:Nn \stex_mathml_arg:nn { #2 }
 \cs_new_protected:Nn \stex_annotate_invisible:n {}
 \cs_new_protected:Nn \stex_annotate_invisible:nnn {}
 \NewDocumentEnvironment{stex_annotate_env} { m m } {}{}

Modified: trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-rustex.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-rustex.cfg	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-rustex.cfg	2022-09-14 19:58:16 UTC (rev 64383)
@@ -20,6 +20,16 @@
         }
     }
 }
+\cs_new_protected:Nn \stex_mathml_intent:nn {
+    \rustex_annotate_HTML:nn {
+        mml:intent="#1"
+    }{ #2 }
+}
+\cs_new_protected:Nn \stex_mathml_arg:nn {
+    \rustex_annotate_HTML:nn {
+        mml:arg="#1"
+    }{ #2 }
+}
 
 \cs_new_protected:Nn \stex_annotate_invisible:n {
     \_stex_html_checkempty:n { #1 }

Added: trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-tex4ht.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-tex4ht.cfg	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-tex4ht.cfg	2022-09-14 19:58:16 UTC (rev 64383)
@@ -0,0 +1,13 @@
+% TODO
+\tl_const:Nx \c_stex_html_emptyarg_tl {~}
+
+\cs_new_protected:Nn \stex_annotate:nnn {#3} % TODO
+\cs_new_protected:Nn \stex_mathml_intent:nn { #2 } % TODO
+\cs_new_protected:Nn \stex_mathml_arg:nn { #2 } % TODO
+\cs_new_protected:Nn \stex_annotate_invisible:n {} % TODO
+\cs_new_protected:Nn \stex_annotate_invisible:nnn {} % TODO
+\NewDocumentEnvironment{stex_annotate_env} { m m } {}{} % TODO
+
+\prg_new_conditional:Nnn \stex_html_backend: {p, T, F, TF} {
+  \prg_return_true:
+}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/stex/etc/stex-backend-tex4ht.cfg
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/stex/etc/stexthm.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/etc/stexthm.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/etc/stexthm.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -4,51 +4,53 @@
 \RequirePackage{amsthm}
 \RequirePackage{thmtools}
 
+\ExplSyntaxOn
+
 \declaretheorem[parent=section]{theorem}
 \stexpatchassertion[theorem]
-{\ifx\sassertiontitle\@empty\begin{theorem}\else\begin{theorem}[\sassertiontitle]\fi}
+{\ifx\sassertiontitle\@empty\begin{theorem}\else\exp_args:Nno\use:nn{\begin{theorem}[}\sassertiontitle]\fi}
 {\end{theorem}}    
 
 \declaretheorem[sibling=theorem]{observation}
 \stexpatchassertion[observation]
-{\ifx\sassertiontitle\@empty\begin{observation}\else\begin{observation}[\sassertiontitle]\fi}
+{\ifx\sassertiontitle\@empty\begin{observation}\else\exp_args:Nno\use:nn{\begin{observation}[}\sassertiontitle]\fi}
 {\end{observation}}
 
 \declaretheorem[sibling=theorem]{corollary}
 \stexpatchassertion[corollary]
-{\ifx\sassertiontitle\@empty\begin{corollary}\else\begin{corollary}[\sassertiontitle]\fi}
+{\ifx\sassertiontitle\@empty\begin{corollary}\else\exp_args:Nno\use:nn{\begin{corollary}[}\sassertiontitle]\fi}
 {\end{corollary}}
 
 \declaretheorem[sibling=theorem]{lemma}
 \stexpatchassertion[lemma]
-{\ifx\sassertiontitle\@empty\begin{lemma}\else\begin{lemma}[\sassertiontitle]\fi}
+{\ifx\sassertiontitle\@empty\begin{lemma}\else\exp_args:Nno\use:nn{\begin{lemma}[}\sassertiontitle]\fi}
 {\end{lemma}}
   
 \declaretheorem[sibling=theorem]{axiom}
 \stexpatchassertion[axiom]
-{\ifx\sassertiontitle\@empty\begin{axiom}\else\begin{axiom}[\sassertiontitle]\fi}
+{\ifx\sassertiontitle\@empty\begin{axiom}\else\exp_args:Nno\use:nn{\begin{axiom}[}\sassertiontitle]\fi}
 {\end{axiom}}
 
 \declaretheorem[sibling=theorem,style=remark]{remark}
 \stexpatchassertion[remark]
-{\ifx\sassertiontitle\@empty\begin{remark}\else\begin{remark}[\sassertiontitle]\fi}
+{\ifx\sassertiontitle\@empty\begin{remark}\else\exp_args:Nno\use:nn{\begin{remark}[}\sassertiontitle]\fi}
 {\end{remark}}
 \stexpatchparagraph[remark]
-{\ifx\sparagraphtitle\@empty\begin{remark}\else\begin{remark}[\sparagraphtitle]\fi}
+{\ifx\sparagraphtitle\@empty\begin{remark}\else\exp_args:Nno\use:nn{\begin{remark}[}\sparagraphtitle]\fi}
 {\end{remark}}
 
 \declaretheorem[sibling=theorem,style=definition]{example}
 \stexpatchexample
-{\ifx\sexampletitle\@empty\begin{example}\else\begin{example}[\sexampletitle]\fi}
+{\ifx\sexampletitle\@empty\begin{example}\else\exp_args:Nno\use:nn{\begin{example}[}\sexampletitle]\fi}
 {\end{example}}
 
 \declaretheorem[sibling=theorem,style=definition]{definition}
 \stexpatchdefinition
-{\ifx\sdefinitiontitle\@empty\begin{definition}\else\begin{definition}[\sdefinitiontitle]\fi}
+{\ifx\sdefinitiontitle\@empty\begin{definition}\else\exp_args:Nno\use:nn{\begin{definition}[}\sdefinitiontitle]\fi}
     {\end{definition}}
 
-
-\RequirePackage{pdfcomment}
+\ExplSyntaxOff
+  
 \RequirePackage{xcolor}
 
 \def\compemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{#1}\else#1\fi}
@@ -56,31 +58,32 @@
 \def\defemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{\textbf{#1}}\else\textbf{#1}\fi}
 \def\varemph#1{\ifcsname textcolor\endcsname\textcolor{gray}{#1}\else#1\fi}
 
+\RequirePackage{pdfcomment}
 \protected\def\compemph at uri#1#2{%
-  \pdftooltip{%
-    \srefsymuri{#2}{\compemph{#1}}%
-  }{%
-    URI:~\detokenize{#2}%
-  }%
+   \pdftooltip{%
+     \srefsymuri{#2}{\compemph{#1}}%
+   }{%
+     URI:~\detokenize{#2}%
+   }%
 }
 \protected\def\symrefemph at uri#1#2{%
-  \pdftooltip{%
-    \srefsymuri{#2}{\symrefemph{#1}}%
-  }{%
-    URI:~\detokenize{#2}%
-  }%
-}
+   \pdftooltip{%
+     \srefsymuri{#2}{\symrefemph{#1}}%
+   }{%
+     URI:~\detokenize{#2}%
+   }%
+ }
 \protected\def\defemph at uri#1#2{%
-  \pdftooltip{%
-    \defemph{#1}%
-  }{%
-    URI:~\detokenize{#2}%
-  }%
+   \pdftooltip{%
+     \defemph{#1}%
+   }{%
+     URI:~\detokenize{#2}%
+   }%
 }
 \protected\def\varemph at uri#1#2{%
-  \pdftooltip{%
-    \varemph{#1}%
-  }{%
-    Variable~\detokenize{#2}%
-  }%
-}
\ No newline at end of file
+   \pdftooltip{%
+     \varemph{#1}%
+   }{%
+     Variable~\detokenize{#2}%
+   }%
+}

Modified: trunk/Master/texmf-dist/tex/latex/stex/hwexam.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/hwexam.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/hwexam.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -6,13 +6,14 @@
 %%
 %% hwexam.dtx  (with options: `package')
 %% 
-\ProvidesExplPackage{hwexam}{2022/05/24}{3.1.0}{homework assignments and exams}
+\ProvidesExplPackage{hwexam}{2022/09/14}{3.2.0}{homework assignments and exams}
 \RequirePackage{l3keys2e}
 
 \newif\iftest\testfalse
-\DeclareOption{test}{\testtrue}
+\DeclareOption{test}{\testtrue\PassOptionsToPackage{\CurrentOption}{problem}}
 \newif\ifmultiple\multiplefalse
 \DeclareOption{multiple}{\multipletrue}
+\DeclareOption{lang}{\PassOptionsToPackage{\CurrentOption}{problem}}
 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{problem}}
 \ProcessOptions
 \RequirePackage{keyval}[1997/11/10]
@@ -20,9 +21,8 @@
 \newcommand\hwexam at assignment@kw{Assignment}
 \newcommand\hwexam at given@kw{Given}
 \newcommand\hwexam at due@kw{Due}
-\newcommand\hwexam at testemptypage@kw{This~page~was~intentionally~left~
-blank~for~extra~space}
-\def\hwexam at minutes@kw{minutes}
+\newcommand\hwexam at testemptypage@kw{This~page~was~intentionally~left~blank~for~extra~space}
+\newcommand\hwexam at minutes@kw{minutes}
 \newcommand\correction at probs@kw{prob.}
 \newcommand\correction at pts@kw{total}
 \newcommand\correction at reached@kw{reached}
@@ -33,16 +33,16 @@
 \ltx at ifpackageloaded{babel}{
 \makeatletter
 \clist_set:Nx \l_tmpa_clist {\bbl at loaded}
-\clist_if_in:NnT \l_tmpa_clist {ngerman}{
+\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{
   \input{hwexam-ngerman.ldf}
 }
-\clist_if_in:NnT \l_tmpa_clist {finnish}{
+\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{
   \input{hwexam-finnish.ldf}
 }
-\clist_if_in:NnT \l_tmpa_clist {french}{
+\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{
   \input{hwexam-french.ldf}
 }
-\clist_if_in:NnT \l_tmpa_clist {russian}{
+\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{
   \input{hwexam-russian.ldf}
 }
 \makeatother
@@ -145,7 +145,7 @@
 }{
 \global\setcounter{assignment}{\int_use:N\l__problems_assign_number_int}
 }
-\setcounter{problem}{0}
+\setcounter{sproblem}{0}
 \renewcommand\prob at label[1]{\assignment at number.##1}
 \def\current at section@level{\document at hwexamtype}
 \begin{@assignment}
@@ -262,9 +262,6 @@
 }{
 \newpage
 }
-\newcommand\testspace[1]{\iftest\vspace*{#1}\fi}
-\newcommand\testnewpage{\iftest\newpage\fi}
-\newcommand\testemptypage[1][]{\iftest\begin{center}\hwexam at testemptypage@kw\end{center}\vfill\eject\else\fi}
 \renewcommand\@problem[3]{
 \stepcounter{assignment at probs}
 \def\__problemspts{#2}

Modified: trunk/Master/texmf-dist/tex/latex/stex/ldf/problem-ngerman.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/ldf/problem-ngerman.ldf	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/ldf/problem-ngerman.ldf	2022-09-14 19:58:16 UTC (rev 64383)
@@ -14,4 +14,6 @@
 \def\prob at note@kw{Bewertung}
 \def\prob at pt@kw{Pkt}
 \def\prob at min@kw{Min}
+\def\prob at correct@kw{Korrekt}
+\def\prob at wrong@kw{Falsch}
 }

Modified: trunk/Master/texmf-dist/tex/latex/stex/notesslides.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/notesslides.cls	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/notesslides.cls	2022-09-14 19:58:16 UTC (rev 64383)
@@ -6,7 +6,7 @@
 %%
 %% notesslides.dtx  (with options: `cls')
 %% 
-\ProvidesExplClass{notesslides}{2022/05/24}{3.1.0}{notesslides Class}
+\ProvidesExplClass{notesslides}{2022/09/14}{3.2.0}{notesslides Class}
 \RequirePackage{l3keys2e}
 
 \keys_define:nn{notesslides / cls}{

Modified: trunk/Master/texmf-dist/tex/latex/stex/notesslides.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/notesslides.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/notesslides.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -6,7 +6,7 @@
 %%
 %% notesslides.dtx  (with options: `package')
 %% 
-\ProvidesExplPackage{notesslides}{2022/05/24}{3.1.0}{notesslides Package}
+\ProvidesExplPackage{notesslides}{2022/09/14}{3.2.0}{notesslides Package}
 \RequirePackage{l3keys2e}
 
 \keys_define:nn{notesslides / pkg}{
@@ -52,24 +52,16 @@
   \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}
+\RequirePackage{bookmark}
 \bool_if:NT \c__notesslides_notes_bool {
-  \renewcommand\usetheme[2][]{\usepackage[#1]{beamernotestheme#2}}
+  \renewcommand\usetheme[2][]{\usepackage[#1]{beamertheme#2}}
 }
-
 \NewDocumentCommand \libusetheme {O{} m} {
-  \bool_if:NTF \c__notesslides_notes_bool {
-    \libusepackage[#1]{beamernotestheme#2}
-  }{
   \libusepackage[#1]{beamertheme#2}
-  }
 }
 
 \newcounter{slide}
@@ -236,9 +228,21 @@
     \sbox{\slidelogo}{\mhgraphics[height=\slidelogoheight,mhrepos=#1]{#2}}
   }
 }
-\def\source{Michael Kohlhase}% customize locally
+\bool_if:NT \c__notesslides_notes_bool {
+  \def\author{\@dblarg\ns at author}
+  \long\def\ns at author[#1]#2{%
+    \def\c__notesslides_shortauthor{#1}%
+    \def\@author{#2}
+  }
+}
 \newrobustcmd{\setsource}[1]{\def\source{#1}}
-\def\copyrightnotice{\footnotesize\copyright :\hspace{.3ex}{\source}}
+\def\copyrightnotice{%
+  \footnotesize\copyright :\hspace{.3ex}%
+  \ifcsname source\endcsname\source\else%
+  \ifcsname c__notesslides_shortauthor\endcsname\c__notesslides_shortauthor\else%
+  \PackageWarning{notesslides}{Author/Source~undefined~in~copyright~notice}%
+  ?source/author?\fi%
+  \fi}
 \newsavebox{\cclogo}
 \sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{stex-cc_somerights}}
 \newif\ifcchref\cchreffalse
@@ -317,37 +321,6 @@
     \bool_if:NF \c__notesslides_notes_bool { \vfill }
   }
 } % ifmks at 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 at small@dbend}{stex-dangerous-bend}
-\def\smalltextwarning{
-  \pgfuseimage{miko at small@dbend}
-  \xspace
-}
-\pgfdeclareimage[width=1.2em]{miko at dbend}{stex-dangerous-bend}
-\newrobustcmd\textwarning{
-  \raisebox{-.05cm}{\pgfuseimage{miko at dbend}}
-  \xspace
-}
-\pgfdeclareimage[width=2.5em]{miko at big@dbend}{stex-dangerous-bend}
-\newrobustcmd\bigtextwarning{
-  \raisebox{-.05cm}{\pgfuseimage{miko at 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}{
@@ -390,33 +363,48 @@
         \ifcase\l_document_structure_section_level_int\or
           \stepcounter{part}
           \def\__notesslideslabel{{\omdoc at part@kw}~\Roman{part}}
+          \addcontentsline{toc}{part}{\protect\numberline{\thepart}#2}
+          \pdfbookmark[0]{\thepart\ #2}{part.\thepart}
           \def\currentsectionlevel{\omdoc at part@kw}
         \or
           \stepcounter{chapter}
           \def\__notesslideslabel{{\omdoc at chapter@kw}~\arabic{chapter}}
+          \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#2}
+          \pdfbookmark[1]{\thechapter\ #2}{chapter.\cs_if_exist:cT{thepart}\thepart.\thechapter}
           \def\currentsectionlevel{\omdoc at chapter@kw}
         \or
           \stepcounter{section}
           \def\__notesslideslabel{\part at prefix\arabic{section}}
+          \addcontentsline{toc}{section}{\protect\numberline{\thesection}#2}
+          \pdfbookmark[2]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection\ #2}
+          {section.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection}
           \def\currentsectionlevel{\omdoc at section@kw}
         \or
           \stepcounter{subsection}
           \def\__notesslideslabel{\part at prefix\arabic{section}.\arabic{subsection}}
+          \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#2}
+          \pdfbookmark[3]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection\ #2}
+          {subsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection}
           \def\currentsectionlevel{\omdoc at subsection@kw}
         \or
           \stepcounter{subsubsection}
           \def\__notesslideslabel{\part at prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
+          \addcontentsline{toc}{subsubsection}{\protect\numberline{\thesubsubsection}#2}
+          \pdfbookmark[4]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection\ #2}
+          {subsubsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection}
           \def\currentsectionlevel{\omdoc at subsubsection@kw}
         \or
           \stepcounter{paragraph}
           \def\__notesslideslabel{\part at prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}}
+          \addcontentsline{toc}{paragraph}{\protect\numberline{\theparagraph}#2}
+          \pdfbookmark[5]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection.\theparagraph\ #2}
+          {paragraph.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection.\theparagraph}
           \def\currentsectionlevel{\omdoc at paragraph@kw}
         \else
           \def\__notesslideslabel{}
           \def\currentsectionlevel{\omdoc at paragraph@kw}
         \fi% end ifcase
-        \__notesslideslabel%\sref at label@id\__notesslideslabel
-        \quad #2%
+        \__notesslideslabel\quad #2%
       }%
       \vfill%
       \end{frame}%

Modified: trunk/Master/texmf-dist/tex/latex/stex/problem.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/problem.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/problem.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -6,8 +6,9 @@
 %%
 %% problem.dtx  (with options: `package')
 %% 
-\ProvidesExplPackage{problem}{2022/05/24}{3.1.0}{Semantic Markup for Problems}
-\RequirePackage{l3keys2e,stex}
+\ProvidesExplPackage{problem}{2022/09/14}{3.2.0}{Semantic Markup for Problems}
+\RequirePackage{l3keys2e}
+\RequirePackage{amssymb}% for \Box
 
 \keys_define:nn { problem / pkg }{
   notes     .default:n    = { true },
@@ -24,7 +25,11 @@
   min       .bool_set:N   = \c__problems_min_bool,
   boxed     .default:n    = { true },
   boxed     .bool_set:N   = \c__problems_boxed_bool,
-  unknown   .code:n       = {}
+  test     .default:n    = { true },
+  test     .bool_set:N   = \c__problems_test_bool,
+  unknown     .code:n       = {
+    \PassOptionsToPackage{\CurrentOption}{stex}
+  }
 }
 \newif\ifsolutions
 
@@ -34,6 +39,7 @@
 }{
   \solutionsfalse
 }
+\RequirePackage{stex}
 \RequirePackage{comment}
 \bool_if:NT \c__problems_boxed_bool { \RequirePackage{mdframed} }
 \def\prob at problem@kw{Problem}
@@ -43,20 +49,22 @@
 \def\prob at gnote@kw{Grading}
 \def\prob at pt@kw{pt}
 \def\prob at min@kw{min}
+\def\prob at correct@kw{Correct}
+\def\prob at wrong@kw{Wrong}
 \AddToHook{begindocument}{
   \ltx at ifpackageloaded{babel}{
       \makeatletter
       \clist_set:Nx \l_tmpa_clist {\bbl at loaded}
-      \clist_if_in:NnT \l_tmpa_clist {ngerman}{
+      \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{
         \input{problem-ngerman.ldf}
       }
-      \clist_if_in:NnT \l_tmpa_clist {finnish}{
+      \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{
         \input{problem-finnish.ldf}
       }
-      \clist_if_in:NnT \l_tmpa_clist {french}{
+      \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{
         \input{problem-french.ldf}
       }
-      \clist_if_in:NnT \l_tmpa_clist {russian}{
+      \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{
         \input{problem-russian.ldf}
       }
       \makeatother
@@ -86,8 +94,10 @@
     \let\l__problems_prob_refnum_int\undefined
   }
 }
-\newcounter{problem}[section]
-\newcommand\numberproblemsin[1]{\@addtoreset{problem}{#1}}
+\newcounter{sproblem}[section]
+\newcommand\numberproblemsin[1]{\@addtoreset{sproblem}{#1}}
+\def\theplainsproblem{\arabic{sproblem}}
+\def\thesproblem{\thesection.\theplainsproblem}
 \newcommand\prob at label[1]{\thesection.#1}
 \newcommand\prob at number{
   \int_if_exist:NTF \l__problems_inclprob_refnum_int {
@@ -96,18 +106,19 @@
     \int_if_exist:NTF \l__problems_prob_refnum_int {
       \prob at label{\int_use:N \l__problems_prob_refnum_int }
     }{
-        \prob at label\theproblem
+        \prob at label\theplainsproblem
     }
   }
 }
+\def\sproblemautorefname{\prob at problem@kw}
 \newcommand\prob at title[3]{%
   \tl_if_exist:NTF \l__problems_inclprob_title_tl {
     #2 \l__problems_inclprob_title_tl #3
   }{
-    \tl_if_exist:NTF \l__problems_prob_title_tl {
+    \tl_if_empty:NTF \l__problems_prob_title_tl {
+      #1
+    }{
       #2 \l__problems_prob_title_tl #3
-    }{
-      #1
     }
   }
 }
@@ -118,7 +129,7 @@
 \newenvironment{sproblem}[1][]{
   \__problems_prob_args:n{#1}%\sref at target%
   \@in at omtexttrue% we are in a statement (for inline definitions)
-  \stepcounter{problem}\record at problem
+  \refstepcounter{sproblem}\record at problem
   \def\current at section@level{\prob at problem@kw}
 
   \str_if_empty:NT \l__problems_prob_name_str {
@@ -183,7 +194,7 @@
     }
   }
   \stex_ref_new_doc_target:n \sproblemid
-  \stex_smsmode_do:
+  \stex_if_smsmode:TF \stex_smsmode_do: \ignorespacesandpars
 }{
   \__stex_modules_end_module:
   \stex_if_smsmode:F{
@@ -251,41 +262,33 @@
 \def\@problem#1#2#3{}
 \keys_define:nn { problem / solution }{
   id            .str_set_x:N  = \l__problems_solution_id_str ,
-  for           .tl_set:N     = \l__problems_solution_for_tl ,
-  height        .dim_set:N    = \l__problems_solution_height_dim ,
-  creators      .clist_set:N  = \l__problems_solution_creators_clist ,
-  contributors  .clist_set:N  = \l__problems_solution_contributors_clist ,
-  srccite       .tl_set:N     = \l__problems_solution_srccite_tl
+  for           .str_set_x:N  = \l__problems_solution_for_str ,
+  type          .str_set_x:N  = \l__problems_solution_type_str ,
+  title         .tl_set:N     = \l__problems_solution_title_tl
 }
 \cs_new_protected:Nn \__problems_solution_args:n {
   \str_clear:N \l__problems_solution_id_str
-  \tl_clear:N \l__problems_solution_for_tl
-  \tl_clear:N \l__problems_solution_srccite_tl
-  \clist_clear:N \l__problems_solution_creators_clist
-  \clist_clear:N \l__problems_solution_contributors_clist
-  \dim_zero:N \l__problems_solution_height_dim
+  \str_clear:N \l__problems_solution_type_str
+  \str_clear:N \l__problems_solution_for_str
+  \tl_clear:N \l__problems_solution_title_tl
   \keys_set:nn { problem / solution }{ #1 }
 }
-\newcommand\@startsolution[1][]{
-  \__problems_solution_args:n { #1 }
-  \@in at omtexttrue% we are in a statement.
-  \bool_if:NF \c__problems_boxed_bool { \hrule }
-  \smallskip\noindent
-  {\textbf\prob at solution@kw :\enspace}
-  \begin{small}
-  \def\current at section@level{\prob at solution@kw}
-  \ignorespacesandpars
-}
 \box_new:N \l__problems_solution_box
 \newenvironment{solution}[1][]{
+  \__problems_solution_args:n{#1}
   \stex_html_backend:TF{
     \stex_if_do_html:T{
       \begin{stex_annotate_env}{solution}{}
+        \str_if_empty:NF \l__problems_solution_type_str {
+          \par\noindent
+          \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{}
+        }
+        \noindent\textbf{Solution\tl_if_empty:NF\l__problems_solution_title_tl{~(\l__problems_solution_title_tl)}: }~
     }
   }{
     \setbox\l__problems_solution_box\vbox\bgroup
       \par\smallskip\hrule\smallskip
-      \noindent\textbf{Solution:}~
+      \noindent\textbf{Solution\tl_if_empty:NF\l__problems_solution_title_tl{~(\l__problems_solution_title_tl)}: }~
   }
 }{
   \stex_html_backend:TF{
@@ -296,6 +299,7 @@
     \smallskip\hrule
     \egroup
     \bool_if:NT \c__problems_solutions_bool {
+      \strut\par\noindent
       \box\l__problems_solution_box
     }
   }
@@ -303,13 +307,9 @@
 
 \newcommand\startsolutions{
   \bool_set_true:N \c__problems_solutions_bool
+  \solutionstrue
 }
-\newcommand\stopsolutions{\bool_set_false:N \c__problems_solutions_bool}%\excludecomment{solution}}
-\ifsolutions
-  \startsolutions
-\else
-  \stopsolutions
-\fi
+\newcommand\stopsolutions{\bool_set_false:N \c__problems_solutions_bool \solutionsfalse}%\excludecomment{solution}}
 \bool_if:NTF \c__problems_notes_bool {
   \newenvironment{exnote}[1][]{
     \par\smallskip\hrule\smallskip
@@ -366,8 +366,8 @@
   T         .bool_set:N   = \l__problems_mcc_t_bool ,
   F         .default:n    = { false } ,
   F         .bool_set:N   = \l__problems_mcc_f_bool ,
-  Ttext     .tl_set:N     = \l__problems_mcc_Ttext_str ,
-  Ftext     .tl_set:N     = \l__problems_mcc_Ftext_str
+  Ttext     .tl_set:N     = \l__problems_mcc_Ttext_tl ,
+  Ftext     .tl_set:N     = \l__problems_mcc_Ftext_tl
 }
 \cs_new_protected:Nn \l__problems_mcc_args:n {
   \str_clear:N \l__problems_mcc_id_str
@@ -379,12 +379,12 @@
   \str_clear:N \l__problems_mcc_id_str
   \keys_set:nn { problem / mcc }{ #1 }
 }
-\def\mccTrueText{\textbf{(true)~}}
-\def\mccFalseText{\textbf{(false)~}}
+\def\mccTrueText{\textbf{\prob at correct@kw!~}}
+\def\mccFalseText{\textbf{\prob at wrong@kw!~}}
 \newcommand\mcc[2][]{
   \l__problems_mcc_args:n{ #1 }
   \item[$\Box$] #2
-  \ifsolutions
+  \bool_if:NT \c__problems_solutions_bool{
     \\
     \bool_if:NT \l__problems_mcc_t_bool {
       \tl_if_empty:NTF\l__problems_mcc_Ttext_tl\mccTrueText\l__problems_mcc_Ttext_tl
@@ -393,10 +393,16 @@
       \tl_if_empty:NTF\l__problems_mcc_Ttext_tl\mccFalseText\l__problems_mcc_Ftext_tl
     }
     \tl_if_empty:NF \l__problems_mcc_feedback_tl {
-      \emph{(\l__problems_mcc_feedback_tl)}
+      \emph{\l__problems_mcc_feedback_tl}
     }
-  \fi
+  }
 } %solutions
+\newcommand\fillinsol[2][]{%
+  \def\@test{#1}
+  \quad%
+  \ifsolutions\textcolor{red}{#1!}\else%
+  \fbox{\ifx\@test\@empty\phantom{\huge{21}}\else\hspace{#1}\fi}%
+  \fi}
 
 \keys_define:nn{ problem / inclproblem }{
   id      .str_set_x:N  = \l__problems_inclprob_id_str,
@@ -524,6 +530,13 @@
     }
   }
 }
+\newcommand\testspace[1]{\bool_if:NT \c__problems_boxed_bool {\vspace*{#1}}}
+\newcommand\testnewpage{\bool_if:NT \c__problems_boxed_bool  {\newpage}}
+\newcommand\testemptypage[1][]{%
+\bool_if:NT \c__problems_boxed_bool {\begin{center}\hwexam at testemptypage@kw\end{center}\vfill\eject\else}}
+\newcommand\testsmallspace{\testspace{1cm}}
+\newcommand\testmedspace{\testspace{2cm}}
+\newcommand\testbigspace{\testspace{3cm}}
 \endinput
 %%
 %% End of file `problem.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/stex/stex-tikzinput.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/stex-tikzinput.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/stex-tikzinput.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -6,7 +6,7 @@
 %%
 %% tikzinput.dtx  (with options: `stex')
 %% 
-\ProvidesExplPackage{stex-tikzinput}{2022/05/24}{3.1.0}{stex-tikzinput}
+\ProvidesExplPackage{stex-tikzinput}{2022/09/14}{3.2.0}{stex-tikzinput}
 \RequirePackage{stex}
 \RequirePackage{tikzinput}
 
@@ -72,6 +72,7 @@
   }
 }
 
+
 \endinput
 %%
 %% End of file `stex-tikzinput.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/stex/stex.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/stex.cls	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/stex.cls	2022-09-14 19:58:16 UTC (rev 64383)
@@ -10,7 +10,7 @@
 %%%%%%%%%%%%%   basics.dtx   %%%%%%%%%%%%%
 
 \RequirePackage{expl3,l3keys2e}
-\ProvidesExplClass{stex}{2022/05/24}{3.1.0}{sTeX document class}
+\ProvidesExplClass{stex}{2022/09/14}{3.2.0}{sTeX document class}
 
 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{stex}}
 \ProcessOptions

Modified: trunk/Master/texmf-dist/tex/latex/stex/stex.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/stex.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/stex.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -21,7 +21,7 @@
 %%%%%%%%%%%%%   basics.dtx   %%%%%%%%%%%%%
 
 \RequirePackage{expl3,l3keys2e,ltxcmds}
-\ProvidesExplPackage{stex}{2022/05/24}{3.1.0}{sTeX package}
+\ProvidesExplPackage{stex}{2022/09/14}{3.2.0}{sTeX package}
 
 \bool_if_exist:NF \c_stex_document_class_bool {
   \bool_set_false:N \c_stex_document_class_bool
@@ -28,7 +28,7 @@
   \RequirePackage{standalone}
 }
 
-\message{^^J*~This~is~sTeX~version~3.1.0~*^^J}
+\message{^^J*~This~is~sTeX~version~3.2.0~*^^J}
 
 
 \keys_define:nn { stex } {
@@ -71,7 +71,7 @@
     \msg_redirect_module:nnn{ stex }{ none }{ term }
 }{
   \clist_map_inline:Nn \c_stex_debug_clist {
-    \msg_redirect_name:nnn{ stex }{ debug / ##1 }{ term }
+    \msg_redirect_name:nnn{ stex }{ debug / #1 }{ term }
   }
 }
 
@@ -100,14 +100,26 @@
     }
   }
 }
+\ifcsname if at rustex\endcsname\else
+  \expandafter\newif\csname if at rustex\endcsname
+  \@rustexfalse
+\fi
+\ifcsname if at latexml\endcsname\else
+  \expandafter\newif\csname if at latexml\endcsname
+  \@latexmlfalse
+\fi
 \tl_if_exist:NF\stex at backend{
-  \ifcsname if at rustex\endcsname
+  \if at rustex
     \def\stex at backend{rustex}
   \else
-    \ifcsname if at latexml\endcsname
+    \if at latexml
       \def\stex at backend{latexml}
     \else
-      \def\stex at backend{pdflatex}
+      \cs_if_exist:NTF\HCode{
+        \def\stex at backend{tex4ht}
+      }{
+        \def\stex at backend{pdflatex}
+      }
     \fi
   \fi
 }
@@ -192,6 +204,7 @@
     }
   }
 }
+
 \bool_if:NTF \c_stex_persist_mode_bool {
   \def \stex_persist:n #1 {}
   \def \stex_persist:x #1 {}
@@ -360,6 +373,7 @@
   \detokenize{#1}~found~two~candidates~for~#2
 }
 \cs_new_protected:Nn \stex_path_from_string:Nn {
+  \stex_debug:nn{files}{#2}
   \str_set:Nx \l_tmpa_str { #2 }
   \str_if_empty:NTF \l_tmpa_str {
     \seq_clear:N #1
@@ -375,6 +389,7 @@
     }
     \stex_path_canonicalize:N #1
   }
+  \stex_debug:nn{files}{Yields: \stex_path_to_string:N#1}
 }
 
 \cs_new_protected:Nn \stex_path_to_string:NN {
@@ -476,6 +491,7 @@
   }
   \seq_gset_eq:NN\g_stex_currentfile_seq\g_stex_currentfile_seq
   \exp_args:NNo\seq_gpush:Nn\g__stex_files_stack\g_stex_currentfile_seq
+  \stex_get_document_uri:
 }
 \cs_new_protected:Nn \stex_filestack_pop: {
   \seq_if_empty:NF\g__stex_files_stack{
@@ -487,9 +503,14 @@
     \seq_get:NN\g__stex_files_stack\l_tmpa_seq
     \seq_gset_eq:NN\g_stex_currentfile_seq\l_tmpa_seq
   }
+  \stex_get_document_uri:
 }
 \AddToHook{file/before}{
-  \stex_filestack_push:n{\CurrentFilePath/\CurrentFile}
+  \tl_if_empty:NTF\CurrentFilePath{
+    \stex_filestack_push:n{\CurrentFile}
+  }{
+    \stex_filestack_push:n{\CurrentFilePath/\CurrentFile}
+  }
 }
 \AddToHook{file/after}{
   \stex_filestack_pop:
@@ -499,6 +520,7 @@
     \begingroup\escapechar=-1\catcode`\\=12
     \exp_args:Nx\stex_kpsewhich:n{-expand-var~\c_percent_str MATHHUB\c_percent_str}
     \exp_args:NNx\str_replace_all:Nnn\l_stex_kpsewhich_return_str{\c_backslash_str}/
+    \exp_args:NNx\str_if_eq:onT\l_stex_kpsewhich_return_str{\c_percent_str MATHHUB\c_percent_str}{\str_clear:N\l_stex_kpsewhich_return_str}
     \exp_args:Nnx\use:nn{\endgroup}{\str_set:Nn\exp_not:N\l_stex_kpsewhich_return_str{\l_stex_kpsewhich_return_str}}
   }{
     \stex_kpsewhich:n{-var-value~MATHHUB}
@@ -514,15 +536,15 @@
     }{
       \stex_kpsewhich:n{-var-value~HOME}
     }
-    \ior_open:NnT \l_tmpa_ior{\l_stex_kpsewhich_return_str / .stex / mathhub.path}{
+    \ior_open:NnT \g_tmpa_ior{\l_stex_kpsewhich_return_str / .stex / mathhub.path}{
       \begingroup\escapechar=-1\catcode`\\=12
-      \ior_str_get:NN \l_tmpa_ior \l_tmpa_str
+      \ior_str_get:NN \g_tmpa_ior \l_tmpa_str
       \sys_if_platform_windows:T{
         \exp_args:NNx\str_replace_all:Nnn\l_tmpa_str{\c_backslash_str}/
       }
       \str_gset_eq:NN \c_stex_mathhub_str\l_tmpa_str
       \endgroup
-      \ior_close:N \l_tmpa_ior
+      \ior_close:N \g_tmpa_ior
     }
   }
   \str_if_empty:NTF\c_stex_mathhub_str{
@@ -871,18 +893,24 @@
 }
 
 
-%%%%%%%%%%%%%   references.dtx   %%%%%%%%%%%%%
+%%%%%%%%%%%%%   stex-references.dtx   %%%%%%%%%%%%%
 
-
+\msg_new:nnn{stex}{error/extrefmissing}{
+  Missing~in~or~cite~value~for~\detokenize{\extref}!
+}
+\msg_new:nnn{stex}{warning/smsmissing}{
+  .sref~file~#1~doesn't~exist!
+}
+\msg_new:nnn{stex}{warning/smslabelmissing}{
+  No~label~#2~in~.sref~file~#1!
+}
+\iow_new:N \c__stex_refs_refs_iow
 \AtBeginDocument{
+  \iow_open:Nn \c__stex_refs_refs_iow {\jobname.sref}
 }
 \AtEndDocument{
+  \iow_close:N \c__stex_refs_refs_iow
 }
-\str_set:Nn \g__stex_refs_title_tl {Unnamed~Document}
-
-\NewDocumentCommand \STEXreftitle { m } {
-  \tl_gset:Nx \g__stex_refs_title_tl { #1 }
-}
 \str_new:N \l_stex_current_docns_str
 \cs_new_protected:Nn \stex_get_document_uri: {
   \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq
@@ -916,13 +944,14 @@
     }
 
     \seq_if_empty:NTF \l_tmpa_seq {
-      \str_set_eq:NN \l_stex_current_docns_str \l_tmpa_str
+      \str_gset_eq:NN \l_stex_current_docns_str \l_tmpa_str
     }{
-      \str_set:Nx \l_stex_current_docns_str {
+      \str_gset:Nx \l_stex_current_docns_str {
         \l_tmpa_str/\stex_path_to_string:N \l_tmpa_seq
       }
     }
   }
+  %\stex_get_document_url:
 }
 \str_new:N \l_stex_current_docurl_str
 \cs_new_protected:Nn \stex_get_document_url: {
@@ -971,192 +1000,363 @@
 \str_const:Nn \c__stex_refs_ref_str{REF}
 \str_new:N \l__stex_refs_curr_label_str
 \int_new:N \l__stex_refs_unnamed_counter_int
+\cs_new_protected:Npn \STEXInternalSrefRestoreTarget #1#2#3#4#5 {}
+\seq_new:N \g_stex_ref_files_seq
+
 \cs_new_protected:Nn \stex_ref_new_doc_target:n {
-  \stex_get_document_uri:
+  %\stex_get_document_uri:
   \str_clear:N \l__stex_refs_curr_label_str
   \str_set:Nx \l_tmpa_str { #1 }
   \str_if_empty:NT \l_tmpa_str {
-    \int_incr:N \l__stex_refs_unnamed_counter_int
+    \int_gincr:N \l__stex_refs_unnamed_counter_int
     \str_set:Nx \l_tmpa_str {REF\int_use:N \l__stex_refs_unnamed_counter_int}
   }
   \str_set:Nx \l__stex_refs_curr_label_str {
     \l_stex_current_docns_str?\l_tmpa_str
   }
-  \seq_if_exist:cF{g__stex_refs_labels_\l_tmpa_str _seq}{
-    \seq_new:c {g__stex_refs_labels_\l_tmpa_str _seq}
-  }
-  \seq_if_in:coF{g__stex_refs_labels_\l_tmpa_str _seq}\l__stex_refs_curr_label_str {
-    \seq_gput_right:co{g__stex_refs_labels_\l_tmpa_str _seq}\l__stex_refs_curr_label_str
-  }
+
+  \exp_args:Noo \STEXInternalAuxAddDocRef\l_stex_current_docns_str\l_tmpa_str
+
+  %\seq_if_exist:cF{g__stex_refs_labels_\l_tmpa_str _seq}{
+  %  \seq_new:c {g__stex_refs_labels_\l_tmpa_str _seq}
+  %}
+  %\seq_if_in:coF{g__stex_refs_labels_\l_tmpa_str _seq}\l__stex_refs_curr_label_str {
+  %  \seq_gput_right:co{g__stex_refs_labels_\l_tmpa_str _seq}\l__stex_refs_curr_label_str
+  %}
+
   \stex_if_smsmode:TF {
-    \stex_get_document_url:
-    \str_gset_eq:cN {sref_url_\l__stex_refs_curr_label_str _str}\l_stex_current_docurl_str
-    \str_gset_eq:cN {sref_\l__stex_refs_curr_label_str _type}\c__stex_refs_url_str
+    %\stex_get_document_url:
+    %\str_gset_eq:cN {sref_url_\l__stex_refs_curr_label_str _str}\l_stex_current_docurl_str
+    %\str_gset_eq:cN {sref_\l__stex_refs_curr_label_str _type}\c__stex_refs_url_str
   }{
-    %\iow_now:Nx \c__stex_refs_refs_iow { \l_tmpa_str~=~\expandafter\unexpanded\expandafter{\@currentlabel}~in~\exp_args:No\unexpanded\g__stex_refs_title_tl,}
+    \iow_now:Nx \c__stex_refs_refs_iow {
+      \STEXInternalSrefRestoreTarget
+        {\l_stex_current_docns_str}
+        {\l_tmpa_str}
+        {\@currentcounter}
+        {\@currentlabel}
+        {\tl_if_exist:NT\@currentlabelname{\exp_args:No\unexpanded\@currentlabelname}}
+    }
+    %\iow_now:Nx \c__stex_refs_refs_iow {
+    %  {\l_stex_current_docns_str?\l_tmpa_str}~=~{{\use:c{\@currentcounter autorefname}~\@currentlabel}~(\@currentlabelname)~in~\exp_args:No\unexpanded\g__stex_refs_title_tl},}
+    \stex_debug:nn{sref}{New~label~\l__stex_refs_curr_label_str~at~\use:c{\use:c{@currentcounter}autorefname}}
     \exp_args:Nx\label{sref_\l__stex_refs_curr_label_str}
-    \immediate\write\@auxout{\stexauxadddocref{\l_stex_current_docns_str}{\l_tmpa_str}}
-    \str_gset:cx {sref_\l__stex_refs_curr_label_str _type}\c__stex_refs_ref_str
+    \immediate\write\@auxout{\STEXInternalAuxAddDocRef{\l_stex_current_docns_str}{\l_tmpa_str}}
+    %\str_gset:cx {sref_\l__stex_refs_curr_label_str _type}\c__stex_refs_ref_str
   }
 }
-\cs_new_protected:Npn \stexauxadddocref #1 #2 {
-  \str_set:Nn \l_tmpa_str {#1?#2}
-  \str_gset_eq:cN{sref_#1?#2_type}\c__stex_refs_ref_str
-  \seq_if_exist:cF{g__stex_refs_labels_#2_seq}{
-    \seq_new:c {g__stex_refs_labels_#2_seq}
+\NewDocumentCommand \slabel {m} {\stex_ref_new_doc_target:n {#1}}
+\cs_new_protected:Npn \STEXInternalAuxAddDocRef #1 #2 {
+  \exp_args:NNx \seq_if_in:NnTF \g_stex_ref_files_seq {\detokenize{#1}} {
+    \exp_args:Nnx \seq_if_in:cnF{g_stex_ref_ #1 _seq}{\detokenize{#2}}{
+      \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}}
+    }
+  }{
+      \exp_args:NNx \seq_gput_right:Nn \g_stex_ref_files_seq {\detokenize{#1}}
+      %\seq_if_exist:cF{g_stex_ref_ #1 _seq}{
+        \seq_new:c{g_stex_ref_ #1 _seq} % <- seq_new throws errors??
+      %}
+      \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}}
   }
-  \seq_if_in:coF{g__stex_refs_labels_#2_seq}\l_tmpa_str {
-    \seq_gput_right:co{g__stex_refs_labels_#2_seq}\l_tmpa_str
-  }
+
+  %\str_set:Nn \l_tmpa_str {#1?#2}
+  %\str_gset_eq:cN{sref_#1?#2_type}\c__stex_refs_ref_str
+  %\seq_if_exist:cF{g__stex_refs_labels_#2_seq}{
+  %  \seq_new:c {g__stex_refs_labels_#2_seq}
+  %}
+  %\seq_if_in:coF{g__stex_refs_labels_#2_seq}\l_tmpa_str {
+  %  \seq_gput_right:co{g__stex_refs_labels_#2_seq}\l_tmpa_str
+  %}
 }
 \AtEndDocument{
-  \def\stexauxadddocref#1 #2 {}{}
+  \def\STEXInternalAuxAddDocRef#1 #2 {}{}
 }
 \cs_new_protected:Nn \stex_ref_new_sym_target:n {
-  \stex_if_smsmode:TF {
-    \str_if_exist:cF{sref_sym_#1_type}{
-      \stex_get_document_url:
-      \str_gset_eq:cN {sref_sym_url_#1_str}\l_stex_current_docurl_str
-      \str_gset_eq:cN {sref_sym_#1_type}\c__stex_refs_url_str
-    }
-  }{
-    \str_if_empty:NF \l__stex_refs_curr_label_str {
-      \str_gset_eq:cN {sref_sym_#1_label_str}\l__stex_refs_curr_label_str
-      \immediate\write\@auxout{
-        \exp_not:N\expandafter\def\exp_not:N\csname \exp_not:N\detokenize{sref_sym_#1_label_str}\exp_not:N\endcsname{
-            \l__stex_refs_curr_label_str
-          }
-      }
-    }
-  }
+
 }
-\str_new:N \l__stex_refs_indocument_str
 
-\keys_define:nn { stex / sref } {
-  linktext      .tl_set:N  = \l__stex_refs_linktext_tl ,
-  fallback      .tl_set:N  = \l__stex_refs_fallback_tl ,
-  pre           .tl_set:N  = \l__stex_refs_pre_tl ,
-  post          .tl_set:N  = \l__stex_refs_post_tl ,
+\keys_define:nn { stex / sref / 1 } {
+  archive   .str_set_x:N  = \l__stex_refs_repo_str,
+  file      .str_set_x:N  = \l__stex_refs_file_str,
+  % TODO get rid of this
+  fallback  .code:n = {},
+  pre       .code:n = {},
+  post      .code:n = {}
 }
-\cs_new_protected:Nn \__stex_refs_args:n {
-  \tl_clear:N \l__stex_refs_linktext_tl
-  \tl_clear:N \l__stex_refs_fallback_tl
-  \tl_clear:N \l__stex_refs_pre_tl
-  \tl_clear:N \l__stex_refs_post_tl
+\cs_new_protected:Nn \__stex_refs_args_i:n {
   \str_clear:N \l__stex_refs_repo_str
-  \keys_set:nn { stex / sref } { #1 }
+  \str_clear:N \l__stex_refs_file_str
+  \keys_set:nn { stex / sref / 1 } { #1 }
 }
-\NewDocumentCommand \sref { O{} m}{
-  \__stex_refs_args:n { #1 }
-  \str_if_empty:NTF \l__stex_refs_indocument_str {
-    \str_set:Nx \l_tmpa_str { #2 }
-    \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str
-    \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} = 1 {
-      \seq_if_exist:cTF{g__stex_refs_labels_\l_tmpa_str _seq}{
-        \seq_get_left:cNF {g__stex_refs_labels_\l_tmpa_str _seq} \l_tmpa_str {
-          \str_clear:N \l_tmpa_str
+\keys_define:nn { stex / sref / 2 } {
+  in      .str_set_x:N  = \l__stex_refs_in_str,
+  archive    .str_set_x:N  = \l__stex_refs_repob_str,
+  title    .tl_set:N  = \l__stex_refs_title_tl
+}
+\cs_new_protected:Nn \__stex_refs_args_ii:n {
+  \str_clear:N \l__stex_refs_in_str
+  \tl_clear:N \l__stex_refs_title_tl
+  \str_clear:N \l__stex_refs_repob_str
+  \keys_set:nn { stex / sref / 2 } { #1 }
+}
+\NewDocumentCommand \sref { O{} m O{}}{
+  \__stex_refs_args_i:n{#1}
+  \__stex_refs_args_ii:n{#3}
+  \str_clear:N \l__stex_refs_uri_str
+  \__stex_refs_find_uri:n{#2}
+  \__stex_refs_do_sref:n{#2}
+}
+\NewDocumentCommand \extref { O{} m m}{
+  \__stex_refs_args_i:n{#1}
+  \__stex_refs_args_ii:n{#3}
+  \str_if_empty:NT \l__stex_refs_in_str {
+    \msg_error:nn{stex}{error/extrefmissing}
+  }
+  \str_clear:N \l__stex_refs_uri_str
+  \__stex_refs_find_uri:n{#2}
+  \__stex_refs_do_sref_in:n{#2}
+}
+
+\cs_new_protected:Nn \__stex_refs_find_uri:n {
+  \stex_debug:nn{sref}{File:~\l__stex_refs_file_str^^JRepo:\l__stex_refs_repo_str}
+  \str_if_empty:NTF \l__stex_refs_file_str {
+    \stex_debug:nn{sref}{Empty.~Checking~current~file~for~#1}
+    \seq_if_exist:cT{g_stex_ref_\l_stex_current_docns_str _seq}{
+      \seq_map_inline:cn{g_stex_ref_\l_stex_current_docns_str _seq}{
+        \str_if_eq:nnT{#1}{##1}{
+          \str_set_eq:NN \l__stex_refs_uri_str \l_stex_current_docns_str
+          \stex_debug:nn{sref}{Found.}
+          \seq_map_break:
         }
-      }{
-        \str_clear:N \l_tmpa_str
       }
-    }{
-      \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str
-      \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str
-      \int_set:Nn \l_tmpa_int { \exp_args:Ne \str_count:n {\l_tmpb_str?\l_tmpa_str} }
-      \seq_if_exist:cTF{g__stex_refs_labels_\l_tmpa_str _seq}{
-        \str_set_eq:NN \l_tmpc_str \l_tmpa_str
-        \str_clear:N \l_tmpa_str
-        \seq_map_inline:cn {g__stex_refs_labels_\l_tmpc_str _seq} {
-          \str_if_eq:eeT { \l_tmpb_str?\l_tmpc_str }{
-            \str_range:nnn { ##1 }{ -\l_tmpa_int}{ -1 }
-          }{
-            \seq_map_break:n {
-              \str_set:Nn \l_tmpa_str { ##1 }
-            }
+    }
+    \str_if_empty:NT \l__stex_refs_uri_str {
+      \stex_debug:nn{sref}{Checking~other~files}
+      \seq_map_inline:Nn \g_stex_ref_files_seq {
+        \stex_debug:nn{sref}{##1...}
+        \seq_map_inline:cn{g_stex_ref_##1_seq}{
+          \str_if_eq:nnT{#1}{####1}{
+            \stex_debug:nn{sref}{Found~##1}
+            \str_set:Nn \l__stex_refs_uri_str {##1}
+            \seq_map_break:n{\seq_map_break:}
           }
         }
+      }
+    }
+  }{
+    \str_if_empty:NTF \l__stex_refs_repo_str {
+      \prop_if_exist:NTF \l_stex_current_repository_prop {
+        \prop_get:NnN \l_stex_current_repository_prop { ns } \l__stex_refs_uri_str
+        \str_set:Nx \l__stex_refs_uri_str {\l__stex_refs_uri_str / \l__stex_refs_file_str}
+        \stex_path_from_string:Nn \l_tmpb_seq \l__stex_refs_uri_str
+        \str_set:Nx \l__stex_refs_uri_str {\stex_path_to_string:N \l_tmpb_seq}
       }{
-        \str_clear:N \l_tmpa_str
+        \stex_path_from_string:Nn \l_tmpb_seq {
+          \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l__stex_refs_file_str
+        }
+        \str_set:Nx \l__stex_refs_uri_str {file:/\stex_path_to_string:N \l_tmpb_seq}
       }
+    }{
+      \stex_require_repository:n \l__stex_refs_repo_str
+      \prop_get:cnN { c_stex_mathhub_\l__stex_refs_repo_str _manifest_prop } { ns } \l__stex_refs_uri_str
+      \str_set:Nx \l__stex_refs_uri_str {\l__stex_refs_uri_str / \l__stex_refs_file_str}
+      \stex_path_from_string:Nn \l_tmpb_seq \l__stex_refs_uri_str
+      \str_set:Nx \l__stex_refs_uri_str {\stex_path_to_string:N \l_tmpb_seq}
     }
-    \str_if_empty:NTF \l_tmpa_str {
-      \tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl
+  }
+}
+
+\cs_new_protected:Nn \__stex_refs_do_autoref:n{
+  \cs_if_exist:cTF{autoref}{
+     \exp_args:Nx\autoref{sref_#1}
+   }{
+     \exp_args:Nx\ref{sref_#1}
+   }
+}
+
+\cs_new_protected:Nn \__stex_refs_do_sref:n {
+  \str_if_empty:NTF \l__stex_refs_uri_str {
+    \str_if_empty:NTF \l__stex_refs_in_str {
+      \stex_debug:nn{sref}{autoref~on~#1}
+      \__stex_refs_do_autoref:n{#1}
     }{
-      \str_if_eq:cNTF {sref_\l_tmpa_str _type} \c__stex_refs_ref_str {
-        \tl_if_empty:NTF \l__stex_refs_linktext_tl {
-          \cs_if_exist:cTF{autoref}{
-            \l__stex_refs_pre_tl\exp_args:Nx\autoref{sref_\l_tmpa_str}\l__stex_refs_post_tl
-          }{
-            \l__stex_refs_pre_tl\exp_args:Nx\ref{sref_\l_tmpa_str}\l__stex_refs_post_tl
-          }
-        }{
-          \ltx at ifpackageloaded{hyperref}{
-            \hyperref[sref_\l_tmpa_str]\l__stex_refs_linktext_tl
-          }{
-            \l__stex_refs_linktext_tl
-          }
-        }
+      \stex_debug:nn{sref}{srefin~on~#1}
+      \__stex_refs_do_sref_in:n{#1}
+    }
+  }{
+    \exp_args:NNo \seq_if_in:NnTF \g_stex_ref_files_seq \l__stex_refs_uri_str {
+      \exp_args:Nnx \seq_if_in:cnTF{g_stex_ref_\l__stex_refs_uri_str _seq}{\detokenize{#1}}{
+        \stex_debug:nn{sref}{Reference~found~in~ref~files;~autoref~on~#1}
+        \__stex_refs_do_autoref:n{\l__stex_refs_uri_str?#1}
       }{
-        \ltx at ifpackageloaded{hyperref}{
-          \href{\use:c{sref_url_\l_tmpa_str _str}}{\tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl}
+        \str_if_empty:NTF \l__stex_refs_in_str {
+          \stex_debug:nn{sref}{in~empty;~autoref~on~#1}
+          \__stex_refs_do_autoref:n{#1}
         }{
-          \tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl
+          \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1}
+          \__stex_refs_do_sref_in:n{#1}
         }
       }
+    }{
+      \str_if_empty:NTF \l__stex_refs_in_str {
+        \stex_debug:nn{sref}{in~empty;~autoref~on~#1}
+        \__stex_refs_do_autoref:n{#1}
+      }{
+        \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1}
+        \__stex_refs_do_sref_in:n{#1}
+      }
     }
-  }{
-    % TODO
   }
 }
-\NewDocumentCommand \srefsym { O{} m}{
-  \stex_get_symbol:n { #2 }
-  \__stex_refs_sym_aux:nn{#1}{\l_stex_get_symbol_uri_str}
-}
 
-\cs_new_protected:Nn \__stex_refs_sym_aux:nn {
-  \str_if_exist:cTF {sref_sym_#2 _label_str }{
-    \sref[#1]{\use:c{sref_sym_#2 _label_str}}
+\cs_new_protected:Nn \__stex_refs_restore_target:nnnnn {
+  \str_if_empty:NTF \l__stex_refs_uri_str {
+    \exp_args:No \str_if_eq:nnT \l__stex_refs_id_str {#2}{
+      \tl_set:Nn \l__stex_refs_return_tl {
+        \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~
+        \tl_if_empty:nTF\l__stex_refs_title_tl{
+          ???
+        }\l__stex_refs_title_tl
+      }
+    }
   }{
-    \__stex_refs_args:n { #1 }
-    \str_if_empty:NTF \l__stex_refs_indocument_str {
-      \tl_if_exist:cTF{sref_sym_#2 _type}{
-        % doc uri in \l_tmpb_str
-        \str_set:Nx \l_tmpa_str {\use:c{sref_sym_#2 _type}}
-        \str_if_eq:NNTF \l_tmpa_str \c__stex_refs_ref_str {
-          % reference
-          \tl_if_empty:NTF \l__stex_refs_linktext_tl {
-            \cs_if_exist:cTF{autoref}{
-              \l__stex_refs_pre_tl\autoref{sref_sym_#2}\l__stex_refs_post_tl
-            }{
-              \l__stex_refs_pre_tl\ref{sref_sym_#2}\l__stex_refs_post_tl
-            }
-          }{
-            \ltx at ifpackageloaded{hyperref}{
-              \hyperref[sref_sym_#2]\l__stex_refs_linktext_tl
-            }{
-              \l__stex_refs_linktext_tl
-            }
-          }
-        }{
-          % URL
-          \ltx at ifpackageloaded{hyperref}{
-            \href{\use:c{sref_sym_url_#2 _str}}{\tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl}
-          }{
-            \tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl
-          }
+    \stex_debug:nn{sref}{\l__stex_refs_uri_str{}~ == ~ #1 ~ ?}
+    \exp_args:No \str_if_eq:nnT \l__stex_refs_uri_str {#1}{
+      \stex_debug:nn{sref}{\l__stex_refs_id_str~ == ~ #2 ~ ?}
+      \exp_args:No \str_if_eq:nnT \l__stex_refs_id_str {#2}{
+        \stex_debug:nn{sref}{success!}
+        \tl_set:Nn \l__stex_refs_return_tl {
+          \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~
+          \tl_if_empty:nTF\l__stex_refs_title_tl{
+            ???
+          }\l__stex_refs_title_tl
         }
+        \endinput
+      }
+    }
+  }
+}
+
+\cs_new_protected:Nn \__stex_refs_do_sref_in:n {
+  \stex_debug:nn{sref}{In: \l__stex_refs_in_str^^JRepo:\l__stex_refs_repo_str}
+  \stex_debug:nn{sref}{URI: \l__stex_refs_uri_str?#1}
+  %\msg_warning:nnn{stex}{warning/smsmissing}{<filename>}
+  \begingroup\catcode13=9\relax\catcode10=9\relax
+    \str_if_empty:NTF \l__stex_refs_repob_str {
+      \prop_if_exist:NTF \l_stex_current_repository_prop {
+        \str_set:Nx \l_tmpa_str {
+          \c_stex_mathhub_str /
+          \prop_item:Nn \l_stex_current_repository_prop { id }
+          / source / \l__stex_refs_in_str .sref
+        }
       }{
-        \tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl
+        \str_set:Nx \l_tmpa_str {
+          \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l__stex_refs_in_str . sref
+        }
       }
     }{
-      % TODO
+      \str_set:Nx \l_tmpa_str {
+        \c_stex_mathhub_str / \l__stex_refs_repob_str
+        / source / \l__stex_refs_in_str . sref
+      }
     }
-  }
+    \stex_path_from_string:Nn \l_tmpb_seq \l_tmpa_str
+    \stex_path_to_string:NN \l_tmpb_seq \l_tmpa_str
+    \stex_debug:nn{sref}{File: \l_tmpa_str}
+    \exp_args:No \IfFileExists \l_tmpa_str {
+      \tl_clear:N \l__stex_refs_return_tl
+      \str_set:Nn \l__stex_refs_id_str {#1}
+      \let\STEXInternalSrefRestoreTarget\__stex_refs_restore_target:nnnnn
+      \use:c{@ @ input}{\l_tmpa_str}
+      \exp_args:No \tl_if_empty:nTF \l__stex_refs_return_tl {
+        \exp_args:Nnno \msg_warning:nnnn{stex}{warning/smslabelmissing}\l_tmpa_str{#1}
+        \__stex_refs_do_autoref:n{
+          \str_if_empty:NF\l__stex_refs_uri_str{\l__stex_refs_uri_str?}#1
+        }
+      }{
+        \l__stex_refs_return_tl
+      }
+    }{
+      \exp_args:Nnno \msg_warning:nnn{stex}{warning/smsmissing}\l_tmpa_str
+      \__stex_refs_do_autoref:n{
+        \str_if_empty:NF\l__stex_refs_uri_str{\l__stex_refs_uri_str?}#1
+      }
+    }
+  \endgroup
 }
-\cs_new_protected:Npn \srefsymuri #1 #2 {
-  \__stex_refs_sym_aux:nn{linktext={#2}}{#1}
+
+ % \__stex_refs_args:n { #1 }
+ % \str_if_empty:NTF \l__stex_refs_indocument_str {
+ %   \str_set:Nx \l_tmpa_str { #2 }
+ %   \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str
+ %   \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} = 1 {
+ %     \seq_if_exist:cTF{g__stex_refs_labels_\l_tmpa_str _seq}{
+ %       \seq_get_left:cNF {g__stex_refs_labels_\l_tmpa_str _seq} \l_tmpa_str {
+ %         \str_clear:N \l_tmpa_str
+ %       }
+ %     }{
+ %       \str_clear:N \l_tmpa_str
+ %     }
+ %   }{
+ %     \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str
+ %     \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str
+ %    \int_set:Nn \l_tmpa_int { \exp_args:Ne \str_count:n {\l_tmpb_str?\l_tmpa_str} }
+ %     \seq_if_exist:cTF{g__stex_refs_labels_\l_tmpa_str _seq}{
+ %       \str_set_eq:NN \l_tmpc_str \l_tmpa_str
+ %       \str_clear:N \l_tmpa_str
+ %       \seq_map_inline:cn {g__stex_refs_labels_\l_tmpc_str _seq} {
+ %         \str_if_eq:eeT { \l_tmpb_str?\l_tmpc_str }{
+ %           \str_range:nnn { ##1 }{ -\l_tmpa_int}{ -1 }
+ %         }{
+ %           \seq_map_break:n {
+ %             \str_set:Nn \l_tmpa_str { ##1 }
+ %           }
+ %         }
+ %       }
+ %     }{
+ %       \str_clear:N \l_tmpa_str
+ %     }
+ %   }
+ %   \str_if_empty:NTF \l_tmpa_str {
+ %     \tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl
+ %   }{
+ %     \str_if_eq:cNTF {sref_\l_tmpa_str _type} \c__stex_refs_ref_str {
+ %       \tl_if_empty:NTF \l__stex_refs_linktext_tl {
+ %         \cs_if_exist:cTF{autoref}{
+ %           \l__stex_refs_pre_tl\exp_args:Nx\autoref{sref_\l_tmpa_str}\l__stex_refs_post_tl
+ %         }{
+ %           \l__stex_refs_pre_tl\exp_args:Nx\ref{sref_\l_tmpa_str}\l__stex_refs_post_tl
+ %         }
+ %       }{
+ %         \ltx at ifpackageloaded{hyperref}{
+ %           \hyperref[sref_\l_tmpa_str]\l__stex_refs_linktext_tl
+ %         }{
+ %           \l__stex_refs_linktext_tl
+ %         }
+ %       }
+ %     }{
+ %       \ltx at ifpackageloaded{hyperref}{
+ %         \href{\use:c{sref_url_\l_tmpa_str _str}}{\tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl}
+ %       }{
+ %         \tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl
+ %       }
+ %     }
+ %   }
+ % }{
+    % TODO
+ % }
+\NewDocumentCommand \srefsym { O{} m}{
+  \stex_get_symbol:n { #2 }
+  \__stex_refs_sym_aux:nn{#1}{\l_stex_get_symbol_uri_str}
 }
 
+\cs_new_protected:Nn \__stex_refs_sym_aux:nn {
+
+}
+\cs_new_protected:Npn \srefsymuri #1 #2 { % TODO
+  #2%\__stex_refs_sym_aux:nn{linktext={#2}}{#1}
+}
+
 %%%%%%%%%%%%%   modules.dtx   %%%%%%%%%%%%%
 
 \msg_new:nnn{stex}{error/unknownmodule}{
@@ -1641,6 +1841,15 @@
     \use:c{ c_stex_module_#1_code }
   }
 }
+\NewDocumentEnvironment { mmtinterface } { O{} m m } {
+  \begin{smodule}[#1]{#3}
+    \str_set:Nx \l_stex_module_mmtfor_str {#2}
+    \MMTinclude{#2}
+    \stex_reactivate_macro:N \mmtdecl
+    \stex_reactivate_macro:N \mmtdef
+}{
+  \end{smodule}
+}
 
 %%%%%%%%%%%%%   inheritance.dtx   %%%%%%%%%%%%%
 
@@ -1685,7 +1894,9 @@
     sexample,
     sassertion,
     sparagraph,
-    mathstructure
+    mathstructure,
+    extstructure,
+    extstructure*
   }
 }
 \bool_new:N \g__stex_smsmode_bool
@@ -2036,14 +2247,11 @@
   \stex_debug:nn{modules}{Importing~module:~
     \l_stex_import_ns_str ? \l_stex_import_name_str
   }
-  \stex_import_require_module:nnnn
-  { \l_stex_import_ns_str } { \l_stex_import_archive_str }
-  { \l_stex_import_path_str } { \l_stex_import_name_str }
   \stex_if_smsmode:F {
     \stex_annotate_invisible:nnn
       {import} {\l_stex_import_ns_str ? \l_stex_import_name_str} {}
   }
-  \exp_args:Nx \stex_add_to_current_module:n {
+  \stex_execute_in_module:x {
     \stex_import_require_module:nnnn
     { \l_stex_import_ns_str } { \l_stex_import_archive_str }
     { \l_stex_import_path_str } { \l_stex_import_name_str }
@@ -2112,15 +2320,14 @@
 }
 \keys_define:nn { stex / symdecl } {
   name        .str_set_x:N  = \l_stex_symdecl_name_str ,
-  local       .bool_set:N   = \l_stex_symdecl_local_bool ,
   args        .str_set_x:N  = \l_stex_symdecl_args_str ,
   type        .tl_set:N     = \l_stex_symdecl_type_tl ,
   deprecate   .str_set_x:N  = \l_stex_symdecl_deprecate_str ,
   align       .str_set:N    = \l_stex_symdecl_align_str , % TODO(?)
   gfc         .str_set:N    = \l_stex_symdecl_gfc_str , % TODO(?)
-  specializes .str_set:N    = \l_stex_symdecl_specializes_str , % TODO(?)
   def         .tl_set:N     = \l_stex_symdecl_definiens_tl ,
   reorder     .str_set_x:N  = \l_stex_symdecl_reorder_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
   assoc       .choices:nn   =
       {bin,binl,binr,pre,conj,pwconj}
       {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}
@@ -2137,6 +2344,7 @@
   \bool_set_false:N \l_stex_symdecl_local_bool
   \tl_clear:N \l_stex_symdecl_type_tl
   \tl_clear:N \l_stex_symdecl_definiens_tl
+  \clist_clear:N \l_stex_symdecl_argnames_clist
 
   \keys_set:nn { stex / symdecl } { #1 }
 }
@@ -2217,6 +2425,7 @@
       }{##1}
     }
   }
+
   \bool_if:NTF \l_tmpa_bool {
     % possibly numeric
     \str_if_empty:NTF \l_stex_symdecl_args_str {
@@ -2244,6 +2453,19 @@
     \prop_put:Nnx \l_tmpa_prop { defined }{ true }
   }
 
+  % argnames
+
+  \clist_clear:N \l_tmpa_clist
+  \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} {
+    \clist_if_empty:NTF \l_stex_symdecl_argnames_clist {
+      \clist_put_right:Nn \l_tmpa_clist {##1}
+    }{
+      \clist_pop:NN \l_stex_symdecl_argnames_clist \l_tmpa_tl
+      \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl}
+    }
+  }
+  \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,}
+
   % semantic macro
 
   \bool_if:NT \l_stex_symdecl_make_macro_bool {
@@ -2289,7 +2511,7 @@
     _prop
   } {
     \bool_if:NTF \l_stex_symdecl_local_bool \stex_do_up_to_module:x \stex_execute_in_module:x {
-      \__stex_symdecl_restore_symbol:nnnnnnn
+      \__stex_symdecl_restore_symbol:nnnnnnnn
         {\l_stex_symdecl_name_str}
         { \prop_item:Nn \l_tmpa_prop {args} }
         { \prop_item:Nn \l_tmpa_prop {arity} }
@@ -2297,10 +2519,11 @@
         { \prop_item:Nn \l_tmpa_prop {defined} }
         {\bool_if:NT \l_stex_symdecl_make_macro_bool {#1} }
         {\l_stex_current_module_str}
+        { \prop_item:Nn \l_tmpa_prop {argnames} }
     }
   }
 }
-\cs_new_protected:Nn \__stex_symdecl_restore_symbol:nnnnnnn {
+\cs_new_protected:Nn \__stex_symdecl_restore_symbol:nnnnnnnn {
   \prop_clear:N \l_tmpa_prop
   \prop_put:Nnn \l_tmpa_prop { module } { #7 }
   \prop_put:Nnn \l_tmpa_prop { name } { #1}
@@ -2308,6 +2531,7 @@
   \prop_put:Nnn \l_tmpa_prop { arity } { #3 }
   \prop_put:Nnn \l_tmpa_prop { assocs } { #4 }
   \prop_put:Nnn \l_tmpa_prop { defined } { #5 }
+  \prop_put:Nnn \l_tmpa_prop { argnames } { #8 }
   \tl_if_empty:nF{#6}{
     \tl_set:cx{#6}{\stex_invoke_symbol:n{\detokenize{#7 ? #1}}}
   }
@@ -2323,6 +2547,7 @@
 \cs_new_protected:Nn \_stex_textsymdecl_args:n {
   \str_clear:N \l__stex_symdecl_name_str
   \tl_clear:N \l__stex_symdecl_type_tl
+  \clist_clear:N \l_stex_symdecl_argnames_clist
   \keys_set:nn { stex / textsymdecl } { #1 }
 }
 
@@ -2338,12 +2563,12 @@
   \stex_execute_in_module:n{
     \cs_set_nopar:cpn{#1name}{
       \ifvmode\hbox_unpack:N\c_empty_box\fi
-      \hbox{#3}\xspace
+      \ifmmode\hbox{#3}\else#3\fi\xspace
     }
     \cs_set_nopar:cpn{#1}{
       \ifmmode\csname#1-sym\expandafter\endcsname\else
       \ifvmode\hbox_unpack:N\c_empty_box\fi
-      \symref{#1-sym}{\hbox{#3}}\expandafter\xspace
+      \symref{#1-sym}{#3}\expandafter\xspace
       \fi
     }
   }
@@ -2464,12 +2689,13 @@
   }
 }
 \keys_define:nn { stex / notation } {
-  variant .tl_set_x:N  = \l__stex_notation_variant_str ,
-  prec    .str_set_x:N = \l__stex_notation_prec_str ,
-  op      .tl_set:N    = \l__stex_notation_op_tl ,
-  primary .bool_set:N  = \l__stex_notation_primary_bool ,
-  primary .default:n   = {true} ,
-  unknown .code:n      = \str_set:Nx
+  variant .tl_set_x:N   = \l__stex_notation_variant_str ,
+  prec    .str_set_x:N  = \l__stex_notation_prec_str ,
+  op      .tl_set:N     = \l__stex_notation_op_tl ,
+  primary .bool_set:N   = \l__stex_notation_primary_bool ,
+  primary .default:n    = {true} ,
+  hints    .str_set_x:N = \l__stex_notation_hints_str,
+  unknown .code:n       = \str_set:Nx
       \l__stex_notation_variant_str \l_keys_key_str
 }
 
@@ -2476,6 +2702,7 @@
 \cs_new_protected:Nn \_stex_notation_args:n {
   \str_clear:N \l__stex_notation_variant_str
   \str_clear:N \l__stex_notation_prec_str
+  \str_clear:N \l__stex_notation_hints_str
   \tl_clear:N \l__stex_notation_op_tl
   \bool_set_false:N \l__stex_notation_primary_bool
 
@@ -2535,7 +2762,7 @@
           \exp_args:NNNo \exp_args:NNno \seq_set_split:Nnn
             \l_tmpa_seq {\tl_to_str:n{x} } { \l_tmpa_str }
           \seq_map_inline:Nn \l_tmpa_seq {
-            \seq_put_right:Nn \l_tmpb_seq { ##1 }
+            \seq_put_right:Nn \l__stex_notation_precedences_seq { ##1 }
           }
         }
       }{
@@ -2668,11 +2895,12 @@
 
   \seq_pop_left:NN \l__stex_notation_remaining_precs_seq \l_tmpa_str
   \tl_put_right:Nx \l_stex_notation_dummyargs_tl { {
-    \STEXInternalTermMathAssocArgiiii
-      { #1\int_use:N \l__stex_notation_currarg_int }
+    \STEXInternalTermMathAssocArgiiiii
+      { \int_use:N \l__stex_notation_currarg_int }
       { \l_tmpa_str }
       { ####\int_use:N \l__stex_notation_currarg_int }
       { \l_tmpa_cs {####1} {####2} }
+      {#1}
   } }
   \__stex_notation_arguments:
 }
@@ -2861,7 +3089,6 @@
 
 \keys_define:nn { stex / symdef } {
   name    .str_set_x:N = \l_stex_symdecl_name_str ,
-  local   .bool_set:N  = \l_stex_symdecl_local_bool ,
   args    .str_set_x:N = \l_stex_symdecl_args_str ,
   type    .tl_set:N    = \l_stex_symdecl_type_tl ,
   def     .tl_set:N    = \l_stex_symdecl_definiens_tl ,
@@ -2870,6 +3097,7 @@
  % lang    .str_set_x:N = \l__stex_notation_lang_str ,
   variant .str_set_x:N = \l__stex_notation_variant_str ,
   prec    .str_set_x:N = \l__stex_notation_prec_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
   assoc   .choices:nn  =
       {bin,binl,binr,pre,conj,pwconj}
       {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}},
@@ -2885,6 +3113,7 @@
   \bool_set_false:N \l_stex_symdecl_local_bool
   \tl_clear:N \l_stex_symdecl_type_tl
   \tl_clear:N \l_stex_symdecl_definiens_tl
+  \clist_clear:N \l_stex_symdecl_argnames_clist
  % \str_clear:N \l__stex_notation_lang_str
   \str_clear:N \l__stex_notation_variant_str
   \str_clear:N \l__stex_notation_prec_str
@@ -2912,6 +3141,70 @@
 }
 \stex_deactivate_macro:Nn \symdef {module~environments}
 
+\keys_define:nn { stex / mmtdef } {
+  name    .str_set_x:N = \l_stex_symdecl_name_str ,
+  args    .str_set_x:N = \l_stex_symdecl_args_str ,
+  reorder .str_set_x:N = \l_stex_symdecl_reorder_str ,
+  op      .tl_set:N    = \l__stex_notation_op_tl ,
+ % lang    .str_set_x:N = \l__stex_notation_lang_str ,
+  variant .str_set_x:N = \l__stex_notation_variant_str ,
+  prec    .str_set_x:N = \l__stex_notation_prec_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
+  assoc   .choices:nn  =
+      {bin,binl,binr,pre,conj,pwconj}
+      {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}},
+  unknown .code:n      = \str_set:Nx
+      \l__stex_notation_variant_str \l_keys_key_str
+}
+\cs_new_protected:Nn \_stex_mmtdef_args:n {
+  \str_clear:N \l_stex_symdecl_name_str
+  \str_clear:N \l_stex_symdecl_args_str
+  \str_clear:N \l_stex_symdecl_assoctype_str
+  \str_clear:N \l_stex_symdecl_reorder_str
+  \bool_set_false:N \l_stex_symdecl_local_bool
+  \clist_clear:N \l_stex_symdecl_argnames_clist
+ % \str_clear:N \l__stex_notation_lang_str
+  \str_clear:N \l__stex_notation_variant_str
+  \str_clear:N \l__stex_notation_prec_str
+  \tl_clear:N \l__stex_notation_op_tl
+
+  \keys_set:nn { stex / mmtdef } { #1 }
+}
+
+\NewDocumentCommand \mmtdef {m O{} }{
+  \_stex_mmtdef_args:n{ #2 }
+  \bool_set_true:N \l_stex_symdecl_make_macro_bool
+  \str_if_empty:NT \l_stex_symdecl_name_str {
+    \str_set:Nx \l_stex_symdecl_name_str { #1 }
+  }
+  %\tl_set:Nx \l_stex_symdecl_definiens_tl {
+  %  \stex_annotate:nnn{ OMID }{
+  %    \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str
+  %  }{}
+  %}
+  \stex_symdecl_do:n { #1 }
+  \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_current_module_str ? \l_stex_symdecl_name_str
+    }{},
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str
+    }{}
+  }
+  \tl_set:Nn \l_stex_notation_after_do_tl {
+    \__stex_notation_final:
+    \stex_smsmode_do:\ignorespacesandpars
+  }
+  \str_set:Nx \l_stex_get_symbol_uri_str {
+    \l_stex_current_module_str ? \l_stex_symdecl_name_str
+  }
+  \exp_args:Nx \stex_notation_do:nnnnn
+    { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } }
+    { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } }
+    { \l__stex_notation_variant_str }
+    { \l__stex_notation_prec_str}
+}
+
 \keys_define:nn { stex / vardef } {
   name    .str_set_x:N  = \l__stex_variables_name_str ,
   args    .str_set_x:N  = \l__stex_variables_args_str ,
@@ -2920,6 +3213,7 @@
   op      .tl_set:N     = \l__stex_variables_op_tl ,
   prec    .str_set_x:N  = \l__stex_variables_prec_str ,
   reorder .str_set_x:N  = \l__stex_variables_reorder_str ,
+  argnames    .clist_set:N  = \l__stex_variables_argnames_clist ,
   assoc   .choices:nn   =
       {bin,binl,binr,pre,conj,pwconj}
       {\str_set:Nx \l__stex_variables_assoctype_str {\l_keys_choice_tl}},
@@ -2938,6 +3232,7 @@
   \tl_clear:N \l__stex_variables_type_tl
   \tl_clear:N \l__stex_variables_def_tl
   \tl_clear:N \l__stex_variables_op_tl
+  \clist_clear:N \l__stex_variables_argnames_clist
 
   \keys_set:nn { stex / vardef } { #1 }
 }
@@ -2994,8 +3289,21 @@
   \prop_put:Nnx \l_tmpa_prop { assocs } { \int_use:N \l_tmpb_int }
   \tl_set:cx { #1 }{ \stex_invoke_variable:n { \l__stex_variables_name_str } }
 
-  \prop_set_eq:cN { l_stex_variable_\l__stex_variables_name_str _prop} \l_tmpa_prop
+  % argnames
 
+  \clist_clear:N \l_tmpa_clist
+  \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} {
+    \clist_if_empty:NTF \l__stex_variables_argnames_clist {
+      \clist_put_right:Nn \l_tmpa_clist {##1}
+    }{
+      \clist_pop:NN \l__stex_variables_argnames_clist \l_tmpa_tl
+      \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl}
+    }
+  }
+  \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,}
+
+  \prop_set_eq:cN { l_stex_symdecl_var://\l__stex_variables_name_str _prop} \l_tmpa_prop
+
   \tl_if_empty:NF \l__stex_variables_op_tl {
     \cs_set:cpx {
       stex_var_op_notation_ \l__stex_variables_name_str _cs
@@ -3169,6 +3477,14 @@
   \cs_generate_from_arg_count:cNnn {stex_varseq_\l__stex_variables_name_str _cs}
     \cs_set:Npn  {\int_use:N \l__stex_variables_args_int} { #5 }
 
+  % argnames
+
+  \clist_clear:N \l_tmpa_clist
+  \int_step_inline:nn {\l__stex_variables_args_int} {
+      \clist_put_right:Nn \l_tmpa_clist {##1}
+  }
+  \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,}
+
   \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l__stex_variables_name_str _cs}}
   \int_step_inline:nn \l__stex_variables_args_int {
     \tl_put_right:Nx \l_tmpa_tl { {\seq_item:Nn \l_tmpa_seq {##1}} }
@@ -3214,6 +3530,8 @@
     \expandafter\meaning\csname stex_varseq_\l__stex_variables_name_str _cs\endcsname\\~\\
     \prop_to_keyval:N \l_tmpa_prop
   }
+  \prop_set_eq:cN {l_stex_symdecl_varseq://\l__stex_variables_name_str _prop}\l_tmpa_prop
+
   \stex_if_do_html:T{\stex_annotate_invisible:nnn{varseq}{\l__stex_variables_name_str}{
     \tl_if_empty:NF \l__stex_variables_type_tl {
       \stex_annotate:nnn {type}{}{$\l__stex_variables_type_tl$}
@@ -3243,12 +3561,64 @@
 
   }}
 
-  \prop_set_eq:cN {stex_varseq_\l__stex_variables_name_str _prop}\l_tmpa_prop
   \ignorespacesandpars
 }
 
+\keys_define:nn { stex / mmtdecl } {
+  name        .str_set_x:N  = \l_stex_symdecl_name_str ,
+  args        .str_set_x:N  = \l_stex_symdecl_args_str ,
+  deprecate   .str_set_x:N  = \l_stex_symdecl_deprecate_str ,
+  reorder     .str_set_x:N  = \l_stex_symdecl_reorder_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
+  assoc       .choices:nn   =
+      {bin,binl,binr,pre,conj,pwconj}
+      {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}
+}
 
+\cs_new_protected:Nn \_stex_mmtdecl_args:n {
+  \str_clear:N \l_stex_symdecl_name_str
+  \str_clear:N \l_stex_symdecl_args_str
+  \str_clear:N \l_stex_symdecl_deprecate_str
+  \str_clear:N \l_stex_symdecl_reorder_str
+  \str_clear:N \l_stex_symdecl_assoctype_str
+  \bool_set_false:N \l_stex_symdecl_local_bool
+  \clist_clear:N \l_stex_symdecl_argnames_clist
 
+  \keys_set:nn { stex / symdecl } { #1 }
+}
+
+\NewDocumentCommand \mmtdecl { s m O{}} {
+  \_stex_mmtdecl_args:n{#3}
+  \IfBooleanTF #1 {
+    \bool_set_false:N \l_stex_symdecl_make_macro_bool
+  } {
+    \bool_set_true:N \l_stex_symdecl_make_macro_bool
+  }
+  \str_if_empty:NT \l_stex_symdecl_name_str {
+    \str_set:Nx \l_stex_symdecl_name_str { #1 }
+  }
+  %\tl_set:Nx \l_stex_symdecl_definiens_tl {
+  %  \stex_annotate:nnn{ OMID }{
+  %    \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str
+  %  }{}
+  %}
+  \stex_symdecl_do:n{#2}
+  \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_current_module_str ? \l_stex_symdecl_name_str
+    }{},
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str
+    }{}
+  }
+  \stex_smsmode_do:
+}
+
+\stex_deactivate_macro:Nn \mmtdecl {mmtinterface~environments}
+\stex_deactivate_macro:Nn \mmtdef {mmtinterface~environments}
+
+
+
 %%%%%%%%%%%%%   terms.dtx   %%%%%%%%%%%%%
 
 \msg_new:nnn{stex}{error/nonotation}{
@@ -3340,8 +3710,10 @@
     \def\comp{\_comp}
     \str_set:Nn \STEXInternalCurrentSymbolStr { #1 }
     \bool_set_false:N \l_stex_allow_semantic_bool
-    \_stex_term_oms:nnn {#1}{#1 \c_hash_str CUSTOM-}{
-      \comp{ #2 }
+    \stex_mathml_intent:nn{#1}{
+      \_stex_term_oms:nnn {#1}{#1 \c_hash_str CUSTOM-}{
+        \comp{ #2 }
+      }
     }
   }{
     \_stex_reset:N \comp
@@ -3454,6 +3826,8 @@
 }
 
 \prop_new:N \l__stex_terms_custom_args_prop
+\clist_new:N \l_stex_argnames_seq
+\seq_new:N \l__stex_terms_tmp_seq
 
 \cs_new_protected:Nn\__stex_terms_custom_comp:n{\bool_set_false:N \l_stex_allow_semantic_bool\_comp{#1}\bool_set_true:N \l_stex_allow_semantic_bool}
 
@@ -3466,23 +3840,47 @@
     \prop_get:cnN {
       l_stex_symdecl_#1 _prop
     }{ args } \l_tmpa_str
+    \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq {
+      \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames}
+    }
     \prop_put:Nno \l__stex_terms_custom_args_prop {args} \l_tmpa_str
     \tl_set:Nn \arg { \__stex_terms_arg: }
     \str_if_empty:NTF \l_tmpa_str {
-      \_stex_term_oms:nnn {#1}{#1\c_hash_str CUSTOM-}{\ignorespaces#2}
+      \stex_mathml_intent:nn{#1}{
+        \_stex_term_oms:nnn {#1}{#1\c_hash_str CUSTOM-}{\ignorespaces#2}
+      }
     }{
-      \str_if_in:NnTF \l_tmpa_str b {
-        \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
+      \seq_clear:N \l__stex_terms_tmp_seq
+      \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{
+        \tl_set:Nx \l__stex_terms_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}}
+        \bool_lazy_or:nnT{
+          \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}}
+        }{
+          \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}}
+        }{
+          \tl_put_right:Nn \l__stex_terms_tmp_tl +
+        }
+        \seq_put_right:No \l__stex_terms_tmp_seq \l__stex_terms_tmp_tl
+      }
+      \stex_mathml_intent:nn{
+        #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }](
+          \seq_use:Nn \l__stex_terms_tmp_seq ,
+        )
       }{
-        \str_if_in:NnTF \l_tmpa_str B {
+        \str_if_in:NnTF \l_tmpa_str b {
           \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
         }{
-          \_stex_term_oma:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
+          \str_if_in:NnTF \l_tmpa_str B {
+            \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
+          }{
+            \_stex_term_oma:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2}
+          }
         }
       }
     }
     % TODO check that all arguments exist
   }{
+    \_stex_reset:N \l_stex_argnames_seq
     \_stex_reset:N \STEXInternalCurrentSymbolStr
     \_stex_reset:N \arg
     \_stex_reset:N \comp
@@ -3524,15 +3922,21 @@
     }
   }
   \exp_args:NNx \prop_put:Nnn \l__stex_terms_custom_args_prop {\int_use:N \l_tmpa_int} {\ignorespaces#3}
-  \bool_set_true:N \l_stex_allow_semantic_bool
-  \IfBooleanTF#1{
-    \stex_annotate_invisible:n { %TODO
+  \bool_if:NTF \l_stex_allow_semantic_bool \use_i:nn {
+    \bool_set_true:N \l_stex_allow_semantic_bool
+    \use:nn
+  }
+  {
+  \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{
+    \IfBooleanTF#1{
+      \stex_annotate_invisible:n { %TODO
+        \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3}
+      }
+    }{ %TODO
       \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3}
     }
-  }{ %TODO
-    \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3}
-  }
-  \bool_set_false:N \l_stex_allow_semantic_bool
+  }}
+  {\bool_set_false:N \l_stex_allow_semantic_bool}
 }
 
 \cs_new_protected:Nn \_stex_term_arg:nn {
@@ -3544,30 +3948,32 @@
 \cs_new_protected:Npn \STEXInternalTermMathArgiii #1#2#3 {
   \exp_args:Nnx \use:nn
     { \int_set:Nn \l__stex_terms_downprec { #2 }
+      \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{
         \_stex_term_arg:nn { #1 }{ #3 }
+      }
     }
     { \int_set:Nn \exp_not:N \l__stex_terms_downprec { \int_use:N \l__stex_terms_downprec } }
 }
-\cs_new_protected:Npn \STEXInternalTermMathAssocArgiiii #1#2#3#4 {
+\cs_new_protected:Npn \STEXInternalTermMathAssocArgiiiii #1#2#3#4#5 {
   \cs_set:Npn \l_tmpa_cs ##1 ##2 { #4 }
-  \tl_set:Nn \l_tmpb_tl {\STEXInternalTermMathArgiii{#1}{#2}}
+  \tl_set:Nn \l_tmpb_tl {\STEXInternalTermMathArgiii{#5#1}{#2}}
   \tl_if_empty:nTF { #3 }{
-    \STEXInternalTermMathArgiii{#1}{#2}{}
+    \STEXInternalTermMathArgiii{#5#1}{#2}{}
   }{
     \exp_args:Nx \tl_if_empty:nTF { \tl_tail:n{ #3 }}{
       \expandafter\if\expandafter\relax\noexpand#3
-        \tl_set:Nn \l_tmpa_tl {\__stex_terms_math_assoc_arg_maybe_sequence:Nn#3{#1}}
+        \tl_set:Nn \l_tmpa_tl {\__stex_terms_math_assoc_arg_maybe_sequence:Nnn#3{#1}{#5}}
       \else
-        \tl_set:Nn \l_tmpa_tl {\__stex_terms_math_assoc_arg_simple:nn{#1}{#3}}
+        \tl_set:Nn \l_tmpa_tl {\__stex_terms_math_assoc_arg_simple:nnn{#1}{#3}{#5}}
       \fi
       \l_tmpa_tl
     }{
-      \__stex_terms_math_assoc_arg_simple:nn{#1}{#3}
+      \__stex_terms_math_assoc_arg_simple:nnn{#1}{#3}{#5}
     }
   }
 }
 
-\cs_new_protected:Nn \__stex_terms_math_assoc_arg_maybe_sequence:Nn {
+\cs_new_protected:Nn \__stex_terms_math_assoc_arg_maybe_sequence:Nnn {
   \str_set:Nx \l_tmpa_str { \cs_argument_spec:N #1 }
   \str_if_empty:NTF \l_tmpa_str {
     \exp_args:Nx \cs_if_eq:NNTF {
@@ -3575,7 +3981,7 @@
     } \stex_invoke_sequence:n {
       \tl_set:Nx \l_tmpa_tl {\tl_tail:N #1}
       \str_set:Nx \l_tmpa_str {\exp_after:wN \use:n \l_tmpa_tl}
-      \tl_set:Nx \l_tmpa_tl {\prop_item:cn {stex_varseq_\l_tmpa_str _prop}{notation}}
+      \tl_set:Nx \l_tmpa_tl {\prop_item:cn {l_stex_symdecl_varseq://\l_tmpa_str _prop}{notation}}
       \exp_args:NNo \seq_set_from_clist:Nn \l_tmpa_seq \l_tmpa_tl
       \tl_set:Nx \l_tmpa_tl {{\exp_not:N \exp_not:n{
         \exp_not:n{\exp_args:Nnx \use:nn} {
@@ -3591,7 +3997,7 @@
           }
         }
       }}}
-      \exp_args:Nno \use:nn {\seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq} \l_tmpa_tl
+      \exp_args:Nno \use:n {\seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq} \l_tmpa_tl
       \seq_reverse:N \l_tmpa_seq
       \seq_pop:NN \l_tmpa_seq \l_tmpa_tl
       \seq_map_inline:Nn \l_tmpa_seq {
@@ -3607,28 +4013,38 @@
       }
       \exp_args:No\l_tmpb_tl\l_tmpa_tl
     }{
-      \__stex_terms_math_assoc_arg_simple:nn{#2} { #1 }
+      \__stex_terms_math_assoc_arg_simple:nnn{#2} { #1 }{#3}
     }
   } {
-    \__stex_terms_math_assoc_arg_simple:nn{#2} { #1 }
+    \__stex_terms_math_assoc_arg_simple:nnn{#2} { #1 }{#3}
   }
 
 }
 
-\cs_new_protected:Nn \__stex_terms_math_assoc_arg_simple:nn {
+\cs_new_protected:Nn \__stex_terms_math_assoc_arg_simple:nnn {
   \clist_set:Nn \l_tmpa_clist{ #2 }
   \int_compare:nNnTF { \clist_count:N \l_tmpa_clist } < 2 {
-    \tl_set:Nn \l_tmpa_tl { \_stex_term_arg:nn{A#1}{ #2 } }
+    \tl_set:Nn \l_tmpa_tl {
+      \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{
+        \_stex_term_arg:nn{A#3#1}{ #2 } }
+    }
   }{
     \clist_reverse:N \l_tmpa_clist
     \clist_pop:NN \l_tmpa_clist \l_tmpa_tl
-    \tl_set:Nx \l_tmpa_tl { \_stex_term_arg:nn{A#1}{
-      \exp_args:No \exp_not:n \l_tmpa_tl
+    \tl_set:Nx \l_tmpa_tl {
+      \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{
+        \_stex_term_arg:nn{A#3#1}{
+        \exp_args:No \exp_not:n \l_tmpa_tl
+      }
     }}
     \clist_map_inline:Nn \l_tmpa_clist {
       \exp_args:NNNo \exp_args:NNo \tl_set:No \l_tmpa_tl {
         \exp_args:Nno
-        \l_tmpa_cs { \_stex_term_arg:nn{A#1}{##1} } \l_tmpa_tl
+        \l_tmpa_cs {
+          \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{
+            \_stex_term_arg:nn{A#3#1}{##1}
+          }
+        } \l_tmpa_tl
       }
     }
   }
@@ -3699,7 +4115,9 @@
 
 \cs_new_protected:Npn \STEXInternalTermMathOMSiiii #1#2#3#4 {
   \__stex_terms_maybe_brackets:nn { #3 }{
-    \_stex_term_oms:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    \stex_mathml_intent:nn{#1} {
+      \_stex_term_oms:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    }
   }
 }
 \cs_new_protected:Nn \_stex_term_omv:nn {
@@ -3714,9 +4132,36 @@
 }
 
 \cs_new_protected:Npn \STEXInternalTermMathOMAiiii #1#2#3#4 {
+  \exp_args:Nnx \use:nn {
+    \seq_clear:N \l__stex_terms_tmp_seq
+    \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{
+    \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq {
+      \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames}
+    }
+    \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{
+      \tl_set:Nx \l__stex_terms_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}}
+      \bool_lazy_or:nnT{
+        \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}}
+      }{
+        \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}}
+      }{
+        \tl_put_right:Nn \l__stex_terms_tmp_tl +
+      }
+      \seq_put_right:No \l__stex_terms_tmp_seq \l__stex_terms_tmp_tl
+    }
+  }
   \__stex_terms_maybe_brackets:nn { #3 }{
-    \_stex_term_oma:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    \stex_mathml_intent:nn{
+      #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }](
+        \seq_use:Nn \l__stex_terms_tmp_seq ,
+      )
+    }{
+      \_stex_term_oma:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    }
   }
+  }{
+    \_stex_reset:N \l_stex_argnames_seq
+  }
 }
 \cs_new_protected:Nn \_stex_term_ombind:nnn {
   \stex_annotate:nnn{ OMBIND }{ #2 }{
@@ -3725,9 +4170,36 @@
 }
 
 \cs_new_protected:Npn \STEXInternalTermMathOMBiiii #1#2#3#4 {
+  \exp_args:Nnx \use:nn {
+    \seq_clear:N \l__stex_terms_tmp_seq
+    \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{
+    \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq {
+      \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames}
+    }
+    \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{
+      \tl_set:Nx \l__stex_terms_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}}
+      \bool_lazy_or:nnT{
+        \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}}
+      }{
+        \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}}
+      }{
+        \tl_put_right:Nn \l__stex_terms_tmp_tl +
+      }
+      \seq_put_right:No \l__stex_terms_tmp_seq \l__stex_terms_tmp_tl
+    }
+  }
   \__stex_terms_maybe_brackets:nn { #3 }{
-    \_stex_term_ombind:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    \stex_mathml_intent:nn{
+      #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }](
+        \seq_use:Nn \l__stex_terms_tmp_seq ,
+      )
+    }{
+      \_stex_term_ombind:nnn { #1 } { #1\c_hash_str#2 } { #4 }
+    }
   }
+  }{
+    \_stex_reset:N \l_stex_argnames_seq
+  }
 }
 \cs_new:Nn \stex_capitalize:n { \uppercase{#1} }
 
@@ -3950,7 +4422,7 @@
       \_stex_reset:N \STEXInternalCurrentSymbolStr
     }
   }{
-    \int_compare:nNnTF {\prop_item:cn {l_stex_variable_#1_prop}{arity}} = 0{
+    \int_compare:nNnTF {\prop_item:cn {l_stex_symdecl_var://#1_prop}{arity}} = 0{
       \__stex_variables_invoke_math_ii:n {#1}
     }{
       \msg_error:nnxx{stex}{error/noop}{variable~#1}{}
@@ -3984,7 +4456,7 @@
     \prop_clear:N \l__stex_terms_custom_args_prop
     \prop_put:Nnn \l__stex_terms_custom_args_prop {currnum} {1}
     \prop_get:cnN {
-      l_stex_variable_#1 _prop
+      l_stex_symdecl_var://#1 _prop
     }{ args } \l_tmpa_str
     \prop_put:Nno \l__stex_terms_custom_args_prop {args} \l_tmpa_str
     \tl_set:Nn \arg { \__stex_terms_arg: }
@@ -4017,7 +4489,7 @@
       \exp_args:Nnx \use:nn {
         \def\comp{\_varcomp}
         \str_set:Nn \STEXInternalCurrentSymbolStr {varseq://#1}
-        \prop_item:cn{stex_varseq_#1_prop}{notation}
+        \prop_item:cn{l_stex_symdecl_varseq://#1_prop}{notation}
       }{
         \_stex_reset:N \comp
         \_stex_reset:N \STEXInternalCurrentSymbolStr
@@ -4351,6 +4823,9 @@
       { \l_stex_import_ns_str } { \l_stex_import_archive_str }
       { \l_stex_import_path_str } { \l_stex_import_name_str }
   }
+  \exp_args:Nx \stex_add_import_to_current_module:n{
+    \l_stex_import_ns_str ? \l_stex_import_name_str
+  }
 
   \seq_map_inline:Nn \l__stex_copymodule_copymodule_modules_seq {
     \seq_map_inline:cn {c_stex_module_##1_constants}{
@@ -4543,8 +5018,12 @@
   \str_clear:N \l__stex_structures_name_str
   \keys_set:nn { stex / features / structure } { #1 }
 }
-
 \NewDocumentEnvironment{mathstructure}{m O{}}{
+  \begin{mathstructure_inner}{#1}[#2]
+    \stex_smsmode_do:
+    \ignorespacesandpars
+  }{\end{mathstructure_inner}}
+\NewDocumentEnvironment{mathstructure_inner}{m O{}}{
   \__stex_structures_structure_args:n { #2 }
   \str_if_empty:NT \l__stex_structures_name_str {
     \str_set:Nx \l__stex_structures_name_str { #1 }
@@ -4566,7 +5045,6 @@
   \exp_args:Nnnx
   \begin{structural_feature_module}{ structure }
     { \l__stex_structures_name_str }{}
-  \stex_smsmode_do:
 }{
   \end{structural_feature_module}
   \_stex_reset_up_to_module:n \l_stex_last_feature_str
@@ -4645,7 +5123,8 @@
   \seq_map_inline:Nn \l_stex_all_modules_seq {
     \prop_if_exist:cT {c_stex_module_##1_structures} {
       \prop_map_inline:cn {c_stex_module_##1_structures} {
-        \str_if_eq:eeT { \l_tmpa_str }{ \str_range:nnn {##1?####1}{-\l_tmpa_int}{-1}}{
+        \exp_args:No \str_if_eq:nnT \l_tmpa_str {####1}{
+        %\str_if_eq:eeT { \l_tmpa_str }{ \str_range:nnn {##1?####1}{-\l_tmpa_int}{-1}}{
           \prop_map_break:n{\seq_map_break:n{
             \tl_set:Nn \l_tmpa_tl {
               \str_set:Nn \l_stex_get_structure_str {##1?####1}
@@ -4659,6 +5138,12 @@
   \l_tmpa_tl
 }
 
+\NewDocumentEnvironment{usestructure}{m}{
+  \stex_get_structure:n {#1}
+  \exp_args:Nnx \stex_debug:nn{features}{using~structure:~\l_stex_get_structure_module_str}
+  \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str
+}{}
+
 \keys_define:nn { stex / instantiate } {
   name        .str_set_x:N  = \l__stex_structures_name_str
 }
@@ -4667,6 +5152,37 @@
   \keys_set:nn { stex / instantiate } { #1 }
 }
 
+\NewDocumentEnvironment{extstructure}{m m O{}}{
+  \begin{mathstructure_inner}{#1}[#3]
+    \seq_set_split:Nnn\__stex_structures_extstructure_imports_seq,{#2}
+    \seq_map_inline:Nn\__stex_structures_extstructure_imports_seq {
+      \stex_get_structure:n {##1}
+      \exp_args:Nnx \stex_debug:nn{features}{importing~structure:~\l_stex_get_structure_module_str{}~into~\l_stex_current_module_str}
+      \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str
+      \stex_if_smsmode:F {
+        \stex_annotate_invisible:nnn
+          {import} {\l_stex_get_structure_module_str} {}
+      }
+      \exp_args:Nx \stex_add_import_to_current_module:n {
+        \l_stex_get_structure_module_str
+      }
+      \exp_args:Nx \stex_add_to_current_module:n {
+        \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str
+      }
+    }
+    \stex_smsmode_do:
+    \ignorespacesandpars
+}{
+  \end{mathstructure_inner}
+}
+
+\NewDocumentEnvironment{extstructure*}{m m O{}}{
+  % TODO
+  \begin{extstructure}{#1}{#2}[#3]
+}{
+  \end{extstructure}
+}
+
 \NewDocumentCommand \instantiate {m O{} m m O{}}{
   \begingroup
     \stex_get_structure:n {#3}
@@ -4718,7 +5234,8 @@
           name   = \l_tmpa_str ,
           args   = \prop_item:cn {l_stex_symdecl_##1_prop}{args} ,
           arity  = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} ,
-          assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs}
+          assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} ,
+          argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}}
         }
         \seq_clear:c {l_stex_symdecl_\l_stex_current_module_str?\l_tmpa_str _notations}
       }
@@ -4813,7 +5330,7 @@
 }
 
 \cs_new_protected:Nn \__stex_structures_symbolorvar_from_string:n {
-  \prop_if_exist:cTF {l_stex_variable_#1 _prop}{
+  \prop_if_exist:cTF {l_stex_symdecl_var://#1 _prop}{
     \bool_set_true:N \l_stex_symbol_or_var_bool
     \str_set:Nn \l_stex_get_symbol_uri_str { #1 }
   }{
@@ -4876,12 +5393,12 @@
           \bool_if:NTF \l_stex_symbol_or_var_bool {
             \exp_args:Nxx \str_if_eq:nnF
               {\prop_item:cn{l_stex_symdecl_\l__stex_structures_dom_str _prop}{args}}
-              {\prop_item:cn{l_stex_variable_\l_stex_get_symbol_uri_str _prop}{args}}{
+              {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}}{
               \msg_error:nnxxxx{stex}{error/incompatible}
                 {\l__stex_structures_dom_str}
                 {\prop_item:cn{l_stex_symdecl_\l__stex_structures_dom_str _prop}{args}}
                 {\l_stex_get_symbol_uri_str}
-                {\prop_item:cn{l_stex_variable_\l_stex_get_symbol_uri_str _prop}{args}}
+                {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}}
             }
             \prop_put:Nxx \l_tmpa_prop {\seq_item:Nn \l_tmpb_seq 1} {\stex_invoke_variable:n {\l_stex_get_symbol_uri_str}}
           }{
@@ -4915,11 +5432,12 @@
         }
 
         \exp_args:NNx \tl_gput_right:Nn \g__stex_structures_aftergroup_tl {
-          \prop_set_from_keyval:cn { l_stex_variable_ \l_tmpa_str _prop}{
+          \prop_set_from_keyval:cn { l_stex_symdecl_ var://\l_tmpa_str _prop}{
             name   = \l_tmpa_str ,
             args   = \prop_item:cn {l_stex_symdecl_##1_prop}{args} ,
             arity  = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} ,
-            assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs}
+            assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} ,
+            argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}} ,
           }
           \cs_set_eq:cc {stex_var_notation_\l_tmpa_str _cs}
             {g__stex_structures_tmpa_\l_tmpa_str _cs}
@@ -5287,6 +5805,7 @@
       }
     }
     \clist_set_from_seq:NN \l__stex_statements_sdefinition_for_clist \l_tmpb_seq
+    \ifvmode\noindent\fi
     \exp_args:Nnx
     \stex_annotate:nnn{definition}{\seq_use:Nn \l_tmpb_seq {,}}{
       \str_if_empty:NF \sdefinitiontype {
@@ -5445,6 +5964,7 @@
         }
       }
     }
+    \ifvmode\noindent\fi
     \exp_args:Nnx
     \stex_annotate:nnn{assertion}{\seq_use:Nn \l_tmpb_seq {,}}{
       \str_if_empty:NF \sassertiontype {
@@ -5590,6 +6110,7 @@
         }
       }
     }
+    \ifvmode\noindent\fi
     \exp_args:Nnx
     \stex_annotate:nnn{example}{\seq_use:Nn \l_tmpb_seq {,}}{
       \str_if_empty:NF \sexampletype {
@@ -5799,6 +6320,7 @@
         }
       }
     }
+    \ifvmode\noindent\fi
     \exp_args:Nnx
     \stex_annotate:nnn{paragraph}{\seq_use:Nn \l_tmpb_seq {,}}{
       \str_if_empty:NF \sparagraphtype {
@@ -5840,7 +6362,9 @@
   title       .tl_set:N     = \spftitle,
   continues   .tl_set:N     = \l__stex_sproof_spf_continues_tl,
   functions   .tl_set:N     = \l__stex_sproof_spf_functions_tl,
-  method      .tl_set:N     = \l__stex_sproof_spf_method_tl
+  term        .tl_set:N     = \l__stex_sproof_spf_term_tl,
+  method      .tl_set:N     = \l__stex_sproof_spf_method_tl,
+  hide        .bool_set:N   = \l__stex_sproof_spf_hide_bool
 }
 \cs_new_protected:Nn \__stex_sproof_spf_args:n {
 \str_clear:N \spfid
@@ -5850,11 +6374,13 @@
 \str_clear:N \spftype
 \tl_clear:N \spftitle
 \tl_clear:N \l__stex_sproof_spf_continues_tl
+\tl_clear:N \l__stex_sproof_spf_term_tl
 \tl_clear:N \l__stex_sproof_spf_functions_tl
 \tl_clear:N \l__stex_sproof_spf_method_tl
-  \bool_set_false:N \l__stex_sproof_inc_counter_bool
+  \bool_set_false:N \l__stex_sproof_spf_hide_bool
 \keys_set:nn { stex / spf }{ #1 }
 }
+\bool_set_true:N \l__stex_sproof_inc_counter_bool
 \str_set:Nn\c__stex_sproof_flow_str{inline}
 \intarray_new:Nn\l__stex_sproof_counter_intarray{50}
 \cs_new_protected:Npn \sproofnumber {
@@ -5987,155 +6513,130 @@
   \stex_smsmode_do:
 }
 
-\newenvironment{spfeq}[2][]{
-  \__stex_sproof_spf_args:n{#1}
-  \let \premise \stex_proof_premise:
-  \stex_if_smsmode:TF {
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }{
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l__stex_sproof_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
-        }
-      }
-    }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{spfeq}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
-    }
+\bool_set_false:N \l__stex_sproof_in_spfblock_bool
 
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_clear:N \l_tmpa_tl
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \tl_if_exist:cT {__stex_sproof_spfeq_##1_start:}{
-        \tl_set:Nn \l_tmpa_tl {\use:c{__stex_sproof_spfeq_##1_start:}}
-      }
-      \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} {
-        \tl_set:Nn \l_tmpa_tl {\use:n{}}
-      }
-    }
-    \tl_if_empty:NTF \l_tmpa_tl {
-      \__stex_sproof_spfeq_start:
-    }{
-      \l_tmpa_tl
-    }{~#2}
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-    \begin{displaymath}\begin{array}{rcll}
+\cs_new_protected:Nn \__stex_sproof_maybe_comment: {
+  \bool_if:NF \l__stex_sproof_in_spfblock_bool {
+    \par \setbox \l_tmpa_box \vbox \bgroup \everypar{\__stex_sproof_start_comment:}
   }
-  \stex_smsmode_do:
-}{
-  \stex_if_smsmode:F {
-    \end{array}\end{displaymath}
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_clear:N \l_tmpa_tl
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \tl_if_exist:cT {__stex_sproof_spfeq_##1_end:}{
-        \tl_set:Nn \l_tmpa_tl {\use:c{__stex_sproof_spfeq_##1_end:}}
+}
+\cs_new_protected:Nn \__stex_sproof_maybe_comment_end: {
+  \bool_if:NF \l__stex_sproof_in_spfblock_bool { \egroup }
+}
+\cs_new_protected:Nn \__stex_sproof_start_comment: {
+  \csname @ @ par\endcsname\egroup\item[]\bgroup\stexcommentfont
+}
+
+\cs_new_protected:Npn \stexcommentfont {
+  \small\itshape
+}
+\cs_new_protected:Nn \__stex_sproof_start_env:nnn {
+  \seq_clear:N \l_tmpa_seq
+  \clist_map_inline:Nn \l__stex_sproof_spf_for_clist {
+    \tl_if_empty:nF{ ##1 }{
+      \stex_get_symbol:n { ##1 }
+      \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
+        \l_stex_get_symbol_uri_str
       }
     }
-    \tl_if_empty:NTF \l_tmpa_tl {
-      \__stex_sproof_spfeq_end:
-    }{
-      \l_tmpa_tl
-    }
-    \end{stex_annotate_env}
   }
-}
+  \exp_args:Nnnx
+  \begin{stex_annotate_env}{#1}{\seq_use:Nn \l_tmpa_seq {,}}
+  \str_if_empty:NF \spftype {
+    \stex_annotate_invisible:nnn{type}{\spftype}{}
+  }
+  #3 {~\stex_annotate:nnn{spftitle}{}{#2}}
+  \str_if_empty:NF \spfid {
+    \stex_ref_new_doc_target:n \spfid
+  }
+  \begin{stex_annotate_env}{spfbody}{\bool_if:NTF \l__stex_sproof_spf_hide_bool {false}{true}}
+  \bool_if:NT \l__stex_sproof_spf_hide_bool{
+    \stex_html_backend:F{\setbox\l_tmpa_box\vbox\bgroup}
+  }
+  \begin{list}{}{
+    \setlength\topsep{0pt}
+    \setlength\parsep{0pt}
+    \setlength\rightmargin{0pt}
 
-\cs_new_protected:Nn \__stex_sproof_spfeq_start: {
-  \titleemph{
-    \tl_if_empty:NTF \spftitle {
-      \spf at proof@kw
-    }{
-      \spftitle
-    }
-  }:
+  }\__stex_sproof_maybe_comment:
 }
-\cs_new_protected:Nn \__stex_sproof_spfeq_end: {\sproofend}
-
-\newcommand\stexpatchspfeq[3][] {
-    \str_set:Nx \l_tmpa_str{ #1 }
-    \str_if_empty:NTF \l_tmpa_str {
-      \tl_set:Nn \__stex_sproof_spfeq_start: { #2 }
-      \tl_set:Nn \__stex_sproof_spfeq_end: { #3 }
-    }{
-      \exp_after:wN \tl_set:Nn \csname __stex_sproof_spfeq_#1_start:\endcsname{ #2 }
-      \exp_after:wN \tl_set:Nn \csname __stex_sproof_spfeq_#1_end:\endcsname{ #3 }
+\cs_new_protected:Nn \__stex_sproof_end_env:n {
+  \stex_if_smsmode:F{
+    \__stex_sproof_maybe_comment_end:
+    \end{list}
+    \bool_if:NT \l__stex_sproof_spf_hide_bool{
+      \stex_html_backend:F{\egroup}
     }
+    \clist_set:No \l_tmpa_clist \spftype
+    #1
+    \end{stex_annotate_env}
+    \end{stex_annotate_env}
+  }
 }
-
-\newenvironment{sproof}[2][]{
-  \let \premise \stex_proof_premise:
+\NewDocumentEnvironment{sproof}{s O{} m}{
   \intarray_gzero:N \l__stex_sproof_counter_intarray
   \intarray_gset:Nnn \l__stex_sproof_counter_intarray 1 1
-  \__stex_sproof_spf_args:n{#1}
+  \stex_reactivate_macro:N \yield
+  \stex_reactivate_macro:N \eqstep
+  \stex_reactivate_macro:N \assumption
+  \stex_reactivate_macro:N \conclude
+  \stex_reactivate_macro:N \spfstep
+  \__stex_sproof_spf_args:n{#2}
   \stex_if_smsmode:TF {
     \str_if_empty:NF \spfid {
       \stex_ref_new_doc_target:n \spfid
     }
   }{
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l__stex_sproof_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
+    \__stex_sproof_start_env:nnn{sproof}{#3}{
+      \clist_set:No \l_tmpa_clist \spftype
+      \tl_clear:N \l_tmpa_tl
+      \clist_map_inline:Nn \l_tmpa_clist {
+        \tl_if_exist:cT {__stex_sproof_sproof_##1_start:}{
+          \tl_set:Nn \l_tmpa_tl {\use:c{__stex_sproof_sproof_##1_start:}}
         }
+        \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} {
+          \tl_set:Nn \l_tmpa_tl {\use:n{}}
+        }
       }
+      \tl_if_empty:NTF \l_tmpa_tl {
+        \__stex_sproof_sproof_start:
+      }{
+        \l_tmpa_tl
+      }
     }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{sproof}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
+  }
+  \stex_smsmode_do:
+}{\__stex_sproof_end_env:n{
+  \tl_clear:N \l_tmpa_tl
+  \clist_map_inline:Nn \l_tmpa_clist {
+    \tl_if_exist:cT {__stex_sproof_sproof_##1_end:}{
+      \tl_set:Nn \l_tmpa_tl {\use:c{__stex_sproof_sproof_##1_end:}}
     }
-
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_clear:N \l_tmpa_tl
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \tl_if_exist:cT {__stex_sproof_sproof_##1_start:}{
-        \tl_set:Nn \l_tmpa_tl {\use:c{__stex_sproof_sproof_##1_start:}}
-      }
-      \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} {
-        \tl_set:Nn \l_tmpa_tl {\use:n{}}
-      }
-    }
-    \tl_if_empty:NTF \l_tmpa_tl {
-      \__stex_sproof_sproof_start:
-    }{
-      \l_tmpa_tl
-    }{~#2}
+  }
+  \tl_if_empty:NTF \l_tmpa_tl {
+    \__stex_sproof_sproof_end:
+  }{
+    \l_tmpa_tl
+  }
+}}
+\NewDocumentEnvironment{subproof}{s O{} m}{
+  \__stex_sproof_spf_args:n{#2}
+  \stex_if_smsmode:TF {
     \str_if_empty:NF \spfid {
       \stex_ref_new_doc_target:n \spfid
     }
-    \begin{description}
+  }{
+    \__stex_sproof_start_env:nnn{subproof}{\item[\sproofnumber]\ignorespacesandpars #3}{}
   }
+  \__stex_sproof_add_counter:
   \stex_smsmode_do:
-}{
-  \stex_if_smsmode:F{
-    \end{description}
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_clear:N \l_tmpa_tl
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \tl_if_exist:cT {__stex_sproof_sproof_##1_end:}{
-        \tl_set:Nn \l_tmpa_tl {\use:c{__stex_sproof_sproof_##1_end:}}
-      }
-    }
-    \tl_if_empty:NTF \l_tmpa_tl {
-      \__stex_sproof_sproof_end:
-    }{
-      \l_tmpa_tl
-    }
-    \end{stex_annotate_env}
+}{\__stex_sproof_remove_counter:\__stex_sproof_end_env:n{}
+  \bool_if:NT \l__stex_sproof_inc_counter_bool {
+    \__stex_sproof_inc_counter:
   }
+  \aftergroup\__stex_sproof_maybe_comment:
 }
+\AddToHook{env/subproof/before}{\__stex_sproof_maybe_comment_end:}
 
 \cs_new_protected:Nn \__stex_sproof_sproof_start: {
   \par\noindent\titleemph{
@@ -6158,211 +6659,88 @@
     \exp_after:wN \tl_set:Nn \csname __stex_sproof_sproof_#1_end:\endcsname{ #3 }
   }
 }
-\newcommand\spfidea[2][]{
-  \__stex_sproof_spf_args:n{#1}
-  \titleemph{
-    \tl_if_empty:NTF \spftype {Proof~Idea}{
-      \spftype
-    }:
-  }~#2
-  \sproofend
+
+\keys_define:nn { stex / spfsteps } {
+  id          .str_set_x:N  = \spfstepid,
+  for         .clist_set:N  = \l__stex_sproof_spf_for_clist ,
+  type        .str_set_x:N  = \spftype,
+  title       .tl_set:N     = \spftitle,
+  method      .tl_set:N     = \l__stex_sproof_spf_method_tl,
+  term        .tl_set:N     = \l__stex_sproof_spf_term_tl
 }
-\newenvironment{spfstep}[1][]{
-  \__stex_sproof_spf_args:n{#1}
-  \stex_if_smsmode:TF {
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }{
-    \@in at omtexttrue
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_set:Nn \l_tmpa_tl {
-      \item[\sproofnumber]
-      \bool_set_true:N \l__stex_sproof_inc_counter_bool
-    }
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} {
-        \tl_clear:N \l_tmpa_tl
+\cs_new_protected:Nn \__stex_sproof_spfstep_args:n {
+\str_clear:N \spfstepid
+\clist_clear:N \l__stex_sproof_spf_for_clist
+\str_clear:N \spftype
+\tl_clear:N \l__stex_sproof_spf_method_tl
+\tl_clear:N \l__stex_sproof_spf_term_tl
+  %\bool_set_false:N \l__stex_sproof_inc_counter_bool
+\keys_set:nn { stex / spfsteps }{ #1 }
+}
+
+\cs_new_protected:Nn \__stex_sproof_make_step_macro:Nnnnn {
+  \NewDocumentCommand #1 {s O{} +m} {
+    \__stex_sproof_maybe_comment_end:
+
+    \__stex_sproof_spfstep_args:n{##2}
+    \stex_annotate:nnn{spfstep}{#2}{
+      \tl_if_empty:NF \l__stex_sproof_spf_term_tl {
+        \stex_annotate_invisible:nnn{spfyield}{}{$\l__stex_sproof_spf_term_tl$}
       }
-    }
-    \l_tmpa_tl
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l__stex_sproof_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
-        }
+      \bool_if:NTF \l__stex_sproof_in_spfblock_bool {
+        #4
+      }{
+        \item[\IfBooleanTF ##1 {}{#3}]
       }
+      \ignorespacesandpars ##3
     }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{spfstep}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
-    }
-    \tl_if_empty:NF \spftitle {
-      {(\titleemph{\spftitle})\enspace}
-    }
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
+    \bool_if:NF \l__stex_sproof_in_spfblock_bool { \IfBooleanTF ##1 {}{ #5 } }
+    \__stex_sproof_maybe_comment:
   }
-  \stex_smsmode_do:
-  \ignorespacesandpars
-}{
-  \bool_if:NT \l__stex_sproof_inc_counter_bool {
-    \__stex_sproof_inc_counter:
-  }
-  \stex_if_smsmode:F {
-    \end{stex_annotate_env}
-  }
+  \stex_deactivate_macro:Nn #1 {sproof~environments}
 }
-\newenvironment{spfcomment}[1][]{
-  \__stex_sproof_spf_args:n{#1}
-  \clist_set:No \l_tmpa_clist \spftype
-  \tl_set:Nn \l_tmpa_tl {
-    \item[\sproofnumber]
-    \bool_set_true:N \l__stex_sproof_inc_counter_bool
+
+\__stex_sproof_make_step_macro:Nnnnn \assumption {assumption} \sproofnumber {} \__stex_sproof_inc_counter:
+\__stex_sproof_make_step_macro:Nnnnn \conclude {conclusion} {$\Rightarrow$} {} {}
+\__stex_sproof_make_step_macro:Nnnnn \spfstep {} \sproofnumber {} \__stex_sproof_inc_counter:
+
+\NewDocumentCommand \eqstep {s m}{
+  \__stex_sproof_maybe_comment_end:
+  \bool_if:NTF \l__stex_sproof_in_spfblock_bool {
+    $=$
+  }{
+    \item[$=$]
   }
-  \clist_map_inline:Nn \l_tmpa_clist {
-    \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} {
-      \tl_clear:N \l_tmpa_tl
-    }
-  }
-  \l_tmpa_tl
-}{
-  \bool_if:NT \l__stex_sproof_inc_counter_bool {
-    \__stex_sproof_inc_counter:
-  }
+  $\stex_annotate:nnn{spfstep}{eq}{ #2 }$
+  \__stex_sproof_maybe_comment:
 }
-\newenvironment{subproof}[2][]{
-  \__stex_sproof_spf_args:n{#1}
-  \stex_if_smsmode:TF{
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }{
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l__stex_sproof_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
-        }
-      }
-    }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{subproof}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
-    }
+\stex_deactivate_macro:Nn \eqstep {sproof~environments}
 
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_set:Nn \l_tmpa_tl {
-      \item[\sproofnumber]
-      \bool_set_true:N \l__stex_sproof_inc_counter_bool
-    }
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} {
-        \tl_clear:N \l_tmpa_tl
-      }
-    }
-    \l_tmpa_tl
-    \tl_if_empty:NF \spftitle {
-      {(\titleemph{\spftitle})\enspace}
-    }
-    {~#2}
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }
-  \__stex_sproof_add_counter:
-  \stex_smsmode_do:
-}{
-  \__stex_sproof_remove_counter:
-  \bool_if:NT \l__stex_sproof_inc_counter_bool {
-    \__stex_sproof_inc_counter:
-  }
-  \stex_if_smsmode:F{
-    \end{stex_annotate_env}
-  }
+\NewDocumentCommand \yield {+m}{
+  \stex_annotate:nnn{spfyield}{}{ #1 }
 }
-\newenvironment{spfcases}[2][]{
-  \tl_if_empty:nTF{#1}{
-    \begin{subproof}[method=by-cases]{#2}
-  }{
-    \begin{subproof}[#1,method=by-cases]{#2}
-  }
+\stex_deactivate_macro:Nn \yield {sproof~environments}
+
+\NewDocumentEnvironment{spfblock}{}{
+  \item[]
+  \bool_set_true:N \l__stex_sproof_in_spfblock_bool
 }{
-  \end{subproof}
+  \aftergroup\__stex_sproof_maybe_comment:
 }
-\newenvironment{spfcase}[2][]{
+\AddToHook{env/spfblock/before}{\__stex_sproof_maybe_comment_end:}
+
+\NewDocumentCommand\spfidea{O{} +m}{
   \__stex_sproof_spf_args:n{#1}
-  \stex_if_smsmode:TF {
-    \str_if_empty:NF \spfid {
-      \stex_ref_new_doc_target:n \spfid
-    }
-  }{
-    \seq_clear:N \l_tmpa_seq
-    \clist_map_inline:Nn \l__stex_sproof_spf_for_clist {
-      \tl_if_empty:nF{ ##1 }{
-        \stex_get_symbol:n { ##1 }
-        \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq {
-          \l_stex_get_symbol_uri_str
-        }
-      }
-    }
-    \exp_args:Nnnx
-    \begin{stex_annotate_env}{spfcase}{\seq_use:Nn \l_tmpa_seq {,}}
-    \str_if_empty:NF \spftype {
-      \stex_annotate_invisible:nnn{type}{\spftype}{}
-    }
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_set:Nn \l_tmpa_tl {
-      \item[\sproofnumber]
-      \bool_set_true:N \l__stex_sproof_inc_counter_bool
-    }
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} {
-        \tl_clear:N \l_tmpa_tl
-      }
-    }
-    \l_tmpa_tl
-    \tl_if_empty:nF{#2}{
-      \titleemph{#2}:~
-    }
-  }
-  \__stex_sproof_add_counter:
-  \stex_smsmode_do:
-}{
-  \__stex_sproof_remove_counter:
-  \bool_if:NT \l__stex_sproof_inc_counter_bool {
-    \__stex_sproof_inc_counter:
-  }
-  \stex_if_smsmode:F{
-    \clist_set:No \l_tmpa_clist \spftype
-    \tl_set:Nn \l_tmpa_tl{\sproofend}
-    \clist_map_inline:Nn \l_tmpa_clist {
-      \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} {
-        \tl_clear:N \l_tmpa_tl
-      }
-    }
-    \l_tmpa_tl
-    \end{stex_annotate_env}
-  }
+  \titleemph{
+    \tl_if_empty:NTF \spftype {Proof~Idea}{
+      \spftype
+    }:
+  }~#2
+  \sproofend
 }
-\newcommand\spfcasesketch[3][]{
-  \begin{spfcase}[#1]{#2}#3\end{spfcase}
+\newcommand\spfjust[1]{
+  #1
 }
-\keys_define:nn { stex / just }{
-  id        .str_set_x:N  = \l__stex_sproof_just_id_str,
-  method    .tl_set:N     = \l__stex_sproof_just_method_tl,
-  premises  .tl_set:N     = \l__stex_sproof_just_premises_tl,
-  args      .tl_set:N     = \l__stex_sproof_just_args_tl
-}
-\newcommand\spfjust[1][]{}
-\newcommand\stex_proof_premise:[2][]{#2}
-\newcommand\justarg[2][]{#2}
 
 %%%%%%%%%%%%%   metatheory.dtx   %%%%%%%%%%%%%
 
@@ -6516,6 +6894,8 @@
     \exp_args:Nx \stex_set_current_repository:n { \l_tmpa_str }
   }
 }
+
+\stex_get_document_uri:
 \endinput
 %%
 %% End of file `stex.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/stex/tikzinput.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stex/tikzinput.sty	2022-09-14 15:38:18 UTC (rev 64382)
+++ trunk/Master/texmf-dist/tex/latex/stex/tikzinput.sty	2022-09-14 19:58:16 UTC (rev 64383)
@@ -9,7 +9,7 @@
 
 %%%%%%%%%%%%%   tikzinput.dtx   %%%%%%%%%%%%%
 
-\ProvidesExplPackage{tikzinput}{2022/05/24}{3.1.0}{tikzinput package}
+\ProvidesExplPackage{tikzinput}{2022/09/14}{3.2.0}{tikzinput package}
 \RequirePackage{l3keys2e}
 
 \keys_define:nn { tikzinput } {
@@ -64,6 +64,7 @@
 }{}
 
 
+
 \endinput
 %%
 %% End of file `tikzinput.sty'.



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