我正在使用elsarticle
,我想申请biblatex
我的推荐人,但显然natbib.sty
默认加载。在这种情况下,我该如何使用biblatex
或如何禁用natbib
?
%% natbib.sty is loaded by default. However, natbib options can be
%% provided with \biboptions{...} command. Following options are
%% valid:
%% round - round parentheses are used (default)
%% square - square brackets are used [option]
%% curly - curly braces are used {option}
%% angle - angle brackets are used <option>
%% semicolon - multiple citations separated by semi-colon
%% colon - same as semicolon, an earlier confusion
%% comma - separated by comma
%% numbers- selects numerical citations
%% super - numerical citations as superscripts
%% sort - sorts multiple citations according to order in ref. list
%% sort&compress - like sort, but also compresses numerical citations
%% compress - compresses without sorting
%%
%% \biboptions{comma,round}
% \biboptions{}
\usepackage[
backend=biber,
style=alphabetic,
citestyle=authoryear
]{biblatex}
\addbibresource{references.bib}
\begin{document}
bla bla bla
\printbibliography
\end{document}
消息/日志文件:Command \bibhang already defined,
答案1
根据文档最新版本的elsarticle
,选项nonatbib
可以使用。但是,
\makeatletter
\let\c@author\relax
\makeatother
根据这个答案消除以下错误:
命令 \c@author 已定义。\abx@donames。
\documentclass[nonatbib]{elsarticle}
\makeatletter
\let\c@author\relax
\makeatother
\usepackage[backend=biber,hyperref=true,doi=false,url=false,isbn=false, uniquename=false, uniquelist=false ]{biblatex}
\usepackage{filecontents,hyperref}
\begin{filecontents*}{\jobname.bib}
@Article{Fornberg2008,
author = {Fornberg, Bengt and Piret, Cécile},
title = {On choosing a radial basis function and a shape parameter when solving a convective PDE on a sphere},
journal = {Journal of Computational Physics},
year = {2008},
volume = {227},
number = {5},
pages = {2758-2780},
month = {feb},
doi = {10.1016/j.jcp.2007.11.016},
issn = {0021-9991},
publisher = {Elsevier {BV}},
type = {Journal Article},
url = {http://dx.doi.org/10.1016/j.jcp.2007.11.016}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
Lorem ipsum~\cite{Fornberg2008}.
\printbibliography
\end{document}
答案2
此解决方案仅可用于排版个人笔记!
不要这样提交你的论文!
如果您考虑使用此技巧提交您的论文,请立即停止阅读!
仅供学术使用
\RequirePackage{scrlfile}
\PreventPackageFromLoading[\typeout{Please don't do this for journal submission}]{natbib}
\documentclass{elsarticle}
\expandafter\let\csname c@author\endcsname=\relax
\usepackage[
backend=biber,
style=authoryear,
]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\cite{aristotle:physics}
\printbibliography
\end{document}
答案3
此解决方案仅可用于排版个人笔记!
不要这样提交你的论文!
如果您考虑使用此技巧提交您的论文,请立即停止阅读!
有时,日记文档类定义的宏对于排版个人笔记很有用。然而,对于这种私人文档,人们也希望利用诸如 之类的现代软件包的便利性biblatex
。
documentclass在内部elsarticle
加载natbib
,这是 的一大亮点biblatex
。该natbib
包通过以下行加载
\RequirePackage[\@biboptions]{natbib}
为此,入侵\RequirePackage
并使其跳过natbib
将解决手头的问题。我使用xparse
包和底层expl3
编程层来实现这样的宏。显然必须将这种宏的(重新)定义放在前 \documentclass
。
此外,elsarticle
还定义了一个名为 的计数器author
,该计数器从未被类使用,但 需要biblatex
。我们只需将其底层计数变量设置为 即可取消定义计数器\relax
。
\RequirePackage{xparse}
\ExplSyntaxOn
\clist_new:N \pkg_ignored_clist
\clist_put_right:Nn \pkg_ignored_clist { natbib }
\msg_new:nnn { pkg } { pkg-ignored } { Package~#1~ignored! }
\cs_set_eq:NN \latex_require_package:wnw \RequirePackage
\cs_new_protected:Npn \pkg_require_package:nnn #1#2#3
{
\IfValueTF { #1 }
{
\IfValueTF { #3 }
{ \latex_require_package:wnw [ #1 ] { #2 } [ #3 ] }
{ \latex_require_package:wnw [ #1 ] { #2 } }
}
{
\IfValueTF { #3 }
{ \latex_require_package:wnw { #2 } [ #3 ] }
{ \latex_require_package:wnw { #2 } }
}
}
\RenewDocumentCommand \RequirePackage { o m o }
{
\clist_if_in:NnTF \pkg_ignored_clist { #2 }
{
\msg_warning:nnn { pkg } { pkg-ignored } { #2 }
}
{
\pkg_require_package:nnn { #1 } { #2 } { #3 }
}
}
\ExplSyntaxOff
\documentclass{elsarticle}
\expandafter\let\csname c@author\endcsname=\relax
\usepackage[style=authoryear,natbib]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\Citet{weinberg}
\printbibliography
\end{document}
答案4
@Oromion 问我如何解决这个问题,3p
所以5p
在这里放了一个 MWE。请注意,这不是为了发表论文,我是在几个学生请求帮助后才这么做的,因为他们被要求为一门课程写一篇“Elsevier 风格的论文”。
\documentclass[5p]{elsarticle}
%% Fix so biblatex works instead of natbib
\makeatletter
\let\c@author\relax
\makeatother
\let\bibhang\relax
\let\citename\relax
\let\bibfont\relax
\let\Citeauthor\relax
\expandafter\let\csname [email protected]\endcsname\relax
%% Fix headers and footers
\makeatletter
\def\ps@pprintTitle{%
\let\@oddhead\@empty
\let\@evenhead\@empty
\def\@oddfoot{}%
\let\@evenfoot\@oddfoot}
\makeatother
%% Load some packages and stuff
%% Library and stuff
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
%% biblatex with apa-style.
\DeclareLanguageMapping{american}{american-apa}
\bibliography{library}
%% Rest as usual....