title: How to fix alignment of algorithm in latex
body: <p>I need to fix the alignment of this LaTeX code.</p>
  
  <p>When I compile it, the output has the wrong alignment of <code>if</code>, <code>for</code>, <code>else</code> statements.</p>
  
  <pre><code>\begin{algorithm}[H]
         \caption{:The $ASP\_Tree$ algorithm}     
         \SetKwInOut{Input}{Input}
         \SetKwInOut{Output}{Output}   
         \Input{TV database and min\_sup }
           \Output{Bla bla bla}
           \KwData{bla bla bla} 
           \Procedure{Tree}{$TV_i, min\_sup$}
          {
              \State {$[Root] \leftarrow [NULL]$} \newline
              \For {$i=1$ to $N$} {\label{forins} \newline
                  {
                  %\Statex \Comment {\%Comments: insert TV values into the tree based on rules}
                          \State {$Root \leftarrow TV_1$}
                          \State {$i \leftarrow i+1$} \newline                        
                          \If {TV_i \textgreater Root}
                      \State Root \gets TV_i
                          \ELSIF {TV_i\leq Root}
                      \State i\gets i+1
                          \ELSE
                                \State do something interesting
                          \ENDIF
                          }
                \EndFor   
                              }
              \EndProcedure       
              \end{algorithm}     
  </code></pre>