diff options
author | Karl Berry <karl@freefriends.org> | 2020-02-15 22:16:00 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-02-15 22:16:00 +0000 |
commit | c9e4d3609b9024d4f14214ed64e9ee63b445e82b (patch) | |
tree | 7e705196e7f54871ba7722eed1aa6976c3765f30 /Master/texmf-dist/tex/latex/sdaps/sdapsclassic.cls | |
parent | 09bdbbbf4b3244f848a57eb27845a24eafbbe0a9 (diff) |
sdaps (15feb20)
git-svn-id: svn://tug.org/texlive/trunk@53795 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/sdaps/sdapsclassic.cls')
-rw-r--r-- | Master/texmf-dist/tex/latex/sdaps/sdapsclassic.cls | 119 |
1 files changed, 90 insertions, 29 deletions
diff --git a/Master/texmf-dist/tex/latex/sdaps/sdapsclassic.cls b/Master/texmf-dist/tex/latex/sdaps/sdapsclassic.cls index c0d2d07a043..1a4a52ddfcf 100644 --- a/Master/texmf-dist/tex/latex/sdaps/sdapsclassic.cls +++ b/Master/texmf-dist/tex/latex/sdaps/sdapsclassic.cls @@ -11,12 +11,10 @@ %% Copyright (C) 2015 by Benjamin Berg <benjamin@sipsolutions.net> %% %% This work may be distributed and/or modified under the -%% conditions of the LaTeX Project Public License, either version 1.3 +%% conditions of the LaTeX Project Public License, either version 1.3c %% of this license or (at your option) any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt -%% and version 1.3 or later is part of all distributions of LaTeX -%% version 2005/12/01 or later. %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesClass{sdapsclassic} @@ -209,7 +207,7 @@ \newcommand\qid{\tl_use:N \g__sdaps_questionnaire_id_tl} -\def\question#1{% +\def\_sdaps_classic_question#1{% \tl_if_empty:nTF{#1}{ \refstepcounter{subsection}% \par% @@ -321,7 +319,7 @@ \keys_set:nn { sdapsclassic / textbox } { #1 } \sdaps_classic_ensure_section: - \question{#3} + \_sdaps_classic_question{#3} \tl_if_empty:NTF \l_sdaps_classic_textbox_text_tl { \sdaps_qobject_begin:nnn { textbox } { Text } { #3 } @@ -420,7 +418,7 @@ \int_set:Nn \l_sdaps_singlemark_count_int { \themarkcheckboxcount } } - \question{#2}% + \_sdaps_classic_question{#2}% \sdaps_qobject_begin:nnn { singlemark } { range } { #2 } @@ -454,7 +452,7 @@ \int_set:Nn \l_sdaps_singlemark_count_int { \themarkcheckboxcount } } - \question{#2}% + \_sdaps_classic_question{#2}% \sdaps_qobject_begin:nnn { singlemark } { range } { #2 } @@ -482,6 +480,7 @@ \dim_new:N \l__sdaps_classic_choiceitem_pad_dim \int_new:N \l__sdaps_classic_choiceitem_cols_int \int_new:N \l__sdaps_classic_choiceitem_col_int +\dim_new:N \l__sdaps_classic_choicequestion_prevdepth_dim \coffin_new:N \l__sdaps_classic_choicequestion_coffin \msg_new:nnn { sdapsclassic } { choicequestion_wrong_mode } { Mode~should~always~be~vertical~inside~a~choicequestion.\\ This~likely~means~that~the~choicequestion~contains~content~other~than~one~of~the~permissable~macros. } @@ -538,7 +537,7 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \keys_set:nn { sdaps / choicequestion } { #1 } - \question{#2}% + \_sdaps_classic_question{#2}% % Setup the context \tl_if_eq:VnTF \l_sdaps_choicquestion_type_tl { multichoice } { @@ -562,6 +561,7 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \int_set:NV \l__sdaps_classic_choiceitem_cols_int \l_sdaps_choicequestion_cols_int \int_set:Nn \l__sdaps_classic_choiceitem_col_int { 0 } + \dim_set:Nn \l__sdaps_classic_choicequestion_prevdepth_dim { 1000pt } \coffin_clear:N \l__sdaps_classic_choicequestion_coffin % We have to be in vertical mode at this point. @@ -590,6 +590,7 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \choicequestion_widowpenalty \vbox:n { \skip_horizontal:N \@totalleftmargin \box_use:N \l__sdaps_classic_choicequestion_coffin } + \prevdepth=\l__sdaps_classic_choicequestion_prevdepth_dim \coffin_clear:N \l__sdaps_classic_choicequestion_coffin \sdaps_qobject_end:n { choicequestion } @@ -603,7 +604,7 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \endchoicequestion } -\cs_new_protected_nopar:Nn \_sdaps_classic_line_shipout_add:Nn +\cs_new_protected_nopar:Nn \_sdaps_classic_line_shipout_add:NNn { % We have to be in vertical mode at this point. \if_mode_vertical: @@ -613,11 +614,13 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \fi: % Is linewidth the right thing here? - \int_compare:nT { \l__sdaps_classic_choiceitem_col_int + #2 > \l__sdaps_classic_choiceitem_cols_int } { + \int_compare:nT { \l__sdaps_classic_choiceitem_col_int + #3 > \l__sdaps_classic_choiceitem_cols_int } { % We can only typeset a coffin in vertical mode if we use the box function \vbox:n { \skip_horizontal:N \@totalleftmargin \box_use:N \l__sdaps_classic_choicequestion_coffin } + \prevdepth=\l__sdaps_classic_choicequestion_prevdepth_dim \skip_vertical:N \l_sdaps_choicequestion_rowsep_dim \coffin_clear:N \l__sdaps_classic_choicequestion_coffin + \dim_set:Nn \l__sdaps_classic_choicequestion_prevdepth_dim { 1000pt } \choicequestion_clubpenalty \int_set:Nn \l__sdaps_classic_choiceitem_col_int { 0 } } @@ -625,8 +628,14 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \dim_set:Nn \l_tmpa_dim { \linewidth / \l__sdaps_classic_choiceitem_cols_int + \l__sdaps_classic_choiceitem_pad_dim / \l__sdaps_classic_choiceitem_cols_int } \dim_set:Nn \l_tmpa_dim { \l__sdaps_classic_choiceitem_col_int \l_tmpa_dim } + \dim_compare:nNnTF { \coffin_dp:N \l__sdaps_classic_choicequestion_coffin } > { \coffin_dp:N #1 } { + \dim_set:Nn \l__sdaps_classic_choicequestion_prevdepth_dim {\dim_min:nn { \l__sdaps_classic_choicequestion_prevdepth_dim } { #2 + \coffin_dp:N \l__sdaps_classic_choicequestion_coffin - \coffin_dp:N #1 } } + } { + \dim_set:Nn \l__sdaps_classic_choicequestion_prevdepth_dim {\dim_min:nn { \l__sdaps_classic_choicequestion_prevdepth_dim + \coffin_dp:N #1 - \coffin_dp:N \l__sdaps_classic_choicequestion_coffin } { #2 } } + } + \coffin_join:NnnNnnnn \l__sdaps_classic_choicequestion_coffin { l } { H } #1 { l } { H } { \l_tmpa_dim } { 0pt } - \int_add:Nn \l__sdaps_classic_choiceitem_col_int { #2 } + \int_add:Nn \l__sdaps_classic_choiceitem_col_int { #3 } } \providecommand*{\choiceitem}[2][]{% @@ -648,13 +657,16 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \hbox_set:Nn \l_tmpa_box { \strut \sdaps_checkbox:VV \l_sdaps_choicequestion_choice_var_tl \l_sdaps_choicequestion_choice_val_tl {}\ } \dim_set:Nn \l_tmpb_dim { \box_wd:N \l_tmpa_box } \hskip \l_sdaps_choicequestion_colsep_dim - \hbox_unpack_clear:N \l_tmpa_box + \hbox_unpack:N \l_tmpa_box \begin{minipage}[t]{\dim_eval:n { \l_tmpa_dim - \l_tmpb_dim - 2\l_sdaps_choicequestion_colsep_dim}} - \noindent \usekomafont{choiceitemfont} \tl_trim_spaces:n { #2 } + \noindent \usekomafont{choiceitemfont} \tl_trim_spaces:n { #2 }\strut + \par + \dim_gset:Nn \g_tmpa_dim { \dim_max:nn { \box_dp:N \l_tmpa_box } { \prevdepth } } + \unskip \end{minipage} } - \_sdaps_classic_line_shipout_add:Nn \l_tmpa_coffin { 1 } + \_sdaps_classic_line_shipout_add:NNn \l_tmpa_coffin \g_tmpa_dim { 1 } \ignorespaces } @@ -677,13 +689,16 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \hbox_set:Nn \l_tmpa_box { \strut \sdaps_checkbox:VV \l_sdaps_choicequestion_choice_var_tl \l_sdaps_choicequestion_choice_val_tl {}\ } \dim_set:Nn \l_tmpb_dim { \box_wd:N \l_tmpa_box } \hskip \l_sdaps_choicequestion_colsep_dim - \hbox_unpack_clear:N \l_tmpa_box + \hbox_unpack:N \l_tmpa_box \begin{minipage}[t]{\dim_eval:n { \l_tmpa_dim - \l_tmpb_dim - 2\l_sdaps_choicequestion_colsep_dim}} - \noindent \usekomafont{choiceitemfont} \tl_trim_spaces:n { #3 } + \noindent \usekomafont{choiceitemfont} \tl_trim_spaces:n { #3 }\strut + \par + \dim_gset:Nn \g_tmpa_dim { \dim_max:nn { \box_dp:N \l_tmpa_box } { \prevdepth } } + \unskip \end{minipage} } - \_sdaps_classic_line_shipout_add:Nn \l_tmpa_coffin { #2 } + \_sdaps_classic_line_shipout_add:NNn \l_tmpa_coffin \g_tmpa_dim { #2 } \ignorespaces } @@ -718,10 +733,13 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \dim_set:Nn \l_tmpb_dim { 0.5 \l_tmpb_dim + 0.8ex } \strut\ignorespaces \tl_trim_spaces:n { #4 } ~ \sdaps_textbox_hstretch:VVVnn \l_sdaps_choicequestion_choice_var_tl \l_tmpa_dim \l_tmpb_dim { 0pt } { 1 } + \par + \dim_gset:Nn \g_tmpa_dim { \prevdepth } + \unskip \end{minipage} } - \_sdaps_classic_line_shipout_add:Nn \l_tmpa_coffin { #3 } + \_sdaps_classic_line_shipout_add:NNn \l_tmpa_coffin \g_tmpa_dim { #3 } \ignorespaces } @@ -875,11 +893,30 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } } +\tl_new:N \l__sdaps_classic_group_var_tl +\tl_new:N \l__sdaps_classic_group_text_tl +\tl_new:N \l__sdaps_classic_group_extra_tl +\keys_define:nn { sdapsclassic / group } +{ + var .tl_set:N = \l__sdaps_classic_group_var_tl, + text .tl_set:N = \l__sdaps_classic_group_text_tl, +} + \newenvironment { choicegroup } [ 2 ] [] { \group_begin: + \keys_set_known:nnN { sdapsclassic / group } { #1 } \l__sdaps_classic_group_extra_tl - \question{#2} + \_sdaps_classic_question{#2} + \tl_if_empty:NTF \l__sdaps_classic_group_text_tl { + \sdaps_qobject_begin:nnn { choicegroup } { Head } { #2 } + } { + \sdaps_qobject_begin:nnV { choicegroup } { Head } \l__sdaps_classic_group_text_tl + } + + \tl_if_empty:NF \l__sdaps_classic_group_var_tl { + \sdaps_qobject_append_var:V \l__sdaps_classic_group_var_tl + } % Undefine the question (and choice) commands in local scope so that they % can be redefined by choicearray without any issues. @@ -887,7 +924,7 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \cs_set_eq:NN\question\tex_undefined:D \cs_set_eq:NN\choice\tex_undefined:D - \begin{choicearray}[#1]{#2} + \expandafter\choicearray\expandafter[\l__sdaps_classic_group_extra_tl] % XXX: This is a bit of a hack, set in global scope because the choicearray % environment does evil things with scopes. \cs_gset_eq:NN\groupaddchoice\choice @@ -897,15 +934,27 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \cs_gset_eq:NN\groupaddchoice\undefined \cs_gset_eq:NN\choiceline\undefined - \end{choicearray} + \endchoicearray + + \sdaps_qobject_end:n { choicegroup } \group_end: } \newenvironment { optiongroup } [ 2 ] [] { \group_begin: + \keys_set_known:nnN { sdapsclassic / group } { #1 } \l__sdaps_classic_group_extra_tl - \question{#2} + \_sdaps_classic_question{#2} + \tl_if_empty:NTF \l__sdaps_classic_group_text_tl { + \sdaps_qobject_begin:nnn { optiongroup } { Head } { #2 } + } { + \sdaps_qobject_begin:nnV { optiongroup } { Head } \l__sdaps_classic_group_text_tl + } + + \tl_if_empty:NF \l__sdaps_classic_group_var_tl { + \sdaps_qobject_append_var:V \l__sdaps_classic_group_var_tl + } % Undefine the question (and choice) commands in local scope so that they % can be redefined by optionarray without any issues. @@ -913,7 +962,7 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \cs_set_eq:NN\question\tex_undefined:D \cs_set_eq:NN\choice\tex_undefined:D - \begin{optionarray}[#1]{#2} + \expandafter\optionarray\expandafter[\l__sdaps_classic_group_extra_tl] % XXX: This is a bit of a hack, set in global scope because the optionarray % environment does evil things with scopes. \cs_gset_eq:NN\groupaddchoice\choice @@ -923,22 +972,33 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } \cs_gset_eq:NN\groupaddoption\undefined \cs_gset_eq:NN\optionline\undefined - \end{optionarray} + \endoptionarray + \sdaps_qobject_end:n { optiongroup } \group_end: } \newenvironment { markgroup } [ 2 ] [] { \group_begin: + \keys_set_known:nnN { sdapsclassic / group } { #1 } \l__sdaps_classic_group_extra_tl - \question{#2} + \_sdaps_classic_question{#2} + \tl_if_empty:NTF \l__sdaps_classic_group_text_tl { + \sdaps_qobject_begin:nnn { markgroup } { Head } { #2 } + } { + \sdaps_qobject_begin:nnV { markgroup } { Head } \l__sdaps_classic_group_text_tl + } - % Undefine the question (and choice) commands in local scope so that they - % can be redefined by choicearray without any issues. + \tl_if_empty:NF \l__sdaps_classic_group_var_tl { + \sdaps_qobject_append_var:V \l__sdaps_classic_group_var_tl + } + + % Undefine the range command in local scope so that it can be redefined + % by rangearray without any issues. % Note that \cs_undefine:N works in global scope, so we cannot use it here. \cs_set_eq:NN\range\tex_undefined:D - \begin{rangearray}[#1]{#2} + \expandafter\rangearray\expandafter[\l__sdaps_classic_group_extra_tl] % XXX: This is a bit of a hack, set in global scope because the choicearray % environment does evil things with scopes. \cs_gset_eq:NN\markline\range @@ -946,7 +1006,8 @@ you~can~get~similar~results~by~temporarily~changing~the~checkbox~style. } { \cs_gset_eq:NN\markline\undefined - \end{rangearray} + \endrangearray + \sdaps_qobject_end:n { markgroup } \group_end: } |