# Algorithm In LaTeX Elsevier Template

Actually, I wrote algorithm first in general LaTeX format and done successfully. Following algorithm packages I had used:

\usepackage{algorithm,algpseudocode}
\usepackage{algorithmic}
\usepackage{program}
\usepackage{algorithm}


But when I copied same algorithm code in the Elsvier LaTeX template it's not working correctly. Please help me to get out this problem. The class which I am using in elsearticle format:

\documentclass[review]{elsarticle}
\usepackage{lineno,hyperref}
\bibliographystyle{elsarticle-num}


\documentclass[review]{elsarticle}
\usepackage{lineno,hyperref}
\modulolinenumbers[5]
\usepackage{graphicx}
\usepackage[font=small,labelfont=bf]{caption}%do
\usepackage{subcaption}
\usepackage{algpseudocode}
\usepackage{algorithmic}
\begin{algorithm}[h]
\State $a$ is AB valyes, $T$ is dec, $R\textsubscript{Data}$ is NOTHING\;
\State A\textsubscript{Ab} is values\;
\begin{algorithmic}[1]
\State $R\textsubscript{Data} \gets abs \Comment{my name is Xyz}$ \;
\State $L_i \gets$ Labeling my name    \Comment(i=1,2,3)\;
\State $T_{0}\gets R_{Data}$.$T$($start$)\;
\State $T_{end}\gets R_{Data}$.$T$($end$)\;
\Procedure {who} {$A\textsubscript{ab}$, $D\textsubscript{i}$}
\For {$s\gets A_{ab}(1)$ \TO $D_{Data}(end)$}
\If{AB}
\State No Matter
\Else

\State yes $A_{b}$ nothing special
\EndIf
\For {$F_{S}\gets 1 \leq 6$}
\State $S_{F}\gets F(T_{sw})$
\EndFor
\EndFor
\EndProcedure

\Procedure {where}{$A_{ab}$}
\For {Man}
\State Guess where I am
\EndFor
\EndProcedure
\caption{STGY}
\end{algorithmic}
\end{algorithm}


• Welcome to Tex Stackexchange. You should include more information. At this moment, it is difficult to help you. – Karlo Oct 10 '18 at 11:59
• In addition to Karlos comment, please provide a full (but minimal) example that others can copy and test to see your problem (without having to guess for example your preamble). As it sits now we have to guess a lot about your document and thus might make mistakes. – daleif Oct 10 '18 at 12:17
• please first try to give me some information. After that, If not solved then I'll provide you some information (code) – Nafees Ahmed Oct 10 '18 at 12:32
• A statement such as "Its not working correctly" is not actionable. Please be more specific. E.g., do you get warning and/or messages? At which point do these messages show up? Do they show up while still in the preamble, or later on in the document? – Mico Oct 10 '18 at 12:37
• In addition to karlo, daleif and @Mico comments, to guess where the problem is in your file, get to the last point at which you were able to compile successfully, then try to locate and share with us what new commands or packages you have added that would be the problematic code. You can provide the minimal working example by not including those potential "problematic" commands/packages then ask how to include them properly. You don't have to worry about stealing your code :) – hesham Oct 10 '18 at 12:54

Well, in your given code there are some issues:

1. First of all you have no \begin{document}.
2. I commented some \; at the end of some lines.
3. You need to change \TO to \to.
4. Some $ are missing. Please see the following compilable code \documentclass[review]{elsarticle} \usepackage{lineno} \modulolinenumbers[5] \usepackage{graphicx} \usepackage[font=small,labelfont=bf]{caption} \usepackage{subcaption} \usepackage{algorithm}% <=================http://ctan.org/pkg/algorithms \usepackage{algpseudocode}% <========== http://ctan.org/pkg/algorithmicx \usepackage{hyperref} % <=============================================== \begin{document} \begin{algorithm} \begin{algorithmic}[1] \State$a$is AB valyes,$T$is dec,$R\textsubscript{Data}$is NOTHING%\; \State$A\textsubscript{Ab}$is values%\; % <=========================== \State$R\textsubscript{Data} \gets $abs \Comment{my name is Xyz} %\; \State$L_i \gets $Labeling my name \Comment(i=1,2,3)%\; \State$T_{0}\gets R_{Data}$.$T$($start$)%\; \State$T_{end}\gets R_{Data}$.$T$($end$)%\; \Procedure {who} {$A\textsubscript{ab}$,$D\textsubscript{i}$} \For {$s\gets A_{ab}(1) \to D_{Data}(end)$} % <======================= \If{AB} \State No Matter \Else \State yes$A_{b}$nothing special \EndIf \For {$F_{S}\gets 1 \leq 6$} \State$S_{F}\gets F(T_{sw})$\EndFor \EndFor \EndProcedure \Procedure {where}{$A_{ab}\$}
\For {Man}
\State Guess where I am
\EndFor
\EndProcedure
\caption{STGY}\label{STGY}
\end{algorithmic}
\end{algorithm}

\end{document}


and the result:

BTW: package hyperref should be called as last package in your case.