I want to compile this code in Latex (shown below). I use three libraries. I especially need elseif
and \state
command and line number
.
LaTeX Error:
Command \algorithmicindent already defined.Or name \end... illegal,
see p.192 of the manual.See the LaTeX manual or LaTeX Companion for
explanation.Type H <return> for immediate help....
\newlength{\algorithmicindent}
MWE:
\documentclass[12pt]{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
%\usepackage{algorithmic}
\begin{document}
\begin{algorithm}
\caption{Offloading decision}\label{offloading_decision_pseudocode}
\begin{algorithmic}[1]
\State Known: Smartphone to Edge Cloud and Smartphone to Core Cloud bandwidth,
smartphone to Edge Cloud and smartphone to Core Cloud RTT,
smartphone and Edge/Core Cloud processor speed,
Edge and Core Cloud processing cost
\State Set weights $w1$, $w2$, $w3$ based on user preferences
\State Estimate $T_{L}$, $T_{R-edge}$, $T_{R-Core}$ (section \ref{estimate_processing_time})
\State Estimate $E_{L}$, $E_{R-edge}$, $E_{R-Core}$ (section \ref{estimate_energy_consumption})
\State Estimate $C_{L}$, $C_{R-edge}$, $C_{R-Core}$ (section \ref{estimate_processing_cost})
\State Compute $P_{s}$, $P_{E}$, $P_{C}$
\If {$P_{s}\: is\: maximum $}
\State
\ElseIf {$P_{E}$ is maximum}
\EndIf
\If {$i > \textit{stringlen}$} \Return false
\EndIf
\State $i \gets i-1$.
\State \textbf{goto} \emph{loop}.
\State \textbf{close};
\State $i \gets i+\max(\textit{delta}_1(\textit{string}(i)),\textit{delta}_2(j))$.
\State \textbf{goto} \emph{top}.
\end{algorithmic}
\end{algorithm}
\end{document}
Best Answer
algpseudocode
package defines the command\ElsIf
and not\ElseIF
\usepackage{algoritmic}
If you use
\usepackage{algpseudocode}
you don't have to call\usepackage{algortihmicx}
explicitly !