TeX - LaTeX Asked on August 15, 2021
Sometimes I need to write a Newey–West (1987) estimator rather than Newey and West’s (1987) estimator as follows.
documentclass{article}
usepackage{filecontents,natbib}
begin{filecontents}{z.bib}
@article{newey1987simple,
title={A Simple, Positive Semi-Definite, Heteroskedasticity and Autocorrelation},
author={Newey, Whitney K and West, Kenneth D},
journal={Econometrica},
volume={55},
number={3},
pages={703--708},
year={1987}
}
end{filecontents}
bibliographystyle{apalike}
begin{document}
citeauthor{newey1987simple}'s citeyearpar{newey1987simple} estimator.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Newey--West (1987) estimator.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bibliography{z}
end{document}
In this way, can I cite a paper with author names connected via an en dash?
If your bibliography style supports a customisable name delimiter, then this would be as easy as locally changing this delimiter. Unfortunately, not all .bst
files support a customisable name delimiter, many just hard-code the "and".
Step 1 is to make apalike
use a customisable delimiter in citations. To this end
Locate apalike.bst
on your machine. You can do this by typing kpsewhich apalike.bst
into the command line/terminal. Alternatively, obtain a copy of the file from CTAN http://mirrors.ctan.org/biblio/bibtex/base/apalike.bst
Copy the file to a location where TeX can find it. The document directory will do fine. See also https://texfaq.org/FAQ-inst-wlcf
Rename the file to apalike-namedelim.bst
, say (the license of apalike.bst
requires you to change the name if you modify the file)
Find FUNCTION {format.lab.names}
(ll. 841-587) and replace the complete function definition with
FUNCTION {format.lab.names}
{ 's :=
s #1 "{vv~}{ll}" format.name$
s num.names$ duplicate$
#2 >
{ pop$ " et~al." * }
{ #2 <
'skip$
{ s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
{ " et~al." * }
{ "finalnamedelim " * s #2 "{vv~}{ll}" format.name$ * }
if$
}
if$
}
if$
}
Add a comment with your name, the current date and a short description of the changes to the top of the file.
Use bibliographystyle{apalike-namedelim}
instead of bibliographystyle{apalike}
in your document.
As alternative for steps 1 to 5 you can obtain the patched version of the file at https://gist.github.com/moewew/1808df0569958a79ce5058b133495260
Step 2 is to make use of the customisable macro in new commands that we define for the purpose of citing with en-dashes. We just copy the definitions of citet
and citeauthor
from natbib.sty
and inject some code to change finalnamedelim
.
documentclass{article}
usepackage{natbib}
bibliographystyle{apalike-namedelim}
newcommand*{finalnamedelim}{}
DeclareRobustCommand*{finalnamedelim}{ and }
makeatletter
newcommand*{citetattr}{}
DeclareRobustCommandcitetattr
{begingroup
DeclareRobustCommand*{finalnamedelim}{--}%
NAT@swafalseletNAT@ctypez@NAT@partrue
@ifstar{NAT@fulltrueNAT@citetp}{NAT@fullfalseNAT@citetp}}
newcommand*{citeauthorattr}{}
DeclareRobustCommandciteauthorattr
{begingroup
DeclareRobustCommand*{finalnamedelim}{--}%
NAT@swafalseletNAT@ctype@neNAT@parfalse
@ifstar{NAT@fulltrueNAT@citetp}{NAT@fullfalseNAT@citetp}}
newcommand*{Citetattr}{}
DeclareRobustCommandCitetattr
{begingroup
DeclareRobustCommand*{finalnamedelim}{--}%
NAT@swafalseletNAT@ctypez@NAT@partrue
letNAT@upNAT@Up
@ifstar{NAT@fulltrueNAT@citetp}{NAT@fullfalseNAT@citetp}}
makeatother
begin{filecontents}{jobname.bib}
@article{newey1987simple,
title = {A Simple, Positive Semi-Definite, Heteroskedasticity
and Autocorrelation Consistent Covariance Matrix},
author = {Newey, Whitney K. and West, Kenneth D.},
journal = {Econometrica},
volume = 55,
number = 3,
pages = {703--708},
year = 1987,
}
end{filecontents}
begin{document}
citeauthor{newey1987simple}'s citeyearpar{newey1987simple} estimator.
citetattr{newey1987simple} --- with citation alias
bibliography{jobname}
end{document}
These sort of things are a bit simpler with biblatex
.
documentclass[british]{article}
usepackage{babel}
usepackage{csquotes}
usepackage[style=authoryear]{biblatex}
newcommand*{textattrcite}{%
AtNextCite{AtEachCitekey{delimcontext{textattrcite}}}%
textcite}
DeclareDelimFormat[textattrcite]{multinamedelim}{textendash}
DeclareDelimAlias[textattrcite]{finalnamedelim}[textattrcite]{multinamedelim}
begin{filecontents}{jobname.bib}
@article{newey1987simple,
title = {A Simple, Positive Semi-Definite, Heteroskedasticity
and Autocorrelation Consistent Covariance Matrix},
author = {Newey, Whitney K. and West, Kenneth D.},
journal = {Econometrica},
volume = 55,
number = 3,
pages = {703--708},
year = 1987,
}
end{filecontents}
addbibresource{jobname.bib}
begin{document}
citeauthor{newey1987simple}'s parencite*{newey1987simple} estimator.
textattrcite{newey1987simple} --- with citation alias
printbibliography
end{document}
Correct answer by moewe on August 15, 2021
Since you employ the natbib
citation management package, you may employ its defcitealias
and citetalias
macros to achieve your formatting objective.
documentclass{article}
begin{filecontents}[overwrite]{z.bib}
@article{newey1987simple,
title ={A Simple, Positive Semi-Definite, Heteroskedasticity
and Autocorrelation Consistent Covariance Matrix},
author ={Newey, Whitney K. and West, Kenneth D.},
journal={Econometrica},
volume =55,
number =3,
pages ={703--708},
year =1987,
}
end{filecontents}
usepackage{natbib}
defcitealias{newey1987simple}{Newey--West (1987)}
bibliographystyle{apalike}
begin{document}
setlengthparindent{0pt} % just for this example
citeauthor{newey1987simple}'s citeyearpar{newey1987simple} estimator.
citetalias{newey1987simple} --- with citation alias
Newey--West (1987) --- brute force
bibliography{z}
end{document}
Answered by Mico on August 15, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP