自定义书目样式

自定义书目样式

我引用了两篇论文,并想改变参考文献的风格,即改变一篇的风格而保持另一篇不变。

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

\begin{document}

 My citation \citep{desmet2015geography}

 another citation \citep{roberts2012evaluating}

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

\end{document}

参考书目文件(citation.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 之间传递的唯一信息是引用键。因此,如果您想区分应该使用“and”的条目和应该使用“&”的条目,那么似乎应该使用引用键传递此信息。所以这是我的解决方案。

  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。不同之处在于(用第二行替换第一行。):

l.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}

相关内容