根据上下文,我可能更喜欢在同一文档中使用上标样式的引用(即a recent paper\cite{paper} said XYZ
--> 最近的一篇论文1说 XYZ)或作者年份样式的引用(即\citet{paper} said XYZ
--> John Smith (1990) 说 XYZ)。我该如何使用 来实现这一点natbib
?
我知道使用\usepackage[super]{natbib}
允许我在命令中使用上标引用\cite
。但这会导致\citet
命令打印“John Smith 1 said XYZ”而不是上面的内容,并导致\citep
命令打印“ 1 said XYZ”。
有没有什么方法可以让我有时使用上标样式的引用,有时使用作者年份样式的引用,使用natbib
界面/一些解决方法?
以下是一个简单的例子:
\documentclass[11pt]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage[super,comma]{natbib}
\bibliographystyle{plainnat} % most basic and widely used bibliography style
\begin{filecontents}{\jobname.bib}
@article{ref1,
author = {Smith, John},
journal = {Very Important Journal},
title = {Very Important Paper},
year = {2000}
}
@article{ref2,
author = {Smith, John},
journal = {Another Very Important Journal},
title = {Another Very Important Paper},
year = {2001}
}
\end{filecontents}
% Body
\begin{document}
Results from \citep{ref1} and \citet{ref2} imply XYZ\cite{ref1,ref2}.
\bibliography{\jobname}
\end{document}
产生
答案1
正如您所发现的,如果包super
的选项natbib
到位,\cite
和\citep
都会生成上标样式的数字引用标注,而\citet
会生成混合名称上标引用标注。
如果natbib
的super
选项有效,则命令\citename
和\citeyear
仍然可用。以下示例文档定义了宏\citeA
、、和以帮助您实现格式化需求。请注意\citeY
,我建议不要直接重新定义包的、和的行为。\citeAYp
\citeAYt
\cite
\citep
\citet
\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@article{ref1,
author = {Smith, John},
journal = {Very Important Journal},
title = {Very Important Paper},
year = {2000},
}
@article{ref2,
author = {Smith, John},
journal = {Another Important Journal},
title = {Another Important Paper},
year = {2001},
}
\end{filecontents}
\documentclass{article}
\bibliographystyle{plainnat}
\usepackage[super,comma]{natbib}
\newcommand\citeA[1]{\citeauthor{#1}}
\newcommand\citeY[1]{(\citeyear{#1})}
\newcommand\citeAYt[1]{\citeauthor{#1} (\citeyear{#1})}
\newcommand\citeAYp[1]{(\citeauthor{#1} \citeyear{#1})}
\begin{document}
\begin{tabular}{ll}
\verb+\cite+ & \cite{ref1}\\
\verb+\citep+ & \citep{ref2}\\
\verb+\citet+ & \citet{ref2}\\
\verb+\citeA+ & \citeA{ref1}\\
\verb+\citeY+ & \citeY{ref2}\\
\verb+\citeAYp+ & \citeAYp{ref2}\\
\verb+\citeAYt+ & \citeAYt{ref1}
\end{tabular}
\bibliography{mybib}
\end{document}