有没有自动添加属格撇号的方法,或者“ ‘s“以作者的名字命名?
目前我使用:
\citeauthor{kuran1989}'s \citeyear{kuran1989}
但由于这种情况经常出现,我想知道是否有一个通用的解决方案。
答案1
如果您正在使用natbib
包,所有格引用命令的行为应该与文本引用命令非常相似\citet
。这可以通过更改\NAT@nmfmt
定义中的名称格式化命令来实现\citet
。这种方法的一个缺点是数字样式不适用,但您可以通过包\NAT@nmfmt
进行修补来使它们适用。(是数字样式用来打印文本引用标签的命令。)\NAT@test
etoolbox
\NAT@test
\documentclass{article}
\usepackage{natbib}
\usepackage[colorlinks]{hyperref}
\usepackage{etoolbox}
\makeatletter
% make numeric styles use name format
\patchcmd{\NAT@test}{\else \NAT@nm}{\else \NAT@nmfmt{\NAT@nm}}{}{}
% define \citepos just like \citet
\DeclareRobustCommand\citepos
{\begingroup
\let\NAT@nmfmt\NAT@posfmt% ...except with a different name format
\NAT@swafalse\let\NAT@ctype\z@\NAT@partrue
\@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}}
\let\NAT@orig@nmfmt\NAT@nmfmt
\def\NAT@posfmt#1{\NAT@orig@nmfmt{#1's}}
\makeatother
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{companion,
author = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
title = {The LaTeX Companion},
edition = {1},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
year = {1994}}
@book{adams:life,
title = {Life, the Universe and Everything},
author = {Adams, Douglas},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980}}
@book{adams:rest,
title = {The Restaurant at the End of the Universe},
author = {Douglas Adams},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980}}
\end{filecontents}
\newcommand{\cmd}[1]{\textbackslash\texttt{#1}}
\begin{document}
\noindent
Compact \cmd{citet}: \citet{adams:life,adams:rest} \\
Compact \cmd{citepos}: \citepos{adams:life,adams:rest} \\
\cmd{citet} with postnote: \citet[pp.~10--20]{companion} \\
\cmd{citepos} with postnote: \citepos[pp.~10--20]{companion} \\
\cmd{citepos*} with postnote: \citepos*[p.~10]{companion}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}
加载natbib
则\usepackage[numbers]{natbib}
得到:
在英语中,单数所有格名词通常通过添加“'s”来形成,即使名称以“s”结尾(例如“Adams's”)。如果所有格应该反映发音(即“Adams'”),您可以扩展\NAT@posfmt
使用xstring
包的定义。
...
\usepackage{xstring}
...
\makeatletter
...
\def\NAT@posfmt#1{%
\StrRemoveBraces{#1}[\NAT@temp]%
\IfEndWith{\NAT@temp}{s}
{\NAT@orig@nmfmt{#1'}}
{\NAT@orig@nmfmt{#1's}}}
\makeatother
...