diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/stex/problem.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/stex/problem.sty | 199 |
1 files changed, 141 insertions, 58 deletions
diff --git a/Master/texmf-dist/tex/latex/stex/problem.sty b/Master/texmf-dist/tex/latex/stex/problem.sty index 2e927431576..091eb3c5b36 100644 --- a/Master/texmf-dist/tex/latex/stex/problem.sty +++ b/Master/texmf-dist/tex/latex/stex/problem.sty @@ -6,7 +6,7 @@ %% %% problem.dtx (with options: `package') %% -\ProvidesExplPackage{problem}{2022/02/26}{3.0.1}{Semantic Markup for Problems} +\ProvidesExplPackage{problem}{2022/05/24}{3.1.0}{Semantic Markup for Problems} \RequirePackage{l3keys2e,stex} \keys_define:nn { problem / pkg }{ @@ -68,23 +68,27 @@ min .tl_set:N = \l__problems_prob_min_tl, title .tl_set:N = \l__problems_prob_title_tl, type .tl_set:N = \l__problems_prob_type_tl, + imports .tl_set:N = \l__problems_prob_imports_tl, + name .str_set_x:N = \l__problems_prob_name_str, refnum .int_set:N = \l__problems_prob_refnum_int } \cs_new_protected:Nn \__problems_prob_args:n { \str_clear:N \l__problems_prob_id_str + \str_clear:N \l__problems_prob_name_str \tl_clear:N \l__problems_prob_pts_tl \tl_clear:N \l__problems_prob_min_tl \tl_clear:N \l__problems_prob_title_tl \tl_clear:N \l__problems_prob_type_tl + \tl_clear:N \l__problems_prob_imports_tl \int_zero_new:N \l__problems_prob_refnum_int \keys_set:nn { problem / problem }{ #1 } \int_compare:nNnT \l__problems_prob_refnum_int = 0 { \let\l__problems_prob_refnum_int\undefined } } -\newcounter{problem} +\newcounter{problem}[section] \newcommand\numberproblemsin[1]{\@addtoreset{problem}{#1}} -\newcommand\prob@label[1]{#1} +\newcommand\prob@label[1]{\thesection.#1} \newcommand\prob@number{ \int_if_exist:NTF \l__problems_inclprob_refnum_int { \prob@label{\int_use:N \l__problems_inclprob_refnum_int } @@ -116,6 +120,43 @@ \@in@omtexttrue% we are in a statement (for inline definitions) \stepcounter{problem}\record@problem \def\current@section@level{\prob@problem@kw} + + \str_if_empty:NT \l__problems_prob_name_str { + \seq_get_right:NN \g_stex_currentfile_seq \l_tmpa_str + \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str + \seq_get_left:NN \l_tmpa_seq \l__problems_prob_name_str + } + + \stex_if_do_html:T{ + \tl_if_empty:NF \l__problems_prob_title_tl { + \exp_args:No \stex_document_title:n \l__problems_prob_title_tl + } + } + + \exp_args:Nno\stex_module_setup:nn{type=problem}\l__problems_prob_name_str + + \stex_reactivate_macro:N \STEXexport + \stex_reactivate_macro:N \importmodule + \stex_reactivate_macro:N \symdecl + \stex_reactivate_macro:N \notation + \stex_reactivate_macro:N \symdef + + \stex_if_do_html:T{ + \begin{stex_annotate_env} {problem} { + \l_stex_module_ns_str ? \l_stex_module_name_str + } + + \stex_annotate_invisible:nnn{header}{} { + \stex_annotate:nnn{language}{ \l_stex_module_lang_str }{} + \stex_annotate:nnn{signature}{ \l_stex_module_sig_str }{} + \str_if_eq:VnF \l_stex_module_meta_str {NONE} { + \stex_annotate:nnn{metatheory}{ \l_stex_module_meta_str }{} + } + } + } + + \stex_csl_to_imports:No \importmodule \l__problems_prob_imports_tl + \tl_if_exist:NTF \l__problems_inclprob_type_tl { \tl_set_eq:NN \sproblemtype \l__problems_inclprob_type_tl }{ @@ -127,36 +168,47 @@ \str_set_eq:NN \sproblemid \l__problems_prob_id_str } - \clist_set:No \l_tmpa_clist \sproblemtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__problems_sproblem_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__problems_sproblem_##1_start:}} + \stex_if_smsmode:F { + \clist_set:No \l_tmpa_clist \sproblemtype + \tl_clear:N \l_tmpa_tl + \clist_map_inline:Nn \l_tmpa_clist { + \tl_if_exist:cT {__problems_sproblem_##1_start:}{ + \tl_set:Nn \l_tmpa_tl {\use:c{__problems_sproblem_##1_start:}} + } + } + \tl_if_empty:NTF \l_tmpa_tl { + \__problems_sproblem_start: + }{ + \l_tmpa_tl } - } - \tl_if_empty:NTF \l_tmpa_tl { - \__problems_sproblem_start: - }{ - \l_tmpa_tl } \stex_ref_new_doc_target:n \sproblemid + \stex_smsmode_do: }{ - \clist_set:No \l_tmpa_clist \sproblemtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__problems_sproblem_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__problems_sproblem_##1_end:}} + \__stex_modules_end_module: + \stex_if_smsmode:F{ + \clist_set:No \l_tmpa_clist \sproblemtype + \tl_clear:N \l_tmpa_tl + \clist_map_inline:Nn \l_tmpa_clist { + \tl_if_exist:cT {__problems_sproblem_##1_end:}{ + \tl_set:Nn \l_tmpa_tl {\use:c{__problems_sproblem_##1_end:}} + } + } + \tl_if_empty:NTF \l_tmpa_tl { + \__problems_sproblem_end: + }{ + \l_tmpa_tl } } - \tl_if_empty:NTF \l_tmpa_tl { - \__problems_sproblem_end: - }{ - \l_tmpa_tl + \stex_if_do_html:T{ + \end{stex_annotate_env} } \smallskip } +\seq_put_right:Nx\g_stex_smsmode_allowedenvs_seq{\tl_to_str:n{sproblem}} + \cs_new_protected:Nn \__problems_sproblem_start: { \par\noindent\textbf\prob@heading\show@pts\show@min\\\ignorespacesandpars } @@ -224,18 +276,35 @@ \def\current@section@level{\prob@solution@kw} \ignorespacesandpars } -\newcommand\startsolutions{ - \specialcomment{solution}{\@startsolution}{ - \bool_if:NF \c__problems_boxed_bool { - \hrule\medskip +\box_new:N \l__problems_solution_box +\newenvironment{solution}[1][]{ + \stex_html_backend:TF{ + \stex_if_do_html:T{ + \begin{stex_annotate_env}{solution}{} } - \end{small}% + }{ + \setbox\l__problems_solution_box\vbox\bgroup + \par\smallskip\hrule\smallskip + \noindent\textbf{Solution:}~ } - \bool_if:NT \c__problems_boxed_bool { - \surroundwithmdframed{solution} +}{ + \stex_html_backend:TF{ + \stex_if_do_html:T{ + \end{stex_annotate_env} + } + }{ + \smallskip\hrule + \egroup + \bool_if:NT \c__problems_solutions_bool { + \box\l__problems_solution_box + } } } -\newcommand\stopsolutions{\excludecomment{solution}} + +\newcommand\startsolutions{ + \bool_set_true:N \c__problems_solutions_bool +} +\newcommand\stopsolutions{\bool_set_false:N \c__problems_solutions_bool}%\excludecomment{solution}} \ifsolutions \startsolutions \else @@ -244,7 +313,7 @@ \bool_if:NTF \c__problems_notes_bool { \newenvironment{exnote}[1][]{ \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@note@kw : }\small + \noindent\textbf{\prob@note@kw :~ }\small }{ \smallskip\hrule } @@ -271,7 +340,7 @@ \bool_if:NTF \c__problems_notes_bool { \newenvironment{gnote}[1][]{ \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@gnote@kw : }\small + \noindent\textbf{\prob@gnote@kw :~ }\small }{ \smallskip\hrule } @@ -293,43 +362,38 @@ \keys_define:nn { problem / mcc }{ id .str_set_x:N = \l__problems_mcc_id_str , feedback .tl_set:N = \l__problems_mcc_feedback_tl , - T .default:n = { true } , + T .default:n = { false } , T .bool_set:N = \l__problems_mcc_t_bool , - F .default:n = { true } , + F .default:n = { false } , F .bool_set:N = \l__problems_mcc_f_bool , - Ttext .code:n = { - \__problems_do_yes_param:Nn \l__problems_mcc_Ttext_bool { #1 } - } , - Ftext .code:n = { - \__problems_do_yes_param:Nn \l__problems_mcc_Ftext_bool { #1 } - } + Ttext .tl_set:N = \l__problems_mcc_Ttext_str , + Ftext .tl_set:N = \l__problems_mcc_Ftext_str } \cs_new_protected:Nn \l__problems_mcc_args:n { \str_clear:N \l__problems_mcc_id_str \tl_clear:N \l__problems_mcc_feedback_tl - \bool_set_true:N \l__problems_mcc_t_bool - \bool_set_true:N \l__problems_mcc_f_bool - \bool_set_true:N \l__problems_mcc_Ttext_bool - \bool_set_false:N \l__problems_mcc_Ftext_bool + \bool_set_false:N \l__problems_mcc_t_bool + \bool_set_false:N \l__problems_mcc_f_bool + \tl_clear:N \l__problems_mcc_Ttext_tl + \tl_clear:N \l__problems_mcc_Ftext_tl + \str_clear:N \l__problems_mcc_id_str \keys_set:nn { problem / mcc }{ #1 } } +\def\mccTrueText{\textbf{(true)~}} +\def\mccFalseText{\textbf{(false)~}} \newcommand\mcc[2][]{ \l__problems_mcc_args:n{ #1 } - \item #2 + \item[$\Box$] #2 \ifsolutions \\ \bool_if:NT \l__problems_mcc_t_bool { - % TODO! - % \ifcsstring{mcc@T}{T}{}{\mcc@Ttext}% + \tl_if_empty:NTF\l__problems_mcc_Ttext_tl\mccTrueText\l__problems_mcc_Ttext_tl } \bool_if:NT \l__problems_mcc_f_bool { - % TODO! - % \ifcsstring{mcc@F}{F}{}{\mcc@Ftext}% + \tl_if_empty:NTF\l__problems_mcc_Ttext_tl\mccFalseText\l__problems_mcc_Ftext_tl } - \tl_if_empty:NTF \l__problems_mcc_feedback_tl { - ! - }{ - \l__problems_mcc_feedback_tl + \tl_if_empty:NF \l__problems_mcc_feedback_tl { + \emph{(\l__problems_mcc_feedback_tl)} } \fi } %solutions @@ -382,11 +446,24 @@ \newcommand\includeproblem[2][]{ \__problems_inclprob_args:n{ #1 } - \str_if_empty:NTF \l__problems_inclprob_mhrepos_str { - \input{#2} - }{ - \stex_in_repository:nn{\l__problems_inclprob_mhrepos_str}{ - \input{\mhpath{\l__problems_inclprob_mhrepos_str}{#2}} + \exp_args:No \stex_in_repository:nn\l__problems_inclprob_mhrepos_str{ + \stex_html_backend:TF { + \str_clear:N \l_tmpa_str + \prop_get:NnNF \l_stex_current_repository_prop { narr } \l_tmpa_str { + \prop_get:NnNF \l_stex_current_repository_prop { ns } \l_tmpa_str {} + } + \stex_annotate_invisible:nnn{includeproblem}{ + \l_tmpa_str / #2 + }{} + }{ + \begingroup + \inputreftrue + \tl_if_empty:nTF{ ##1 }{ + \input{#2} + }{ + \input{ \c_stex_mathhub_str / ##1 / source / #2 } + } + \endgroup } } \__problems_inclprob_clear: @@ -419,6 +496,9 @@ }{ \tl_if_exist:NT \l__problems_prob_pts_tl { \bool_if:NT \c__problems_pts_bool { + \tl_if_empty:NT\l__problems_prob_pts_tl{ + \tl_set:Nn \l__problems_prob_pts_tl {0} + } \marginpar{\l__problems_prob_pts_tl\ \prob@pt@kw\smallskip} \addtocounter{pts}{\l__problems_prob_pts_tl} } @@ -435,6 +515,9 @@ }{ \tl_if_exist:NT \l__problems_prob_min_tl { \bool_if:NT \c__problems_min_bool { + \tl_if_empty:NT\l__problems_prob_min_tl{ + \tl_set:Nn \l__problems_prob_min_tl {0} + } \marginpar{\l__problems_prob_min_tl\ min} \addtocounter{min}{\l__problems_prob_min_tl} } |