有关 DeclareCiteCommand 的附加参数的帮助

有关 DeclareCiteCommand 的附加参数的帮助

我使用自定义引用命令cite,该命令将引用放在页脚中。问题是,使用此引用命令无法引用页面或部分。
示例:\cite[p. 12]{somebibref}忽略可选参数。
引用应放在括号中,如下所示:...Lorem explains [1, p.12]... 这是我得到的代码片段,但我不知道如何修改它以达到我的目的。

我需要修改什么才能仅在文本中的引用中添加附加参数而不是在页脚中?

\makeatletter

\newtoggle{cbx@togcite}

% remove doi, eprint and url from footnote
%\renewbibmacro*{doi+eprint+url}{}%

% Citation number superscript in brackets
\renewcommand\@makefntext[1]{%
  \iftoggle{cbx@togcite}
    {\@textsuperscript{\normalfont[\@thefnmark]}\enspace #1}
    {\@textsuperscript{\normalfont\@thefnmark}\enspace #1}%
  \global\togglefalse{cbx@togcite}}

\renewcommand\@makefntext[1]{%
  \iftoggle{cbx@togcite}
    {\normalfont[\@thefnmark]\enspace #1}
    {\normalfont\@thefnmark\enspace #1}%
  \global\togglefalse{cbx@togcite}}

\DeclareCiteCommand{\cite}[\cbx@superscript]%
  {\usebibmacro{cite:init}%
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}}
  {\usebibmacro{citeindex}%
   \usebibmacro{sfcite}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}}

\newbibmacro*{sfcite}{%
  \ifciteseen
  {}
  {\xappto\cbx@citehook{%
   \global\toggletrue{cbx@togcite}%
   \noexpand\footnotetextA[\thefield{labelnumber}]{%
     \fullcite{\thefield{entrykey}}\addperiod}}}}

\newrobustcmd{\cbx@superscript}[1]{%
  %\mkbibsuperscript{\mkbibbrackets{#1}}%
  \mkbibbrackets{#1}%
  \cbx@citehook%
  \global\let\cbx@citehook=\empty}

\let\cbx@citehook=\empty

\endinput

答案1

由于您实际上并没有在这里实现“超级引用”,而是实现了普通的括号引用,您可以尝试

\DeclareCiteCommand{\cite}[\cbx@superscript]%
  {\usebibmacro{prenote}%
   \usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{sfcite}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}}

尽管我认为整个事情可以做得更容易。


我相信你可以得到同样的东西(当使用时numeric-comp

\makeatletter
\renewbibmacro*{cite:comp}{%
  \addtocounter{cbx@tempcntb}{1}%
  \ifciteseen
    {}
    {\renewcommand{\@makefntext}[1]{\noindent\normalfont##1}%
     \footnotetext{%
       \printtext[labelnumberwidth]{%
         \printfield{prefixnumber}%
         \printfield{labelnumber}}%
       \addspace
       \bibfootnotewrapper{\fullcite{\thefield{entrykey}}}}}%
  \iffieldundef{shorthand}
    {\ifbool{bbx:subentry}
       {\iffieldundef{entrysetcount}
          {\usebibmacro{cite:comp:comp}}
          {\usebibmacro{cite:comp:inset}}}
       {\usebibmacro{cite:comp:comp}}}
    {\usebibmacro{cite:comp:shand}}}
\makeatletter

无需您进行任何修改。

平均能量损失

\documentclass{article}

\usepackage[%
    backend=biber,
    style=numeric-comp,
    citetracker=true,
    ]{biblatex}

\makeatletter
\renewbibmacro*{cite:comp}{%
  \addtocounter{cbx@tempcntb}{1}%
  \ifciteseen
    {}
    {\renewcommand{\@makefntext}[1]{\noindent\normalfont##1}%
     \footnotetext{%
       \printtext[labelnumberwidth]{%
         \printfield{prefixnumber}%
         \printfield{labelnumber}}%
       \addspace
       \bibfootnotewrapper{\fullcite{\thefield{entrykey}}}}}%
  \iffieldundef{shorthand}
    {\ifbool{bbx:subentry}
       {\iffieldundef{entrysetcount}
          {\usebibmacro{cite:comp:comp}}
          {\usebibmacro{cite:comp:inset}}}
       {\usebibmacro{cite:comp:comp}}}
    {\usebibmacro{cite:comp:shand}}}
\makeatletter

\addbibresource{biblatex-examples.bib}


\begin{document}
\cite[1]{sigfridsson,wilde} and \cite[2]{sigfridsson} and \cite[3]{worman} and \cite[4]{geer}

Lorem\footnote{Duizend}

\printbibliography
\end{document}

在此处输入图片描述

相关内容