5

In a pseudocode, I would like to assign \varnothing to a variable.
My code goes like this:

\documentclass[runningheads]{llncs} 
\usepackage{graphicx} 
\usepackage{algpseudocode} 
\usepackage{algorithm}
\usepackage{amsmath}
\begin{document}
\begin{algorithm} 
\caption{Find...} 
\begin{algorithmic}[1] \State $RS$ $\leftarrow$ $\varnothing$ \end{algorithmic} 
\end{algorithm} 
\end{document}

Unfortunately this doesn't work. The error message I got is the following:

State $RS$ $\leftarrow \varnothing $ 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. 
\varnothing l.103 ...\quad \quad $R$ $\leftarrow$ $\varnothing $
\Comment{$R$ is the set ... 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.

Do you have any ides on how this can be resolved?

FYI, I've already installed amsmath from texlive-latex-base in debian 9.

Thanks,
Pavlos

  • Could you add fully compilable MWE? – Raaja Nov 23 '18 at 9:57
  • welcome to tex.se! please extend your code fragment to complete small document (caled minimal working example: mwe) beginning with \documentclass... and ending with \end{document} – Zarko Nov 23 '18 at 9:58
  • \documentclass[runningheads]{llncs} \usepackage{graphicx} \usepackage{algpseudocode} \usepackage{algorithm} \usepackage{amsmath} \begin{document} \begin{algorithm} \caption{Find...} \begin{algorithmic}[1] \State $RS$ $\leftarrow$ \end{algorithmic} \end{algorithm} \end{document} – Pavlos Ponos Nov 23 '18 at 10:10
  • @PavlosPonos You can also remove the comment with your code as Raaja has edited your question. – Sebastiano Nov 23 '18 at 10:51
5

\varnothing belongs to the set of symbols in the package amssymb. So include it in your preamble as \usepackage{amssymb} and you are good to go.

\documentclass{article} 
\usepackage{graphicx} 
\usepackage{algpseudocode} 
\usepackage{algorithm}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
    \begin{algorithm} 
        \caption{Find...} 
        \begin{algorithmic}[1] \State $RS$ $\leftarrow$ $\varnothing$ \end{algorithmic} 
    \end{algorithm} 
\end{document}

with which you will get:

enter image description here

  • 3
    \usepackage{amssymb} was the solution to my "problem". When adding this, without changing anything else, it solved my problem! Thanks! – Pavlos Ponos Nov 23 '18 at 10:23
  • 1
    @Pavlos Ponos you are welcome. – Raaja Nov 23 '18 at 10:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.