อ้างกับ En Dash

Oct 31 2020

บางครั้งฉันจำเป็นต้องเขียนตัวประมาณค่า Newey – West (1987)แทนตัวประมาณค่าของNewey และ West (1987)ดังนี้

\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}

ด้วยวิธีนี้ฉันสามารถอ้างถึงกระดาษที่มีชื่อผู้แต่งเชื่อมต่อผ่าน en dash ได้หรือไม่?

คำตอบ

3 moewe Oct 31 2020 at 18:54

หากรูปแบบบรรณานุกรมของคุณรองรับตัวคั่นชื่อที่ปรับแต่งได้สิ่งนี้จะง่ายพอ ๆ กับการเปลี่ยนตัวคั่นนี้ น่าเสียดายที่ไม่ใช่ทุก.bstไฟล์ที่รองรับตัวคั่นชื่อที่ปรับแต่งได้ แต่ส่วนมากจะเข้ารหัสเฉพาะ "และ" เท่านั้น

ขั้นตอนที่ 1 คือการapalikeใช้ตัวคั่นที่ปรับแต่งได้ในการอ้างอิง ด้วยเหตุนี้

  1. ค้นหาapalike.bstบนเครื่องของคุณ คุณสามารถทำได้โดยพิมพ์kpsewhich apalike.bstลงในบรรทัดคำสั่ง / เทอร์มินัล หรือรับสำเนาของไฟล์จาก CTANhttp://mirrors.ctan.org/biblio/bibtex/base/apalike.bst

  2. คัดลอกไฟล์ไปยังตำแหน่งที่ TeX สามารถค้นหาได้ ไดเร็กทอรีเอกสารจะทำได้ดี ดูสิ่งนี้ด้วยhttps://texfaq.org/FAQ-inst-wlcf

  3. เปลี่ยนชื่อไฟล์เป็นapalike-namedelim.bstพูด (สิทธิ์การapalike.bstใช้งานกำหนดให้คุณเปลี่ยนชื่อหากคุณแก้ไขไฟล์)

  4. ค้นหาFUNCTION {format.lab.names}(ล. 841-587) และแทนที่นิยามฟังก์ชันทั้งหมดด้วย

     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$
     }
    
  5. เพิ่มความคิดเห็นพร้อมชื่อของคุณวันที่ปัจจุบันและคำอธิบายสั้น ๆ ของการเปลี่ยนแปลงที่ด้านบนของไฟล์

  6. ใช้\bibliographystyle{apalike-namedelim}แทน\bibliographystyle{apalike}ในเอกสารของคุณ

อีกทางเลือกหนึ่งสำหรับขั้นตอนที่ 1 ถึง 5 คุณสามารถรับไฟล์เวอร์ชันแพตช์ได้ที่ https://gist.github.com/moewew/1808df0569958a79ce5058b133495260

ขั้นตอนที่ 2 คือการใช้ประโยชน์จากมาโครที่ปรับแต่งได้ในคำสั่งใหม่ที่เรากำหนดเพื่อจุดประสงค์ในการอ้างถึงด้วยเครื่องหมายขีดกลาง เราเพียงแค่คัดลอกคำจำกัดความของ\citetและ\citeauthorจากและฉีดรหัสบางอย่างเพื่อการเปลี่ยนแปลงnatbib.sty\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}


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}
2 Mico Oct 31 2020 at 18:25

เนื่องจากคุณใช้natbibแพ็คเกจการจัดการการอ้างอิงคุณอาจใช้มัน\defcitealiasและ\citetaliasมาโครเพื่อให้บรรลุวัตถุประสงค์ในการจัดรูปแบบของคุณ

\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}