summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/citeall/citeall.sty
blob: fa949c920d5923456745286e825663b444008a43 (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
115
116
117
118
%% ---------------------------------------------------------------
%% 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
%% $UFDate: 2015-04-28 13:27:07 +0200 -- Commit: f04431e -- master$
%% ---------------------------------------------------------------

\RequirePackage{expl3,xparse}

\ProvidesExplPackage {citeall} {2015/04/28} {1.2}
  {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_UFca_citecommands_clist
\tl_new:N    \l_UFca_temp_citefunction_tl
\tl_new:N    \l_UFca_temp_entrykey_tl
\int_new:N   \l_UFca_temp_listitem_int
\int_new:N   \l_UFca_temp_listlength_int
\int_new:N   \l_UFca_entrynum_int
\int_new:N   \l_UFca_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 \_UFca_init_bblfields:
 {\newcommand\true [2][]{\ignorespaces}
  \newcommand\field[3][]{\ignorespaces}
  \newcommand\name [5][]{\ignorespaces}
  \newcommand\strng[2]{\ignorespaces}%
  \renewenvironment{refsection}[1]{}{\ignorespaces}
  \newenvironment{sortlist}[2]{}{\ignorespaces}
  %\renewcommand\verb{\@ifnextchar\bgroup{\@gobble}{\my@verb}}
  \def\verb##1\endverb{\ignorespaces}
  \renewcommand\list[4][]{\ignorespaces}
  \newcommand\inset[1]{\ignorespaces}
  \newcommand\keyw[1]{\ignorespaces}
  \newcommand\set[1]{\ignorespaces}
  \newcommand\warn[1]{\ignorespaces}
  \renewcommand\inset[1]{\addtocategory{citeall}{##1}\ignorespaces}
  \newcommand\range[2]{\ignorespaces} %for biblatex-dev
  }


% init the entry environment
%#1=number of entries to process, if 0: process all
\cs_new:Nn \_UFca_init_bblentryenv:n
 {\int_set:Nn   \l_UFca_entrynum_int {#1}
  \int_zero:N   \l_UFca_cur_entrynum_int
  \NewDocumentEnvironment{entry} {m m m}
  {\int_incr:N  \l_UFca_cur_entrynum_int
   \tl_set:Nn  \l_UFca_temp_entrykey_tl {##1}
   \int_zero:N \l_UFca_temp_listitem_int
   \int_set:Nn \l_UFca_temp_listlength_int
    {\clist_count:N\l_UFca_citecommands_clist}
   \bool_if:nT
    {
     \int_compare_p:n { \l_UFca_entrynum_int = 0 }
      ||
     \int_compare_p:n { \l_UFca_cur_entrynum_int <= \l_UFca_entrynum_int}
    }
    {\addtocategory{citeall}{##1}
     \clist_map_variable:NNn \l_UFca_citecommands_clist \l_UFca_temp_citefunction_tl
     {
      \int_incr:N \l_UFca_temp_listitem_int
      %\tl_set:Nn  \l_UFca_temp_citefunction_tl {####1}
      \l_UFca_temp_citefunction_tl {\l_UFca_temp_entrykey_tl}
      \int_compare:nNnTF
      {\l_UFca_temp_listitem_int}<{\l_UFca_temp_listlength_int}
      {\citeallseparator}{\citeallfinentry}
     }
     \citeallgroupseparator
    }
  }
  {}
 }


% the main command

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


\endinput