summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/citeall/citeall.sty
blob: e547b097b1ed116e116eceef6afa7fb28418590a (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
%% ---------------------------------------------------------------
%% The citeall package --- A package to test biblatex-cite commands
%% Maintained by Ulrike Fischer
%% E-mail: fischer@troubleshooting-tex.de
%% www.troubleshooting-tex.de
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ---------------------------------------------------------------

\RequirePackage{expl3,xparse}

\ProvidesExplPackage {citeall} {2015/02/27} {1.1}
  {a package to test biblatex-cite commands}

\@ifpackageloaded{biblatex}{}{%
   \PackageWarning{citeall}
    {
     This~package~works~only~with~biblatex!\MessageBreak
     Load~it~before~citeall!\MessageBreak
     Loading~citeall~will~abort!
     }%
   \NewDocumentCommand\citeall { O{} } {}
   \tex_endinput:D}

\DeclareBibliographyCategory{citeall}

% commands to hold arguments and temporary values
\clist_new:N \l_UF_citecommands_clist
\tl_new:N    \l_UF_temp_citefunction_tl
\tl_new:N    \l_UF_temp_entrykey_tl
\int_new:N   \l_UF_temp_listitem_int
\int_new:N   \l_UF_temp_listlength_int
\int_new:N   \l_UF_entrynum_int
\int_new:N   \l_UF_cur_entrynum_int

% formatting commands
\NewDocumentCommand\citeallgroupseparator{}{\par}
\NewDocumentCommand\citeallseparator     {}{,\c_space_tl}
\NewDocumentCommand\citeallfinentry      {}{}
\NewDocumentCommand\citealldefaultcite   {}{\cite}

%init suitable definitions for the fields in the bbl
\cs_new:Nn \_UF_init_bblfields:
 {\newcommand\true [2][]{}
  \newcommand\field[3][]{}
  \newcommand\name [5][]{}
  \newcommand\strng[2]{}%
  \renewenvironment{refsection}[1]{}{}
  \newenvironment{sortlist}[2]{}{}
  \renewcommand\verb{\@ifnextchar\bgroup{\@gobble}{\my@verb}}
  \def\my@verb##1\endverb{}
  \renewcommand\list[4][]{}
  \newcommand\inset[1]{}
  \newcommand\keyw[1]{}
  \newcommand\set[1]{}
  \newcommand\warn[1]{}
  }

% init the entry environment
%#1=number of entries to process, if 0: process all
\cs_new:Nn \_UF_init_bblentryenv:n
 {\int_set:Nn   \l_UF_entrynum_int {#1}
  \int_zero:N   \l_UF_cur_entrynum_int
  \NewDocumentEnvironment{entry} {m m m}
  {\int_incr:N  \l_UF_cur_entrynum_int
   \tl_set:Nn  \l_UF_temp_entrykey_tl {##1}
   \int_zero:N \l_UF_temp_listitem_int
   \int_set:Nn \l_UF_temp_listlength_int
    {\clist_count:N\l_UF_citecommands_clist}
   \bool_if:nT
    {
     \int_compare_p:n { \l_UF_entrynum_int = 0 }
      ||
     \int_compare_p:n { \l_UF_cur_entrynum_int <= \l_UF_entrynum_int}
    }
    {\addtocategory{citeall}{##1}
     \clist_map_inline:Nn \l_UF_citecommands_clist
     {
      \int_incr:N \l_UF_temp_listitem_int
      \tl_set:Nn  \l_UF_temp_citefunction_tl {####1}
      \l_UF_temp_citefunction_tl {\l_UF_temp_entrykey_tl}
      \int_compare:nNnTF
      {\l_UF_temp_listitem_int}<{\l_UF_temp_listlength_int}
      {\citeallseparator}{\citeallfinentry}
     }
     \citeallgroupseparator
    }
  }
  {}
 }


% the main command

\NewDocumentCommand\citeall { O{\citealldefaultcite} o}
 {\nocite{*} %cite all entries
  \clist_set:Nn\l_UF_citecommands_clist{#1}
  \clist_if_empty:NT\l_UF_citecommands_clist
   {
    \clist_put_right:Nn\l_UF_citecommands_clist{\citealldefaultcite}
   }
  \group_begin:
   \IfNoValueTF{#2}
   {\_UF_init_bblentryenv:n{0}}
   {\_UF_init_bblentryenv:n{#2}}
   \_UF_init_bblfields:
   \file_if_exist:nT
    {\jobname.bbl}
    {\file_input:n{\jobname.bbl}}%
  \group_end:
 }


\endinput