2

I got the error while creating a pseudocode for my report. The following is my code in LaTeX. This gives out an stating "undefined control sequence \BState ->\State \algbackskip \BState". Kindly help me out with this.

\documentclass{article}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\begin{document}
\begin{algorithm}[H]
  \begin{algorithmic}[1]
    \BState \emph{\textbf{Key(s)}}:
  \end{algorithmic}
\end{algorithm}
\end{document}
2

The part that is causing this problem is an underfined \@algbackskip (which forms part of \BState).

The main algorithmicx package code - algorithmicx.sty - contains a definitions for \@algbackskip, but it's been commented out:

%\def\algbackskip{\hskip-\ALG@thistlm}

My assumption is that this might be a mistake and should be corrected.

enter image description here

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

\makeatletter
% Reinsert missing \algbackskip
\def\algbackskip{\hskip-\ALG@thistlm}
\makeatother

\begin{document}

\begin{algorithmic}[1]
  \State something
  \If{this}
    \State do this
    \BState do that
  \EndIf
  \BState now this
\end{algorithmic}

\end{document}
1
  • By the way, \BState is not even mentioned in the manual for algorithmicx.
    – egreg
    Feb 11 '16 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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