[Tex/LaTex] algorithm2e – How to remove space between colon and text

algorithm2ealgorithmspseudocodespacingvertical alignment

How can I reduce this large space between colon and text in line with Input: ?
Also please how to remove align of text after Input: and Precondition: ? I am using algorithm2e. Is it possible with this package? Here is my code:

\documentclass{article}

\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{amsmath}
\usepackage{setspace}

\begin{document}

    \begin{algorithm}
        \SetAlgorithmName{Algorithm}{}{}
        \SetKwInOut{Precondition}{Precondition~}
        \SetKwInOut{Input}{Input~}
        \Input{~There is some fancy input definition.}
        \Precondition {~There is some fancy precondition.}
        \begin{doublespace}
            \eIf{$b=0$}
            {
                return $a$
            }
            {
                $b$
            }
        \end{doublespace}   
        \caption{Best algorithm ever.}
    \end{algorithm}

\end{document}

This is actual state:

enter image description here

This is wanted final state:

enter image description here

Best Answer

You could use SetKwInput for the first conditions, as SetKwInOut works just adjusting the space as you have seen.

Here an example

\documentclass{article}

\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{amsmath}
\usepackage{setspace}

\begin{document}

    \begin{algorithm}
        \SetAlgorithmName{Algorithm}{}{}
              \SetKwInput{Precondition}{Precondition~}
                              \SetKwInput{Input}{Input~}


        \Input{~There is some fancy input definition.}
        \Precondition {~There is some fancy precondition.}
        \begin{doublespace}
            \eIf{$b=0$}
            {
                return $a$
            }
            {
                $b$
            }
        \end{doublespace}   
        \caption{Best algorithm ever.}
    \end{algorithm}

\end{document}

result:

enter image description here