我喜欢用此处显示的代码在每个页面中将排序的引用显示为脚注。除非您使用两个不同的参考书目,否则代码可以正常工作。在下面显示的示例中(相同代码如上链接+ 参考书目文件 + 定义了两个参考书目),第一个参考文献在文本中显示为 P1,但在脚注中显示为 0。可以修复此问题吗?任何帮助都将不胜感激...
\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}
这就是输出:
答案1
代码缺少对 refcontext 的初始化\blx@getrefcontext{#1}
。
\cbx@do
您需要将的定义更改为
\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}
{}}