summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex-contrib/biblatex-publist/publist.cbx
blob: d1b46b1ab99178bca61530e156539b223d00c148 (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
% publist.cbx, biblatex citation style by Juergen Spitzmueller
% requires biblatex >= 3.4
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
% 
% This Current Maintainer of this work is Jürgen Spitzmüller.
%
% This work consists of the file publist.cbx and publist.bbx.
%
%
% This is a simple portmanteau file that just loads the standard
% "numeric" citation style. This file is provided to allow the loading
% of biblatex-publist via the "style=" (alternatively to "bibstyle=")
% option.
%
% Please send suggestions and bug reports to 
% https://github.com/jspitz/biblatex-publist
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\bpl@version{2.8}
\def\bpl@rdate{2024/03/08}

\ProvidesFile{publist.cbx}[\bpl@rdate\space v.\bpl@version\space
                           biblatex citation style (JSP)]

\RequireCitationStyle{numeric}

\DeclareCiteCommand{\citeitem}
  {\defcounter{maxnames}{999}%
   \boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\usebibmacro{bpl:cite:extern}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newbibmacro*{bpl:cite:extern}{%
  \printtext[bibhyperref]{%
    \printfield{labelprefix}%
    \usebibmacro{bpl:cite:labelnumber}%
    \ifbool{bbx:subentry}
      {\printfield{entrysetcount}}
      {}}}

\newbibmacro*{bpl:cite:labelnumber}{%
    \printtext[labelnumberwidth]{\mkrefdesc{\thefield{labelnumber}}}%
}

% Manual way to adjust numbering
\csdef{bpl@secstartshift}{0}
\newcommand*\shiftciteitem[1]{\csdef{bpl@secstartshift}{#1}}

% Print labelnumber as actual number, plus item total
% and probably a manual shift value
\newrobustcmd{\mkrefdesc}[1]{%
  \number\numexpr#1+\csuse{bpl@itemtotal}+\csuse{bpl@secstartshift}\relax%
}

\providebool{@bpl@reversenum}
\providebool{@bpl@numberreset}
\providebool{plnumgroup}

\AtEndOfPackage{%
\if@bpl@reversenum
  \newcounter{prevcrefsection}%
  \renewrobustcmd{\mkrefdesc}[1]{%
     \ifbool{@bpl@numberreset}{%
        % Print the labelnumber as the total number of entries in the
        % current refsection, minus the actual labelnumber, plus one
        \ifbool{plnumgroup}{%
             \number\numexpr\csuse{bpl@itemtotal}-#1+1%
                            +\csuse{bpl@secstartshift}\relax%
          }{%
             \ifcsdef{bpl@secitems:\therefsection}{%
                \number\numexpr\csuse{bpl@secitems:\therefsection}-#1+1%
                           +\csuse{bpl@secstartshift}\relax%
             }{%
                \number\numexpr\csuse{bpl@itemtotal}-#1+1%
                           +\csuse{bpl@secstartshift}\relax%
             }%
          }%
     }{%
        % Use decreasing counter
        \setcounter{prevcrefsection}{\therefsection}%
        \addtocounter{prevcrefsection}{-1}%
        \ifcsdef{bpl@items:\theprevcrefsection}{%
           \number\numexpr\csuse{bpl@itemtotal}-#1+1%
           -\csuse{bpl@items:\theprevcrefsection}%
           +\csuse{bpl@secstartshift}\relax%
        }{%
           \number\numexpr\csuse{bpl@itemtotal}-#1+1%
           +\csuse{bpl@secstartshift}\relax%
        }%
     }%
  }%
\fi%
}

%%
\endinput