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'm using the LaTeX algorithm2e package by defining

\usepackage[ruled, linesnumbered, vlined]{algorithm2e}

The linesnumbered argument adds lines numbers from [1,...,n] if we have an algorithm with n lines. I would like to know if there's any possibility to change the numbers in something like: [1*,...,n*] (adding a symbol like a * or a ' behind the number). Note I have several algorithms in my document, thus I want to define the above described "different line number style" in a local \begin{algorithm} ... \end{algorithm} scope. I am thankful for all help and information.

share|improve this question
    
Welcome to TeX.sx!. A tip: You can use backticks ` to mark your inline code as I did in my edit. –  texenthusiast Feb 27 '13 at 10:54
    
@lockstep: looks much better, thank you for the hint! –  bobb_the_builder Feb 27 '13 at 11:26

1 Answer 1

up vote 4 down vote accepted

Use the command \SetNlSty to change the style of the numbering. It takes three argumnts, the first is the font to use, the second the text to appear before the number and the third the text to appear after. Thus

\SetNlSty{textbf}{}{*}

will place * after the line numbers, all bold face (which is the default font).

Sample output

\documentclass{article}

\usepackage[ruled,linesnumbered,vlined]{algorithm2e}

\begin{document}

\begin{algorithm}
  \eIf {\( x>y \)}{greater}{less than or equal}
\end{algorithm}

\SetNlSty{textbf}{}{*}

\begin{algorithm}
  \eIf {\( x>y \)}{greater}{less than or equal}
\end{algorithm}

\end{document}
share|improve this answer
    
thats exactly the representation i was looking for - thank you for the clear answer! –  bobb_the_builder Feb 27 '13 at 11:28

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.