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}
  • 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 – David Carlisle Jan 16 '17 at 8:12
  • That does the job ! – projetmbc Jan 16 '17 at 10:30
2

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

| improve this answer | |
  • 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 '17 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.