我遇到了一个 Latex 错误信息,内容是:
Can be used only in preamble.
Command \citename already defined.
Command \bibhang already defined.
Package biblatex: Incompatible package 'natbib'.
Command \Citeauthor already defined.
Command \bibfont already defined.
我意识到该问题可能源于我的参考文献、图表和表格中的无效超链接。
我在body之前已经定义了Latex文件:
\documentclass[preprint,12pt]{elsarticle}
\usepackage{amssymb}
\makeatletter
\let\c@author\relax
\makeatother
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{algpseudocode}
\expandafter\let\csname equation*\endcsname\relax
\expandafter\let\csname endequation*\endcsname\relax
\usepackage{amsmath}
% \usepackage[backend=bibtex]{biblatex}
\usepackage[backend=biber, style=numeric]{biblatex}
\addbibresource{references.bib}
\journal{}
\begin{document}
\begin{frontmatter}
.
.
.
\bibliographystyle{elsarticle-num}
\bibliography{re-ref.bib}
\end{document}
但我仍在努力解决这个问题。
答案1
默认情况下,elsarticle
该类会加载natbib
,但这与不兼容biblatex
。
你能biblatex
一起使用elsarticle
,但不应使用\bibliographystyle
和。\bibliography
\documentclass[preprint,12pt,nonatbib]{elsarticle}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{algpseudocode}
\makeatletter\let\c@author\relax\makeatother
\usepackage[backend=biber, style=numeric]{biblatex}
\addbibresource{biblatex-examples.bib}% <-- replace with your bib file
\AddToHook{env/frontmatter/after}{\setcounter{author}{0}}
\journal{}
\begin{document}
\begin{frontmatter}
.
.
.
\end{frontmatter}
\cite{doody}
\printbibliography
\end{document}
如果你想使用natbib
\documentclass[preprint,12pt,nonatbib]{elsarticle}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{algpseudocode}
\journal{}
\begin{document}
\begin{frontmatter}
.
.
.
\end{frontmatter}
\cite{doody}
\bibliographystyle{elsarticle-num}
\bibliography{biblatex-examples}% <-- replace with your bib file
\end{document}