[Tex/LaTex] algorithm and controlling comment lines (shifting right or left)

algorithms

I need to shift a comment to the right. Basically, in the below picture

enter image description here

The comment is distracting the pseudocode, therefore, I'm hoping to get the below picture

enter image description here

How to shift the comment to the right? This is my code

\documentclass{article}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{algorithm,algpseudocode,float}

%-----------
\makeatletter
\newenvironment{breakablealgorithm}
  {% \begin{breakablealgorithm}
   \begin{center}
     \refstepcounter{algorithm}% New algorithm
     \hrule height.8pt depth0pt \kern2pt% \@fs@pre for \@fs@ruled
     \renewcommand{\caption}[2][\relax]{% Make a new \caption
       {\raggedright\textbf{\ALG@name~\thealgorithm} ##2\par}%
       \ifx\relax##1\relax % #1 is \relax
         \addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##2}%
       \else % #1 is not \relax
         \addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##1}%
       \fi
       \kern2pt\hrule\kern2pt
     }
  }{% \end{breakablealgorithm}
     \kern2pt\hrule\relax% \@fs@post for \@fs@ruled
   \end{center}
  }
\makeatother

\begin{document}

\begin{breakablealgorithm}
  \caption{PPPPPPPPPPPPP}
  \begin{algorithmic}[1]
  \makeatletter\setcounter{ALG@line}{0}\makeatother
  \If { $\phi < 10^\circ$}
        \State{$A = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$} \Comment{ where \textbf{a} is aaaaaaaaaa   constant.}
        \Else
           \State{$B =  bbbbbbbbb$ }
        \EndIf  
\end{algorithmic}
\end{breakablealgorithm}


\end{document}

Best Answer

You can use a \parbox (with \raggedright text if too narrow):

\documentclass{article}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{algorithm,algpseudocode,float}

%-----------
\makeatletter
\newenvironment{breakablealgorithm}
  {% \begin{breakablealgorithm}
   \begin{center}
     \refstepcounter{algorithm}% New algorithm
     \hrule height.8pt depth0pt \kern2pt% \@fs@pre for \@fs@ruled
     \renewcommand{\caption}[2][\relax]{% Make a new \caption
       {\raggedright\textbf{\ALG@name~\thealgorithm} ##2\par}%
       \ifx\relax##1\relax % #1 is \relax
         \addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##2}%
       \else % #1 is not \relax
         \addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##1}%
       \fi
       \kern2pt\hrule\kern2pt
     }
  }{% \end{breakablealgorithm}
     \kern2pt\hrule\relax% \@fs@post for \@fs@ruled
   \end{center}
  }
\makeatother

\begin{document}

\begin{breakablealgorithm}
  \caption{PPPPPPPPPPPPP}
  \begin{algorithmic}[1]
  \makeatletter\setcounter{ALG@line}{0}\makeatother
  \If { $\phi < 10^\circ$}
        \State{$A = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$} \Comment{\parbox[t]{4cm}{\raggedright where \textbf{a} is some unknown constant.}}
        \Else
           \State{$B =  bbbbbbbbb$ }
        \EndIf  
\end{algorithmic}
\end{breakablealgorithm}

\end{document}

enter image description here