我正在尝试使用 TeXLive 2020 和 Overleaf 编译一个文件。但是,出现了一个Undefined control sequence
,如下所示:
The compiler is having trouble understanding a command you have used. Check that the command is spelled correctly. If the command is part of a package, make sure you have included the package in your preamble using \usepackage{...}.
Learn more
l.48 \affiliation
[a]{organization={A}, % Address/affiliation
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
l.56 \affiliation
[b]{organization={A}, % Address/affiliation
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
奇怪的是,使用 TeXLive 2021 没有问题。遗憾的是 arXiv 只能使用 TexLive 2020。有什么办法可以解决这个问题吗?
%% ---------------------------------------- Class ---------------------------------------- %%
\documentclass[preprint,12pt,authoryear]{elsarticle}
%% Use the option review to obtain double line spacing
%% \documentclass[authoryear,preprint,review,12pt]{elsarticle}
%% Use the options 1p,twocolumn; 3p; 3p,twocolumn; 5p; or 5p,twocolumn
%% for a journal layout:
%% \documentclass[final,1p,times,authoryear]{elsarticle}
%% \documentclass[final,1p,times,twocolumn,authoryear]{elsarticle}
%% \documentclass[final,3p,times,authoryear]{elsarticle}
%% \documentclass[final,3p,times,twocolumn,authoryear]{elsarticle}
%% \documentclass[final,5p,times,authoryear]{elsarticle}
%% \documentclass[final,5p,times,twocolumn,authoryear]{elsarticle}
%% ---------------------------------------- Packages ---------------------------------------- %%
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{booktabs}
\usepackage{caption,setspace}
\usepackage{tabularx}
\usepackage[export]{adjustbox}
\usepackage{tikz}
\def\checkmark{\tikz\fill[scale=0.3](0,.45) -- (.25,0) -- (.8,.62) -- (.25,.15) -- cycle;}
\hypersetup{pdfauthor={Name}}
%% ---------------------------------------- Information ---------------------------------------- %%
\journal{E}
\begin{document}
\begin{sloppypar}
\begin{frontmatter}
\title{S}
\author[1]{FA}
\author[2]{SA}
\author[1]{TA\corref{cor1}}
\cortext[cor1]{Corresponding author}
\affiliation[a]{organization={A}, % Address/affiliation
addressline={B},
% city={},
% citysep={}, % Uncomment if no comma needed between city and postcode
postcode={C},
% state={},
country={D}}
\affiliation[b]{organization={A}, % Address/affiliation
addressline={B},
% city={},
% citysep={}, % Uncomment if no comma needed between city and postcode
postcode={C},
% state={},
country={D}}
\begin{abstract}
A
\end{abstract}
\begin{keyword}
%% keywords here, in the form: keyword \sep keyword
K
\end{keyword}
\end{frontmatter}
%% \linenumbers
%% ---------------------------------------- Main Text ---------------------------------------- %%
\section{Intorduction}
\label{1}
\end{sloppypar}
\end{document}
\endinput
%% End of file `elsarticle-template-harv.tex'.
1分钟内轻松制作:
- 下载模板来自https://ctan.org/tex-archive/macros/latex/contrib/elsarticle
elsarticle-template-harv.tex
使用以上代码替换内容,然后编译
答案1
我们可以用一种迂回的方法来解决这个问题。
只是改变
\affiliation[a]{organization={A}, % Address/affiliation
addressline={B},
% city={},
% citysep={}, % Uncomment if no comma needed between city and postcode
postcode={C},
% state={},
country={D}}
到
\address[a]{A, B, C, D}
答案2
Elsevier 提交系统有 TL 2022。但是,它从不同的路径读取非常旧的版本elsarticle.cls
(“elsarticle 2008/10/09, 1.0.2”),而不是从 访问它$path/texmf-dist/tex/latex/elsarticle/elsarticle.cls
。它从 读取旧包$path/texmf-local/tex/latex/aries/elsarticle.cls
。这就是问题所在。
解决方法是,在他们更新路径之前,请将您使用的课程文件版本与源文件一起上传到提交文件夹。文件类型应选择为“手稿”而不是“LaTeX 源文件”。
答案3
在终端中运行命令“latex elsarticle.ins”以创建“elsarticle.cls”文件。使用此文件,缺少的命令应该可用。
如果您还有其他问题,请考虑将您的 Texlive 版本更新至最新版本。