3
\documentclass{article}
\usepackage{amsmath}
\usepackage[noend]{algpseudocode}
\usepackage{algorithm}

\makeatletter
\def\BState{\State\hskip-\ALG@thistlm}
`\makeatother

\begin{document}
\begin{algorithm}
\caption{AIP}\label{euclid}
\begin{algorithmic}[1]
\State \textit{$\sum^{N_agent}_{i=1}$$L_A$} $\gets$ position of \textit{$agent_i$}
\BState \emph{loop}:
\State \textit{$i$}$\gets one
\State \textit{$i$ plus one}
\If {\textit{distance(eNB,$L_i$)} $< \delta$} \textit{close $agent_i$}
\IF {\textit{distance(eNB,$L_i$)}$>\Delta$} \textit{$agent_i$ power equals P$}
\State \textbf{goto} loop

\end{algorithmic}
\end{algorithm}
\end{document}

Can someone help me compile this successfully?

1 Answers1

3

Something likes this. There are typo errors involved, as displayed below.

  1. An extra ` before makeatother.
  2. IF was a typo of If.
  3. A missing $ after $gets.
  4. an $ is missing before P$.
  5. Forget to end IF with \EndIf

enter image description here

Code

\documentclass{article}
\usepackage{amsmath}
\usepackage[noend]{algpseudocode}
\usepackage{algorithm}

\makeatletter
\def\BState{\State\hskip-\ALG@thistlm}
\makeatother                           % error was here

\begin{document}
\begin{algorithm}
\caption{AIP}\label{euclid}
\begin{algorithmic}[1]
\State \textit{$\sum^{N_agent}_{i=1}$$L_A$} $\gets$ position of \textit{$agent_i$}
\BState \emph{loop}:
\State \textit{$i$}$\gets$ one         % error was here
\State \textit{$i$ plus one}
\If {\textit{distance(eNB,$L_i$)} $< \delta$} \textit{close $agent_i$}
\If {\textit{distance(eNB,$L_i$)}$>\Delta$} \textit{$agent_i$ power equals $P$}  % error was here
\State \textbf{goto} loop
\EndIf                                 % error was here
\EndIf                                 % error was here
\end{algorithmic}
\end{algorithm}
\end{document}
Jesse
  • 29,686