Biblatex 加载为
\usepackage[style=numeric-comp,hyperref=true]{biblatex}
\ExecuteBibliographyOptions{citetracker=true,sorting=none,firstinits=true}
我正在寻找一个 if 命令,它可以执行与\ifciteseen
does 相同的工作,但仅适用于当前页面。
这个想法是测试当前页面上是否已经引用了某个来源,并根据结果更改引用。例如,如果我只想在第一次引用时生成脚注在当前页面上, 我可以
\ifciteseenONTHISPAGE
{% yes, do nothing
}
{% no, do smth
\noexpand\footnote[\thefield{labelnumber}]{%
\fullcite{\thefield{entrykey}}\addperiod}}}}
我知道\iffirstonpage
,\ifsamepage
但不知道他们是否可以提供任何帮助以及如何提供帮助。
答案1
计数器instcount
唯一地标识了参考书目/速记列表中的引文或条目。如果在同一页上找到由值和标识的两个引文/条目,则测试\ifsamepage{<inst1>}{<inst2>}{<true>}{<false>}
会扩展。<true>
instcount
<inst1>
<inst2>
在您的测试中,我们需要将当前值 ( \value{instcount}
) 与当前条目上次被引用时的值进行比较instcount
。通常,这不是instcount
上次引用的值(即\value{instcount}-1
)。据我所知,您必须使用instcount
一些附加代码来跟踪每个条目的最后一个值。
下面的例子演示了如何使用引用格式来实现这一点上一篇。它依赖于一些命令etoolbox
并需要额外的传递才能正确进行测试。
\documentclass{report}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[colorlinks]{hyperref}
\usepackage[style=numeric-comp,citetracker=true,pagetracker=true,sorting=none]{biblatex}
\makeatletter
%---------------------------------------------------------------
% Essentially verbatim from Joseph Wright (except for refinements to \ifciteseen test)
% http://www.texdev.net/2010/03/08/biblatex-numbered-citations-as-footnotes/
\DeclareCiteCommand{\superfootcite}[\cbx@superscript]
{\usebibmacro{cite:init}%
\let\multicitedelim=\supercitedelim
\iffieldundef{prenote}
{}
{\BibliographyWarning{Ignoring prenote argument}}%
\iffieldundef{postnote}
{}
{\BibliographyWarning{Ignoring postnote argument}}}
{\usebibmacro{citeindex}%
\usebibmacro{cite:superfoot}%
\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}}
\newbibmacro*{cite:superfoot}{%
\xdef\cbx@citekey{\thefield{entrykey}}%
\ifciteseen
{}
{\csnumgdef{cbx@instcount\cbx@citekey}{-100}}%
\ifsamepage{\value{instcount}}{\number\csuse{cbx@instcount\cbx@citekey}}
{}
{\xappto\cbx@citehook{%
\noexpand\footnotetext[\thefield{labelnumber}]{%
\fullcite{\thefield{entrykey}}\addperiod}}}%
\csnumgdef{cbx@instcount\cbx@citekey}{\value{instcount}}}
\newrobustcmd{\cbx@superscript}[1]{%
\mkbibsuperscript{#1}%
\cbx@citehook
\global\let\cbx@citehook=\empty}
\let\cbx@citehook=\empty
%---------------------------------------------------------------
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
\chapter{Title}
\null\vfill\noindent
First citation.\superfootcite{bertram}
First citation.\superfootcite{companion}
Some recurrent citations on same page.\superfootcite{bertram,companion,augustine}
\chapter{Title}
\null\vfill\noindent
Recurrent citation on different page.\superfootcite{companion}
Recurrent on different page and first citations.\superfootcite{augustine,cicero}
Recurrent citation on same page.\superfootcite{companion}
\printbibliography
\end{document}
以下是第一页的引用:
从第二个开始:
答案2
这是 Audrey 上述方法的稍微修改版本
\AtEveryCitekey{%
\ifcsundef{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}
{\csnumgdef{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}{0}}
{}%
\csnumgdef{cbx@instcount@last@\the\c@refsection @\thefield{entrykey}}{%
\csuse{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}}%
\csnumgdef{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}{\value{instcount}}}
\def\iflastciteonsamepage{%
\ifsamepage
{\number\csuse{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}}
{\number\csuse{cbx@instcount@last@\the\c@refsection @\thefield{entrykey}}}}
Where\iflastciteonsamepage
检查当前作品的最后一次引用是否在同一页面上(由 检测\ifsamepage
)。
请注意,此测试不能保证在所有情况下都有效,我已经针对一些(相对常见的)情况进行了测试,但在某些情况下,它可能会完全失效。感谢 Audrey 在评论中指出了这一点。
Audrey 的 MWE 则变为
\documentclass{report}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[colorlinks]{hyperref}
\usepackage[style=numeric-comp,citetracker=true,pagetracker=true,sorting=none]{biblatex}
\makeatletter
%---------------------------------------------------------------
% Essentially verbatim from Joseph Wright (except for refinements to \ifciteseen test)
% http://www.texdev.net/2010/03/08/biblatex-numbered-citations-as-footnotes/
\DeclareCiteCommand{\superfootcite}[\cbx@superscript]
{\usebibmacro{cite:init}%
\let\multicitedelim=\supercitedelim
\iffieldundef{prenote}
{}
{\BibliographyWarning{Ignoring prenote argument}}%
\iffieldundef{postnote}
{}
{\BibliographyWarning{Ignoring postnote argument}}}
{\usebibmacro{citeindex}%
\usebibmacro{cite:superfoot}%
\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}}
\AtEveryCitekey{%
\ifcsundef{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}
{\csnumgdef{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}{0}}
{}%
\csnumgdef{cbx@instcount@last@\the\c@refsection @\thefield{entrykey}}{%
\csuse{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}}%
\csnumgdef{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}{\value{instcount}}}
\def\iflastciteonsamepage{%
\ifsamepage
{\number\csuse{cbx@instcount@curr@\the\c@refsection @\thefield{entrykey}}}
{\number\csuse{cbx@instcount@last@\the\c@refsection @\thefield{entrykey}}}}
\newbibmacro*{cite:superfoot}{%
\iflastciteonsamepage
{}
{\xappto\cbx@citehook{%
\noexpand\footnotetext[\thefield{labelnumber}]{%
\fullcite{\thefield{entrykey}}\addperiod}}}}
\newrobustcmd{\cbx@superscript}[1]{%
\mkbibsuperscript{#1}%
\cbx@citehook
\global\let\cbx@citehook=\empty}
\let\cbx@citehook=\empty
%---------------------------------------------------------------
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
\chapter{Title}
\null\vfill\noindent
First citation.\superfootcite{bertram}
First citation.\superfootcite{companion}
Some recurrent citations on same page.\superfootcite{bertram,companion,augustine}
\chapter{Title}
\null\vfill\noindent
Recurrent citation on different page.\superfootcite{companion}
Recurrent on different page and first citations.\superfootcite{augustine,cicero}
Recurrent citation on same page.\superfootcite{companion}
\printbibliography
\end{document}
第一页
第二页
虽然这个版本在某些方面更加强大,但仍然不能保证在所有情况下都能正常工作。
答案3
您应该尝试(pagetracker
激活)类似这样的操作(当我以我的自定义风格使用它时,它可以工作):
\ifciteseen{%
\ifsamepage{\value{instcount}}{\value{instcount}-1}{Do nothing}
{Print the reference}}