在 apalike2 参考书目样式中将 natbib 包和引文中的“&”替换为“and”

在 apalike2 参考书目样式中将 natbib 包和引文中的“&”替换为“and”

apalike2我正在尝试使用包中的样式将参考书目和引文中的“&”替换为“and” natbib。我尝试了 texstackexchange 上给出的许多解决方案,但无法成功获得所需的结果。我需要帮助将“&”更改为“and”。我的问题和期望的输出如下图所示:
问题描述和期望结果
以下是我的 MWE:

\documentclass[12pt,openany]{book}
\usepackage[ 
left=2.5cm,
right=2.5cm, 
top=3cm,
bottom=3cm,
headheight = 3\baselineskip,
headsep = 5mm,
a4paper
]{geometry}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\newcommand\HRule{\noindent\rule{\linewidth}{1.5pt}}
\usepackage{background}
\backgroundsetup{contents={}}
\usepackage{fancyhdr}
\usepackage{hhline}
\pagestyle{fancy}   

\usepackage{natbib}
\bibliographystyle{apalike2}
\usepackage{etoolbox}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    citecolor=red,      
    urlcolor=yellow,
}
\usepackage{showframe}
\begin{document} 
    
    \chapter*{Acknowledgements}
    I want this citation \cite{hapa:graphenum} to be \textcolor{red}{Harary and Palmer }\textcolor{black}{(\textcolor{red}{1973})}. I want this citation \cite{Knuth94:TheTeXbook} to be \textcolor{red}{Knuth }\textcolor{black}{(\textcolor{red}{1994})}.This text is quoted from \cite{datta2017latex} should be (\textcolor{red}{Datta\textcolor{black}{,} 2017}).
    \mainmatter
    \setcounter{tocdepth}{1}

    \chapter{Introduction}
    
    \backmatter
    
    \nocite{*}
    \bibliography{references}
    
\end{document}

以下是我的 references.bib 文件

@book{hapa:graphenum,
    author =     {F. Harary and E. M. Palmer},
    title =      {Graphical Enumeration},
    publisher =      {Academic Press},
    pages={465--523},
    year =   1973
}
@book{Knuth94:TheTeXbook,
    author =     {Knuth, Donald Ervin},
    title =      {The \TeX book},
    publisher =      {Addison-Wesley Publishing Company},
    pages={465--523},
    year =   1994,
    series =     {Computers \& Typesetting A},
    address =    {Reading, MA},
    titlenote  =        {with illustrations by Duane Bibby}
}
@book{datta2017latex,
    title={LaTeX in 24 Hours: A Practical Guide for Scientific Writing},
    author={Datta, Dilip},
    pages={465--523},
    year={2017},
    publisher={Springer}
}

答案1

APA 因在参考文献中使用 & 而出名。他们很不幸,我不希望这样。像商业公司那样制作作者名单的愿望的原因尚不清楚。

无论如何,如果你查看apalike2.bst你的 TeX 系统,你会发现三次出现\&

    297                 { " et~al." * }
    298                 { " \& " * t * }    % changed from " and " for names -- BJR 10/5/89
    299               if$

    329                 { " et~al." * }
    330                 { " \& " * t * }    % changed from " and " for names -- BJR 10/5/89
    331               if$

   1018             { " et~al." * }
   1019             { " \& " * s #2 "{vv~}{ll}" format.name$ * } % " and " --  BJR 10/5/89
   1020           if$

左侧的行号用于引用。你会看到原始版本中有“and”,但它在 1989 年被 & 取代了。

如何避免可怕的 &?首先,不要使用基于 APA 的样式。

如果你确实需要使用旧的 bib 样式(例如) ,请在工作目录中apalike2复制一份,并将其命名为。在副本中,将其替换为(保留所有空格)。apalike2.bstapalike2-and.bst\&and

变成\bibliographystyle{apalike2}

\bibliographystyle{apalike2-and}

运行 LaTeX、BibTeX、LaTeX 你就会得到“和”。

关于 Datta 的第三次标注应该是\citep{datta2017latex}

完整示例。

\begin{filecontents*}{\jobname.bib}
@book{hapa:graphenum,
    author =     {F. Harary and E. M. Palmer},
    title =      {Graphical Enumeration},
    publisher =      {Academic Press},
    pages={465--523},
    year =   1973
}
@book{Knuth94:TheTeXbook,
    author =     {Knuth, Donald Ervin},
    title =      {The \TeX book},
    publisher =      {Addison-Wesley Publishing Company},
    pages={465--523},
    year =   1994,
    series =     {Computers \& Typesetting A},
    address =    {Reading, MA},
    titlenote  =        {with illustrations by Duane Bibby}
}
@book{datta2017latex,
    title={LaTeX in 24 Hours: A Practical Guide for Scientific Writing},
    author={Datta, Dilip},
    pages={465--523},
    year={2017},
    publisher={Springer}
}
\end{filecontents*}

\documentclass[12pt,openany]{book}

\usepackage{natbib}

\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    citecolor=red,      
    urlcolor=yellow,
}

\begin{document} 
    
I want this citation \cite{hapa:graphenum} to be 
\textcolor{red}{Harary and Palmer }\textcolor{black}{(\textcolor{red}{1973})}. 
I want this citation \cite{Knuth94:TheTeXbook} to be 
\textcolor{red}{Knuth }\textcolor{black}{(\textcolor{red}{1994})}.
This text is quoted from \citep{datta2017latex} should be 
(\textcolor{red}{Datta\textcolor{black}{,} 2017}).

\nocite{*}

\bibliographystyle{apalike2-and}
\bibliography{\jobname}
    
\end{document}

在此处输入图片描述

在此处输入图片描述

笔记。我以前filecontents*只是让示例自成一体,并删除了所有不必要的包。当然,您可以保留您的前言和常规设置。

相关内容