我很高兴将 BibLaTeX (3.4) 和 Biber (2.5) 结合使用。
有一些技巧http://tex.stackexchange.com我已经获得了我想要的参考书目,但是在脚注引用方面存在问题。
我想要这样的结果: 但使用相同的命令用于第一和第二个脚注引用,以避免担心哪个是第一个引用。
请注意,我只希望在脚注中自动出现“ibidem”(我在这里找到: 仅在脚注中同上,而不在正文中如何做到这一点)并且我有一些带有 shortauthor 的 bib 项目。
以下是 MWE:
\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{verbatim}
\usepackage[british,english]{babel}
\usepackage{filecontents}
% package hyperref
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
{hyperref}
% ibidem only in footnotes
\makeatletter
\def\blx@opt@ibidtracker@foot{%
\let\blx@imc@ifciteibid\blx@ifciteibid@foot
\let\blx@ibidtracker\blx@ibidtracker@foot
\let\blx@ibidreset\blx@ibidreset@foot
\booltrue{citetracker}}
\def\blx@ifciteibid@foot{%
\ifbool{citetracker}
{\iftoggle{blx@footnote}
{\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}
{\@secondoftwo}}
{\@secondoftwo}}
\def\blx@ibidtracker@foot{%
\ifbool{citetracker}
{\iftoggle{blx@footnote}
{\global\let\blx@lastkey@text\abx@field@entrykey}
{\global\let\blx@lastkey@foot\abx@field@entrykey}}
{}}
\def\blx@ibidreset@foot{%
\iftoggle{blx@footnote}
{\global\undef\blx@lastkey@text}}
{}
\makeatother
% biblatex package
\usepackage[style=authoryear-icomp, natbib=true, backend=biber, hyperref=true, ibidtracker=foot, pagetracker=page]{biblatex}
\usepackage{csquotes}
\addbibresource{\jobname.bib}
% CITATION
% no comma in author (year)
\renewcommand{\nameyeardelim}{\addspace}
% unified hyperlink on author (year)
\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{postnote}} and
test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
}
{\DeclareFieldAlias{textcitehyperref}{noformat}}
{}%
\printtext[textcitehyperref]{%
\restorebibmacro{textcite}%
\usebibmacro{textcite}}}
% unified hyperlink on (author, year)
\DeclareCiteCommand{\citep}[\mkbibparens]
{\usebibmacro{cite:init}\usebibmacro{prenote}}
{\def\nameyeardelim{\addcomma\addspace}%
\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}%
\def\nameyeardelim{\addspace}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\begin{filecontents}{\jobname.bib}
@article{item,
title={Title A},
author={AuthorA, NameA},
year={2015}
}
@manual{shortitem,
title={Title C},
author={{Basel Committee on Banking Supervision}},
year={1988},
shortauthor = {BCBS}
}
\end{filecontents}
\begin{document}
First footnote citation when the bib item has only "author".\footnote{\citet{item} for first footnote citation when the bib item has only "author".} \\
Second footnote citation when the bib item has only "author".\footnote{\Cite{item} for second footnote citation when the bib item has only "author".}
First footnote citation when the bib item also has "shortauthor".\footnote{\citet{shortitem} for first footnote citation when the bib item also has "shortauthor".} \\
Second footnote citation when the bib item also has "shortauthor".\footnote{\Cite{shortitem} for second footnote citation when the bib item also has "shortauthor".} \\
\end{document}
编辑:
为了自己找到解决方案,我添加了这个命令(请不要笑):
\DeclareCiteCommand{\citet}
{\usebibmacro{cite:init}\usebibmacro{prenote}}
{\ifciteibid{\usebibmacro{cite}}{\usebibmacro{textcite}}}
{\multicitedelim}
{\usebibmacro{postnote}}
现在,如果我\Citet
对原始 MWE 的所有引用使用它,它可以起作用,但如果我尝试在引用中输入页码,则会出现错误:
! 包 biblatex 错误:括号或方括号不匹配。
查看新的 MWE:
\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{verbatim}
\usepackage[british,english]{babel}
\usepackage{filecontents}
% package hyperref
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
{hyperref}
% ibidem only in footnotes
\makeatletter
\def\blx@opt@ibidtracker@foot{%
\let\blx@imc@ifciteibid\blx@ifciteibid@foot
\let\blx@ibidtracker\blx@ibidtracker@foot
\let\blx@ibidreset\blx@ibidreset@foot
\booltrue{citetracker}}
\def\blx@ifciteibid@foot{%
\ifbool{citetracker}
{\iftoggle{blx@footnote}
{\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}
{\@secondoftwo}}
{\@secondoftwo}}
\def\blx@ibidtracker@foot{%
\ifbool{citetracker}
{\iftoggle{blx@footnote}
{\global\let\blx@lastkey@text\abx@field@entrykey}
{\global\let\blx@lastkey@foot\abx@field@entrykey}}
{}}
\def\blx@ibidreset@foot{%
\iftoggle{blx@footnote}
{\global\undef\blx@lastkey@text}}
{}
\makeatother
% biblatex package
\usepackage[style=authoryear-icomp, natbib=true, backend=biber, hyperref=true, ibidtracker=foot, pagetracker=page]{biblatex}
\usepackage{csquotes}
\addbibresource{\jobname.bib}
% CITATION
% no comma in author (year)
\renewcommand{\nameyeardelim}{\addspace}
% unified hyperlink on author (year)
\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{postnote}} and
test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
}
{\DeclareFieldAlias{textcitehyperref}{noformat}}
{}%
\printtext[textcitehyperref]{%
\restorebibmacro{textcite}%
\usebibmacro{textcite}}}
% unified hyperlink on (author, year)
\DeclareCiteCommand{\citep}[\mkbibparens]
{\usebibmacro{cite:init}\usebibmacro{prenote}}
{\def\nameyeardelim{\addcomma\addspace}%
\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}%
\def\nameyeardelim{\addspace}}}
{\multicitedelim}
{\usebibmacro{postnote}}
% My citet command
\DeclareCiteCommand{\citet}
{\usebibmacro{cite:init}\usebibmacro{prenote}}
{\ifciteibid{\usebibmacro{cite}}{\usebibmacro{textcite}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\begin{filecontents}{\jobname.bib}
@article{item,
title={Title A},
author={AuthorA, NameA},
year={2015}
}
@manual{shortitem,
title={Title C},
author={{Basel Committee on Banking Supervision}},
year={1988},
shortauthor = {BCBS}
}
\end{filecontents}
\begin{document}
First footnote citation when the bib item has only "author".\footnote{\Citet{item} for first footnote citation when the bib item has only "author".} \\
Second footnote citation when the bib item has only "author".\footnote{\Citet{item} for second footnote citation when the bib item has only "author".}
First footnote citation when the bib item also has "shortauthor".\footnote{\Citet{shortitem} for first footnote citation when the bib item also has "shortauthor".} \\
Second footnote citation when the bib item also has "shortauthor".\footnote{\Citet{shortitem} for second footnote citation when the bib item also has "shortauthor".} \\
Error with \citet[11]{item}.
\end{document}
答案1
最后我自己找到了解决方案。
authoryear
我删除了指向而不是的“统一超链接”的代码authoryear-icomp
,并且创建了自己的\citet
和\citep
命令。
以下是代码:
\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{verbatim}
\usepackage[british,english]{babel}
\usepackage{filecontents}
% package hyperref
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
{hyperref}
% ibidem only in footnotes
\makeatletter
\def\blx@opt@ibidtracker@foot{%
\let\blx@imc@ifciteibid\blx@ifciteibid@foot
\let\blx@ibidtracker\blx@ibidtracker@foot
\let\blx@ibidreset\blx@ibidreset@foot
\booltrue{citetracker}}
\def\blx@ifciteibid@foot{%
\ifbool{citetracker}
{\iftoggle{blx@footnote}
{\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}
{\@secondoftwo}}
{\@secondoftwo}}
\def\blx@ibidtracker@foot{%
\ifbool{citetracker}
{\iftoggle{blx@footnote}
{\global\let\blx@lastkey@text\abx@field@entrykey}
{\global\let\blx@lastkey@foot\abx@field@entrykey}}
{}}
\def\blx@ibidreset@foot{%
\iftoggle{blx@footnote}
{\global\undef\blx@lastkey@text}}
{}
\makeatother
% biblatex package
\usepackage[style=authoryear-icomp, natbib=true, backend=biber, hyperref=true, ibidtracker=foot, pagetracker=page]{biblatex}
\usepackage{csquotes}
\addbibresource{\jobname.bib}
% CITATION
% no comma in author (year)
\renewcommand{\nameyeardelim}{\addspace}
% semicolon as compcitedelim
\renewcommand{\compcitedelim}{;\addspace}
% my citet command
\DeclareCiteCommand{\citet}
{\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\ifciteibid%
{\usebibmacro{citeindex}\usebibmacro{cite}}%
{\usebibmacro{citeindex}\usebibmacro{textcite}}}
{}
{\usebibmacro{textcite:postnote}}
% my citep command
\DeclareCiteCommand{\citep}[\mkbibparens]
{\usebibmacro{cite:init}\usebibmacro{prenote}}
{\def\nameyeardelim{\addcomma\addspace}%
\usebibmacro{citeindex}%
\usebibmacro{cite}}
{}
{\usebibmacro{cite:postnote}}
\begin{filecontents}{\jobname.bib}
@article{itemA,
title={Title A},
author={AuthorA, NameA},
year={2015}
}
@article{itemB,
title={Title B},
author={AuthorA, NameA},
year={2015}
}
@article{itemC,
title={Title C},
author={AuthorA, NameA},
year={2016}
}
@manual{shortitemA,
title={Title A},
author={{Basel Committee on Banking Supervision}},
year={1988},
shortauthor = {BCBS}
}
@manual{shortitemB,
title={Title B},
author={{Basel Committee on Banking Supervision}},
year={1988},
shortauthor = {BCBS}
}
@manual{shortitemC,
title={Title C},
author={{Basel Committee on Banking Supervision}},
year={2006},
shortauthor = {BCBS}
}
\end{filecontents}
\begin{document}
Now footnotes work as I like:\\
Author: first\footnote{\Citet{itemA} first footnote citation} and second\footnote{\Citet{itemA} second footnote citation} footnote\\
Shortauthor: first\footnote{\Citet{shortitemA} first footnote citation} and second\footnote{\Citet{shortitemA} second footnote citation} footnote\\
And also all the rest works:\\
With author:\\
\verb|\citet| normal: \citet{itemA} \\
\verb|\citet| with page: \citet[1]{itemA}\\
\verb|\citet| multicite: \citet{itemA, itemB, itemC} \\
\verb|\citep| normal: \citep{itemA}\\
\verb|\citep| with page: \citep[1]{itemA}\\
\verb|\citep| multicite: \citep{itemA, itemB, itemC}\\
With shortauthor:\\
\verb|\citet| normal: \citet{shortitemA} \\
\verb|\citet| with page: \citet[1]{shortitemA}\\
\verb|\citet| multicite: \citet{shortitemA, shortitemB, shortitemC}\\
\verb|\citep| normal: \citep{shortitemA}\\
\verb|\citep| with page: \citep[1]{shortitemA}\\
\verb|\citep| multicite: \citep{shortitemA, shortitemB, shortitemC}
\newpage
Also footnotes with \verb|\citep| works as I like:\\
Author: first\footnote{First footnote citation \citep{itemA} } and second\footnote{Second footnote citation \citep{itemA}} footnote\\
Shortauthor: first\footnote{First footnote citation \Citep{shortitemA}} and second\footnote{Second footnote citation \citep{shortitemA}} footnote
\end{document}