diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/tasks/tasks.cfg | 32 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tasks/tasks.sty | 507 |
2 files changed, 272 insertions, 267 deletions
diff --git a/Master/texmf-dist/tex/latex/tasks/tasks.cfg b/Master/texmf-dist/tex/latex/tasks/tasks.cfg index 7a62d42383f..d76ad264cdf 100644 --- a/Master/texmf-dist/tex/latex/tasks/tasks.cfg +++ b/Master/texmf-dist/tex/latex/tasks/tasks.cfg @@ -1,14 +1,14 @@ % -------------------------------------------------------------------------- % the TASKS package % -% Horizontal columned lists. +% horizontally columned lists % % -------------------------------------------------------------------------- % Clemens Niederberger % Web: https://github.com/cgnieder/tasks/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2013-2016 Clemens Niederberger +% Copyright 2013--2019 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -25,29 +25,5 @@ % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. % -------------------------------------------------------------------------- -% further instances for the `tasks' environment -\ProvidesFile{tasks.cfg} - [% - \csname c_tasks_date_tl\endcsname\space - v\csname c_tasks_version_tl\endcsname\space - tasks instances% - ] - -% ITEMIZE: -\DeclareInstance {tasks} {itemize} {default} - { - enumerate = false , - label-width = 1.125em - } - -% ENUMERATE: -\DeclareInstance {tasks} {enumerate} {default} - { counter-format = tsk. } - -% MULTIPLECHOICE -\DeclareInstance {tasks} {multiplechoice} {default} - { - enumerate = false , - label = \choicebox - } - +% +% fill this file with your custom definitions: diff --git a/Master/texmf-dist/tex/latex/tasks/tasks.sty b/Master/texmf-dist/tex/latex/tasks/tasks.sty index 81e265ed5ef..26260ba6a26 100644 --- a/Master/texmf-dist/tex/latex/tasks/tasks.sty +++ b/Master/texmf-dist/tex/latex/tasks/tasks.sty @@ -1,14 +1,14 @@ % -------------------------------------------------------------------------- % the TASKS package % -% Horizontal columned lists. +% horizontally columned lists % % -------------------------------------------------------------------------- % Clemens Niederberger % Web: https://github.com/cgnieder/tasks/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2013-2016 Clemens Niederberger +% Copyright 2013--2019 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -25,45 +25,89 @@ % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. % -------------------------------------------------------------------------- -\RequirePackage { expl3 , xparse , epic , cntformats , xtemplate , environ } +\RequirePackage {expl3,xparse,xtemplate} \ExplSyntaxOn -\tl_const:Nn \c_tasks_name_tl {tasks} -\tl_const:Nn \c_tasks_date_tl {2016/08/13} -\tl_const:Nn \c_tasks_version_tl {0.12} -\tl_const:Nn \c_tasks_info_tl {Horizontal columned lists} - +\tl_const:Nn \c_tasks_date_tl {2019/10/04} +\tl_const:Nn \c_tasks_version_major_number_tl {1} +\tl_const:Nn \c_tasks_version_minor_number_tl {0} +\tl_const:Nn \c_tasks_version_subrelease_tl {} +\tl_const:Nx \c_tasks_version_number_tl + { + \c_tasks_version_major_number_tl . + \c_tasks_version_minor_number_tl + } +\tl_const:Nx \c_tasks_version_tl + { + \c_tasks_version_number_tl + \c_tasks_version_subrelease_tl + } +\tl_const:Nn \c_tasks_info_tl {horizontally ~ columned ~ lists} + \ProvidesExplPackage - {\c_tasks_name_tl} + {tasks} {\c_tasks_date_tl} {\c_tasks_version_tl} - {\c_tasks_info_tl \c_space_tl (CN)} + {\c_tasks_info_tl} % -------------------------------------------------------------------------- % variants of kernel functions: -\cs_generate_variant:Nn \tl_if_eq:nnTF { V } -\cs_generate_variant:Nn \tl_if_eq:nnT { V } +\cs_generate_variant:Nn \tl_if_eq:nnTF {V} +\cs_generate_variant:Nn \tl_if_eq:nnT {V} +\cs_generate_variant:Nn \coffin_attach:NnnNnnnn {NnnNx} +\cs_generate_variant:Nn \tl_set_rescan:Nnn {NnV} +\cs_generate_variant:Nn \hbox_set:Nn {NV} +\cs_generate_variant:Nn \msg_warning:nnnn {nnV,nnnx} + +% -------------------------------------------------------------------------- +\msg_new:nnn {tasks} {width-too-small} + { + The~ width~ off~ `#1'~ is~ too~ small~ \msg_line_context: .~ + Please~ set~ it~ at~ least~ to~ #2. + } + +\msg_new:nnn {tasks} {no-item} + { + You've~ placed~ `#1'~ before~ the~ first~ #2~ \msg_line_context: .~ + I~ will~ through~ it~ away~ and~ ignore~ it~ for~ the~ rest~ of~ the~ + list. + } + +\msg_new:nnn {tasks} {deprecated} + { + You've~ tried~ setting~ #1~ `#2'~ \msg_line_context: .~ However,~ + #1~ `#2'~ is~ deprecated.~ + \tl_if_blank:nF {#2} {Please~ use~ #1~ `#3'~ instead.~} + Refer~ to~ the~ manual~ for~ details. + } + +% -------------------------------------------------------------------------- +\cs_new_protected:Npn \tasks_deprecated:NN #1#2 + { + \cs_undefine:N #1 + \cs_new:Npn #1 + { \msg_warning:nnnnn {tasks} {deprecated} {command} {#1} {#2} #2 } + } % -------------------------------------------------------------------------- % variables: \seq_new:N \l__tasks_seq -\int_new:N \l__tasks_depth_int -\int_new:N \g__tasks_int \int_new:N \g__tasks_total_items_int \int_new:N \l__tasks_columns_int -\int_new:N \l__tasks_rows_int +\int_new:N \g__tasks_rows_int \int_new:N \g__tasks_current_col_num_int \int_new:N \g__tasks_current_row_num_int \int_new:N \l__tasks_item_columns_int +\int_new:N \g__tasks_env_int -\bool_new:N \l__tasks_enumerate_bool \bool_new:N \l__tasks_resume_bool \bool_new:N \l__tasks_load_tasks_bool \bool_new:N \l__tasks_label_width_bool \bool_new:N \l__tasks_item_indent_bool \bool_new:N \l__tasks_label_offset_bool \bool_new:N \l__tasks_custom_label_bool +\bool_new:N \l__tasks_custom_label_format_bool \bool_new:N \l__tasks_custom_after_item_skip_bool \bool_new:N \l__tasks_debug_bool \bool_new:N \l__tasks_item_full_line_bool @@ -72,8 +116,6 @@ \tl_new:N \l__tasks_instance_tl \tl_new:N \l__tasks_label_tl \tl_new:N \l__tasks_custom_label_tl -\tl_new:N \l__tasks_label_pattern_tl -\tl_new:N \l__tasks_custom_label_pattern_tl \tl_new:N \l__tasks_label_format_tl \tl_new:N \l__tasks_custom_label_format_tl \tl_new:N \l__tasks_item_format_tl @@ -81,7 +123,6 @@ \tl_new:N \l__tasks_item_fill_left_tl \tl_new:N \l__tasks_item_fill_right_tl \tl_new:N \l__tasks_label_align_tl -% \tl_new:N \task \tl_new:N \l__tasks_item_tl \tl_new:N \l__tasks_tmp_label_tl @@ -93,6 +134,9 @@ \dim_new:N \l__tasks_label_offset_dim \dim_new:N \l__tasks_label_default_offset_dim \dim_new:N \l__tasks_column_sep_dim +\dim_new:N \l__tasks_correction_dim + +\dim_new:N \l__tasks_full_width_dim \skip_new:N \l__tasks_after_item_skip \skip_new:N \l__tasks_custom_after_item_skip @@ -102,14 +146,14 @@ \coffin_new:N \l__tasks_item_coffin \coffin_new:N \l__tasks_label_coffin -\NewCounterPattern* [ tasks ] { task } { tsk } -\ReadCounterFrom [ tasks ] { task } \g__tasks_int +\newcounter {task} % temporary variables: \int_new:N \l__tasks_tmpa_int \int_new:N \l__tasks_tmpb_int \tl_new:N \l__tasks_tmpa_tl \coffin_new:N \l__tasks_tmpa_coffin +\box_new:N \l__tasks_tmpa_box \cs_new:Npn \__tasks_debug:n #1 { @@ -119,36 +163,28 @@ } % -------------------------------------------------------------------------- -% collect the tasks: -\cs_new_protected:Npn \__tasks_collect_tasks:nww #1#2 \end #3 - { - \tl_put_right:Nn \l__tasks_body_tl {#1} - \end {#3} - \tl_if_eq:nnF {#1} {#3} - { \__tasks_collect_tasks:nww {#1} } - } - % #1: instance % #2: number of columns % #3: item separator % #4: environment body -\cs_new_protected:Npn \__tasks:nnnn #1#2#3#4 +\cs_new_protected:Npn \tasks_environment:nnnn #1#2#3#4 { \bool_if:NT \l__tasks_debug_bool { \dim_set:Nn \fboxsep {0pt} } \seq_set_split:Nnn \l__tasks_seq {#3} {#4} % remove the first (empty) item: \seq_pop_left:NN \l__tasks_seq \l__tasks_tmpa_tl - \tl_if_blank:VF \l__tasks_tmpa_tl { \@noitemerr } + \tl_if_blank:VF \l__tasks_tmpa_tl + { \msg_warning:nnVn {tasks}{no-item} \l__tasks_tmpa_tl {#3} } \int_gset:Nn \g__tasks_total_items_int { \seq_count:N \l__tasks_seq } \UseInstance {tasks} {#1} { \g__tasks_total_items_int } {#2} - { \l__tasks_custom_label_pattern_tl } + { } % just to be sure: \seq_clear:N \l__tasks_seq } -\cs_generate_variant:Nn \__tasks:nnnn { VnnV } +\cs_generate_variant:Nn \tasks_environment:nnnn {V} % #1: label % #2: item format @@ -169,17 +205,31 @@ \dim_set:Nn \l__tasks_item_width_dim { \bool_if:NTF \l__tasks_item_full_line_bool - { \linewidth } + { \l__tasks_full_width_dim } { ( - \linewidth + \l__tasks_full_width_dim - \l__tasks_columns_int \l__tasks_column_sep_dim + \l__tasks_column_sep_dim ) / \l__tasks_columns_int } - - \l__tasks_depth_int \l__tasks_item_indent_dim + - \l__tasks_item_indent_dim \bool_if:NT \l__tasks_debug_bool { -2\fboxrule } } + \dim_set:Nn \l_tmpa_dim + { + \l__tasks_columns_int \l__tasks_item_width_dim + + \l__tasks_columns_int \l__tasks_column_sep_dim + - \l__tasks_column_sep_dim + + \l__tasks_columns_int \l__tasks_item_indent_dim + \bool_if:NT \l__tasks_debug_bool { +\l__tasks_columns_int\fboxrule } + \bool_if:NT \l__tasks_debug_bool { +\l__tasks_columns_int\fboxrule } + } + \dim_compare:nNnT + { \l_tmpa_dim } + > + { \l__tasks_full_width_dim } + { \dim_sub:Nn \l__tasks_item_width_dim { \l__tasks_correction_dim } } \__tasks_gset_rows_num:NN \g__tasks_total_items_int \l__tasks_columns_int @@ -188,17 +238,17 @@ \int_compare:nNnT { \g__tasks_current_col_num_int } > { \l__tasks_columns_int } { - \int_gset:Nn \g__tasks_current_col_num_int { 1 } - \int_incr:N \g__tasks_current_row_num_int + \int_gset:Nn \g__tasks_current_col_num_int {1} + \int_gincr:N \g__tasks_current_row_num_int } + % if the next item fills rest of line: \bool_if:NT \l__tasks_item_rest_of_line_bool { + % number of remaining columns: \int_set:Nn \l__tasks_tmpa_int { \l__tasks_columns_int - \g__tasks_current_col_num_int + 1 } - \int_compare:nNnTF { \l__tasks_item_columns_int } = { 0 } - { - \int_set:Nn \l__tasks_tmpb_int { \l__tasks_tmpa_int - 1 } % 8 - } + % check requested column number and adjust: + \int_compare:nNnF { \l__tasks_item_columns_int } = {0} { \int_compare:nNnTF { \l__tasks_tmpa_int } > { \l__tasks_item_columns_int } @@ -207,16 +257,16 @@ \bool_if:nT { \l__tasks_item_rest_of_line_bool && - !\int_compare_p:nNn { \l__tasks_item_columns_int} = { 0 } + !\int_compare_p:nNn { \l__tasks_item_columns_int } = {0} } { \int_gadd:Nn \g__tasks_current_col_num_int - { \l__tasks_item_columns_int -1 } + { \l__tasks_item_columns_int -1 } \int_gadd:Nn \g__tasks_total_items_int - { \l__tasks_item_columns_int -1 } + { \l__tasks_item_columns_int - 1 } } - \int_set:Nn \l__tasks_tmpb_int { \l__tasks_tmpa_int -1 } } + \int_set:Nn \l__tasks_tmpb_int { \l__tasks_tmpa_int - 1 } \dim_set:Nn \l__tasks_item_width_dim { \l__tasks_tmpa_int \l__tasks_item_width_dim @@ -231,7 +281,7 @@ { \vcoffin_set:Nnn \l__tasks_tmpa_coffin { \l__tasks_item_width_dim } - { \__tasks_setup: #2 {#3} \strut } + { \__tasks_setup: #2 {#3} \mode_if_horizontal:T { \strut } } \__tasks_debug:n { \coffin_typeset:Nnnnn \l__tasks_tmpa_coffin @@ -243,14 +293,15 @@ { \vcoffin_set:Nnn \l__tasks_tmpa_coffin { - \l__tasks_label_width_dim - \bool_if:NT \l__tasks_debug_bool {-2\fboxrule } + \dim_abs:n { \l__tasks_label_width_dim } + \bool_if:NT \l__tasks_debug_bool {+2\fboxrule } } { \noindent - \tl_use:N \l__tasks_item_fill_left_tl - \strut #1 - \tl_use:N \l__tasks_item_fill_right_tl + \l__tasks_item_fill_left_tl + #1 + \l__tasks_item_fill_right_tl + \strut } \__tasks_debug:n { @@ -260,19 +311,26 @@ } % attach the label box at the left of the item box, shifted by % \l__tasks_label_offset_dim : - \coffin_attach:NnnNnnnn - \l__tasks_item_coffin {l} {T} - \l__tasks_label_coffin {l} {T} + \dim_compare:nNnTF { \l__tasks_label_width_dim } < {0pt} { - \dim_compare:nNnTF - { \l__tasks_item_indent_dim } - < - { \l__tasks_label_offset_dim + \l__tasks_label_width_dim } + \coffin_attach:NnnNnnnn + \l__tasks_item_coffin {l} {T} + \l__tasks_label_coffin {r} {T} + { - \l__tasks_label_offset_dim } + {0pt} + } + { + \coffin_attach:NnnNnnnn + \l__tasks_item_coffin {l} {T} + \l__tasks_label_coffin {l} {T} + { + - \l__tasks_label_offset_dim - \l__tasks_label_width_dim + \bool_if:NT \l__tasks_debug_bool {-2\fboxrule } + } {0pt} - { - \l__tasks_label_width_dim - \l__tasks_label_offset_dim } - } { 0pt } + } % when a new row starts enter vertical mode: - \int_compare:nNnT { \g__tasks_current_col_num_int } = { 1 } + \int_compare:nNnT { \g__tasks_current_col_num_int } = {1} { \skip_vertical:N \c_zero_skip } % skip horizontally by \l__tasks_item_indent_dim \noindent @@ -288,11 +346,11 @@ \l__tasks_item_full_line_bool || ( \l__tasks_item_rest_of_line_bool && - \int_compare_p:nNn { \l__tasks_item_columns_int } = { 0 } + \int_compare_p:nNn { \l__tasks_item_columns_int } = {0} ) } { \tasks_new_row: } - % are we between items in a row? The skip by \l__tasks_column_sep_dim : + % are we between items in a row? Then skip by \l__tasks_column_sep_dim : \int_compare:nNnT { \g__tasks_current_col_num_int } < { \l__tasks_columns_int } { \skip_horizontal:N \l__tasks_column_sep_dim } @@ -302,7 +360,7 @@ { ( \int_compare_p:nNn { \g__tasks_current_col_num_int } = { \l__tasks_columns_int } ) && - ( \int_compare_p:n { \g__tasks_current_row_num_int != \l__tasks_rows_int } ) + ( \int_compare_p:n { \g__tasks_current_row_num_int != \g__tasks_rows_int } ) } { \skip_vertical:N \l__tasks_after_item_skip } % clean up: @@ -312,35 +370,23 @@ \bool_set_false:N \l__tasks_item_full_line_bool \bool_set_false:N \l__tasks_item_rest_of_line_bool } -\cs_generate_variant:Nn \__tasks_task:nnn { VVV } +\cs_generate_variant:Nn \__tasks_task:nnn {VVV} \cs_new_protected:Npn \__tasks_setup: { - \dim_set:Nn \parskip { 0pt } - \skip_set:Nn \parfillskip { 0pt plus 1fil } + \dim_set:Nn \parskip {0pt} + \skip_set:Nn \parfillskip {0pt plus 1fil} \dim_set_eq:NN \parskip \parsep \dim_set_eq:NN \parindent \listparindent \noindent - \dim_compare:nNnT - { \l__tasks_item_indent_dim } - < - { \l__tasks_label_offset_dim + \l__tasks_label_width_dim } - { - \skip_horizontal:n - { - \l__tasks_label_offset_dim - + \l__tasks_label_width_dim - - \l__tasks_item_indent_dim - } - } \strut } \cs_new_protected:Npn \__tasks_gset_rows_num:NN #1#2 { - \int_gset:Nn \l__tasks_rows_int { \int_div_truncate:nn {#1} {#2} } - \int_compare:nNnT { \int_mod:nn {#1} {#2} } > { 0 } - { \int_gincr:N \l__tasks_rows_int } + \int_gset:Nn \g__tasks_rows_int { \int_div_truncate:nn {#1} {#2} } + \int_compare:nNnT { \int_mod:nn {#1} {#2} } > {0} + { \int_gincr:N \g__tasks_rows_int } } \cs_new_protected:Npn \__tasks_label_align:n #1 @@ -349,28 +395,27 @@ { {left} { - \tl_clear:N \l__tasks_item_fill_left_tl - \tl_set_eq:NN \l__tasks_item_fill_right_tl \hfill + \tl_clear:N \l__tasks_item_fill_left_tl + \tl_set:Nn \l__tasks_item_fill_right_tl {\hfill} } {right} { - \tl_set_eq:NN \l__tasks_item_fill_left_tl \hfill - \tl_clear:N \l__tasks_item_fill_right_tl + \tl_set:Nn \l__tasks_item_fill_left_tl {\hfill} + \tl_clear:N \l__tasks_item_fill_right_tl } {center} { - \tl_set_eq:NN \l__tasks_item_fill_left_tl \hfill - \tl_set_eq:NN \l__tasks_item_fill_right_tl \hfill + \tl_set:Nn \l__tasks_item_fill_left_tl {\hfill} + \tl_set:Nn \l__tasks_item_fill_right_tl {\hfill} } } { - \tl_clear:N \l__tasks_item_fill_left_tl - \tl_set_eq:NN \l__tasks_item_fill_right_tl \hfill + \tl_clear:N \l__tasks_item_fill_left_tl + \tl_set:Nn \l__tasks_item_fill_right_tl {\hfill} } } -\cs_generate_variant:Nn \__tasks_label_align:n { V } -\__tasks_label_align:n {left} - +\cs_generate_variant:Nn \__tasks_label_align:n {V} + % -------------------------------------------------------------------------- % the `tasks' object: % #1: number of items @@ -380,15 +425,13 @@ % the `default' template interface: \DeclareTemplateInterface {tasks} {default} {3} { - enumerate : boolean = true , - label : tokenlist , - indent : length = 2.5em , - counter-format : tokenlist = tsk[a]) , + label : tokenlist = \alph*) , + indent : length = 2.5em , label-format : tokenlist , - label-width : length = 1em , - label-offset : length = .3333em , + label-width : length = 11pt , + label-offset : length = .3333em , item-format : tokenlist , - after-item-skip : skip = 1ex plus 1ex minus 1ex + after-item-skip : skip = 1ex plus 1ex minus 1ex } % in the next three commands we want a really unlikely to occur marker; for @@ -400,10 +443,8 @@ % the `default' template code: \DeclareTemplateCode {tasks} {default} {3} { - enumerate = \l__tasks_enumerate_bool , label = \l__tasks_label_tl , indent = \l__tasks_item_default_indent_dim , - counter-format = \l__tasks_label_pattern_tl , label-format = \l__tasks_label_format_tl , label-width = \l__tasks_label_default_width_dim , label-offset = \l__tasks_label_default_offset_dim , @@ -430,41 +471,20 @@ \l__tasks_label_offset_dim \l__tasks_label_default_offset_dim } - % \dim_compare:nNnT - % { \l__tasks_item_indent_dim } - % < - % { \l__tasks_label_offset_dim + \l__tasks_label_width_dim } - % { - % \dim_set:Nn \l__tasks_item_indent_dim - % { \l__tasks_label_offset_dim + \l__tasks_label_width_dim } - % } \bool_if:NT \l__tasks_custom_after_item_skip_bool { \skip_set_eq:NN \l__tasks_after_item_skip \l__tasks_custom_after_item_skip } - \bool_if:NT \l__tasks_custom_label_bool - { - \tl_set_eq:NN - \l__tasks_label_tl - \l__tasks_custom_label_tl - \bool_set_false:N \l__tasks_enumerate_bool - } \__tasks_label_align:V \l__tasks_label_align_tl % need this for enumerate list: - \bool_if:nT { !\l__tasks_resume_bool && \l__tasks_enumerate_bool } - { \int_gzero:N \g__tasks_int } + \bool_if:NF \l__tasks_resume_bool + { \setcounter {task} {0} } \int_set:Nn \l__tasks_columns_int {#2} % set all the items in their own coffins and join with the ground: \int_gzero:N \g__tasks_current_col_num_int - \int_set:Nn \g__tasks_current_row_num_int {1} - \tl_if_blank:VF \l__tasks_custom_label_pattern_tl - { - \tl_set_eq:NN - \l__tasks_label_pattern_tl - \l__tasks_custom_label_pattern_tl - } + \int_gset:Nn \g__tasks_current_row_num_int {1} \tl_if_blank:VF \l__tasks_custom_label_format_tl { \tl_set_eq:NN @@ -477,27 +497,46 @@ \l__tasks_item_format_tl \l__tasks_custom_item_format_tl } + % prepare counter according to given format: + \tl_set:Nx \l__tasks_tmpa_tl + { + \bool_if:NTF \l__tasks_custom_label_bool + { \tl_to_str:V \l__tasks_custom_label_tl } + { \tl_to_str:V \l__tasks_label_tl } + } + \tl_replace_once:Nnn \l__tasks_tmpa_tl {*} {{task}} + \tl_set_rescan:NnV \l__tasks_tmpa_tl {} \l__tasks_tmpa_tl + \dim_compare:nNnT + { \l__tasks_item_indent_dim } + < + { \l__tasks_label_offset_dim + \l__tasks_label_width_dim } + { + \msg_warning:nnnx {tasks} + {width-too-small} + {item-indent} + { \dim_to_decimal:n { \l__tasks_label_offset_dim + \l__tasks_label_width_dim } } + } + % do the tasks: \seq_map_inline:Nn \l__tasks_seq { \__tasks_read_item:www ##1 \q_stop - \bool_if:NTF \l__tasks_enumerate_bool - { - \tl_if_eq:VnT \l__tasks_tmp_label_tl { $tasks$default$label$ } - { - \int_gincr:N \g__tasks_int - \SaveCounterPatternFrom [tasks] - \l__tasks_tmpa_tl - \l__tasks_label_tl - \l__tasks_label_pattern_tl - \cs_gset:Npx \@currentlabel { \l__tasks_label_tl } - } - } + \refstepcounter {task} + \tl_set:NV \l__tasks_label_tl \l__tasks_tmpa_tl + \bool_if:NTF \l__tasks_custom_label_format_bool + { \tl_put_left:NV \l__tasks_label_tl \l__tasks_custom_label_format_tl } + { \tl_put_left:NV \l__tasks_label_tl \l__tasks_label_format_tl } + % check if the label width is big enough: + \hbox_set:NV \l__tasks_tmpa_box \l__tasks_label_tl + \dim_compare:nNnF + { \box_wd:N \l__tasks_tmpa_box } + < + { \l__tasks_label_width_dim } { - \tl_if_blank:VT \l__tasks_label_tl - { \tl_set_eq:NN \l__tasks_label_tl \labelitemi } + \msg_warning:nnnx {tasks} + {width-too-small} + {label-width} + { \dim_to_decimal:n { \box_wd:N \l__tasks_tmpa_box } } } - \tl_put_left:NV \l__tasks_label_tl \l__tasks_label_format_tl - % \tl_put_left:NV \l__tasks_item_tl \l__tasks_item_format_tl \tl_if_eq:VnTF \l__tasks_tmp_label_tl { $tasks$default$label$ } { \__tasks_task:VVV @@ -517,13 +556,13 @@ \cs_new_protected:Npn \__tasks_read_item:www { - \peek_meaning_remove:NTF ! + \peek_charcode_remove:NTF ! { \bool_set_true:N \l__tasks_item_full_line_bool \__tasks_read_item_aux:ww } { - \peek_meaning_remove:NTF * + \peek_charcode_remove:NTF * { \bool_set_true:N \l__tasks_item_rest_of_line_bool \__tasks_read_item_rest_of_line:ww @@ -555,7 +594,7 @@ \cs_new_protected:Npn \__tasks_read_item_aux_ii:ww [#1]#2 \q_stop { \tl_set:Nn \l__tasks_tmp_label_tl {#1} - \tl_if_eq:nnF { #1 } { $tasks$default$label$ } + \tl_if_eq:nnF {#1} { $tasks$default$label$ } { \tl_put_left:NV \l__tasks_tmp_label_tl \l__tasks_label_format_tl } \tl_set:Nx \l__tasks_item_tl { \tl_trim_spaces:n {#2} } } @@ -563,100 +602,56 @@ \__tasks_restore_dollar: % -------------------------------------------------------------------------- -% choice box: -\bool_new:N \l__tasks_choice_checked_bool -\dim_new:N \l__tasks_choice_width_dim -\dim_set:Nn \l__tasks_choice_width_dim { 1.25ex } -\dim_new:N \l__tasks_choice_linewidth_dim -\dim_set:Nn \l__tasks_choice_linewidth_dim { .3pt } -\dim_new:N \l__tasks_choice_checkwidth_dim -\dim_set:Nn \l__tasks_choice_checkwidth_dim { .5pt } -\dim_new:N \l__tasks_choice_raise_dim -\dim_set:Nn \l__tasks_choice_raise_dim { .1ex } - -\cs_new_protected:Npn \tasks_choice: - { - \leavevmode - \group_begin: - \bool_set_false:N \l__tasks_choice_checked_bool - \box_move_up:nn - { \l__tasks_choice_raise_dim } - { \hbox:n { \__tasks_choice: } } - \group_end: - } - -\cs_new_protected:Npn \tasks_choice_checked: - { - \leavevmode - \group_begin: - \bool_set_true:N \l__tasks_choice_checked_bool - \box_move_up:nn - { \l__tasks_choice_raise_dim } - { \hbox:n { \__tasks_choice: } } - \group_end: - } - -\cs_new_protected:Npn \__tasks_choice: - {% - \dim_set:Nn \unitlength { .1\l__tasks_choice_width_dim } - \begin{picture}(10,0) - \linethickness \l__tasks_choice_linewidth_dim - \drawline(0,0)(0,10)(10,10)(10,0)(0,0) - \linethickness \l__tasks_choice_checkwidth_dim - \bool_if:NT \l__tasks_choice_checked_bool - { - \drawline(2,2)(8,8) - \drawline(2,8)(8,2) - } - \end{picture}% - } - -\providecommand* \choicebox { \tasks_choice: } -\providecommand* \checkedchoicebox { \tasks_choice_checked: } - -% -------------------------------------------------------------------------- -% base instance: -% ALPHABETIZE: a) b) c) -\DeclareInstance {tasks} {alphabetize} {default} { } - \keys_define:nn {tasks/list} { - debug .bool_set:N = \l__tasks_debug_bool , - style .tl_set:N = \l__tasks_instance_tl , - style .initial:n = alphabetize , - counter-format .tl_set:N = \l__tasks_custom_label_pattern_tl , - label .code:n = + debug .bool_set:N = \l__tasks_debug_bool , + break-correction .dim_set:N = \l__tasks_correction_dim , + break-correction .initial:n = .00001pt , + style .tl_set:N = \l__tasks_instance_tl , + style .initial:n = alphabetize , + counter-format .code:n = + \msg_warning:nnnn {tasks} {deprecated} {option} {counter-format} {label} + \keys_set:nn {tasks/list} { label = #1 } , + label .code:n = \bool_set_true:N \l__tasks_custom_label_bool \tl_set:Nn \l__tasks_custom_label_tl {#1} , - label-format .tl_set:N = \l__tasks_custom_label_format_tl , - label-width .code:n = + label-format .code:n = + \bool_set_true:N \l__tasks_custom_label_format_bool + \tl_set:Nn \l__tasks_custom_label_format_tl , + label-width .code:n = \dim_set:Nn \l__tasks_label_width_dim {#1} \bool_set_true:N \l__tasks_label_width_bool , - label-offset .code:n = + label-offset .code:n = \dim_set:Nn \l__tasks_label_offset_dim {#1} \bool_set_true:N \l__tasks_label_offset_bool , - label-align .tl_set:N = \l__tasks_label_align_tl , - item-format .tl_set:N = \l__tasks_custom_item_format_tl , - item-indent .code:n = + label-align .tl_set:N = \l__tasks_label_align_tl , + item-format .tl_set:N = \l__tasks_custom_item_format_tl , + item-indent .code:n = \dim_set:Nn \l__tasks_item_indent_dim {#1} \bool_set_true:N \l__tasks_item_indent_bool , - column-sep .dim_set:N = \l__tasks_column_sep_dim , - before-skip .skip_set:N = \l__tasks_before_list_skip , - after-skip .skip_set:N = \l__tasks_after_list_skip , + column-sep .dim_set:N = \l__tasks_column_sep_dim , + before-skip .skip_set:N = \l__tasks_before_list_skip , + after-skip .skip_set:N = \l__tasks_after_list_skip , after-item-skip .code:n = \bool_set_true:N \l__tasks_custom_after_item_skip_bool \skip_set:Nn \l__tasks_custom_after_item_skip {#1} , - resume .bool_set:N = \l__tasks_resume_bool + resume .bool_set:N = \l__tasks_resume_bool } % -------------------------------------------------------------------------- -% the generic environment: -\NewEnviron {__tasks_env:} [3] + +\cs_new_protected:Npn \tasks_body:nnnn #1#2#3#4 { - \if@inlabel - \noindent\par\nobreak\vskip-\parskip\vskip-\baselineskip\hrule\@height\z@ - \fi - \dim_compare:nNnF { \l__tasks_before_list_skip } = { 0pt } + \int_gincr:N \g__tasks_env_int + \legacy_if:nT {@inlabel} + { + \noindent\par + \nobreak + \vskip-\parskip + \vskip-\baselineskip + \hrule\@height\z@ + } + \dim_compare:nNnF { \l__tasks_before_list_skip } = {0pt} { \vspace {\l__tasks_before_list_skip} } \list {} { @@ -664,11 +659,11 @@ \dim_set:Nn \leftmargin {0pt} \dim_set:Nn \rightmargin {0pt} } - \item \scan_stop: - \int_incr:N \l__tasks_depth_int - \__tasks:VnnV \l__tasks_instance_tl {#3} {#1} \BODY + \item \scan_stop: + \dim_set:Nn \l__tasks_full_width_dim { \linewidth } + \tasks_environment:Vnnn \l__tasks_instance_tl {#3} {#1} {#4} \endlist - \dim_compare:nNnF { \l__tasks_after_list_skip } = { 0pt } + \dim_compare:nNnF { \l__tasks_after_list_skip } = {0pt} { \vspace {\l__tasks_after_list_skip} } } @@ -693,25 +688,41 @@ % -------------------------------------------------------------------------- % the user environment: -\NewDocumentCommand \NewTasks { O{}mO{\task}D(){1} } +\NewDocumentCommand \NewTasksEnvironment { O{}mO{\task}D(){1} } { - \NewDocumentEnvironment {#2} { O{}D(){#4} } - { \__tasks_env: {#3} { #1,##1 } {##2} } - { \end__tasks_env: } + \NewDocumentEnvironment {#2} { O{}D(){#4}+b } + { \tasks_body:nnnn {#3} {#1,##1} {##2} {##3} } + { } } -\NewDocumentCommand \RenewTasks { O{}mO{\task}D(){1} } +\NewDocumentCommand \RenewTasksEnvironment { O{}mO{\task}D(){1} } { - \RenewDocumentEnvironment {#2} { O{}D(){#4} } - { \__tasks_env: {#3} { #1,##1 } {##2} } - { \end__tasks_env: } + \RenewDocumentEnvironment {#2} { O{}D(){#4}+b } + { \tasks_body:nnnn {#3} {#1,##1} {##2} {##3} } + { } } +\tasks_deprecated:NN \NewTasks \NewTasksEnvironment +\tasks_deprecated:NN \RenewTasks \RenewTasksEnvironment + % -------------------------------------------------------------------------- % default list: -\NewTasks {tasks} +\NewTasksEnvironment {tasks} -\file_if_exist:nT {tasks.cfg} { \file_input:n {tasks.cfg} } +% base instance: +% ALPHABETIZE: a) b) c) +\DeclareInstance {tasks} {alphabetize} {default} { } + +% ITEMIZE: +\DeclareInstance {tasks} {itemize} {default} + { + label-width = 1.125em , + label = \labelitemi + } + +% ENUMERATE: +\DeclareInstance {tasks} {enumerate} {default} + { label = \arabic*. } % -------------------------------------------------------------------------- % setup: @@ -721,9 +732,21 @@ \NewDocumentCommand \settasks { m } { \tasks_setup:n {#1} } +% default: + \__tasks_label_align:n {left} + % -------------------------------------------------------------------------- -\tex_endinput:D +\file_if_exist:nT {tasks.cfg} { \file_input:n {tasks.cfg} } + +\AtBeginDocument + { + \@ifpackageloaded {hyperref} + { \tl_set:Nn \theHtask { \int_use:N \g__tasks_env_int . \thetask } } + {} + } +\file_input_stop: +% -------------------------------------------------------------------------- % HISTORY: 2013/01/19 v0.7 - extracted from `exsheets' package; this also lead to a slightly new syntax and a few new options for it @@ -776,3 +799,9 @@ together like one would expect: an item indent of 0pt will align the complete item with the margin and the needed overlap for the label is reserved +2016/08/16 v0.13 - a negative value for label width will make the label + protrude to the margin +2019/10/04 v1.0 - get rid of `cntformats', `environ' and `epic' + - no default multiple choice any more + - rename \NewTasks and \RenewTasks + - the option `counter-format' is deprecated |