自訂參考書目樣式

自訂參考書目樣式

我引用了兩篇論文,想改變參考書目的風格,也就是改變一篇論文的風格,另一篇則保持不變。

\documentclass[12pt,a4paper]{article}
\usepackage[round]{natbib}

\begin{document}

 My citation \citep{desmet2015geography}

 another citation \citep{roberts2012evaluating}

\medskip
\bibliographystyle{plainnat}
\bibliography{citation}

\end{document}

參考書目文件(引用.bib)

@article{roberts2012evaluating,
Author = {Roberts, Mark and Deichmann, Uwe and Fingleton, Bernard and Shi, Tuo},
Journal = {Regional Science and Urban Economics},
Number = {4},
Pages = {580--594},
Publisher = {Elsevier},
Title = {Evaluating China's road to prosperity: A new economic geography approach},
Volume = {42},
Year = {2012}}

@techreport{desmet2015geography,
Author = {Desmet, Klaus and Nagy, D{\'a}vid Kriszti{\'a}n and Rossi-Hansberg, Esteban},
Date-Added = {2016-09-03 13:29:14 +0000},
Date-Modified = {2016-09-03 13:29:14 +0000},
Institution = {National Bureau of Economic Research},
Title = {The geography of development: Evaluating migration restrictions and coastal flooding},
Year = {2015}}

IDE:Texpad 1.731

引擎:Xelatex、BibTex

迷你範例的編譯輸出: 在此輸入影像描述 期望的輸出: 在此輸入影像描述

答案1

在 LaTeX 和 BibTeX 之間傳遞的唯一訊息是引用鍵。因此,如果您想區分應該使用“和”的條目和應該使用“&”的條目,那麼您似乎應該使用引用鍵傳遞此資訊。所以這是我的解決方案。

  1. 應使用“&”的條目將獲得以“&”結尾的引用鍵。在上面的範例中,這是在參考書目文件中:

    @article{roberts2012evaluating&,
    Author = {Roberts, Mark and Deichmann, Uwe and Fingleton, Bernard and Shi, Tuo},
    Journal = {Regional Science and Urban Economics},
    Number = 4,
    Pages = {580--594},
    Publisher = {Elsevier},
    Title = {Evaluating {China}'s road to prosperity: A new economic geography approach},
    Volume = 42,
    Year = 2012}
    

引用命令變為

\citep{roberts2012evaluating&}

(有趣的是,裸露&是允許的。)

  1. 現在我們必須更改參考書目樣式以產生巨集\AND而不是“and”。所以我們複製plainnat.bst並命名它myplainnat.bst。區別是(將第一行替換為第二行。):

湖232 和 325

       { " and " * t * }
       { " \AND{} " * t * }

湖1111

    { " and " * s #2 "{vv~}{ll}" format.name$ * }
    { " \AND{} " * s #2 "{vv~}{ll}" format.name$ * }
  1. 現在用它\bibliographystyle{myplainnat}來代替plainnat那個。我們必須重寫\bibitem以檢查引用鍵是否以以下結尾&,然後定義\AND&如果是,and否則為。

所以這是改編後的 MWE:

\documentclass[12pt,a4paper]{article}
\usepackage[round]{natbib}
\usepackage{ifthen}
\newcommand\AND{and}
\let\origbibitem\bibitem
\renewcommand\bibitem[2][]{%
   \bibitemcheckkey{#2}\origbibitem[#1]{#2}}
\newcommand\bibitemcheckkey[1]{%
    \bibitemampcheck#1&\relax}
\def\bibitemampcheck#1&#2\relax{%
     \ifthenelse{\equal{#2}{&}}{\def\AND{\&}}{\def\AND{and}}}

\begin{document}

 My citation \citep{desmet2015geography}

 another citation \citep{roberts2012evaluating&}

\medskip
\bibliographystyle{myplainnat}
\bibliography{citation}

\end{document}

相關內容