diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/exsheets/exsheets.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/exsheets/exsheets.sty | 251 |
1 files changed, 154 insertions, 97 deletions
diff --git a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty index df10a42d33f..0d5fd6cbc35 100644 --- a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty +++ b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty @@ -31,8 +31,8 @@ % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. % ---------------------------------------------------------------------------- -\def\exsheets@date{2013/04/21} -\def\exsheets@version{0.9c} +\def\exsheets@date{2013/04/25} +\def\exsheets@version{0.9d} \RequirePackage { expl3 , xparse } \ProvidesExplPackage @@ -88,6 +88,12 @@ \token_to_str:N \totalpoints .~I~will~do~nothing~instead. } +\msg_new:nnn { exsheets} { parse-points } + { + You~need~to~activate~"points/parse"~if~you~want~to~use~ + \token_to_str:N #1 .~I~will~do~nothing~instead. + } + \msg_new:nnn { exsheets} { headings } { You~requested~the~headings~instance~`#1'~\msg_line_context: \c_space_tl @@ -281,6 +287,8 @@ \tl_set:Nn \l__exsheets_points_pre_bonus_marker_tl { (+ } \tl_new:N \l__exsheets_points_post_bonus_marker_tl \tl_set:Nn \l__exsheets_points_post_bonus_marker_tl { ) } +\tl_new:N \l__exsheets_points_format_tl +\tl_set:Nn \l__exsheets_points_format_tl { \use:n } \cs_new_protected_nopar:Npn \exsheets_set_points_name:n #1 { @@ -310,11 +318,17 @@ % FIXME: \fp_add will deprecate! \cs_new_protected_nopar:Npn \exsheets_add_points:n #1 - { \fp_gadd:Nn \g__exsheets_points_sum_fp { #1 } } + { + \fp_gadd:Nn \g__exsheets_points_sum_fp { #1 } + \fp_gadd:Nn \g__exsheets_this_question_points_fp { #1 } + } \cs_generate_variant:Nn \exsheets_add_points:n { V } \cs_new_protected_nopar:Npn \exsheets_add_bonus:n #1 - { \fp_gadd:Nn \g__exsheets_bonus_sum_fp { #1 } } + { + \fp_gadd:Nn \g__exsheets_bonus_sum_fp { #1 } + \fp_gadd:Nn \g__exsheets_this_question_bonus_fp { #1 } + } \cs_generate_variant:Nn \exsheets_add_bonus:n { V } \cs_new_protected_nopar:Npn \exsheets@sum@of@points #1 @@ -330,7 +344,7 @@ { \bool_if:NTF \l__exsheets_parse_points_bool { \exsheets_num:n { \fp_to_decimal:n { #1 } } } - { \use:n { \fp_to_decimal:n { #1 } } } + { \use:n { #1 } } } \group_end: } @@ -343,7 +357,7 @@ { \bool_if:NTF \l__exsheets_parse_points_bool { \exsheets_num:n { \fp_to_decimal:n { #1 } } } - { \use:n { \fp_to_decimal:n { #1 } } } + { \use:n { #1 } } } \group_end: } @@ -440,8 +454,13 @@ \cs_new_protected_nopar:Npn \exsheets_print_points:n #1 { - \exsheets_parse_points:n { #1 } - \exsheets_points_name:n { #1 } + \group_begin: + \tl_use:N \l__exsheets_points_format_tl + { + \exsheets_parse_points:n { #1 } + \exsheets_points_name:n { #1 } + } + \group_end: } \cs_generate_variant:Nn \exsheets_print_points:n { V } @@ -454,30 +473,46 @@ \NewDocumentCommand \pointssum { s } { - \IfBooleanTF { #1 } - { \exsheets_parse_points:n { \g__exsheets_total_points_fp } } - { \exsheets_print_points:n { \g__exsheets_total_points_fp } } + \bool_if:NTF \l__exsheets_parse_points_bool + { + \IfBooleanTF { #1 } + { \exsheets_parse_points:n { \g__exsheets_total_points_fp } } + { \exsheets_print_points:n { \g__exsheets_total_points_fp } } + } + { \msg_warning:nnn { exsheets } { parse-points } { \pointssum } } } \NewDocumentCommand \bonussum { s } { - \IfBooleanTF { #1 } - { \exsheets_parse_bonus:n { \g__exsheets_total_bonus_fp } } - { \exsheets_print_bonus:n { \g__exsheets_total_bonus_fp } } + \bool_if:NTF \l__exsheets_parse_points_bool + { + \IfBooleanTF { #1 } + { \exsheets_parse_bonus:n { \g__exsheets_total_bonus_fp } } + { \exsheets_print_bonus:n { \g__exsheets_total_bonus_fp } } + } + { \msg_warning:nnn { exsheets } { parse-points } { \bonussum } } } \NewDocumentCommand \currentpointssum { s } { - \IfBooleanTF { #1 } - { \exsheets_parse_points:n { \g__exsheets_points_sum_fp } } - { \exsheets_print_points:n { \g__exsheets_points_sum_fp } } + \bool_if:NTF \l__exsheets_parse_points_bool + { + \IfBooleanTF { #1 } + { \exsheets_parse_points:n { \g__exsheets_points_sum_fp } } + { \exsheets_print_points:n { \g__exsheets_points_sum_fp } } + } + { \msg_warning:nnn { exsheets } { parse-points } { \currentpointssum } } } \NewDocumentCommand \currentbonussum { s } { - \IfBooleanTF { #1 } - { \exsheets_parse_bonus:n { \g__exsheets_bonus_sum_fp } } - { \exsheets_print_bonus:n { \g__exsheets_bonus_sum_fp } } + \bool_if:NTF \l__exsheets_parse_points_bool + { + \IfBooleanTF { #1 } + { \exsheets_parse_bonus:n { \g__exsheets_bonus_sum_fp } } + { \exsheets_print_bonus:n { \g__exsheets_bonus_sum_fp } } + } + { \msg_warning:nnn { exsheets } { parse-points } { \currentbonussum } } } \NewDocumentCommand \totalpoints { s } @@ -551,6 +586,7 @@ pre-bonus .tl_set:N = \l__exsheets_points_pre_bonus_marker_tl , post-bonus .tl_set:N = \l__exsheets_points_post_bonus_marker_tl , use-name .bool_set:N = \l__exsheets_points_name_bool , + format .tl_set:N = \l__exsheets_points_format_tl , number-format .tl_set:N = \l__exsheets_points_number_format_tl , bonus-format .tl_set:N = \l__exsheets_bonus_number_format_tl , parse .bool_set:N = \l__exsheets_parse_points_bool , @@ -920,9 +956,13 @@ \tl_new:N \g__exsheets_questions_current_id_tl \tl_new:N \l__exsheets_title_tl \tl_new:N \l__exsheets_questions_label_tl +\tl_new:N \l__exsheets_questions_points_tl \bool_new:N \l__exsheets_points_not_given_bool +\fp_new:N \g__exsheets_this_question_points_fp +\fp_new:N \g__exsheets_this_question_bonus_fp + \cs_new_protected:Npn \__exsheets_read_points:w #1+#2+#3 \q_stop { \tl_if_blank:nTF { #1 } @@ -937,7 +977,11 @@ } } \cs_new_protected:Npn \__exsheets_read_points:n #1 - { \__exsheets_read_points:w #1++ \q_stop } + { + \bool_if:NTF \l__exsheets_parse_points_bool + { \__exsheets_read_points:w #1++ \q_stop } + { \tl_set:Nn \l__exsheets_questions_points_tl { #1 } } + } \newenvironment { __exsheets_question: } [2] { @@ -1012,6 +1056,8 @@ \g__exsheets_questions_id_int } % Punktevergabe: + \fp_gzero:N \g__exsheets_this_question_points_fp + \fp_gzero:N \g__exsheets_this_question_bonus_fp \IfNoValueTF { #2 } { \__exsheets_read_points:n { 0 } @@ -1025,6 +1071,9 @@ } } { + \fp_gset_eq:NN + \g__exsheets_this_question_points_fp + \l__exsheets_question_points_fp \__exsheets_read_points:n { #2 } \SetQuestionProperties{points=#2} } @@ -1087,17 +1136,38 @@ \bool_if:NTF \l__exsheets_exam_bool { \tl_set_eq:NN \l__exsheets_title_tl \l__exsheets_questions_name_tl } { \tl_set_eq:NN \l__exsheets_title_tl \l__exsheets_exsheets_name_tl } - \__exsheets_use_heading:VVVnn - \l__exsheets_question_heading_instance_tl - \l__exsheets_title_tl - \l__exsheets_qu_counter_interpretation_tl - { \l__exsheets_question_points_fp } - { \l__exsheets_question_bonus_fp } + \bool_if:NTF \l__exsheets_parse_points_bool + { + \__exsheets_use_heading:VVVnn + \l__exsheets_question_heading_instance_tl + \l__exsheets_title_tl + \l__exsheets_qu_counter_interpretation_tl + { \l__exsheets_question_points_fp } + { \l__exsheets_question_bonus_fp } + } + { + \__exsheets_use_heading:VVVnn + \l__exsheets_question_heading_instance_tl + \l__exsheets_title_tl + \l__exsheets_qu_counter_interpretation_tl + { \l__exsheets_questions_points_tl } + { 0 } + } } } \__exsheets_questions_internal: } - { \end__exsheets_questions_internal: } + { + \end__exsheets_questions_internal: + \bool_if:NF \l__exsheets_points_questions_default_bool + { + \fp_compare:nT { \g__exsheets_this_question_points_fp > 0 } + { + \exp_args:Nx \SetQuestionProperties + { points = \fp_to_tl:N \g__exsheets_this_question_points_fp } + } + } + } % current question number: \prop_new:N \g__exsheets_question_number_prop @@ -1398,6 +1468,9 @@ \group_end: } +\int_new:N \l__exsheets_questions_set_int +\int_new:N \g__exsheets_select_random_int + \cs_new_protected:Npn \exsheets_include_questions:n #1 { \bool_set_true:N \l__exsheets_select_questions_bool @@ -1406,7 +1479,13 @@ \seq_map_inline:Nn \l__exsheets_tmpa_seq { \bool_set_true:N \l__exsheets_questions_deactivate_bool - \int_set_eq:NN \l__exsheets_tmpc_int \g__exsheets_questions_id_int + \int_set_eq:NN + \l__exsheets_questions_set_int + \g__exsheets_questions_used_int + \int_set_eq:NN + \l__exsheets_tmpc_int + \g__exsheets_questions_id_int + \int_gzero:N \g__exsheets_select_random_int \exsheets_file_input_if_exist:n { ##1 } \__exsheets_prop_count:NN \g__exsheets_included_questions_prop @@ -1489,23 +1568,12 @@ \int_gincr:N \g__exsheets_questions_id_int \bool_if:NTF \l__exsheets_include_random_bool { - \int_set:Nn \l__exsheets_tmpa_int - { - \int_mod:nn - { \g__exsheets_questions_id_int } - { \g__exsheets_selection_number_int } - } - \int_set:Nn \l__exsheets_tmpa_int { \l__exsheets_tmpa_int - 1 } - \int_compare:nTF { \l__exsheets_tmpa_int = -1 } - { - \int_set_eq:NN - \l__exsheets_tmpa_int - \g__exsheets_selection_number_int - } - { - \int_compare:nT { \l__exsheets_tmpa_int = 0 } - { \int_set:Nn \l__exsheets_tmpa_int { 1 } } - } + \int_gincr:N \g__exsheets_select_random_int + \int_set_eq:NN \l__exsheets_tmpa_int \g__exsheets_select_random_int +% ID: \int_use:N \g__exsheets_questions_id_int ,~ +% set: \int_use:N \l__exsheets_questions_set_int ,~ +% selection: \int_use:N \g__exsheets_selection_number_int ,~ +% tmpa: \int_use:N \l__exsheets_tmpa_int \par } { \int_set_eq:NN @@ -2245,15 +2313,15 @@ { style .choice: , style / line .code:n = - { \cs_set_eq:NN \exsheets_write_blank:n \uline } , + \cs_set_eq:NN \exsheets_write_blank:n \uline , style / wave .code:n = - { \cs_set_eq:NN \exsheets_write_blank:n \uwave } , + \cs_set_eq:NN \exsheets_write_blank:n \uwave , style / dline .code:n = - { \cs_set_eq:NN \exsheets_write_blank:n \uuline } , + \cs_set_eq:NN \exsheets_write_blank:n \uuline , style / dotted .code:n = - { \cs_set_eq:NN \exsheets_write_blank:n \dotuline } , + \cs_set_eq:NN \exsheets_write_blank:n \dotuline , style / dashed .code:n = - { \cs_set_eq:NN \exsheets_write_blank:n \dashuline } , + \cs_set_eq:NN \exsheets_write_blank:n \dashuline , scale .tl_set:N = \l__exsheets_blank_scale_tl , width .code:n = { @@ -2269,8 +2337,7 @@ { \group_begin: \IfNoValueF { #2 } { \keys_set:nn { exsheets / blank } { #2 } } - \mode_if_horizontal:TF - { \exsheets_blank:n { #3 } } + \mode_if_vertical:TF { \IfBooleanF { #1 } { \noindent } \exsheets_blank:n { #3 } @@ -2281,13 +2348,16 @@ \par } } + { \exsheets_blank:n { #3 } } \group_end: } \cs_new_protected:Npn \exsheets_blank:n #1 { \box_clear:N \l__exsheets_blank_box - \hbox_set:Nn \l__exsheets_blank_box { #1 } + \mode_if_math:TF + { \hbox_set:Nn \l__exsheets_blank_box { $ \m@th \mathpalette{}{#1} $ } } + { \hbox_set:Nn \l__exsheets_blank_box { #1 } } \bool_if:NTF \l__exsheets_inside_solution_bool { \exsheets_write_blank:n { #1 } } { @@ -2305,23 +2375,27 @@ \bool_if:NTF \l__exsheets_blank_width_bool { \dim_set:Nn \l__exsheets_tmpa_dim { #1 } } { - \fp_set:Nn \l_tmpa_fp { \dim_to_fp:n { #1 } } - \fp_mul:Nn \l_tmpa_fp { \l__exsheets_blank_scale_tl } + \fp_set:Nn \l_tmpa_fp + { \dim_to_fp:n { #1 } * \l__exsheets_blank_scale_tl } \dim_set:Nn \l__exsheets_tmpa_dim { \fp_to_dim:N \l_tmpa_fp } } \dim_compare:nTF { \l__exsheets_tmpa_dim > 2em } { - \exsheets_write_blank:n { \skip_horizontal:n { 1em } } - \dim_sub:Nn \l__exsheets_tmpa_dim { 2em } - \dim_do_while:nn { \l__exsheets_tmpa_dim > \c_zero_dim } + \mode_if_math:TF + { \exsheets_write_blank:n { \skip_horizontal:N \l__exsheets_tmpa_dim } } { - \tex_penalty:D \hyphenpenalty - \dim_compare:nTF { \l__exsheets_tmpa_dim < 1pt } - { \exsheets_write_blank:n { \skip_horizontal:N \l__exsheets_tmpa_dim } } - { \exsheets_write_blank:n { \skip_horizontal:n { 1pt } } } - \dim_sub:Nn \l__exsheets_tmpa_dim { 1pt } + \exsheets_write_blank:n { \skip_horizontal:n { 1em } } + \dim_sub:Nn \l__exsheets_tmpa_dim { 2em } + \dim_do_while:nn { \l__exsheets_tmpa_dim > \c_zero_dim } + { + \tex_penalty:D \hyphenpenalty + \dim_compare:nTF { \l__exsheets_tmpa_dim < 1pt } + { \exsheets_write_blank:n { \skip_horizontal:N \l__exsheets_tmpa_dim } } + { \exsheets_write_blank:n { \skip_horizontal:n { 1pt } } } + \dim_sub:Nn \l__exsheets_tmpa_dim { 1pt } + } + \exsheets_write_blank:n { \skip_horizontal:n { 1em } } } - \exsheets_write_blank:n { \skip_horizontal:n { 1em } } } { \exsheets_write_blank:n { \skip_horizontal:N \l__exsheets_tmpa_dim } } } @@ -2535,8 +2609,6 @@ HISTORY: \bonus, \bonussum, \pointssum, \currentpointssum, \currentbonussum - added grades distribution - - `translations' got \LoadDictionary and \LoadDictionaryFor - added and loads of languages defined. 2012/10/05 v0.2a - resolved bug in saving and recovering question number using \exsheets@save@number and \QuestionNumber 2012/10/08 v0.2b - improved the reference to chapter/solution numbers @@ -2577,7 +2649,6 @@ HISTORY: - define unexpandable internal commands protected - translations basic dictionaries for English, German, French and Spanish - - translations: new command \DeclareDictTranslation - new \includequestions option `exclude' - new way of handling the `class' of questions: instead of hard-coded `classes' and `topics' @@ -2590,40 +2661,26 @@ HISTORY: - \includequestions[random=<num>] now obeys class as done with \SetupExSheets{use-topics={foo,bar}} - new macro \questionsincludedlast -2013/04/04 v0.8a - translations: bug fix in \DeclareDictTranslation - - exsheets: added Portuguese translations - - tasks: corrected \seq_length:N => \seq_count:N -2013/04/07 v0.9 - translations: slightly improved messages - - tasks: protected internal commands where appropriate - - tasks: made enumerated item referenceable with \label{} - and \ref{}; this introduced new options: - * the former `label-format' is now `counter-format' - * new: `label-format' - - tasks: changed defaults for `label-width' and - `label-offset' - - tasks: ensure that the `after-item-skip' is only - inserted in between rows - - tasks: new option `after-item-skip' - - tasks: improvements when label are set with optional - argument: - * a provided but empty argument is now correctly - recognized - * the counter is _not_ stepped anymore for enumerated - lists when the optional argument is provided - - tasks: new command \startnewitemline that forces the next - item to be put at the beginning of a row - - exsheets: protected internal commands where appropriate - - exsheets: added possibility to set general options - with \NewQuSolPair and \RenewQuSolPair -2013/04/08 v0.9a - exsheets: added headings instance `empty' - - translations: changed fallback warning into info +2013/04/04 v0.8a - added Portuguese translations +2013/04/07 v0.9 - protected internal commands where appropriate + - added possibility to set general options with + \NewQuSolPair and \RenewQuSolPair +2013/04/08 v0.9a - added headings instance `empty' 2013/04/18 v0.9b - fixed erroneous behaviour of \includequestions when used more than once - added hook \l__exsheets_heading_points_post_hook_tl 2013/04/21 v0.9c - bug fix: \ForEachQuestion seems to work correctly again - +2013/04/25 v0.9d - bug fix: \includequestions works correctly when used + multiple times together with ordinary instances of + the {question} environment + - bug fix: points/parse=false correctly disables parsing + points again + - bug fix: \addpoints didn't add to the question property + - new option `points/format' + - \blank now works in math mode, it doesn't do linebreaks + there if `ulem' doesn't allow them (which it doesn't) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % TODO: -- points/decimal-marker, points/frac (?), points/format (?,im interface) +- points/decimal-marker, points/frac (?), points/format (?,im interface)
\ No newline at end of file |