我正在尝试类似的事情:Biblatex 脚注到页边距 在某种程度上我可以窃取他们的榜样。
我想要做的是,通常在正文中引用文本,然后在侧边栏中使用作者姓名,然后是日期,然后是作品名称。
出于此 MWE 的目的,我仅使用基本 latex \marginpar
。 (在实际工作中,我使用的是 Koma scrnote-layer 材料。但这并不重要,因为我正在尝试理解 BibLaTeX)
梅威瑟:
\documentclass{article}
\usepackage{blindtext}
% bib-file
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = {1986},
title = {The \TeX book},
}
@BOOK{KandR,
AUTHOR = {Kernighan, Brian W. and Ritchie, Dennis M.},
TITLE = {{The C Programming Language Second Edition}},
PUBLISHER = {Prentice-Hall, Inc.},
YEAR = {1988},
}
\end{filecontents}
\usepackage[]{biblatex}
\addbibresource{\jobname}
\newcommand{\tcite}[1]{
\textcite{#1}
\marginpar{
\citeauthor{#1},
\citeyear{#1}.
\citetitle{#1}
}
}
% doc
\begin{document}
\blindtext
\tcite{Knu86}
\blindtext
\tcite{Knu86,KandR}
\blindtext
\end{document}
可以看出,蓝色圆圈内的文本是完美的。但红色圆圈内的文本是错误的,因为它是按字段排序的。原因当然很明显。我的命令不是按每个键进行处理,而是将所有键一起处理。
我当前的命令是:
\newcommand{\tcite}[1]{
\textcite{#1}
\marginpar{
\citeauthor{#1},
\citeyear{#1}.
\citetitle{#1}
}
}
我认为我想用 BibLaTeX 制作的东西来代替它\DeclareCiteCommand
因此我尝试了一下:
\DeclareCiteCommand{\tcite}
{ % prenote
\usebibmacro{prenote}%
}
{ %loopcode
\printnames{author}%
\marginpar{
\printnames{author},
\printfield{year}.
\printfield{title}
}
}
{ %sepcode
\multicitedelim%
}
{\usebibmacro{postnote}}
这有效,我们可以看到蓝色圆圈和红色圆圈都是分开的。但我并没有从作者姓名的样式中受益(例如,根据我的设置,仅缩写为姓氏)。而且由于我没有使用,\textcite
而只是放入printnames{author}
,所以我也没有从那里的任何样式中受益。
这是(我猜)因为我已经使用了低级命令来完成这些事情。我如何使用尊重样式/配置的高级命令
答案1
\citeauthor
您不应使用之 类的高级命令\DeclareCiteCommand
。使用 可以做到这一点\citeauthor{\thefield{entrykey}}
,但这不是一个好主意。
相反,只需使用用于\citeauthor
\newbibmacro{sidecite}{%
\printnames{labelname}%
\setunit{\printdelim{nametitledelim}}%
\printfield[citetitle]{labeltitle}%
\setunit{\addperiod\space}%
\printfield{year}}
因为在您的示例中您想要重新创建\textcite
,numeric
所以我选择了。
\documentclass{article}
\usepackage{blindtext}
% bib-file
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = {1986},
title = {The \TeX book},
}
@BOOK{KandR,
AUTHOR = {Kernighan, Brian W. and Ritchie, Dennis M.},
TITLE = {{The C Programming Language Second Edition}},
PUBLISHER = {Prentice-Hall, Inc.},
YEAR = {1988},
}
\end{filecontents}
\usepackage[]{biblatex}
\newbibmacro{sidecite}{%
\printnames{labelname}%
\setunit{\printdelim{nametitledelim}}%
\printfield[citetitle]{labeltitle}%
\setunit{\addperiod\space}%
\printfield{year}}
\makeatletter
\DeclareCiteCommand{\cbx@textcite}
{\usebibmacro{textcite:init}}
{\usebibmacro{citeindex}%
\usebibmacro{textcite}%
\setunit{}%
\marginpar{\usebibmacro{sidecite}}%
\setunit{%
\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}%
\textcitedelim}}
{}
{\usebibmacro{textcite:postnote}}
\makeatother
\addbibresource{\jobname.bib}
% doc
\begin{document}
\blindtext
\textcite{Knu86}
\blindtext
\textcite{Knu86,KandR}
\blindtext
\end{document}
事情authoryear
变得更容易
\documentclass{article}
\usepackage{blindtext}
% bib-file
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = {1986},
title = {The \TeX book},
}
@BOOK{KandR,
AUTHOR = {Kernighan, Brian W. and Ritchie, Dennis M.},
TITLE = {{The C Programming Language Second Edition}},
PUBLISHER = {Prentice-Hall, Inc.},
YEAR = {1988},
}
\end{filecontents}
\usepackage[style=authoryear]{biblatex}
\newbibmacro{sidecite}{%
\printnames{labelname}%
\setunit{\printdelim{nametitledelim}}%
\printfield[citetitle]{labeltitle}%
\setunit{\addperiod\space}%
\printfield{year}}
\DeclareCiteCommand{\tcite}
{\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}%
\marginpar{\usebibmacro{sidecite}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\addbibresource{\jobname.bib}
% doc
\begin{document}
\blindtext
\tcite{Knu86}
\blindtext
\tcite{Knu86,KandR}
\blindtext
\end{document}
答案2
\usebibmacro{<macroname>}
允许您在 中调用 bib-macro DeclareCiteCommand
。但是,它不允许您调用使用DeclareCiteCommand
so no本身定义的内容\usebibmacro{citeauthor}
。
因此新的代码可能是:
\DeclareCiteCommand{\tcite}%
{\usebibmacro{prenote}}% prenote
{ %loopcode
\usebibmacro{cite}%
\marginpar{\usebibmacro{cite}, \printfield{title} \\
}
}
{\multicitedelim}% sepcode
{\usebibmacro{postnote}}
运行此程序,并在 biblatex 中设置更有趣的引用样式:
\usepackage[citestyle=authoryear]{biblatex}
得到: