summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gatherenum/gatherenum.sty
blob: 4e8e7b65c59bac5693c8e9f69c911ebe1e655474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%%
%% This is file `gatherenum.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% gatherenum.dtx  (with options: `package')
%% 
%% File: gatherenum.dtx (C) Copyright 2016-2019 RIVAUD Julien
%%
%% It may be distributed and/or modified under the conditions of the
%% General Public License (GPL), either version 3 of this
%% license or (at your option) any later version.
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\RequirePackage{expl3}[2018/06/19]
\def\ExplFileName{gatherenum}
\def\ExplFileDescription{Crossover between align* and enumerate}
\def\ExplFileDate{2019/09/29}
\def\ExplFileVersion{1.8}
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\RequirePackage{enumitem}
\RequirePackage{xparse}
\tl_set:Nn \enit@shortgatherenum {enum}
\newlist{gatherenum}{enumerate*}{3}
\tl_new:N \l__gatherenum_itemformat
\cs_new_protected_nopar:Nn \__gatherenum_boxitem: {
    \nobreak\skip_horizontal:n {\labelsep}
    \hbox_set:Nn \enit@inbox {
        \hbox:n {
            \l__gatherenum_itemformat{\hbox_unpack:N \enit@inbox}
        }
    }
}
\enitkv@key{enumitem}{gatherformat}{\tl_set:Nn\l__gatherenum_itemformat{#1}}
\let\__gatherenum_save_enumerate:w\enumerate
\let\__gatherenum_save_endenumerate:w\endenumerate
\RenewDocumentEnvironment{enumerate}{ O{} }{
    \clist_if_in:nnTF { #1 } { gathered } {
        \if@inlabel
            \leavevmode
        \fi
        \par
        \centering
        \int_set_eq:NN \enitdp@gatherenum \enitdp@enumerate
        \penalty \predisplaypenalty
        \gatherenum[
            itemjoin=\skip_horizontal:n{1em plus 1fil},
            #1,
            mode=boxed,
            align=none,
            afterlabel=\__gatherenum_boxitem:,
        ]
    }{
        \__gatherenum_save_enumerate:w[#1]
    }
}{
    \clist_if_in:nnTF { #1 } { gathered } {
        \endgatherenum
        \unskip
        \int_set_eq:NN \clubpenalty \interlinepenalty
        \int_set_eq:NN \widowpenalty \interlinepenalty
        \use:c{@ @ par}% avoid l3docstrip replacement of @
    }{
        \__gatherenum_save_endenumerate:w
    }
}
\SetEnumitemKey{gathered}{}
\SetLabelAlign{none}{#1}
\SetEnumitemKey{centered}{before*=\centering}
\SetEnumitemKey{alignleft}{before*=\raggedright}
%% 
%%
%% End of file `gatherenum.sty'.