3

When I compile document with this code:

\documentclass[final,3p,times]{elsarticle}

\usepackage{amsmath, amssymb, amsfonts, amsfonts, amsthm,latexsym}


\usepackage{enumerate}

\usepackage{mathtools} \usepackage[normalem]{ulem} \usepackage{scalerel}

\newcommand{\Ro}{\mathrel{\overset{0}{\sim}}}

\title{test}

\date{March 2020}


\usepackage{graphicx}

\begin{document}

\maketitle \section{test.\ $\Ro$}


\end{document}

I get that the compiler is having trouble understanding a command I have defined. Check whether 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{...}.

It does not work on overleaf.com and my PC, however in my laptop with Ubuntu it does not produce any error.

Could anyone tell me how to avoid or fix this?


update:

I tried to take the suggestion of changing the ordering of how amssymb and amsmath are loaded; it works.

\documentclass[3p,times]{elsarticle}
\usepackage{amssymb,amsthm,amsmath}
\newcommand{\Ro}{\mathrel{\overset{0}{\sim}}}
\begin{document}
    \section{test.\ $\Ro$}

    \begin{proof}
        asfaag
    \end{proof}
\end{document}

However, if I add all my packages, the problem returns.

\documentclass[3p,times]{elsarticle}
\usepackage{amssymb,amsthm,amsmath}
\usepackage{algorithmic,algorithm}
\renewcommand{\algorithmiccomment}[1]{\hfill$\rhd∗$\textit{#1}}
\usepackage{graphics}
\usepackage{enumerate}
\usepackage{color}
\usepackage{mathtools}
\usepackage[normalem]{ulem}
\usepackage{scalerel}

\newcommand{\Ro}{\mathrel{\overset{0}{\sim}}}
\begin{document}
    \section{test.\ $\Ro$}

    \begin{proof}
        asfaag
    \end{proof}
\end{document}
2
  • 1
    Off-topic: (a) No need to load the amsfonts package explicitly (twice, no less!) since the package is loaded automatically by the amssymb package. (b) No need to load latexsym at all, since it's been superseded (more than 25 years ago, by the way) by the amssymb/amsfonts pair of packages.
    – Mico
    Mar 22, 2020 at 7:04
  • 1
    Thanks for telling
    – Ginger
    Mar 22, 2020 at 7:44

2 Answers 2

5

It's quite a strange interaction with scalerel. I can reproduce the behavior with a simpler example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{scalerel}

\newcommand{\Ro}{\mathrel{\overset{0}{\sim}}}

\begin{document}

\section{test.\ $\Ro$}

\end{document}

The issue disappears when scalerel is removed.

Solution: use

\DeclareRobustCommand{\Ro}{\overset{0}{\sim}}

(I removed \mathrel because it's not necessary, since \sim is a relation symbol and \overset is able to guess it correctly).

2

Many thanks for producing a full MWE (minimum working example). I was immediately able to reproduce the error on a pre-release version of MacTeX2020. Specifically, I got the following sequence of messages:

! Undefined control sequence.
\@tempa ->\catcode `\<
                      12\relax \catcode `\>12\relax \catcode `\=12\relax 
l.22 \section{test.\ $\Ro$}

? r
OK, entering \nonstopmode...
! Undefined control sequence.
\@tempa ->\catcode `\<
                      12\relax \catcode `\>12\relax \catcode `\=12\relax 
l.22 \section{test.\ $\Ro$}

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.

I'm not sure why the following solution works, but here goes: Load the amssymb package before, not after, the amsmath package.

Reducing your code to the bare essentials, i.e. to

\documentclass[3p,times]{elsarticle}
\usepackage{amssymb,amsmath}
\newcommand{\Ro}{\mathrel{\overset{0}{\sim}}}
\begin{document}
\section{test.\ $\Ro$}
\end{document}

I get

enter image description here

without any error or warning messages. What makes the difference is that amssymb is loaded before rather than after amsmath.

3
  • thanks, somehow if i add all of my packages, it fails again.
    – Ginger
    Mar 22, 2020 at 8:47
  • @ginger - Your initial posting didn't mention the fact that your real document loads the scalerel package. Would you like me to delete my answer as it doesn't appear to address the real document's issue?
    – Mico
    Mar 22, 2020 at 10:05
  • 1
    I think it is good if you keep it. Since this is also a way to fix it, if there is no scalerel. I did not know that this causes the problem.
    – Ginger
    Mar 22, 2020 at 11:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .