1

I like to use the code shown here to show sorted cites as footnotes in each page. The code works fine unless you use two different bibliographies. In the example shown below (same code as linked above + bibliography file + two bibliographies defined), the first reference shows up as P1 in the text as it should, but as 0 in the footnote. Is it possible to fix this? Any help would be very much appreciated...

\documentclass{article}
\usepackage[style=numeric-comp,sorting=none,citetracker,pagetracker=page,defernumbers]{biblatex}
\usepackage[colorlinks]{hyperref}

\begin{filecontents}{test.bib}
@article{article:1,
author="Autor1",
journaltitle="Journal1",
year="2018",
keywords="own"}

@article{article:2,
author="Autor2",
journaltitle="Journal2",
year="2018"
}
\end{filecontents}


\makeatletter
% user-level citation command
\DeclareCiteCommand{\sfcite}[\cbx@superscript]
{\usebibmacro{cite:init}%
 \let\multicitedelim\supercitedelim
 \iffieldundef{prenote}{}{\BibliographyWarning{Ignoring prenote argument}}%
 \iffieldundef{postnote}{}{\BibliographyWarning{Ignoring postnote argument}}}
{\usebibmacro{citeindex}%
 \usebibmacro{cite:super:foot}%
 \usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}}

% save instcount, save key and last inline instcount if seen first on page
\newbibmacro*{cite:super:foot}{%
\xdef\cbx@key{\thefield{entrykey}}%
\ifsamepage{\value{instcount}}{\csuse{cbx@instcount@\cbx@key}}{}{%
  \listxadd{\cbx@savelist}{\cbx@key}%
  \ifnumequal{\value{cbx@tempcntd}}{0}{%
    \defcounter{cbx@tempcntc}{\value{instcount}}%
    \loop\ifnum\value{cbx@tempcntc}>0
      \ifsamepage{\value{instcount}}{\value{cbx@tempcntc}}
        {\ifcsundef{blx@fnpage@\number\numexpr\value{cbx@tempcntc}}
           {\setcounter{cbx@tempcntd}{\value{cbx@tempcntc}}}{}%
         \stepcounter{cbx@tempcntc}}
        {\setcounter{cbx@tempcntc}{0}}%
    \repeat}{}}%
\csnumgdef{cbx@instcount@\cbx@key}{\value{instcount}}}
\let\cbx@savelist\@empty
\newcounter{cbx@tempcntc}
\newcounter{cbx@tempcntd}
\setcounter{cbx@tempcntd}{0}

\newrobustcmd*{\cbx@superscript}[1]{%
\global\toggletrue{cbx@sfcite}
\mkbibsuperscript{#1}%
\cbx@footnote%
\global\togglefalse{cbx@sfcite}}
\newtoggle{cbx@sfcite}

\AtEveryCitekey{%
\ifciteseen{}{\csnumgdef{cbx@instcount@\thefield{entrykey}}{-1}}%
\iftoggle{cbx@sfcite}{}{\cbx@footnote}}
\AtEveryBibitem{\cbx@footnote}
\AtEveryLositem{\cbx@footnote}

% defer citation footnotes to last inline reference instance on page
\newrobustcmd*{\cbx@footnote}{%
\ifboolexpr{ not test {\ifdefempty{\cbx@savelist}}
             and test {\ifnumequal{\value{instcount}}{\value{cbx@tempcntd}}} }
  {\cbx@sortlist@init%
   \let\do\cbx@do
   \dolistloop{\cbx@sortlist}%
   \global\let\cbx@savelist\@empty
   \setcounter{cbx@tempcntd}{0}}{}}

% print footnotes in 'sorting' order
\def\cbx@do#1{%
\ifinlist{#1}{\cbx@savelist}
  {\begingroup
   \blx@resetdata
   \blx@getdata@cite{#1}%
   \blx@setoptions@type\abx@field@entrytype
   \blx@setoptions@entry
   \blx@execute
   \blx@beglang
   \iffieldundef{shorthand}
     {\gdef\@thefnmark{\printfield{labelprefix}\printfield{labelnumber}}}
     {\gdef\@thefnmark{\printfield{shorthand}}}%
   \gappto\@thefnmark{\blx@initunit}%
   \ifhyperref
     {\H@@footnotetext{\blx@driver\abx@field@entrytype}}
     {\@footnotetext{\blx@driver\abx@field@entrytype}}%
   \blx@endlang
   \endgroup}
  {}}

% access internal list of sorted entry keys
\def\cbx@sortlist@init{%
\global\letcs{\cbx@sortlist}
  {blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}}
\let\cbx@sortlist\@empty

\makeatother

\addbibresource{test.bib}
\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
\begin{document}
New citation.\sfcite{article:1}. Another cites\sfcite{article:2}
\newrefcontext[labelprefix=P]
\printbibliography[keyword=own]
\newrefcontext[labelprefix=]
\printbibliography[notkeyword=own]
\end{document}

That's the output:

enter image description here

1 Answer 1

1

The code is missing the initialisation of the refcontext with \blx@getrefcontext{#1}.

You need to change the definition of \cbx@do to

\def\cbx@do#1{%
  \ifinlist{#1}{\cbx@savelist}
    {\begingroup
     \blx@resetdata
     \blx@getrefcontext{#1}%
     \blx@getdata@cite{#1}%
     \blx@setoptions@type\abx@field@entrytype
     \blx@setoptions@entry
     \blx@execute
     \blx@beglang
     \iffieldundef{shorthand}
       {\gdef\@thefnmark{\printfield{labelprefix}\printfield{labelnumber}}}
       {\gdef\@thefnmark{\printfield{shorthand}}}%
     \gappto\@thefnmark{\blx@initunit}%
     \ifhyperref
       {\H@@footnotetext{\blx@driver\abx@field@entrytype}}
       {\@footnotetext{\blx@driver\abx@field@entrytype}}%
     \blx@endlang
     \endgroup}
    {}}
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .