summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/biblatex/blx-mcite.def
blob: b2260b1b716f256acde47a966d423a31f54ad1ef (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
% $Id: blx-mcite.def,v 1.7 2011/11/13 19:09:07 lehman stable $

\ProvidesFile{blx-mcite.def}
[\abx@rcsid $Id: blx-mcite.def,v 1.7 2011/11/13 19:09:07 lehman stable $
 mcite-like citation commands]

\newrobustcmd*{\mcite}{\mcitelike\cite}
\newrobustcmd*{\Mcite}{\mcitelike\Cite}
\newrobustcmd*{\mparencite}{\mcitelike\parencite}
\newrobustcmd*{\Mparencite}{\mcitelike\Parencite}
\newrobustcmd*{\mfootcite}{\mcitelike\footcite}
\newrobustcmd*{\mfootcitetext}{\mcitelike\footcitetext}
\newrobustcmd*{\mtextcite}{\mcitelike\textcite}
\newrobustcmd*{\Mtextcite}{\mcitelike\Textcite}
\newrobustcmd*{\msupercite}{\mcitelike\supercite}

%    \mcite{key1,setA,*keyA1,*keyA2,*keyA3,key2,setB,*keyB1,*keyB2,*keyB3}
% => \mcitelike\cite{key1,setA,*keyA1,*keyA2,*keyA3,key2,setB,*keyB1,*keyB2,*keyB3}
% => \defbibentryset{setA}{keyA1,keyA2,keyA3}
%    \defbibentryset{setB}{keyB1,keyB2,keyB3}
%    \cite{key1,setA,key2,setB}

\newrobustcmd*{\mcitelike}[1]{%
  \@ifstar
    {\blx@citeargs{\blx@mclike{#1*}}}
    {\blx@citeargs{\blx@mclike{#1}}}}

\long\def\blx@mclike#1#2#3#4{%
  \begingroup
  \let\blx@mclike@tempa\@empty
  \let\blx@mclike@tempb\@empty
  \let\blx@mclike@tempc\@empty
  \blx@xsanitizeafter\blx@mclike@i{#4}%
  \edef\blx@mclike@tempa{\endgroup\unexpanded{#1[#2][#3]}{\blx@mclike@tempa}}%
  \blx@mclike@tempa}

\def\blx@mclike@i#1{%
  \forcsvlist\blx@mclike@ii{#1}%
  \blx@mclike@iv}

\def\blx@mclike@ii#1{\blx@mclike@iii#1&}

\def\blx@mclike@iii#1#2&{%
  \if*#1%
    \blx@mclike@tail{#2}%
  \else
    \blx@mclike@head{#1#2}%
  \fi}

\def\blx@mclike@iv{%
  \ifx\blx@mclike@tempb\@empty
  \else
    \ifx\blx@mclike@tempc\@empty
      \nocite{\blx@mclike@tempb}% preserve citation order for sorting=none
    \else
      \defbibentryset{\blx@mclike@tempb}{\blx@mclike@tempc}%
      \let\blx@mclike@tempc\@empty
    \fi
    \let\blx@mclike@tempb\@empty
  \fi}

\def\blx@mclike@head#1{%
  \blx@mclike@iv
  \edef\blx@mclike@tempa{%
    \ifx\blx@mclike@tempa\@empty
    \else
      \blx@mclike@tempa,%
    \fi#1}%
  \def\blx@mclike@tempb{#1}}

\def\blx@mclike@tail#1{%
  \edef\blx@mclike@tempc{%
    \ifx\blx@mclike@tempc\@empty
    \else
      \blx@mclike@tempc,%
    \fi#1}}

\endinput