[Tex/LaTex] algorithm2e and extra vertical spaces

algorithm2espacing

Solution

The comment below of David Carlisle gives the solution.

Problem

With the code below, I can add extra vertical spaces where I want but not everywhere. My problem is that the compilation complains by saying the following ugly things even if at the end the job ii done. How can I do to make back peace between me and my LaTeX compiler ?

Hurting log messages 😉

./extra_vertical_space.tex:9: 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.9     \\

? 

MMWE (Minimal Merly Working Example)

\documentclass[a4,11pt]{article}
    \usepackage[french, vlined]{algorithm2e}

\begin{document}

\begin{algorithm}[H]
    \KwData{some datas}
    \vspace{0.4em}
    \\
    \Begin{
        \vspace{0.4em}
        \\
        Step 1
        \\
        Step 2
        \\
        \vspace{0.4em}
        \\
        \While{one condition is true}{
            \vspace{0.4em}
            \\
            ... and so on.
        }
    }
\end{algorithm}

\end{document}

Best Answer

You could use the setspace package to increase the linespacing.

\documentclass{article}
\usepackage[french,vlined]{algorithm2e}
\usepackage{setspace}

\begin{document}

\begin{algorithm}
  \begin{doublespace}
    \KwData{some datas}
    \Begin{
      Step 1\;
      Step 2\;
      \While{one condition is true}{
        ... and so on.\;
      }
    }
  \end{doublespace}
\end{algorithm}

\end{document}

enter image description here