texlive[68880] Master/texmf-dist: q-and-a (17nov23)

commits+karl at tug.org commits+karl at tug.org
Fri Nov 17 23:02:41 CET 2023


Revision: 68880
          https://tug.org/svn/texlive?view=revision&revision=68880
Author:   karl
Date:     2023-11-17 23:02:41 +0100 (Fri, 17 Nov 2023)
Log Message:
-----------
q-and-a (17nov23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.pdf
    trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.tex
    trunk/Master/texmf-dist/doc/latex/q-and-a/doc/code/Q-and-A-doc-code-sample-document.tex
    trunk/Master/texmf-dist/tex/latex/q-and-a/Q-and-A.cls

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/
    trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple-content.tex
    trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.pdf
    trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.tex

Added: trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple-content.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple-content.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple-content.tex	2023-11-17 22:02:41 UTC (rev 68880)
@@ -0,0 +1,85 @@
+"
+  We start with the **normal** mode.
+
+?
+  Question.
+
+:
+  Answer.
+
+?
+  Question.
+
+:
+  Answer.
+
+"
+  Now start the **multiple question** mode.
+
+\EnableMultipleQuestion
+
+?
+  Question.
+
+?
+  Question.
+
+:
+  Answer.
+
+"
+  Now stop the **multiple question** mode, and start the **multiple answer** mode.
+
+\DisableMultipleQuestion
+
+\EnableMultipleAnswer
+
+?
+  Question.
+
+:
+  Answer.
+
+:
+  Answer.
+
+"
+  Now start both the **multiple question** mode and the **multiple answer** mode.
+
+\EnableMultipleQuestion
+
+\EnableMultipleAnswer
+
+?
+  Question.
+
+?
+  Question.
+
+:
+  Answer.
+
+:
+  Answer.
+
+:
+  Answer.
+
+"
+  Back to the **normal** mode.
+
+\DisableMultipleQuestion
+
+\DisableMultipleAnswer
+
+?
+  Question.
+
+:
+  Answer.
+
+?
+  Question.
+
+:
+  Answer.


Property changes on: trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple-content.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.pdf	2023-11-17 22:02:24 UTC (rev 68879)
+++ trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.pdf	2023-11-17 22:02:41 UTC (rev 68880)

Property changes on: trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.tex	2023-11-17 22:02:41 UTC (rev 68880)
@@ -0,0 +1,33 @@
+\documentclass[%11pt,
+  numbered question,
+  numbered answer,
+  % multiple question,
+  % multiple answer,
+  enlarge left margin by = .5cm,
+  scroll,
+]{Q-and-A}
+
+\SetSubcounterStyle{\smaller}
+\SetSubcounterSeparator{\,/\,}
+% \SetSubcounterSeparator{-}
+
+\begin{document}
+
+
+:: {Q-and-A-demo-multiple-content}
+
+
+---
+
+"
+  Below is the code of this conversation.
+
+  == {Q-and-A-demo-multiple-content}
+
+"
+  Below is the code of the main document.
+
+  == [latex] {\jobname}
+
+
+\end{document}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/q-and-a/demo/mode-multiple/Q-and-A-demo-multiple.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.tex	2023-11-17 22:02:24 UTC (rev 68879)
+++ trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.tex	2023-11-17 22:02:41 UTC (rev 68880)
@@ -5,8 +5,8 @@
   scroll,
 ]{Q-and-A}
 
-\def\PackageVersion{2023/11/11}
-\def\PackageSubVersion{}
+\def\PackageVersion{2023/11/17}
+\def\PackageSubVersion{a}
 
 \newcommand{\QApackage}{{\normalfont\textsf{Q-and-A}}}
 
@@ -75,6 +75,10 @@
     \item `use theme = \meta{theme}`: use the selected theme, available choices include: `default` (like the current document), `ChatGPT-light` and `ChatGPT-dark` (see the demo documents).
     \item `numbered question`, or `question number`: enable the numbering of questions.
     \item `numbered answer`, or `answer number`: enable the numbering of answers.
+    \item `multiple question` and `multiple answer`: enable subcounter for questions and answers. This can also be enabled/disabled manually in the middle of the document, via `\textbackslash EnableMultipleQuestion` / `\textbackslash DisableMultipleQuestion` and `\textbackslash EnableMultipleAnswer` / `\textbackslash DisableMultipleAnswer`.
+    \item `smaller subcounter`: when `multiple question` (and/or `multiple answer`) is enabled, use this option to show the subcounter in a smaller size.
+    \item `enlarge left margin by = \meta{length}`, or `increase left margin by = \meta{length}`: enlarge the left margin by the amount of `\meta{length}`. This would be useful if there are so many questions/answers that the numbering becomes too long to fit in the margin.
+    \QANote{Here `\meta{length}` should be specified with absolute unit like `pt`, `cm`, `mm`, `in`, etc., but not with unit like `ex` or `em`.}
     \item `answer outside the box`, or `answer out of the box` (or even omit `the`): enable another implementation for printing the answer that does not involve putting it into a colored box. This would be useful if the answers contain many long pieces of code while you still want the pages to break normally.
   \end{itemize}
 
@@ -135,13 +139,13 @@
   \begin{itemize}
     \item For centered image, the caption can be written via `\textgreater\textgreater{} \meta{caption text}`.
   \end{itemize}
-  \QANote{Currently, the `\meta{caption text}` shall be directly printed in the center. You may wish to add a pair of parentheses around it.}
+  % \QANote{Currently, the `\meta{caption text}` shall be directly printed in the center. You may wish to add a pair of parentheses around it.}
 
   [Code]
   Due to the current implementation of this document class, it is unfortunate that you cannot directly insert source code in your document. There are some workarounds, though.
   \begin{itemize}
     \item For *inline* code, you may simply write it between two backticks `\textbacktick\meta{code}\textbacktick`, similar to the Markdown syntax. However, be aware that special characters need to be escaped, for example, `\textbackslash` should be written as `\textbackslash textbackslash`, `\{` should be written as `\textbackslash\{`, `\%` should be written as `\textbackslash\%`, etc.
-    \item For *displayed* code, stored the code into a separate file, and then use `\textequalsign\textequalsign{} \{\meta{file name}\}` to print~it. You may also use an optional argument like `\textequalsign\textequalsign{} [\meta{language}] \{\meta{file name}\}` to select the language of your code.
+    \item For *displayed* code, store the code into a separate file, and then use `\textequalsign\textequalsign{} \{\meta{file name}\}` to print~it. You may also use an optional argument like `\textequalsign\textequalsign{} [\meta{language}] \{\meta{file name}\}` to select the language of your code.
     \QANote{If the answers contain many long pieces of code, you may consider using the class option `answer outside the box`.}
   \end{itemize}
 
@@ -166,6 +170,8 @@
 
   And don't forget that you are still using \LaTeX, so images, tables and lists can be written as usual.
 
+  \medskip
+
   >>> Currently, the default style for showing tables has not been settled (since the color configuration for tables with or without headers would be slightly different). As a temporary solution, it is recommended for you to consult the several nice answers of this question: \url{https://tex.stackexchange.com/q/10224}.
 
 
@@ -220,14 +226,15 @@
   Here, \meta{identifier} is a comma list of your specified identifiers. For example, the default identifier for narrations is preset via `\textbackslash QASetTypePrefix\{N\}\{N:,",“,”,「\}`.
   \QANote{Note that, due to its implementation, the identifier cannot contain comma `,` in it. If you wish to use an identifier that contains a comma, you may use `\textbackslash QAAddTypePrefix` instead, which only adds *one* identifier per use.}
   \QANote{Note also that, the identifiers are *reset* upon changing of language. Thus, you need to put your setting into the corresponding language configuration, for example, via `\textbackslash AddLanguageSetting[\meta{language name}]\{\meta{settings}\}`}
+  \QANote{You may use `\textbackslash QARemovePrefix\{\meta{identifier}\}` to remove a certain identifier, or use `\textbackslash QARemoveAllPrefix` to remove all of them. This is especially useful if you wish to clear all the previous setting in the language configuration.}
 
   [Changing labels]
-  You may also change the labels. For example, from the text \textquote{Q:} to a logo icon. This can be done via the use of `\textbackslash SetLogoCode` in the preamble of your document.
+  You may also change the labels. For example, from the text \textquote{Q:} to a logo icon. This can be done via the use of `\textbackslash QASetLogoCode` in the preamble of your document.
   \begin{itemize}
-    \item Use `\textbackslash SetLogoCode\{Q\}\{\meta{logo code}\}` to set the labels for questions.
-    \item Use `\textbackslash SetLogoCode\{A\}\{\meta{logo code}\}` to set the labels for answers.
+    \item Use `\textbackslash QASetLogoCode\{Q\}\{\meta{logo code}\}` to set the labels for questions.
+    \item Use `\textbackslash QASetLogoCode\{A\}\{\meta{logo code}\}` to set the labels for answers.
   \end{itemize}
-  Here, \meta{logo code} is the actual code for displaying the corresponding label. For example, the default label for (unnumbered) questions is preset via `\textbackslash SetLogoCode\{Q\}\{\textbackslash textbf\{Q\textbackslash,:\}\}`.
+  Here, \meta{logo code} is the actual code for displaying the corresponding label. For example, the default label for (unnumbered) questions is preset via `\textbackslash QASetLogoCode\{Q\}\{\textbackslash textbf\{Q\textbackslash,:\}\}`.
   \QANote{In the demo document, you can find an example on how to use this command to specify a logo for each role in the conversation.}
   If you wish to include the question number or answer number, you may use the command `\textbackslash QAShowCounter`:
   \begin{itemize}
@@ -234,9 +241,18 @@
     \item Use `\textbackslash QAShowCounter\{Q\}` to step the counter of question and print it.
     \item Use `\textbackslash QAShowCounter\{A\}`  to step the counter of answer and print it.
   \end{itemize}
-  For example, the default label for numbered questions is preset by adding `\textbackslash QAShowCounter\{Q\}` to the unnumbered version: `\textbackslash SetLogoCode\{Q\}\{\textbackslash textbf\{Q\textbackslash QAShowCounter\{Q\}\textbackslash,:\}\}`.
+  For example, the default label for numbered questions is preset by adding `\textbackslash QAShowCounter\{Q\}` to the unnumbered version: `\textbackslash QASetLogoCode\{Q\}\{\textbackslash textbf\{Q\textbackslash QAShowCounter\{Q\}\textbackslash,:\}\}`.
 
+  [Controlling subcounters]
+  When using `\textbackslash QAShowCounter` to show a counter that contains a subcounter, it is possible to control the style and the separator of the subcounter:
+  \begin{itemize}
+    \item Use `\textbackslash QASetSubcounterStyle\{\meta{style code}\}` to define the style of the subcounter. For example, the class option `smaller subcounter` is equivalent to `\textbackslash QASetSubcounterStyle\{\textbackslash smaller\}`.
+    \item Use `\textbackslash QASetSubcounterSeparator\{\meta{separator}\}` to define the separator between the parent and child counters. By default it is `.`, but you may set it to, say, `-`, or `/`.
+  \end{itemize}
 
+  >>> In this section, all commands with the prefix `QASet` also has an abbreviation form with the prefix `Set`. For example, instead of `\textbackslash QASetLogoCode`, you may simply write `\textbackslash SetLogoCode`.
+
+
 ##+ {Known Issues}
 
 ?
@@ -260,7 +276,7 @@
   \end{itemize}
 
 
-##+ {Get Support}
+##+ {Getting Support}
 
 ?
   What should I do if I encounter any problem?

Modified: trunk/Master/texmf-dist/doc/latex/q-and-a/doc/code/Q-and-A-doc-code-sample-document.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/q-and-a/doc/code/Q-and-A-doc-code-sample-document.tex	2023-11-17 22:02:24 UTC (rev 68879)
+++ trunk/Master/texmf-dist/doc/latex/q-and-a/doc/code/Q-and-A-doc-code-sample-document.tex	2023-11-17 22:02:41 UTC (rev 68880)
@@ -2,6 +2,9 @@
   use theme = (@@@\meta{theme}),
   numbered question,
   numbered answer,
+  % multiple question,
+  % multiple answer,
+  % smaller subcounter,
   % answer outside the box,
   scroll,
 ]{Q-and-A}

Modified: trunk/Master/texmf-dist/tex/latex/q-and-a/Q-and-A.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/q-and-a/Q-and-A.cls	2023-11-17 22:02:24 UTC (rev 68879)
+++ trunk/Master/texmf-dist/tex/latex/q-and-a/Q-and-A.cls	2023-11-17 22:02:41 UTC (rev 68880)
@@ -12,14 +12,22 @@
 \NeedsTeXFormat{LaTeX2e}[2022-06-01]
 \ProvidesExplClass
   {Q-and-A}
-  {2023/11/11} {}
+  {2023/11/17a} {}
   {Document class for typesetting Q&A conversation}
 
 \keys_define:nn { Q-and-A }
   {
-    , scroll      .bool_set:N   = \l__QA_scroll_bool
-    , scroll      .initial:n    = { false }
+    , scroll                  .bool_set:N   = \l__QA_scroll_bool
+    , scroll                  .initial:n    = { false }
 
+    , enlarge-left-margin-by  .dim_set:N    = \l__QA_extra_left_margin_dim
+    , enlarge-left-margin-by  .initial:n    = { 0pt }
+    , enlarge~left~margin~by  .dim_set:N    = \l__QA_extra_left_margin_dim
+    , enlarge left margin by  .dim_set:N    = \l__QA_extra_left_margin_dim
+    , increase-left-margin-by .dim_set:N    = \l__QA_extra_left_margin_dim
+    , increase~left~margin~by .dim_set:N    = \l__QA_extra_left_margin_dim
+    , increase left margin by .dim_set:N    = \l__QA_extra_left_margin_dim
+
     , theme             .str_set:N          = \l__QA_theme_str
     , theme             .initial:n          = { default }
     , use-theme         .str_set:N          = \l__QA_theme_str
@@ -49,6 +57,21 @@
     , answer~number     .bool_set:N         = \l__QA_numbered_answer_bool
     , answer number     .bool_set:N         = \l__QA_numbered_answer_bool
 
+    , multiple-question .bool_set:N         = \l__QA_multiple_question_bool
+    , multiple-question .initial:n          = { false }
+    , multiple~question .bool_set:N         = \l__QA_multiple_question_bool
+    , multiple question .bool_set:N         = \l__QA_multiple_question_bool
+
+    , multiple-answer   .bool_set:N         = \l__QA_multiple_answer_bool
+    , multiple-answer   .initial:n          = { false }
+    , multiple~answer   .bool_set:N         = \l__QA_multiple_answer_bool
+    , multiple answer   .bool_set:N         = \l__QA_multiple_answer_bool
+
+    , smaller-subcounter     .bool_set:N    = \l__QA_smaller_subcounter_bool
+    , smaller-subcounter     .initial:n     = { false }
+    , smaller~subcounter     .bool_set:N    = \l__QA_smaller_subcounter_bool
+    , smaller subcounter     .bool_set:N    = \l__QA_smaller_subcounter_bool
+
     , answer-outside-the-box .bool_set:N    = \l__QA_answer_outside_the_box_bool
     , answer-outside-the-box .initial:n     = { false }
     , answer~outside~the~box .bool_set:N    = \l__QA_answer_outside_the_box_bool
@@ -157,7 +180,7 @@
 \dim_new:N \l_QA_item_indentation_dim
 \dim_set:Nn \l_QA_item_indentation_dim { 1.5em }
 \dim_new:N \l_QA_list_indentation_dim
-\dim_set:Nn \l_QA_list_indentation_dim { 3em }
+\dim_set:Nn \l_QA_list_indentation_dim { 3em + \l__QA_extra_left_margin_dim }
 \dim_new:N \l_QA_list_labelsep_dim
 \dim_set:Nn \l_QA_list_labelsep_dim { 1em }
 
@@ -164,12 +187,12 @@
 \exp_args:No \str_if_in:nnT { \l__QA_theme_str } { ChatGPT }
   {
     \dim_set:Nn \l_QA_item_indentation_dim { .33em }
-    \dim_set:Nn \l_QA_list_indentation_dim { 4.5em }
+    \dim_set:Nn \l_QA_list_indentation_dim { 4.5em + \l__QA_extra_left_margin_dim }
     \dim_set:Nn \l_QA_list_labelsep_dim { 1.5em }
   }
 
 \newlist { QA-entry } { description } { 1 }
-\setlist [ QA-entry ] { font = \normalfont\sffamily, leftmargin = \l_QA_list_indentation_dim, labelsep = \l_QA_list_labelsep_dim, labelwidth=3em, itemindent=0pt, parsep=\parskip }
+\setlist [ QA-entry ] { font = \normalfont\sffamily, leftmargin = \l_QA_list_indentation_dim, labelsep = \l_QA_list_labelsep_dim, labelwidth=4em, itemindent=0pt, parsep=\parskip }
 \renewcommand{\descriptionlabel}[1]{#1}
 
 \bool_new:N \l__QA_inside_list_bool
@@ -352,6 +375,7 @@
     includegraphics,
     definecolor, colorlet, color, textcolor,
     tikz, draw, fill, filldraw, node, clip,
+    smaller,larger,
   }
   {% LaTeX3 commands
   }
@@ -361,6 +385,12 @@
     UseLanguage,
     TheDate,
     SetLogoCode,
+    SetSubcounterStyle,
+    SetSubcounterSeparator,
+    EnableMultipleQuestion,
+    EnableMultipleAnswer,
+    DisableMultipleQuestion,
+    DisableMultipleAnswer,
   }
   {% LaTeX3 commands
   }
@@ -464,7 +494,7 @@
   }
 \NewDocumentCommand \QAEnum { s m m }
   {
-    \tl_if_blank:nTF { #1 }
+    \tl_if_blank:nTF { #2 }
       {
         \tl_set:Nn \l_tmpa_tl { }
       }
@@ -735,10 +765,11 @@
       }
   }
 
-\NewDocumentCommand \SetLogoCode { O{void} m }
+\NewDocumentCommand \QASetLogoCode { O{void} m }
   {
     \tl_set:cn { l_QA_logo_code_ #1 _tl } { #2 }
   }
+\NewCommandCopy \SetLogoCode \QASetLogoCode
 
 % Set default logo code
 \SetLogoCode[Q]{\textbf{\l_QA_label_Q_tl}}
@@ -746,12 +777,123 @@
 
 \newcounter{QA_Q}
 \newcounter{QA_A}
+
+\def\QASubcounterStyle{}
+\def\QASubcounterSeparator{.}
+\NewDocumentCommand \QASetSubcounterStyle { m }
+  {
+    \def\QASubcounterStyle{#1}
+  }
+\NewCommandCopy \SetSubcounterStyle \QASetSubcounterStyle
+\NewDocumentCommand \QASetSubcounterSeparator { m }
+  {
+    \def\QASubcounterSeparator{#1}
+  }
+\NewCommandCopy \SetSubcounterSeparator \QASetSubcounterSeparator
+
+\bool_if:NT \l__QA_smaller_subcounter_bool
+  {
+    \QASetSubcounterStyle{\smaller}
+  }
+
+\cs_new_protected:Nn \QA_show_subcounter_with_style:n
+  {
+    \group_begin:
+    \tl_set:Nx \l_tmpa_tl { #1 }
+    \regex_replace_once:nnN { \. (.*) } { \c{QASubcounterStyle}{\c{QASubcounterSeparator}\1} } \l_tmpa_tl
+    \tl_use:N \l_tmpa_tl
+    \group_end:
+  }
 \NewDocumentCommand \QAShowCounter { m }
   {
     \stepcounter{QA_#1}
-    \tl_use:c {theQA_#1}
+    \QA_show_subcounter_with_style:n { \tl_use:c {theQA_#1} }
   }
 
+\newcounter{QA_Q_aux}
+\newcounter{QA_A_aux}
+
+\bool_new:N \g__QA_Q_multiple_counter_already_enabled_bool
+\bool_new:N \g__QA_Q_multiple_counter_already_updated_bool
+\bool_gset_false:N \g__QA_Q_multiple_counter_already_enabled_bool
+\NewDocumentCommand \EnableMultipleQuestion { }
+  {
+    \bool_if:NF \g__QA_Q_multiple_counter_already_enabled_bool
+      {
+        \setcounter{QA_Q_aux}{\value{QA_Q}} % set the outer counter
+        \addtocounter{QA_Q_aux}{1}
+        \setcounter{QA_Q}{0} % reset the inner counter
+        \counterwithin{QA_Q}{QA_Q_aux}
+        \hook_gput_code:nnn { env/QA_Q/begin } { Q-and-A-multi-Q }
+          {
+            \bool_gset_false:N \g__QA_Q_multiple_counter_already_updated_bool
+          }
+        \hook_gput_code:nnn { env/QA_A/begin } { Q-and-A-multi-Q }
+          {
+            \bool_if:NF \g__QA_Q_multiple_counter_already_updated_bool
+              {
+                \stepcounter{QA_Q_aux}
+              }
+            \bool_gset_true:N \g__QA_Q_multiple_counter_already_updated_bool
+          }
+      }
+    \bool_gset_true:N \g__QA_Q_multiple_counter_already_enabled_bool
+  }
+\NewDocumentCommand \DisableMultipleQuestion { }
+  {
+    \bool_if:NT \g__QA_Q_multiple_counter_already_enabled_bool
+      {
+        \counterwithout{QA_Q}{QA_Q_aux}
+        \setcounter{QA_Q}{\value{QA_Q_aux}} % set the outer counter
+        \addtocounter{QA_Q}{-1}
+        \hook_gremove_code:nn { env/QA_Q/begin } { Q-and-A-multi-Q }
+        \hook_gremove_code:nn { env/QA_A/begin } { Q-and-A-multi-Q }
+      }
+    \bool_gset_false:N \g__QA_Q_multiple_counter_already_enabled_bool
+  }
+
+\bool_new:N \g__QA_A_multiple_counter_already_enabled_bool
+\bool_new:N \g__QA_A_multiple_counter_already_updated_bool
+\bool_gset_false:N \g__QA_A_multiple_counter_already_enabled_bool
+\NewDocumentCommand \EnableMultipleAnswer { }
+  {
+    \bool_if:NF \g__QA_A_multiple_counter_already_enabled_bool
+      {
+        \setcounter{QA_A_aux}{\value{QA_A}} % set the outer counter
+        % \addtocounter{QA_A_aux}{1}
+        \setcounter{QA_A}{0} % reset the inner counter
+        \counterwithin{QA_A}{QA_A_aux}
+        \hook_gput_code:nnn { env/QA_A/begin } { Q-and-A-multi-A }
+          {
+            \bool_gset_false:N \g__QA_A_multiple_counter_already_updated_bool
+          }
+        \hook_gput_code:nnn { env/QA_Q/begin } { Q-and-A-multi-A }
+          {
+            \bool_if:NF \g__QA_A_multiple_counter_already_updated_bool
+              {
+                \stepcounter{QA_A_aux}
+              }
+            \bool_gset_true:N \g__QA_A_multiple_counter_already_updated_bool
+          }
+      }
+    \bool_gset_true:N \g__QA_A_multiple_counter_already_enabled_bool
+  }
+\NewDocumentCommand \DisableMultipleAnswer { }
+  {
+    \bool_if:NT \g__QA_A_multiple_counter_already_enabled_bool
+      {
+        \counterwithout{QA_A}{QA_A_aux}
+        \setcounter{QA_A}{\value{QA_A_aux}} % set the outer counter
+        % \addtocounter{QA_A}{-1}
+        \hook_gremove_code:nn { env/QA_A/begin } { Q-and-A-multi-A }
+        \hook_gremove_code:nn { env/QA_Q/begin } { Q-and-A-multi-A }
+      }
+    \bool_gset_false:N \g__QA_A_multiple_counter_already_enabled_bool
+  }
+
+\bool_if:NT \l__QA_multiple_question_bool { \EnableMultipleQuestion }
+\bool_if:NT \l__QA_multiple_answer_bool   { \EnableMultipleAnswer   }
+
 \bool_if:NTF \l__QA_numbered_question_bool
   {
     \projlib_langauge_define_multilingual_text:Nn \l_QA_label_Q_tl
@@ -827,18 +969,22 @@
         \prop_gput_if_new:Nnn \g__QA_prefix_type_prop { ##1 } { #1 }
       }
   }
+\NewCommandCopy \SetTypePrefix \QASetTypePrefix
 \NewDocumentCommand \QAAddTypePrefix { m m }
   {
     \prop_gput_if_new:Nnn \g__QA_prefix_type_prop { #2 } { #1 }
   }
+\NewCommandCopy \AddTypePrefix \QAAddTypePrefix
 \NewDocumentCommand \QARemovePrefix { m }
   {
     \prop_gremove:Nn \g__QA_prefix_type_prop { #1 }
   }
+\NewCommandCopy \RemovePrefix \QARemovePrefix
 \NewDocumentCommand \QARemoveAllPrefix { }
   {
     \prop_gclear:N \g__QA_prefix_type_prop
   }
+\NewCommandCopy \RemoveAllPrefix \QARemoveAllPrefix
 
 % \QASetTypePrefix { void } { VOID }
 % \QASetTypePrefix { Q } { Q: , ? }



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