如何使用 biblatex 使 footcite 看起来像 textcite?

如何使用 biblatex 使 footcite 看起来像 textcite?

\footcite\cite生成看起来像而不是 的格式化引文\textcite。如何使用biblatex使其\footcite看起来像?\textcite

我已经发现https://tex.stackexchange.com/a/458155/36836https://tex.stackexchange.com/a/426113/36836但这只会在年份周围添加括号(而不是页码)。 (它也只适用于ext-authoryear-icomp,但如果它没有其他有害的副作用,我可以使用它可以。)

同样https://tex.stackexchange.com/a/501320/36836。(但是,非ext-authoryear-icomp变体还在我的 s 的年份周围添加了奇怪的额外方括号\textcite。也许与我在文档中使用的另一个修改有某种相互作用。但我不确定。)

这是实际结果和期望结果:

\documentclass{article}
\usepackage[style=authoryear-icomp,autocite=footnote]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{A01,        
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
  journaltitle = {A Journal},
  volume = {1},
  number = {1},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
  location = {There},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
Current result \autocite[23]{A01}.

Wanted result.\footnote{\textcite[23]{B02}.}

\printbibliography
\end{document}

答案1

authoryear-icomp\textcite定义是标准 定义的最复杂的引用命令之一biblatex。它使用两遍结构来获得-comp正确的格式。这意味着它实际上是根据两个引用命令定义的:一个执行预处理,另一个执行实际格式化的内部命令。

幸运的是,可以将该设置从 移植\textcite\footcite\smartcite(即\autocite您的设置中的内容)。

如果您想要移动预注释的位置,则需要修改 bibmacrotextcite以使其不打印预注释并在 cite 命令的预编码中打印预注释。

\documentclass{article}
\usepackage[style=authoryear-icomp, autocite=footnote]{biblatex}

\makeatletter
% same as 'textcite' but does not print the prenote
\newbibmacro*{foottextcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldundef{shorthand}
       {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                    \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
          {\setunit{\addcomma}%
           \usebibmacro{cite:extradate}}
          {\setunit{\compcitedelim}%
           \usebibmacro{cite:labeldate+extradate}%
           \savefield{labelyear}{\cbx@lastyear}}}
       {\setunit{\compcitedelim}%
        \usebibmacro{cite:shorthand}%
        \global\undef\cbx@lastyear}}
    {\ifnameundef{labelname}
       {\iffieldundef{shorthand}
          {\usebibmacro{cite:label}%
           \setunit{%
             \global\booltrue{cbx:parens}%
             \printdelim{nonameyeardelim}\bibopenparen}%
           \ifnumequal{\value{citecount}}{1}
             {\usebibmacro{prenote}}
             {}%
           \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
             {\usebibmacro{cite:ibid}}
             {\usebibmacro{cite:labeldate+extradate}}}
          {\usebibmacro{cite:shorthand}}}
       {\printnames{labelname}%
        \setunit{%
          \global\booltrue{cbx:parens}%
          \printdelim{nameyeardelim}\bibopenparen}%
        \iffieldundef{shorthand}
          {\iffieldundef{labelyear}
             {\usebibmacro{cite:label}}
             {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
                {\usebibmacro{cite:ibid}}
                {\usebibmacro{cite:labeldate+extradate}}}%
           \savefield{labelyear}{\cbx@lastyear}}
          {\usebibmacro{cite:shorthand}%
           \global\undef\cbx@lastyear}}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textcitedelim}}


% \footcite
\DeclareCiteCommand{\cbx@footcite}[\mkbibfootnote]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{foottextcite}}
  {}
  {\usebibmacro{textcite:postnote}}

\DeclareDelimcontextAlias{cbx@footcite}{footcite}

\DeclareCiteCommand{\footcite}[\cbx@textcite@init\cbx@footcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite: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}}}

\DeclareMultiCiteCommand{\cbx@footcites}[\mkbibfootnote]{\cbx@footcite}{}
\DeclareMultiCiteCommand{\footcites}[\cbx@textcites@init\cbx@footcites]{\footcite}{}

% \footcitetext
\DeclareCiteCommand{\cbx@footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{foottextcite}}
  {}
  {\usebibmacro{textcite:postnote}}

\DeclareDelimcontextAlias{cbx@footcitetext}{footcite}

\DeclareCiteCommand{\footcitetext}[\cbx@textcite@init\cbx@footcitetext]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite: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}}}

\DeclareMultiCiteCommand{\cbx@footcitetexts}[\mkbibfootnotetext]{\cbx@footcitetext}{}
\DeclareMultiCiteCommand{\footcitetexts}[\cbx@textcites@init\cbx@footcitetexts]{\footcitetext}{}

% \smartcite (=\autocite in your setup)
\DeclareCiteCommand{\cbx@smartcite}[\iffootnote\mkbibparens\mkbibfootnote]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{foottextcite}}
  {}
  {\usebibmacro{textcite:postnote}}

\DeclareDelimcontextAlias{cbx@smartcite}{smartcite}

\DeclareCiteCommand{\smartcite}[\cbx@textcite@init\cbx@smartcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite: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}}}

\DeclareMultiCiteCommand{\cbx@smartcites}[\iffootnote\mkbibparens\mkbibfootnote]{\cbx@smartcite}{}
\DeclareMultiCiteCommand{\smartcites}[\cbx@textcites@init\cbx@smartcites]{\smartcite}{}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
Current result \autocite[See][380]{sigfridsson}.

Wanted result.\autocites[24-26]{nussbaum}[13]{geer}

\printbibliography
\end{document}

1 参见 Sigfridsson 和 Ryde (1998 年,第 380 页)。//2 Nussbaum (1978 年,第 24-26 页) 和 Geer (1985 年,第 13 页)。

相关内容