Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to use the algorithmic package with Step1. Step2. instead of 1, 2, ... line numbering and I have numberless lines. An example:

\documentclass[11 pt]{report}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{My Algorithm}
\algrenewcommand{\alglinenumber}[1]{\bf Step{#1}.}
\begin{algorithmic}[1]
\State aaa
\Statex bbb
\State ccc
\end{algorithmic}
\end{algorithm}
\end{document}

However, aaa bbb and ccc are not properly left aligned. How can I fix it?

Edit: I have edited the code to make it compilable (MWE)

share|improve this question

1 Answer 1

You should also redefine \Statex to take into account the width:

\documentclass[11pt]{report}
\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}
\begin{algorithm}
\caption{My Algorithm}
\algrenewcommand{\alglinenumber}[1]{\bfseries Step {#1}.}
\renewcommand{\Statex}{\item[\hphantom{\bfseries Step \arabic{ALG@line}.}]}
\begin{algorithmic}[1]
\State aaa
\Statex bbb
\State ccc
\end{algorithmic}
\end{algorithm}
\end{document}

This will align the item with the preceding one.

enter image description here

Note that the size option must be written 11pt and not 11 pt; moreover \bf is an obsolete command and \bfseries should be used in its place.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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