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.

Is there way how to turn off numbering of lines for specific line in algorithm2e? I need bold : after keyword. So I tried redefine these macros:

\renewcommand{\KwIn}[1]{\textbf{Input:} #1}
\renewcommand{\KwOut}[1]{\textbf{Output:} #1}

But after try of this:



\KwIn{$(X_{t-1}, u_t, z_t)$}\\


So I need turn off line numbering of 2 first lines (keyword lines). Or specify new keyword which will have bold : after keyword name. This \SetKwInput{Input}{Input} is generating only normal : after Input name (Input: (X...)). I was searching in documentation how adjust style of input/output keywords but nothing about ending : found. Can anybody help?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Here's one possibility redefining \SetKwInOut:


  \expandafter\ifx\csname InOutSizeDefined\endcsname\relax% if first time used
  \else% else keep the larger dimension
  \fi% the dimension of the box is now defined.
%     {\let\\\algocf@newinout\hangindent=\wd\algocf@inoutbox\hangafter=1\parbox[t]{\inoutsize}{\KwSty{#2}\algocf@typo\hfill:}~##1\par}%
    \algocf@linesnumbered% reset the numbering of the lines

\Input{A bitmap $Im$ of size $w\times l$}
\Output{A partition of the bitmap}
\emph{special treatment of the first line}\;
\For{$i\leftarrow 2$ \KwTo $l$}{
\emph{special treatment of the first element of line $i$}\;
\caption{disjoint decomposition}\label{algo_disjdecomp}


enter image description here

share|improve this answer
I'm getting error while compiling: ! Undefined control sequence. <argument> \inoutindent l.177 \SetKwInOut{Output}{Output}. And could you also give me possibility with KwIn and KwOut? Because I don't need same vertical align of :. Thanks for help anyway. –  Petr Přikryl Mar 27 '13 at 15:33
@PetrPřikryl I updated my answer to suppress vertical alignment. Regarding the error message, please update your packages. My code will work with version 5.0 (january 06 2013) of algorithm2e. –  Gonzalo Medina Mar 27 '13 at 15:54

Your Answer


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.