Trích dẫn bằng En Dash
Đôi khi tôi cần viết công cụ ước lượng của Newey – West (1987) hơn là công cụ ước lượng của Newey và West (1987) như sau.
\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}
Bằng cách này, tôi có thể trích dẫn một bài báo có tên tác giả được kết nối qua dấu gạch ngang không?
Trả lời
Nếu kiểu thư mục của bạn hỗ trợ dấu phân cách tên có thể tùy chỉnh, thì việc này sẽ dễ dàng như thay đổi cục bộ dấu phân cách này. Thật không may, không phải tất cả .bstcác tệp đều hỗ trợ dấu phân cách tên có thể tùy chỉnh, nhiều tệp chỉ viết mã cứng là "và".
Bước 1 là apalikesử dụng dấu phân cách có thể tùy chỉnh trong các trích dẫn. Kết thúc này
Xác định vị trí
apalike.bsttrên máy của bạn. Bạn có thể làm điều này bằng cách nhậpkpsewhich apalike.bstvào dòng lệnh / thiết bị đầu cuối. Ngoài ra, hãy lấy một bản sao của tệp từ CTANhttp://mirrors.ctan.org/biblio/bibtex/base/apalike.bstSao chép tệp vào vị trí mà TeX có thể tìm thấy. Thư mục tài liệu sẽ hoạt động tốt. Xem thêmhttps://texfaq.org/FAQ-inst-wlcf
Đổi tên tệp thành
apalike-namedelim.bst, chẳng hạn (giấy phépapalike.bstyêu cầu bạn thay đổi tên nếu bạn sửa đổi tệp)Tìm
FUNCTION {format.lab.names}(ll. 841-587) và thay thế định nghĩa hàm hoàn chỉnh bằngFUNCTION {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$ }Thêm nhận xét với tên của bạn, ngày hiện tại và mô tả ngắn gọn về những thay đổi ở đầu tệp.
Sử dụng
\bibliographystyle{apalike-namedelim}thay vì\bibliographystyle{apalike}trong tài liệu của bạn.
Để thay thế cho các bước từ 1 đến 5, bạn có thể tải xuống phiên bản đã vá của tệp tại https://gist.github.com/moewew/1808df0569958a79ce5058b133495260
Bước 2 là sử dụng macro có thể tùy chỉnh trong các lệnh mới mà chúng tôi xác định cho mục đích trích dẫn bằng dấu gạch ngang. Chúng tôi chỉ sao chép các định nghĩa của \citetvà \citeauthortừ natbib.styvà chèn một số mã để thay đổi \finalnamedelim.
\documentclass{article}
\usepackage{natbib}
\bibliographystyle{apalike-namedelim}
\newcommand*{\finalnamedelim}{}
\DeclareRobustCommand*{\finalnamedelim}{ and }
\makeatletter
\newcommand*{\citetattr}{}
\DeclareRobustCommand\citetattr
{\begingroup
\DeclareRobustCommand*{\finalnamedelim}{--}%
\NAT@swafalse\let\NAT@ctype\z@\NAT@partrue
\@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}}
\newcommand*{\citeauthorattr}{}
\DeclareRobustCommand\citeauthorattr
{\begingroup
\DeclareRobustCommand*{\finalnamedelim}{--}%
\NAT@swafalse\let\NAT@ctype\@ne\NAT@parfalse
\@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}}
\newcommand*{\Citetattr}{}
\DeclareRobustCommand\Citetattr
{\begingroup
\DeclareRobustCommand*{\finalnamedelim}{--}%
\NAT@swafalse\let\NAT@ctype\z@\NAT@partrue
\let\NAT@up\NAT@Up
\@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@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}
Những thứ này đơn giản hơn một chút 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}
Vì bạn sử dụng natbibgói quản lý trích dẫn, bạn có thể sử dụng gói \defcitealiasvà \citetaliasmacro của nó để đạt được mục tiêu định dạng của mình.
\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}
\setlength\parindent{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}