summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex-ms/latex/cbx/numeric-ms.cbx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/biblatex-ms/latex/cbx/numeric-ms.cbx')
-rw-r--r--macros/latex/contrib/biblatex-ms/latex/cbx/numeric-ms.cbx159
1 files changed, 159 insertions, 0 deletions
diff --git a/macros/latex/contrib/biblatex-ms/latex/cbx/numeric-ms.cbx b/macros/latex/contrib/biblatex-ms/latex/cbx/numeric-ms.cbx
new file mode 100644
index 0000000000..5bdc3648da
--- /dev/null
+++ b/macros/latex/contrib/biblatex-ms/latex/cbx/numeric-ms.cbx
@@ -0,0 +1,159 @@
+\ProvidesFile{numeric-ms.cbx}
+[\abx@cbxid]
+
+\ExecuteBibliographyOptions{labelnumber,autocite=inline}
+
+\renewcommand*{\multicitedelim}{\addcomma\space}
+\renewcommand*{\iffinalcitedelim}{%
+ \ifnumequal{\value{textcitecount}}{\value{textcitetotal}-1}}
+
+\providebool{bbx:subentry}
+\newbool{cbx:parens}
+
+\DeclareFieldFormat{entrysetcount}{\mknumalph{#1}}
+
+\newbibmacro*{cite}{%
+ \printtext[bibhyperref]{%
+ \printfield{labelprefix}%
+ \printfield{labelnumber}%
+ \ifbool{bbx:subentry}
+ {\printfield{entrysetcount}}
+ {}}}
+
+\newbibmacro*{textcite}{%
+ \iffieldequals{namehash}{\cbx@lasthash}
+ {\setunit{\multicitedelim}}
+ {\ifnameundef{labelname}
+ {\printfield[citetitle]{labeltitle}}
+ {\printnames{labelname}}%
+ \setunit*{\printdelim{namelabeldelim}}%
+ \printtext{\bibopenbracket}\global\booltrue{cbx:parens}%
+ \stepcounter{textcitecount}%
+ \savefield{namehash}{\cbx@lasthash}}%
+ \ifnumequal{\value{citecount}}{1}
+ {\usebibmacro{prenote}}
+ {}%
+ \usebibmacro{cite}%
+ \setunit{%
+ \ifbool{cbx:parens}
+ {\bibclosebracket\global\boolfalse{cbx:parens}}
+ {}%
+ \textcitedelim}}
+
+\newbibmacro*{textcite:init}{%
+ \ifnumless{\value{multicitecount}}{2}
+ {\global\boolfalse{cbx:parens}%
+ \global\undef\cbx@lasthash}
+ {\global\undef\cbx@lasthash}}
+
+\newbibmacro*{textcite:postnote}{%
+ \usebibmacro{postnote}%
+ \ifthenelse{\value{multicitecount}=\value{multicitetotal}}
+ {\setunit{}%
+ \printtext{%
+ \ifbool{cbx:parens}
+ {\bibclosebracket\global\boolfalse{cbx:parens}}
+ {}}}
+ {\setunit{%
+ \ifbool{cbx:parens}
+ {\bibclosebracket\global\boolfalse{cbx:parens}}
+ {}%
+ \textcitedelim}}}
+
+\DeclareCiteCommand{\cite}[\mkbibbrackets]
+ {\usebibmacro{prenote}}
+ {\usebibmacro{citeindex}%
+ \usebibmacro{cite}}
+ {\multicitedelim}
+ {\usebibmacro{postnote}}
+
+\DeclareCiteCommand{\parencite}[\mkbibbrackets]
+ {\usebibmacro{prenote}}
+ {\usebibmacro{citeindex}%
+ \usebibmacro{cite}}
+ {\multicitedelim}
+ {\usebibmacro{postnote}}
+
+\DeclareCiteCommand{\footcite}[\mkbibfootnote]
+ {\usebibmacro{prenote}}
+ {\usebibmacro{citeindex}%
+ \usebibmacro{cite}}
+ {\multicitedelim}
+ {\usebibmacro{postnote}}
+
+\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
+ {\usebibmacro{prenote}}
+ {\usebibmacro{citeindex}%
+ \usebibmacro{cite}}
+ {\multicitedelim}
+ {\usebibmacro{postnote}}
+
+\DeclareCiteCommand{\smartcite}[\iffootnote\mkbibbrackets\mkbibfootnote]
+ {\usebibmacro{prenote}}
+ {\usebibmacro{citeindex}%
+ \usebibmacro{cite}}
+ {\multicitedelim}
+ {\usebibmacro{postnote}}
+
+\DeclareCiteCommand{\supercite}[\mkbibsuperscript]
+ {\iffieldundef{prenote}
+ {}
+ {\BibliographyWarning{Ignoring prenote argument}}%
+ \iffieldundef{postnote}
+ {}
+ {\BibliographyWarning{Ignoring postnote argument}}}
+ {\usebibmacro{citeindex}%
+ \usebibmacro{cite}}
+ {\supercitedelim}
+ {}
+
+\DeclareCiteCommand{\cbx@textcite}
+ {\usebibmacro{textcite:init}}
+ {\usebibmacro{citeindex}%
+ \usebibmacro{textcite}}
+ {}
+ {\usebibmacro{textcite:postnote}}
+
+\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
+ {\gdef\cbx@savedkeys{}%
+ \citetrackerfalse%
+ \pagetrackerfalse%
+ \DeferNextCitekeyHook%
+ \usebibmacro{textcite:init}}
+ {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
+ {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
+ \global\clearfield{multipostnote}}
+ {}%
+ \xappto\cbx@savedkeys{\thefield{entrykey},}%
+ \iffieldequals{namehash}{\cbx@lasthash}
+ {}
+ {\stepcounter{textcitetotal}%
+ \savefield{namehash}{\cbx@lasthash}}}
+ {}
+ {\protected@xappto\cbx@savedcites{%
+ [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
+
+% textcite has nested \DeclareCiteCommand definitions for textcite and we want to use
+% the normal textcite context
+\DeclareDelimcontextAlias{cbx@textcite}{textcite}
+
+\newrobustcmd{\cbx@textcite@init}[2]{%
+ \setcounter{textcitetotal}{0}%
+ \setcounter{textcitecount}{0}%
+ \def\cbx@savedcites{#1}#2%
+ \ifnumgreater{\value{textcitetotal}}{0}
+ {\cbx@savedcites}
+ {}}
+
+\DeclareMultiCiteCommand{\cbx@textcites}{\cbx@textcite}{}
+\DeclareMultiCiteCommand{\textcites}[\cbx@textcites@init\cbx@textcites]{\textcite}{}
+
+\let\cbx@textcites@init\cbx@textcite@init
+\pretocmd{\cbx@textcites@init}{\UseNextMultiCiteHook}{}{}
+
+\DeclareMultiCiteCommand{\cites}[\mkbibbrackets]{\cite}{\multicitedelim}
+\DeclareMultiCiteCommand{\parencites}[\mkbibbrackets]{\parencite}{\multicitedelim}
+\DeclareMultiCiteCommand{\smartcites}[\iffootnote\mkbibbrackets\mkbibfootnote]
+ {\smartcite}{\multicitedelim}
+
+\endinput