我想
- 我的引用风格是脚注
Author (Year)
- 整个内容
Author (Year)
作为参考书目的超链接 - 重复引用
Ibid
到目前为止我几乎可以完成所有事情。
以下代码编译后会给出正确的超链接和正确的 ibidem,但引用是Author Year
(没有括号)。如果我将每个代码更改autocite
为,footcite
我会得到正确的超链接和正确的引用,但 ibidem 是错误的:Author (ibid.)
。
如果我做第一个autocite
,footcite
我得到预期的结果...但这意味着我必须跟踪autocite
和footcite
,这违背了自动同上的目的。
\documentclass{article}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,style=authoryear-ibid,ibidtracker=constrict, autocite=footnote]{biblatex}
\DeclareFieldFormat{citehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{#1}}
\DeclareFieldFormat{textcitehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{%
#1%
\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}}}
\savebibmacro{cite}
\savebibmacro{textcite}
\renewbibmacro*{cite}{%
\printtext[citehyperref]{%
\restorebibmacro{cite}%
\usebibmacro{cite}}}
\renewbibmacro*{textcite}{%
\ifboolexpr{
( not test {\iffieldundef{prenote}} and
test {\ifnumequal{\value{citecount}}{1}} )
or
( not test {\iffieldundef{postnote}} and
test {\ifnumequal{\value{citecount}}{\value{citetotal}}} )
}
{\DeclareFieldAlias{textcitehyperref}{noformat}}
{}%
\printtext[textcitehyperref]{%
\restorebibmacro{textcite}%
\usebibmacro{textcite}}}
% The following lines give the correct footcite Author (Year) but make the ibid erroneous
% Author (ibid)
\DeclareCiteCommand{\footcite}[\mkbibfootnote]
{\boolfalse{cbx:parens}}
{\usebibmacro{citeindex}%
\iffirstcitekey
{\setcounter{textcitetotal}{1}}
{\stepcounter{textcitetotal}%
\textcitedelim}%
\usebibmacro{textcite}}
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}}
{\usebibmacro{textcite:postnote}}
\begin{filecontents}{\jobname.bib}
@book{Chomsky1986,
Address = {Cambridge Mass.},
Author = {Noam Chomsky},
Publisher = {{MIT} Press},
Title = {Barriers},
Year = {1986}}
@book{Chomsky1981,
Address = {Dordrecht},
Author = {Noam Chomsky},
Publisher = {Foris Publications},
Title = {Lectures on Government and Binding},
Year = {1981}}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\section{}
% switching between \autocite and \footcite solves some problems but
% exposes others
\autocite{Chomsky1981} and \autocite{Chomsky1981}
\printbibliography
\end{document}
答案1
我们可以重新定义普通cite
宏,将年份括在括号中,为了避免与其他引用命令出现问题,我们为更改后的宏选择了一个新名称cite:paren:labelyear+extrayear
\renewbibmacro*{cite}{\printtext[citehyperref]{%
\global\boolfalse{cbx:loccit}%
\iffieldundef{shorthand}
{\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
{\usebibmacro{cite:ibid}}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\addspace}}
{\printnames{labelname}%
\setunit{\nameyeardelim}}%
\usebibmacro{cite:paren:labelyear+extrayear}}}
{\usebibmacro{cite:shorthand}}}}
\renewbibmacro*{cite:paren:labelyear+extrayear}{%
\iffieldundef{labelyear}
{}
{\printtext[parens]{%
\printfield{labelyear}%
\printfield{extrayear}}}}
无需更改\footcite
命令
平均能量损失
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,style=authoryear-ibid,ibidtracker=constrict, autocite=footnote]{biblatex}
\usepackage{hyperref}
\DeclareFieldFormat{citehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{#1}}
\renewbibmacro*{cite}{\printtext[citehyperref]{%
\global\boolfalse{cbx:loccit}%
\iffieldundef{shorthand}
{\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
{\usebibmacro{cite:ibid}}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\addspace}}
{\printnames{labelname}%
\setunit{\nameyeardelim}}%
\usebibmacro{cite:paren:labelyear+extrayear}}}
{\usebibmacro{cite:shorthand}}}}
\renewbibmacro*{cite:paren:labelyear+extrayear}{%
\iffieldundef{labelyear}
{}
{\printtext[parens]{%
\printfield{labelyear}%
\printfield{extrayear}}}}
\addbibresource{biblatex-examples.bib}
\begin{document}
Lorem \autocite{sigfridsson} ipsum\autocite{sigfridsson}. Dolor\autocite{knuth:ct:a,knuth:ct:b}.
\end{document}