Help with algorithm2e formatting












2















recentely I've got into a bit more advanced LaTeX formatting, i.e algorithms. My package of choice is the algorithm2e package, but I'm having some difficulities operating it.



So I've wanted to create an algorithm using the algorithm2e package, but I can't quite wrap my head around how it operates.



Here is my code.



As for packages, all I've used is



usepackage{amsmath}
usepackage[linesnumbered]{algorithm2e}


amsmath for mathematical library
and re-set the algorithm2e to enumerate the lines of my algorithm



SetAlgoNoLine
begin{algorithm}[H]
DontPrintSemicolon
KwIn{$X_{t-1}, u_t. z_t$}
KwOut{$X_t$}
$overline{X_t} = X_t = 0$;
For{$k = 1$ to $M$}{
$x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
$w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
$m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
$overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
}
For {$k = 1$ to $M$}{
draw i with probability $approx w_t^{[i]}$;
add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
}
Return $X_t$
caption{FastSLAM}
end{algorithm}


Which produces this:



fielded result



My desired result would be:



desired



So I've got 5 questions.



1) How can I redefine the algorithm2e to print "Algoritmus" instead of Algorithm in place of my caption? *Answered in comments
2) Probably will have similar solution as 1), but is it possible for my algorithm to print end for instead of only end?
3) How to place the caption title on the top instead of the bottom of the algorhitm?
4) How to add the <hr>look-a-like line break in the specific parts of algorithm?
5) Is it good practice inside the For loop to define it as For{$k = 1$ to $M$}{ code.. }? Seems a bit artificial to me to add the word to there. Isn't there an inbuilt function for this?



EDIT: Found a solution to question number 3 and 4. Studied the algorithm2e.sty file and found solution.



For those wondering, change the package definition to usepackage[linesnumbered, ruled, vlined]



Produces the following:



edited



The remaining questions however still stand.










share|improve this question

























  • @Naphaneal if i'm not mistaken, that doesn't work with algorithm2e package, but only different ones. At least I did at the very least get an unknown command error. Although I found, that if I change the language options in usepackage, it will change the name of the Algorhitm to Algoritmus automatically. (in this particular case, it was changing it to Slovak).

    – Rawrplus
    Apr 2 '16 at 20:25













  • my bad. I overlooked the missing 2e part. I was actually looking for this answer: tex.stackexchange.com/questions/146050/…

    – naphaneal
    Apr 2 '16 at 20:29











  • yup as i said, defining the language in the algorithm2e usepackage does the trick :) Although by any chance I presume you don't know how to apply namechange to also the ending of for loop, or?

    – Rawrplus
    Apr 2 '16 at 20:40


















2















recentely I've got into a bit more advanced LaTeX formatting, i.e algorithms. My package of choice is the algorithm2e package, but I'm having some difficulities operating it.



So I've wanted to create an algorithm using the algorithm2e package, but I can't quite wrap my head around how it operates.



Here is my code.



As for packages, all I've used is



usepackage{amsmath}
usepackage[linesnumbered]{algorithm2e}


amsmath for mathematical library
and re-set the algorithm2e to enumerate the lines of my algorithm



SetAlgoNoLine
begin{algorithm}[H]
DontPrintSemicolon
KwIn{$X_{t-1}, u_t. z_t$}
KwOut{$X_t$}
$overline{X_t} = X_t = 0$;
For{$k = 1$ to $M$}{
$x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
$w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
$m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
$overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
}
For {$k = 1$ to $M$}{
draw i with probability $approx w_t^{[i]}$;
add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
}
Return $X_t$
caption{FastSLAM}
end{algorithm}


Which produces this:



fielded result



My desired result would be:



desired



So I've got 5 questions.



1) How can I redefine the algorithm2e to print "Algoritmus" instead of Algorithm in place of my caption? *Answered in comments
2) Probably will have similar solution as 1), but is it possible for my algorithm to print end for instead of only end?
3) How to place the caption title on the top instead of the bottom of the algorhitm?
4) How to add the <hr>look-a-like line break in the specific parts of algorithm?
5) Is it good practice inside the For loop to define it as For{$k = 1$ to $M$}{ code.. }? Seems a bit artificial to me to add the word to there. Isn't there an inbuilt function for this?



EDIT: Found a solution to question number 3 and 4. Studied the algorithm2e.sty file and found solution.



For those wondering, change the package definition to usepackage[linesnumbered, ruled, vlined]



Produces the following:



edited



The remaining questions however still stand.










share|improve this question

























  • @Naphaneal if i'm not mistaken, that doesn't work with algorithm2e package, but only different ones. At least I did at the very least get an unknown command error. Although I found, that if I change the language options in usepackage, it will change the name of the Algorhitm to Algoritmus automatically. (in this particular case, it was changing it to Slovak).

    – Rawrplus
    Apr 2 '16 at 20:25













  • my bad. I overlooked the missing 2e part. I was actually looking for this answer: tex.stackexchange.com/questions/146050/…

    – naphaneal
    Apr 2 '16 at 20:29











  • yup as i said, defining the language in the algorithm2e usepackage does the trick :) Although by any chance I presume you don't know how to apply namechange to also the ending of for loop, or?

    – Rawrplus
    Apr 2 '16 at 20:40
















2












2








2


1






recentely I've got into a bit more advanced LaTeX formatting, i.e algorithms. My package of choice is the algorithm2e package, but I'm having some difficulities operating it.



So I've wanted to create an algorithm using the algorithm2e package, but I can't quite wrap my head around how it operates.



Here is my code.



As for packages, all I've used is



usepackage{amsmath}
usepackage[linesnumbered]{algorithm2e}


amsmath for mathematical library
and re-set the algorithm2e to enumerate the lines of my algorithm



SetAlgoNoLine
begin{algorithm}[H]
DontPrintSemicolon
KwIn{$X_{t-1}, u_t. z_t$}
KwOut{$X_t$}
$overline{X_t} = X_t = 0$;
For{$k = 1$ to $M$}{
$x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
$w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
$m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
$overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
}
For {$k = 1$ to $M$}{
draw i with probability $approx w_t^{[i]}$;
add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
}
Return $X_t$
caption{FastSLAM}
end{algorithm}


Which produces this:



fielded result



My desired result would be:



desired



So I've got 5 questions.



1) How can I redefine the algorithm2e to print "Algoritmus" instead of Algorithm in place of my caption? *Answered in comments
2) Probably will have similar solution as 1), but is it possible for my algorithm to print end for instead of only end?
3) How to place the caption title on the top instead of the bottom of the algorhitm?
4) How to add the <hr>look-a-like line break in the specific parts of algorithm?
5) Is it good practice inside the For loop to define it as For{$k = 1$ to $M$}{ code.. }? Seems a bit artificial to me to add the word to there. Isn't there an inbuilt function for this?



EDIT: Found a solution to question number 3 and 4. Studied the algorithm2e.sty file and found solution.



For those wondering, change the package definition to usepackage[linesnumbered, ruled, vlined]



Produces the following:



edited



The remaining questions however still stand.










share|improve this question
















recentely I've got into a bit more advanced LaTeX formatting, i.e algorithms. My package of choice is the algorithm2e package, but I'm having some difficulities operating it.



So I've wanted to create an algorithm using the algorithm2e package, but I can't quite wrap my head around how it operates.



Here is my code.



As for packages, all I've used is



usepackage{amsmath}
usepackage[linesnumbered]{algorithm2e}


amsmath for mathematical library
and re-set the algorithm2e to enumerate the lines of my algorithm



SetAlgoNoLine
begin{algorithm}[H]
DontPrintSemicolon
KwIn{$X_{t-1}, u_t. z_t$}
KwOut{$X_t$}
$overline{X_t} = X_t = 0$;
For{$k = 1$ to $M$}{
$x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
$w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
$m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
$overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
}
For {$k = 1$ to $M$}{
draw i with probability $approx w_t^{[i]}$;
add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
}
Return $X_t$
caption{FastSLAM}
end{algorithm}


Which produces this:



fielded result



My desired result would be:



desired



So I've got 5 questions.



1) How can I redefine the algorithm2e to print "Algoritmus" instead of Algorithm in place of my caption? *Answered in comments
2) Probably will have similar solution as 1), but is it possible for my algorithm to print end for instead of only end?
3) How to place the caption title on the top instead of the bottom of the algorhitm?
4) How to add the <hr>look-a-like line break in the specific parts of algorithm?
5) Is it good practice inside the For loop to define it as For{$k = 1$ to $M$}{ code.. }? Seems a bit artificial to me to add the word to there. Isn't there an inbuilt function for this?



EDIT: Found a solution to question number 3 and 4. Studied the algorithm2e.sty file and found solution.



For those wondering, change the package definition to usepackage[linesnumbered, ruled, vlined]



Produces the following:



edited



The remaining questions however still stand.







formatting algorithms algorithm2e






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 2 '16 at 20:28







Rawrplus

















asked Apr 2 '16 at 19:38









RawrplusRawrplus

1286




1286













  • @Naphaneal if i'm not mistaken, that doesn't work with algorithm2e package, but only different ones. At least I did at the very least get an unknown command error. Although I found, that if I change the language options in usepackage, it will change the name of the Algorhitm to Algoritmus automatically. (in this particular case, it was changing it to Slovak).

    – Rawrplus
    Apr 2 '16 at 20:25













  • my bad. I overlooked the missing 2e part. I was actually looking for this answer: tex.stackexchange.com/questions/146050/…

    – naphaneal
    Apr 2 '16 at 20:29











  • yup as i said, defining the language in the algorithm2e usepackage does the trick :) Although by any chance I presume you don't know how to apply namechange to also the ending of for loop, or?

    – Rawrplus
    Apr 2 '16 at 20:40





















  • @Naphaneal if i'm not mistaken, that doesn't work with algorithm2e package, but only different ones. At least I did at the very least get an unknown command error. Although I found, that if I change the language options in usepackage, it will change the name of the Algorhitm to Algoritmus automatically. (in this particular case, it was changing it to Slovak).

    – Rawrplus
    Apr 2 '16 at 20:25













  • my bad. I overlooked the missing 2e part. I was actually looking for this answer: tex.stackexchange.com/questions/146050/…

    – naphaneal
    Apr 2 '16 at 20:29











  • yup as i said, defining the language in the algorithm2e usepackage does the trick :) Although by any chance I presume you don't know how to apply namechange to also the ending of for loop, or?

    – Rawrplus
    Apr 2 '16 at 20:40



















@Naphaneal if i'm not mistaken, that doesn't work with algorithm2e package, but only different ones. At least I did at the very least get an unknown command error. Although I found, that if I change the language options in usepackage, it will change the name of the Algorhitm to Algoritmus automatically. (in this particular case, it was changing it to Slovak).

– Rawrplus
Apr 2 '16 at 20:25







@Naphaneal if i'm not mistaken, that doesn't work with algorithm2e package, but only different ones. At least I did at the very least get an unknown command error. Although I found, that if I change the language options in usepackage, it will change the name of the Algorhitm to Algoritmus automatically. (in this particular case, it was changing it to Slovak).

– Rawrplus
Apr 2 '16 at 20:25















my bad. I overlooked the missing 2e part. I was actually looking for this answer: tex.stackexchange.com/questions/146050/…

– naphaneal
Apr 2 '16 at 20:29





my bad. I overlooked the missing 2e part. I was actually looking for this answer: tex.stackexchange.com/questions/146050/…

– naphaneal
Apr 2 '16 at 20:29













yup as i said, defining the language in the algorithm2e usepackage does the trick :) Although by any chance I presume you don't know how to apply namechange to also the ending of for loop, or?

– Rawrplus
Apr 2 '16 at 20:40







yup as i said, defining the language in the algorithm2e usepackage does the trick :) Although by any chance I presume you don't know how to apply namechange to also the ending of for loop, or?

– Rawrplus
Apr 2 '16 at 20:40












2 Answers
2






active

oldest

votes


















1














Supposing your document is in German , loading babel with german set via document class does the trick. To replace end with endfor, overwrite the definition of For with SetKwFor:



documentclass[german] {article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{babel} usepackage[linesnumbered, ruled, vlined]{algorithm2e}

SetKwFor{For}{for}{do}{endfor for}%

begin{document}

SetAlgoNoLine
begin{algorithm}[H]
DontPrintSemicolon
KwIn{$X_{t-1}, u_t · z_t$}
KwOut{$X_t$}
$overline{X_t} = X_t = 0$;
For{$k = 1$ to $M$}{
$x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
$w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
$m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
$overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
}
For {$k = 1$ to $M$}{
draw $ i $ with probability $approx w_t^{[i]}$;
add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
}
Return $X_t$
caption{FastSLAM}
end{algorithm}

end{document}


enter image description here






share|improve this answer

































    1














    Well sadly, nobody really answered and by time it took everybody to do so, I managed to find answers to majority of my questions already.



    So to go over them 1 by 1.



    To set the algorithm name (caption) to be displayed on top, to add lines inbetween blocks and to change name of Algorithm to Algoritmus, you have to edit the settings in your usepackage declaration.



    I would strongly recommend downloading and studying the "algorithm2e.sty" file, it's wonderfully documented there and you will pretty much find answers to all your questions.



    So we edited the declaration to following: usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}



    Obviously, you will set the language option to your own personal preference.
    On top of that, you can edit the original algorithm2e.sty file to change the localisation definitions/declarations to your personal liking, if you don't like the default options.



    As for changing the definition of end to print end for instead, this was a tricky one and I've spent hours searching for this, but inside the documentation I found the SetKw command.



    In this particular case, we changed it to SetKwFor{For}{for}{do}{end~for}



    I can't answer my last question, whether it's good practice to manually add to to the for condition, somebody will have to answer that for me.



    Here is the final code



        SetAlgoNoLine
    begin{algorithm}[H]
    DontPrintSemicolon
    SetKwFor{For}{for}{do}{end~for}
    KwIn{$X_{t-1}, u_t. z_t$}
    KwOut{$X_t$}
    $overline{X_t} = X_t = 0$;
    For{$k = 1$ to $M$}{
    $x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
    $w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
    $m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
    $overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
    }
    For {$k = 1$ to $M$}{
    draw i with probability $approx w_t^{[i]}$;
    add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
    }
    Return $X_t$
    caption{FastSLAM}
    label{alg:alg1}
    end{algorithm}


    Package definition is as mentioned usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}
    Will produce the following



    answer






    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%2f302162%2fhelp-with-algorithm2e-formatting%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Supposing your document is in German , loading babel with german set via document class does the trick. To replace end with endfor, overwrite the definition of For with SetKwFor:



      documentclass[german] {article}
      usepackage[utf8]{inputenc}
      usepackage[T1]{fontenc}
      usepackage{babel} usepackage[linesnumbered, ruled, vlined]{algorithm2e}

      SetKwFor{For}{for}{do}{endfor for}%

      begin{document}

      SetAlgoNoLine
      begin{algorithm}[H]
      DontPrintSemicolon
      KwIn{$X_{t-1}, u_t · z_t$}
      KwOut{$X_t$}
      $overline{X_t} = X_t = 0$;
      For{$k = 1$ to $M$}{
      $x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
      $w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
      $m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
      $overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
      }
      For {$k = 1$ to $M$}{
      draw $ i $ with probability $approx w_t^{[i]}$;
      add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
      }
      Return $X_t$
      caption{FastSLAM}
      end{algorithm}

      end{document}


      enter image description here






      share|improve this answer






























        1














        Supposing your document is in German , loading babel with german set via document class does the trick. To replace end with endfor, overwrite the definition of For with SetKwFor:



        documentclass[german] {article}
        usepackage[utf8]{inputenc}
        usepackage[T1]{fontenc}
        usepackage{babel} usepackage[linesnumbered, ruled, vlined]{algorithm2e}

        SetKwFor{For}{for}{do}{endfor for}%

        begin{document}

        SetAlgoNoLine
        begin{algorithm}[H]
        DontPrintSemicolon
        KwIn{$X_{t-1}, u_t · z_t$}
        KwOut{$X_t$}
        $overline{X_t} = X_t = 0$;
        For{$k = 1$ to $M$}{
        $x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
        $w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
        $m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
        $overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
        }
        For {$k = 1$ to $M$}{
        draw $ i $ with probability $approx w_t^{[i]}$;
        add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
        }
        Return $X_t$
        caption{FastSLAM}
        end{algorithm}

        end{document}


        enter image description here






        share|improve this answer




























          1












          1








          1







          Supposing your document is in German , loading babel with german set via document class does the trick. To replace end with endfor, overwrite the definition of For with SetKwFor:



          documentclass[german] {article}
          usepackage[utf8]{inputenc}
          usepackage[T1]{fontenc}
          usepackage{babel} usepackage[linesnumbered, ruled, vlined]{algorithm2e}

          SetKwFor{For}{for}{do}{endfor for}%

          begin{document}

          SetAlgoNoLine
          begin{algorithm}[H]
          DontPrintSemicolon
          KwIn{$X_{t-1}, u_t · z_t$}
          KwOut{$X_t$}
          $overline{X_t} = X_t = 0$;
          For{$k = 1$ to $M$}{
          $x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
          $w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
          $m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
          $overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
          }
          For {$k = 1$ to $M$}{
          draw $ i $ with probability $approx w_t^{[i]}$;
          add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
          }
          Return $X_t$
          caption{FastSLAM}
          end{algorithm}

          end{document}


          enter image description here






          share|improve this answer















          Supposing your document is in German , loading babel with german set via document class does the trick. To replace end with endfor, overwrite the definition of For with SetKwFor:



          documentclass[german] {article}
          usepackage[utf8]{inputenc}
          usepackage[T1]{fontenc}
          usepackage{babel} usepackage[linesnumbered, ruled, vlined]{algorithm2e}

          SetKwFor{For}{for}{do}{endfor for}%

          begin{document}

          SetAlgoNoLine
          begin{algorithm}[H]
          DontPrintSemicolon
          KwIn{$X_{t-1}, u_t · z_t$}
          KwOut{$X_t$}
          $overline{X_t} = X_t = 0$;
          For{$k = 1$ to $M$}{
          $x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
          $w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
          $m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
          $overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
          }
          For {$k = 1$ to $M$}{
          draw $ i $ with probability $approx w_t^{[i]}$;
          add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
          }
          Return $X_t$
          caption{FastSLAM}
          end{algorithm}

          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 4 hours ago

























          answered Apr 2 '16 at 21:00









          BernardBernard

          174k776207




          174k776207























              1














              Well sadly, nobody really answered and by time it took everybody to do so, I managed to find answers to majority of my questions already.



              So to go over them 1 by 1.



              To set the algorithm name (caption) to be displayed on top, to add lines inbetween blocks and to change name of Algorithm to Algoritmus, you have to edit the settings in your usepackage declaration.



              I would strongly recommend downloading and studying the "algorithm2e.sty" file, it's wonderfully documented there and you will pretty much find answers to all your questions.



              So we edited the declaration to following: usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}



              Obviously, you will set the language option to your own personal preference.
              On top of that, you can edit the original algorithm2e.sty file to change the localisation definitions/declarations to your personal liking, if you don't like the default options.



              As for changing the definition of end to print end for instead, this was a tricky one and I've spent hours searching for this, but inside the documentation I found the SetKw command.



              In this particular case, we changed it to SetKwFor{For}{for}{do}{end~for}



              I can't answer my last question, whether it's good practice to manually add to to the for condition, somebody will have to answer that for me.



              Here is the final code



                  SetAlgoNoLine
              begin{algorithm}[H]
              DontPrintSemicolon
              SetKwFor{For}{for}{do}{end~for}
              KwIn{$X_{t-1}, u_t. z_t$}
              KwOut{$X_t$}
              $overline{X_t} = X_t = 0$;
              For{$k = 1$ to $M$}{
              $x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
              $w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
              $m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
              $overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
              }
              For {$k = 1$ to $M$}{
              draw i with probability $approx w_t^{[i]}$;
              add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
              }
              Return $X_t$
              caption{FastSLAM}
              label{alg:alg1}
              end{algorithm}


              Package definition is as mentioned usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}
              Will produce the following



              answer






              share|improve this answer






























                1














                Well sadly, nobody really answered and by time it took everybody to do so, I managed to find answers to majority of my questions already.



                So to go over them 1 by 1.



                To set the algorithm name (caption) to be displayed on top, to add lines inbetween blocks and to change name of Algorithm to Algoritmus, you have to edit the settings in your usepackage declaration.



                I would strongly recommend downloading and studying the "algorithm2e.sty" file, it's wonderfully documented there and you will pretty much find answers to all your questions.



                So we edited the declaration to following: usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}



                Obviously, you will set the language option to your own personal preference.
                On top of that, you can edit the original algorithm2e.sty file to change the localisation definitions/declarations to your personal liking, if you don't like the default options.



                As for changing the definition of end to print end for instead, this was a tricky one and I've spent hours searching for this, but inside the documentation I found the SetKw command.



                In this particular case, we changed it to SetKwFor{For}{for}{do}{end~for}



                I can't answer my last question, whether it's good practice to manually add to to the for condition, somebody will have to answer that for me.



                Here is the final code



                    SetAlgoNoLine
                begin{algorithm}[H]
                DontPrintSemicolon
                SetKwFor{For}{for}{do}{end~for}
                KwIn{$X_{t-1}, u_t. z_t$}
                KwOut{$X_t$}
                $overline{X_t} = X_t = 0$;
                For{$k = 1$ to $M$}{
                $x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
                $w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
                $m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
                $overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
                }
                For {$k = 1$ to $M$}{
                draw i with probability $approx w_t^{[i]}$;
                add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
                }
                Return $X_t$
                caption{FastSLAM}
                label{alg:alg1}
                end{algorithm}


                Package definition is as mentioned usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}
                Will produce the following



                answer






                share|improve this answer




























                  1












                  1








                  1







                  Well sadly, nobody really answered and by time it took everybody to do so, I managed to find answers to majority of my questions already.



                  So to go over them 1 by 1.



                  To set the algorithm name (caption) to be displayed on top, to add lines inbetween blocks and to change name of Algorithm to Algoritmus, you have to edit the settings in your usepackage declaration.



                  I would strongly recommend downloading and studying the "algorithm2e.sty" file, it's wonderfully documented there and you will pretty much find answers to all your questions.



                  So we edited the declaration to following: usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}



                  Obviously, you will set the language option to your own personal preference.
                  On top of that, you can edit the original algorithm2e.sty file to change the localisation definitions/declarations to your personal liking, if you don't like the default options.



                  As for changing the definition of end to print end for instead, this was a tricky one and I've spent hours searching for this, but inside the documentation I found the SetKw command.



                  In this particular case, we changed it to SetKwFor{For}{for}{do}{end~for}



                  I can't answer my last question, whether it's good practice to manually add to to the for condition, somebody will have to answer that for me.



                  Here is the final code



                      SetAlgoNoLine
                  begin{algorithm}[H]
                  DontPrintSemicolon
                  SetKwFor{For}{for}{do}{end~for}
                  KwIn{$X_{t-1}, u_t. z_t$}
                  KwOut{$X_t$}
                  $overline{X_t} = X_t = 0$;
                  For{$k = 1$ to $M$}{
                  $x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
                  $w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
                  $m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
                  $overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
                  }
                  For {$k = 1$ to $M$}{
                  draw i with probability $approx w_t^{[i]}$;
                  add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
                  }
                  Return $X_t$
                  caption{FastSLAM}
                  label{alg:alg1}
                  end{algorithm}


                  Package definition is as mentioned usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}
                  Will produce the following



                  answer






                  share|improve this answer















                  Well sadly, nobody really answered and by time it took everybody to do so, I managed to find answers to majority of my questions already.



                  So to go over them 1 by 1.



                  To set the algorithm name (caption) to be displayed on top, to add lines inbetween blocks and to change name of Algorithm to Algoritmus, you have to edit the settings in your usepackage declaration.



                  I would strongly recommend downloading and studying the "algorithm2e.sty" file, it's wonderfully documented there and you will pretty much find answers to all your questions.



                  So we edited the declaration to following: usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}



                  Obviously, you will set the language option to your own personal preference.
                  On top of that, you can edit the original algorithm2e.sty file to change the localisation definitions/declarations to your personal liking, if you don't like the default options.



                  As for changing the definition of end to print end for instead, this was a tricky one and I've spent hours searching for this, but inside the documentation I found the SetKw command.



                  In this particular case, we changed it to SetKwFor{For}{for}{do}{end~for}



                  I can't answer my last question, whether it's good practice to manually add to to the for condition, somebody will have to answer that for me.



                  Here is the final code



                      SetAlgoNoLine
                  begin{algorithm}[H]
                  DontPrintSemicolon
                  SetKwFor{For}{for}{do}{end~for}
                  KwIn{$X_{t-1}, u_t. z_t$}
                  KwOut{$X_t$}
                  $overline{X_t} = X_t = 0$;
                  For{$k = 1$ to $M$}{
                  $x^{[k]}_t = sample_motion_model(u_t, x^{[k]}_{t-1})$;
                  $w^{[k]}_t = measurement_model(z_t, x^{[k]}_t, m_{t-1})$;
                  $m^{[k]}_t = updated_occupancy_grid(z_t, x^{[k]}_t, m^{[k]}_{t-1})$;
                  $overline{X_t} = overline{X_t} + langle x_x^{[m]}, w_t^{[m]} rangle $;
                  }
                  For {$k = 1$ to $M$}{
                  draw i with probability $approx w_t^{[i]}$;
                  add $langle x_x^{[m]}, w_t^{[m]} rangle$ to $X_t$;
                  }
                  Return $X_t$
                  caption{FastSLAM}
                  label{alg:alg1}
                  end{algorithm}


                  Package definition is as mentioned usepackage[linesnumbered, ruled, vlined, slovak]{algorithm2e}
                  Will produce the following



                  answer







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 2 '16 at 21:04

























                  answered Apr 2 '16 at 20:59









                  RawrplusRawrplus

                  1286




                  1286






























                      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%2f302162%2fhelp-with-algorithm2e-formatting%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

                      Contact image not getting when fetch all contact list from iPhone by CNContact

                      count number of partitions of a set with n elements into k subsets

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks