Is it possible to draw vertical lines in algorithm (not algorithm2e) package?












3















My question is if it is possible to draw vertical lines in the algorithm package. I have seen the following question:



Vertical line for pseudo code



But I don't want to use algorithm2e because it changes the format of the algorithm. Is it possible to handle that with the algorithm package?










share|improve this question























  • welcome to tex.se!

    – Zarko
    Mar 3 at 6:09
















3















My question is if it is possible to draw vertical lines in the algorithm package. I have seen the following question:



Vertical line for pseudo code



But I don't want to use algorithm2e because it changes the format of the algorithm. Is it possible to handle that with the algorithm package?










share|improve this question























  • welcome to tex.se!

    – Zarko
    Mar 3 at 6:09














3












3








3








My question is if it is possible to draw vertical lines in the algorithm package. I have seen the following question:



Vertical line for pseudo code



But I don't want to use algorithm2e because it changes the format of the algorithm. Is it possible to handle that with the algorithm package?










share|improve this question














My question is if it is possible to draw vertical lines in the algorithm package. I have seen the following question:



Vertical line for pseudo code



But I don't want to use algorithm2e because it changes the format of the algorithm. Is it possible to handle that with the algorithm package?







algorithms algorithmic line






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 3 at 4:13









ParisParis

161




161













  • welcome to tex.se!

    – Zarko
    Mar 3 at 6:09



















  • welcome to tex.se!

    – Zarko
    Mar 3 at 6:09

















welcome to tex.se!

– Zarko
Mar 3 at 6:09





welcome to tex.se!

– Zarko
Mar 3 at 6:09










1 Answer
1






active

oldest

votes


















1














Welcome to TeX-SE! With tikz and tikzmark you can certainly add lines. Whether or not this is the most efficient way to produce such an output, i.e. whether or not there is a package that does all that out of the box, I do not know.



documentclass[two column,conference]{IEEEtran}
usepackage{tikz}
usetikzlibrary{tikzmark}
usepackage{algorithm}
begin{document}
begin{algorithm}
caption{HD}
label{array-sum}
1: Initialization of parameters \
2: Randomly generate population using Eq. 28\
tikzmarknode{3}{3}: textbf{for} u=1:k \
tikzmarknode{4}{4}: textbf{for} s=1:i$_{c}$\
5: Randomly generated X$_{s}^{u}$ in da\
tikzmarknode{6}{6}: textbf{end for} \
tikzmarknode{7}{7}: textbf{end for}\
8: End of initialization step\
9: textbf{While} Maximum number of iteration reached textbf{do}\
10: Construction and assessment of new candidate\
11: textbf{if} ($rand (0,1)leq$ cpu)\
12: Choose random no \
13: textbf {if} ($rand (0,1 ) leq$ cpu) \
14: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15: textbf{end if} \
16: textbf{else} \
17: Evaluate fitness function a: F(a) using Eq. 17\
27: End of the construction and assessment step\
28: Construction and assessment of new candidate: a \
29: if (F(y) has best value than the worst member \
30: Replace DA member with new candidate: a\
31: else\
32: Discard x\
33: textbf{endif}\
34: End of update\
35: Until a preset termination criterion is met\
36: end textbf{while}\
end{algorithm}
begin{tikzpicture}[overlay,remember picture]
draw[blue,thick] (3.west) -- ++ (-4pt,0pt) |- (7);
draw[red,thick] (4.west) -- ++ (-2pt,0pt) |- (6);
end{tikzpicture}
end{document}


enter image description here






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%2f477504%2fis-it-possible-to-draw-vertical-lines-in-algorithm-not-algorithm2e-package%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! With tikz and tikzmark you can certainly add lines. Whether or not this is the most efficient way to produce such an output, i.e. whether or not there is a package that does all that out of the box, I do not know.



    documentclass[two column,conference]{IEEEtran}
    usepackage{tikz}
    usetikzlibrary{tikzmark}
    usepackage{algorithm}
    begin{document}
    begin{algorithm}
    caption{HD}
    label{array-sum}
    1: Initialization of parameters \
    2: Randomly generate population using Eq. 28\
    tikzmarknode{3}{3}: textbf{for} u=1:k \
    tikzmarknode{4}{4}: textbf{for} s=1:i$_{c}$\
    5: Randomly generated X$_{s}^{u}$ in da\
    tikzmarknode{6}{6}: textbf{end for} \
    tikzmarknode{7}{7}: textbf{end for}\
    8: End of initialization step\
    9: textbf{While} Maximum number of iteration reached textbf{do}\
    10: Construction and assessment of new candidate\
    11: textbf{if} ($rand (0,1)leq$ cpu)\
    12: Choose random no \
    13: textbf {if} ($rand (0,1 ) leq$ cpu) \
    14: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    15: textbf{end if} \
    16: textbf{else} \
    17: Evaluate fitness function a: F(a) using Eq. 17\
    27: End of the construction and assessment step\
    28: Construction and assessment of new candidate: a \
    29: if (F(y) has best value than the worst member \
    30: Replace DA member with new candidate: a\
    31: else\
    32: Discard x\
    33: textbf{endif}\
    34: End of update\
    35: Until a preset termination criterion is met\
    36: end textbf{while}\
    end{algorithm}
    begin{tikzpicture}[overlay,remember picture]
    draw[blue,thick] (3.west) -- ++ (-4pt,0pt) |- (7);
    draw[red,thick] (4.west) -- ++ (-2pt,0pt) |- (6);
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer




























      1














      Welcome to TeX-SE! With tikz and tikzmark you can certainly add lines. Whether or not this is the most efficient way to produce such an output, i.e. whether or not there is a package that does all that out of the box, I do not know.



      documentclass[two column,conference]{IEEEtran}
      usepackage{tikz}
      usetikzlibrary{tikzmark}
      usepackage{algorithm}
      begin{document}
      begin{algorithm}
      caption{HD}
      label{array-sum}
      1: Initialization of parameters \
      2: Randomly generate population using Eq. 28\
      tikzmarknode{3}{3}: textbf{for} u=1:k \
      tikzmarknode{4}{4}: textbf{for} s=1:i$_{c}$\
      5: Randomly generated X$_{s}^{u}$ in da\
      tikzmarknode{6}{6}: textbf{end for} \
      tikzmarknode{7}{7}: textbf{end for}\
      8: End of initialization step\
      9: textbf{While} Maximum number of iteration reached textbf{do}\
      10: Construction and assessment of new candidate\
      11: textbf{if} ($rand (0,1)leq$ cpu)\
      12: Choose random no \
      13: textbf {if} ($rand (0,1 ) leq$ cpu) \
      14: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      15: textbf{end if} \
      16: textbf{else} \
      17: Evaluate fitness function a: F(a) using Eq. 17\
      27: End of the construction and assessment step\
      28: Construction and assessment of new candidate: a \
      29: if (F(y) has best value than the worst member \
      30: Replace DA member with new candidate: a\
      31: else\
      32: Discard x\
      33: textbf{endif}\
      34: End of update\
      35: Until a preset termination criterion is met\
      36: end textbf{while}\
      end{algorithm}
      begin{tikzpicture}[overlay,remember picture]
      draw[blue,thick] (3.west) -- ++ (-4pt,0pt) |- (7);
      draw[red,thick] (4.west) -- ++ (-2pt,0pt) |- (6);
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer


























        1












        1








        1







        Welcome to TeX-SE! With tikz and tikzmark you can certainly add lines. Whether or not this is the most efficient way to produce such an output, i.e. whether or not there is a package that does all that out of the box, I do not know.



        documentclass[two column,conference]{IEEEtran}
        usepackage{tikz}
        usetikzlibrary{tikzmark}
        usepackage{algorithm}
        begin{document}
        begin{algorithm}
        caption{HD}
        label{array-sum}
        1: Initialization of parameters \
        2: Randomly generate population using Eq. 28\
        tikzmarknode{3}{3}: textbf{for} u=1:k \
        tikzmarknode{4}{4}: textbf{for} s=1:i$_{c}$\
        5: Randomly generated X$_{s}^{u}$ in da\
        tikzmarknode{6}{6}: textbf{end for} \
        tikzmarknode{7}{7}: textbf{end for}\
        8: End of initialization step\
        9: textbf{While} Maximum number of iteration reached textbf{do}\
        10: Construction and assessment of new candidate\
        11: textbf{if} ($rand (0,1)leq$ cpu)\
        12: Choose random no \
        13: textbf {if} ($rand (0,1 ) leq$ cpu) \
        14: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        15: textbf{end if} \
        16: textbf{else} \
        17: Evaluate fitness function a: F(a) using Eq. 17\
        27: End of the construction and assessment step\
        28: Construction and assessment of new candidate: a \
        29: if (F(y) has best value than the worst member \
        30: Replace DA member with new candidate: a\
        31: else\
        32: Discard x\
        33: textbf{endif}\
        34: End of update\
        35: Until a preset termination criterion is met\
        36: end textbf{while}\
        end{algorithm}
        begin{tikzpicture}[overlay,remember picture]
        draw[blue,thick] (3.west) -- ++ (-4pt,0pt) |- (7);
        draw[red,thick] (4.west) -- ++ (-2pt,0pt) |- (6);
        end{tikzpicture}
        end{document}


        enter image description here






        share|improve this answer













        Welcome to TeX-SE! With tikz and tikzmark you can certainly add lines. Whether or not this is the most efficient way to produce such an output, i.e. whether or not there is a package that does all that out of the box, I do not know.



        documentclass[two column,conference]{IEEEtran}
        usepackage{tikz}
        usetikzlibrary{tikzmark}
        usepackage{algorithm}
        begin{document}
        begin{algorithm}
        caption{HD}
        label{array-sum}
        1: Initialization of parameters \
        2: Randomly generate population using Eq. 28\
        tikzmarknode{3}{3}: textbf{for} u=1:k \
        tikzmarknode{4}{4}: textbf{for} s=1:i$_{c}$\
        5: Randomly generated X$_{s}^{u}$ in da\
        tikzmarknode{6}{6}: textbf{end for} \
        tikzmarknode{7}{7}: textbf{end for}\
        8: End of initialization step\
        9: textbf{While} Maximum number of iteration reached textbf{do}\
        10: Construction and assessment of new candidate\
        11: textbf{if} ($rand (0,1)leq$ cpu)\
        12: Choose random no \
        13: textbf {if} ($rand (0,1 ) leq$ cpu) \
        14: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        15: textbf{end if} \
        16: textbf{else} \
        17: Evaluate fitness function a: F(a) using Eq. 17\
        27: End of the construction and assessment step\
        28: Construction and assessment of new candidate: a \
        29: if (F(y) has best value than the worst member \
        30: Replace DA member with new candidate: a\
        31: else\
        32: Discard x\
        33: textbf{endif}\
        34: End of update\
        35: Until a preset termination criterion is met\
        36: end textbf{while}\
        end{algorithm}
        begin{tikzpicture}[overlay,remember picture]
        draw[blue,thick] (3.west) -- ++ (-4pt,0pt) |- (7);
        draw[red,thick] (4.west) -- ++ (-2pt,0pt) |- (6);
        end{tikzpicture}
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 3 at 5:13









        marmotmarmot

        107k5129244




        107k5129244






























            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%2f477504%2fis-it-possible-to-draw-vertical-lines-in-algorithm-not-algorithm2e-package%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?

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

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents