How to align horizontally line numbers with package algorithm2e












0















I'm trying to write an algorithm using the package algorithm2e.



This is my code:



usepackage[linesnumbered,ruled]{algorithm2e}
...
{footnotesize
IncMargin{1em}
begin{algorithm}[H]
SetAlgoVlined
SetAlgoNlRelativeSize{-1}
SetNlSkip{1em}

$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};

end{algorithm}
}


And this is the result:
enter image description here



The problem is that the line numbers are not properly aligned: for example the 9 is a lot more on the right than the 1.



So, how can I properly align them horizontally?










share|improve this question



























    0















    I'm trying to write an algorithm using the package algorithm2e.



    This is my code:



    usepackage[linesnumbered,ruled]{algorithm2e}
    ...
    {footnotesize
    IncMargin{1em}
    begin{algorithm}[H]
    SetAlgoVlined
    SetAlgoNlRelativeSize{-1}
    SetNlSkip{1em}

    $ALIGNMENTS gets NEXT$;
    BlankLine
    While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
    $NEXT gets 0$;
    ForEach{$A in ALIGNMENTS$}{
    $U gets checkAlignments(mu,A,C_{cov})$;
    uIf{$|U| = 1$}{
    $mu gets updateProfile(mu,U)$;
    }
    Else{
    $NEXT = NEXT cup {A}$;
    }
    }
    If{$|ALIGNMENTS| = |NEXT|$}{
    $C_{cov} gets C_{cov} - 1$;
    }
    $ALIGNMENTS gets NEXT$;
    }
    BlankLine
    KwRet{$mu$};

    end{algorithm}
    }


    And this is the result:
    enter image description here



    The problem is that the line numbers are not properly aligned: for example the 9 is a lot more on the right than the 1.



    So, how can I properly align them horizontally?










    share|improve this question

























      0












      0








      0








      I'm trying to write an algorithm using the package algorithm2e.



      This is my code:



      usepackage[linesnumbered,ruled]{algorithm2e}
      ...
      {footnotesize
      IncMargin{1em}
      begin{algorithm}[H]
      SetAlgoVlined
      SetAlgoNlRelativeSize{-1}
      SetNlSkip{1em}

      $ALIGNMENTS gets NEXT$;
      BlankLine
      While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
      $NEXT gets 0$;
      ForEach{$A in ALIGNMENTS$}{
      $U gets checkAlignments(mu,A,C_{cov})$;
      uIf{$|U| = 1$}{
      $mu gets updateProfile(mu,U)$;
      }
      Else{
      $NEXT = NEXT cup {A}$;
      }
      }
      If{$|ALIGNMENTS| = |NEXT|$}{
      $C_{cov} gets C_{cov} - 1$;
      }
      $ALIGNMENTS gets NEXT$;
      }
      BlankLine
      KwRet{$mu$};

      end{algorithm}
      }


      And this is the result:
      enter image description here



      The problem is that the line numbers are not properly aligned: for example the 9 is a lot more on the right than the 1.



      So, how can I properly align them horizontally?










      share|improve this question














      I'm trying to write an algorithm using the package algorithm2e.



      This is my code:



      usepackage[linesnumbered,ruled]{algorithm2e}
      ...
      {footnotesize
      IncMargin{1em}
      begin{algorithm}[H]
      SetAlgoVlined
      SetAlgoNlRelativeSize{-1}
      SetNlSkip{1em}

      $ALIGNMENTS gets NEXT$;
      BlankLine
      While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
      $NEXT gets 0$;
      ForEach{$A in ALIGNMENTS$}{
      $U gets checkAlignments(mu,A,C_{cov})$;
      uIf{$|U| = 1$}{
      $mu gets updateProfile(mu,U)$;
      }
      Else{
      $NEXT = NEXT cup {A}$;
      }
      }
      If{$|ALIGNMENTS| = |NEXT|$}{
      $C_{cov} gets C_{cov} - 1$;
      }
      $ALIGNMENTS gets NEXT$;
      }
      BlankLine
      KwRet{$mu$};

      end{algorithm}
      }


      And this is the result:
      enter image description here



      The problem is that the line numbers are not properly aligned: for example the 9 is a lot more on the right than the 1.



      So, how can I properly align them horizontally?







      algorithms algorithm2e line-numbering algorithmicx algorithmic






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 25 at 11:40









      TommyTommy

      1




      1






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Welcome to TeX.SE. From the documentation of algorithm2e you have:



          enter image description here



          documentclass[12pt]{article}
          usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
          begin{document}
          IncMargin{1em}
          begin{algorithm}
          $ALIGNMENTS gets NEXT$;
          BlankLine
          While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
          $NEXT gets 0$;
          ForEach{$A in ALIGNMENTS$}{
          $U gets checkAlignments(mu,A,C_{cov})$;
          uIf{$|U| = 1$}{
          $mu gets updateProfile(mu,U)$;
          }
          Else{
          $NEXT = NEXT cup {A}$;
          }
          }
          If{$|ALIGNMENTS| = |NEXT|$}{
          $C_{cov} gets C_{cov} - 1$;
          }
          $ALIGNMENTS gets NEXT$;
          }
          BlankLine
          KwRet{$mu$};
          DecMargin{1em}
          end{algorithm}
          end{document}





          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476579%2fhow-to-align-horizontally-line-numbers-with-package-algorithm2e%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Welcome to TeX.SE. From the documentation of algorithm2e you have:



            enter image description here



            documentclass[12pt]{article}
            usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
            begin{document}
            IncMargin{1em}
            begin{algorithm}
            $ALIGNMENTS gets NEXT$;
            BlankLine
            While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
            $NEXT gets 0$;
            ForEach{$A in ALIGNMENTS$}{
            $U gets checkAlignments(mu,A,C_{cov})$;
            uIf{$|U| = 1$}{
            $mu gets updateProfile(mu,U)$;
            }
            Else{
            $NEXT = NEXT cup {A}$;
            }
            }
            If{$|ALIGNMENTS| = |NEXT|$}{
            $C_{cov} gets C_{cov} - 1$;
            }
            $ALIGNMENTS gets NEXT$;
            }
            BlankLine
            KwRet{$mu$};
            DecMargin{1em}
            end{algorithm}
            end{document}





            share|improve this answer






























              1














              Welcome to TeX.SE. From the documentation of algorithm2e you have:



              enter image description here



              documentclass[12pt]{article}
              usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
              begin{document}
              IncMargin{1em}
              begin{algorithm}
              $ALIGNMENTS gets NEXT$;
              BlankLine
              While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
              $NEXT gets 0$;
              ForEach{$A in ALIGNMENTS$}{
              $U gets checkAlignments(mu,A,C_{cov})$;
              uIf{$|U| = 1$}{
              $mu gets updateProfile(mu,U)$;
              }
              Else{
              $NEXT = NEXT cup {A}$;
              }
              }
              If{$|ALIGNMENTS| = |NEXT|$}{
              $C_{cov} gets C_{cov} - 1$;
              }
              $ALIGNMENTS gets NEXT$;
              }
              BlankLine
              KwRet{$mu$};
              DecMargin{1em}
              end{algorithm}
              end{document}





              share|improve this answer




























                1












                1








                1







                Welcome to TeX.SE. From the documentation of algorithm2e you have:



                enter image description here



                documentclass[12pt]{article}
                usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
                begin{document}
                IncMargin{1em}
                begin{algorithm}
                $ALIGNMENTS gets NEXT$;
                BlankLine
                While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
                $NEXT gets 0$;
                ForEach{$A in ALIGNMENTS$}{
                $U gets checkAlignments(mu,A,C_{cov})$;
                uIf{$|U| = 1$}{
                $mu gets updateProfile(mu,U)$;
                }
                Else{
                $NEXT = NEXT cup {A}$;
                }
                }
                If{$|ALIGNMENTS| = |NEXT|$}{
                $C_{cov} gets C_{cov} - 1$;
                }
                $ALIGNMENTS gets NEXT$;
                }
                BlankLine
                KwRet{$mu$};
                DecMargin{1em}
                end{algorithm}
                end{document}





                share|improve this answer















                Welcome to TeX.SE. From the documentation of algorithm2e you have:



                enter image description here



                documentclass[12pt]{article}
                usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
                begin{document}
                IncMargin{1em}
                begin{algorithm}
                $ALIGNMENTS gets NEXT$;
                BlankLine
                While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
                $NEXT gets 0$;
                ForEach{$A in ALIGNMENTS$}{
                $U gets checkAlignments(mu,A,C_{cov})$;
                uIf{$|U| = 1$}{
                $mu gets updateProfile(mu,U)$;
                }
                Else{
                $NEXT = NEXT cup {A}$;
                }
                }
                If{$|ALIGNMENTS| = |NEXT|$}{
                $C_{cov} gets C_{cov} - 1$;
                }
                $ALIGNMENTS gets NEXT$;
                }
                BlankLine
                KwRet{$mu$};
                DecMargin{1em}
                end{algorithm}
                end{document}






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 25 at 12:58

























                answered Feb 25 at 11:47









                SebastianoSebastiano

                10.4k42060




                10.4k42060






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476579%2fhow-to-align-horizontally-line-numbers-with-package-algorithm2e%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to change which sound is reproduced for terminal bell?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?