使用 elsarticle-num-names 和 pagebackref (elsarticle 类) 发生冲突

使用 elsarticle-num-names 和 pagebackref (elsarticle 类) 发生冲突

我目前正在写一篇文章,使用elsarticle 班级elsarticle-num-names,我在结合参考书目样式和功能时遇到了一些问题pagebackref。我的目标是拥有“第 X 页引用”信息以及使用该\citeauthor命令的能力,同时仍保留编号参考部分。

以下是我目前观察到的情况:

  1. 使用elsarticle-num书目样式时,我可以在参考文献部分获得所需的结果。但是,该\citeauthor命令不可用。见下文。 在此处输入图片描述

  2. 如果我切换到使用该elsarticle-num-names样式,我会遇到编译错误,并且“引用第 X 页”信息会出现在错误的位置。我怀疑该问题可能与 bst 文件有关,但我找不到解决方案。见下文。 在此处输入图片描述

我正在 Overleaf 中编译 pdfLaTeX。如果您能提供任何帮助或指导来解决这些问题,我将不胜感激。为了方便故障排除,以下是我使用的测试代码:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[final,10pt]{elsarticle}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{mathpazo} % I am using pdfLaTeX

\usepackage[pagebackref]{hyperref} % Setup hyperlinks
\hypersetup{colorlinks=true, linkcolor=blue, citecolor=blue, urlcolor=blue}
\usepackage{xurl}
\AtBeginDocument{
  \urlstyle{same}
}

% Setup backref
\renewcommand*{\backrefsep}{, }
\renewcommand*{\backreflastsep}{, and~}
\renewcommand*{\backreftwosep}{ and~}
\renewcommand*{\backref}[1]{}   % empty definition for \backrefalt to be used, i.e. disable standard 
\renewcommand*{\backrefalt}[4]{%
   % alternative interface
   % #1: number of distinct back references
   % #2: backref list with distinct entries
   % #3: number of back references including duplicates
   % #4: backref list including duplicates
%%%%%%%%
    \!\scriptsize\itshape\mbox{
    \ifnum#1=1 %
     (Cited on page~%
    \else
      (Cited on pages~%
    \fi
    #2)
    } }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{filecontents}{example.bib}
@book{prince,
    author = {Antoine de Saint-Exupéry},
    title = {The Little Prince},
    year = {2000},
    isbn = {978-0156012195},
    publisher = {Clarion Books},
}
@Article{jasa:2022eac,
  author  = {Fonseca, William {\relax D'A}ndrea and Brandão, Eric and Mareze, Paulo Henrique and Viviane Suzey Melo and Roberto A. Tenenbaum and Christian Santos and Dinara Xavier Paixão},
  title   = {{A}coustical {E}ngineering: a complete academic undergraduate program in {B}razil},
  doi     = {10.1121/10.0013570},
  issn    = {0001-4966, 1520-8524},
  number  = {2},
  pages   = {1180--1191},
  volume  = {152},
  journal = {The Journal of the Acoustical Society of America},
  year    = {2022},
}
\end{filecontents}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Bib Options: elsarticle uses natbib
\biboptions{sort&compress,square}
%% Fix DOI in elsarticle-num-names
\makeatletter
\providecommand{\doi}[1]{%
  \begingroup
    \let\bibinfo\@secondoftwo
    \urlstyle{same}%
    ~\href{http://dx.doi.org/#1}{%
      \discretionary{}{}{}%
      \nolinkurl{#1}%
    }%
  \endgroup
}
\makeatother
%% Fix font for DOI in elsarticle num
\makeatletter
\let\path\relax 
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Test Section}

\textbf{Reference with several names:}
%
\begin{itemize}
    \item citeauthor: \citeauthor{jasa:2022eac}
    \item citeauthor*: \citeauthor*{jasa:2022eac}    
    \item citet: \citet{jasa:2022eac}
    \item cite: \cite{jasa:2022eac}
\end{itemize}

\vspace{2em}

Reference with one name:
%
\begin{itemize}
    \item citeauthor: \citeauthor{prince}
    \item citeauthor*: \citeauthor*{prince}    
    \item citet: \citet{prince}
    \item cite: \cite{prince}
\end{itemize}

\bibliographystyle{elsarticle-num-names}
% \bibliographystyle{elsarticle-num}
\bibliography{example.bib}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document} 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

错误信息如下:

\bibinfo {author}{A.~d. Saint-Exupéry}, \bibinfo {title}{The Little\ETC.
! File ended while scanning use of \BR@@lbibitem.
<inserted text> 
                \par 
l.105 \bibliography{example.bib}

谢谢。

答案1

这是解决方案根据@的评论乌尔丽克·菲舍尔。谢谢,谢谢!

  1. 复制文件elsarticle-num-names.bst
  2. 搜索所有“%Type ="”实例并替换为“\par %Type ="”。我找到了 14 个。
  3. 将“新”elsarticle-num-names.bst文件放在主tex文件所在的文件夹中
  4. 完成了,它开始工作了!我还用一篇有很多参考文献的文章进行了测试,现在它开始工作了。见下文。 在此处输入图片描述

相关内容