3

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}
2
  • 1
    never use \\ at the beginning or end of a paragraph ` \vspace{0.4em}\\ will always give the error you state, if you want a bigger space just give a bigger space eg \vspace{1.5\baselineskip Jan 16, 2017 at 8:12
  • That does the job !
    – projetmbc
    Jan 16, 2017 at 10:30

1 Answer 1

3

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

1
  • I have updated my question to indicate that the spacing are changed in some places and not every where. Your code remains useful.
    – projetmbc
    Jan 16, 2017 at 10:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .