1

I was using the algorithm2e environment so far. However, the springer journal class does not support it. In it's documentation, it is suggesting to use

\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{algorithmicx}

However I have no clue how I can convert my algorithm2e based code using the above packages. Getting compilation error in almost every line. The MWC is below-

\documentclass[pdflatex, sn-aps]{sn-jnl}% American Physical Society (APS) Reference Style
%%%% Standard Packages
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{comment}
\usepackage[center]{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage[misc]{ifsym}
\usepackage{csquotes}
\usepackage[section]{placeins}
\usepackage{siunitx}
%%<additional latex packages if required can be included here>
%\usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{algorithmicx}
\usepackage{amsmath}
\usepackage{graphicx}

\begin{document}

%Algorithm-1 code*****************
\begin{algorithm}
\SetAlgoLined
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
function fall\_check$()$\\
\Input{The accelerometer data and timestamp }
\Output{response $( TRUE/FALSE)$}
{
read\_data$()$\;
Calculate the SVM using the equation \ref{SVM}.\\
\If{ $SVM_\mathrm{acc}>SVM_\mathrm{acc}(threshold)$ \& $time\_count< 2 seconds $}
    {
    \eIf {$record\_count > 150$}
        {
            return$(TRUE)$\;
        }
        {
            return$(FALSE)$\;
        }
    }
}
\caption{Check for the fall event~(runs on the RPi server)}
\label{alg:algo1}
\end{algorithm}

 \end{document}

Please help.

1
  • Any suggestion? stuck here completely. Commented Jan 25, 2022 at 11:08

2 Answers 2

1

Finally after going through several articles online, I could make a basic transformation(Although the effect is not like the previous version). Sharing my experience, in case if helps anyone.

  1. First of all, the journal class itself includes the necessary algorithmic packages, so there is no need to have any of

\usepackage{algorithm} \usepackage{algpseudocode} \usepackage{algorithmicx}

  1. Next I had to make the following changes [ After realizing every statement must be preceded with \State and there is no {} bracket required to group the statements under IF or WHILE ] So my MWC becomes

     \documentclass[pdflatex, sn-aps]{sn-jnl}% American Physical Society (APS) Reference Style
     %%%% Standard Packages
     \usepackage[utf8]{inputenc}
     \usepackage[english]{babel}
     \usepackage{comment}
     \usepackage{float}
     \usepackage[misc]{ifsym}
     \usepackage{csquotes}
     \usepackage[section]{placeins}
     \usepackage{siunitx}
     \usepackage{amsmath}
     \usepackage{graphicx}
    
     \begin{document}
    
     %Algorithm-1 code*****************
     \begin{algorithm}
     \caption{Check for the fall event~(runs on the RPi server)}\label{alg:algo1}
     \begin{algorithmic}[1]
     \State $function fall\_check()$
     \State INPUT: The accelerometer data and timestamp
     \State $OUTPUT: response ( TRUE/FALSE)$
    
     \State read\_data$()$\;
     \State Calculate the SVM using the equation \ref{SVM}.
     \If{ $SVM_\mathrm{acc}>SVM_\mathrm{acc}(threshold)$ \& $time\_count< 2 seconds $}
    
         \If {$record\_count > 150$}
    
             \State return$(TRUE)$\;
    
         \Else
             \State return$(FALSE)$\;
    
    
          \EndIf
    
      \EndIf
    
     \end{algorithmic}
     \end{algorithm}
     \end{document} 
    

Output

1

Not answering how to convert, but I had the same problem, and this thread was the first in search results. So I almost started converting my algorithms already.

Fortunately, the springer journal class only suggests using algorithm and algorithmicx, but it still supports algorithm2e. One can just follow the advice from this answer to avoid compile errors while using algorithm2e with sn-jnl class.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.