我是 LaTeX 新手,所以请多多包涵。我希望引用的格式如下:
e.g. "Bauer et al. (1988) [1]"
so "1st Author et al. (year of publishing) [number in references]".
因此,我希望既有编号的参考文献,也有包含第一作者姓名的引文
e.g. [1] David S. Bauer and Michael E. Koblentz. NIDX-an expert system ...
从下面的代码中你可以看到我使用了宏
\DeclareRobustCommand{\citeext}[1]{\citeauthor{#1}~\citeyearpar{#1}~\cite{#1}}
根据Wiki LaTex 书目管理 \citeauthor
(没有*
)\citeyearpar
应该可以按我预期的方式工作,但目前我得到的引用格式如下:
David S. Bauer and Michael E. Koblentz [1988] [2]
主要存在两个问题:
- 为什么出版年份用方括号而不是圆括号?
- 为什么要显示作者的全名,而不是只显示第一作者的名字(其他作者应该显示为“et al.”)?
梅威瑟:
\documentclass[11pt]{article}
\usepackage[sort&compress,numbers,square,comma,numbers]{natbib}
% makro by which I can cite both author and year simultaneously
% ~ - tilde represent space
\DeclareRobustCommand{\citeext}[1]{\citeauthor{#1}~\citeyearpar{#1}~\cite{#1}}
% what is #1 argument
% this is an macro and I see that citep and citet have troubles so better not use but what is citep vs. citeauthor?
% makes color citations
\usepackage[dvips,dvipdfm,colorlinks=true,urlcolor=blue,citecolor=red,linkcolor=red,bookmarks=true]{hyperref}
% document begin
\begin{document}
% author and title
\title{Work}
\author{Author1 \and Author2\v{C}\'y}
\date{\today}
%\ % this adds empty page to beginning
\maketitle
\pagebreak
%\newline
Bauer (IV.) citation \citeext{Bauer1988}. Anderson (I.) citation \citeext{Anderson1980}. Landwehr (II.) citation \citeext{Landwehr1981}. Denning (III.) citation \citeext{Denning1987}. \citeext{Anderson1981}
% this must be set to use natbib (citep, citet) but requires BibTeX
\bibliographystyle{plainnat}
\bibliography{bibliography}
\end{document}
PS:我的解决方案基于这篇文章:citet 和 citep 的行为类似于 cite。
答案1
最后我几乎是在发帖后立即就明白了:)
\DeclareRobustCommand{\citeext}[1]{\citeauthor{#1}~(\citeyear{#1})~\cite{#1}}
真是神奇。之前我尝试过一些 hacking\setcitestyle
但没有成功。还有一个问题:为什么所有作者的名字都显示在引文中?