# algorithm2e - Unwanted warnings when apply commands to content block

In this page, Andrew Swann points me a way to make verbose formatting of algorithms (I need this only for pedagogical reasons).

The problem with this solution is that it produces unwanted warnings with my second algorithm in the following example. Is there a way to not have this warnings ?

## MWE

\documentclass[10pt,a4paper]{article}
\usepackage[vlined]{algorithm2e}

\newcommand\BlockIf[1]{\KwSty{Start If} \\ #1 \\ \KwSty{End If}}
\newcommand\BlockElseIf[1]{\KwSty{Start Else If} \\ #1 \\ \KwSty{End Else If}}
\newcommand\BlockElse[1]{\KwSty{Start Else} \\ #1 \\ \KwSty{End Else}}

\makeatletter
\renewcommand{\algocf@uIf}[2]{\If@ifthen{#1}\If@noend{\BlockIf{#2}}}
\renewcommand{\algocf@uElseIf}[2]{\ElseIf@elseif{#1}\If@noend{\BlockElseIf{#2}}}
\renewcommand{\algocf@Else}[1]{\Else@else\If@endif{\BlockElse{#1}}}
\makeatother

\begin{document}

\begin{algorithm}[H]
\uIf{1}{if...}
\uElseIf{2}{else if...}
\Else{else...}
\end{algorithm}

\begin{algorithm}[H]
\uIf{1}{if...}
\uElseIf{2}{\ForAll{$i$}{Action $i$}}
\Else{else...}
\end{algorithm}

\end{document}


## Unwanted warning

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.26     \uElseIf{2}{\ForAll{$i$}{Action $i$}}

-

You have a choice, depending on the layout you want.

Either make sure that LaTeX is in a paragraph before forcing a linebreak, so replace each \\ in your example by

\mbox{}\\


or don't force a linebreak if you are between paragraphs so replace each \\ by

\ifhmode\\\fi

-
Very tricky solution ! That's do the job. Thanks. –  projetmbc Oct 30 '12 at 16:28