我的代码有问题。我希望第二个代码\parencite
也包含作者姓名。
导致\DeclareCiteCommand
第一次引用后作者姓名消失
\documentclass{article}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Sutherland and Varnam},
year = {2001},
title = {Title},
}
\end{filecontents}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{\jobname.bib}
\DeclareCiteCommand{\parencite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\usepackage{hyperref}
\begin{document}
First cite \parencite{A01}.
Second cite \parencite{A01}.
\printbibliography
\end{document}
答案1
biblatex-apa
定义\parencite
与示例中的重新定义略有不同。该定义适用于某些标准样式,但不适用于更复杂的样式,如authoryear-icomp
和apa
。
因为apa
你需要
\documentclass{article}
\usepackage[style=apa,backend=biber]{biblatex}
\usepackage{hyperref}
\addbibresource{biblatex-examples.bib}
\DeclareFieldFormat{bibhyperrefnonest}{%
\DeclareFieldFormat{bibhyperref}{##1}%
\bibhyperref{#1}}
\DeclareCiteCommand{\parencite}[\mkbibparens]
{\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperrefnonest]{\usebibmacro{cite}}}
{}
{\usebibmacro{postnote}%
\usebibmacro{cite:post}}
\DeclareCiteCommand{\textcite}
{\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperrefnonest]{\usebibmacro{textcite}}}
{}
{\usebibmacro{textcite:postnote}%
\usebibmacro{cite:post}}
\begin{document}
First cite \parencite{sigfridsson}.
Second cite \parencite{sigfridsson}.
\citereset
First cite \textcite{sigfridsson}.
Second cite \textcite{sigfridsson}.
\printbibliography
\end{document}
编辑:还添加了 的重新定义\textcite
。请注意, 中的括号\textcite
可能未按预期链接。修复这个问题会复杂得多。
答案2
不确定是否仍然需要,但我尝试了以下内容,它似乎也包含右括号:
\DeclareCiteCommand{\textcite}
{\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{textcite}}}
{}
{\printtext[bibhyperref]{\usebibmacro{textcite:postnote}}%
\usebibmacro{cite:post}}
希望它能有所帮助,并且对于没有发布 MWE 表示歉意。