# Vertical line for pseudo code

\documentclass[two column,conference]{IEEEtran}
\usepackage{algorithm}
\begin{document}
\begin{algorithm}
\caption{HD}
\label{array-sum}
1: Initialization of parameters \\
2: Randomly generate population using Eq. 28\\
3: \textbf{for} u=1:k \\
4: \textbf{for} s=1:i$_{c}$\\
5:  Randomly generated X$_{s}^{u}$ in da\\
6: \textbf{end for} \\
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}
\end{document}


I want to draw vertical lines for loops and if statement. Kindly help me out and also I didn't use any specific package

• Welcome to TeX SX! Yet the algorithmis defined by a package… – Bernard Jul 14 '17 at 13:05
• yeah!! Only algorithm package, However, it didn't worked for me can you please help me out. – Smith Jul 14 '17 at 13:10
• I can try. Would you be kind enough to post a full compilable code? – Bernard Jul 14 '17 at 13:20
• It is full code except for package {\usepackage{algorithm} However, I will also edit the code. – Smith Jul 14 '17 at 13:30

## 1 Answer

You have to load algorithm2e to do that easily:

\documentclass[two column,conference]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage[ruled, lined, longend, linesnumbered]{algorithm2e}

\begin{document}

\begin{algorithm}
\caption{HD}
\label{array-sum}
Initialization of parameters\;
Randomly generate population using Eq. 28\;
\For{u=1:k}{%
\For{s=1:i$_{c}$}{%
Randomly generated X$_{s}^{u}$ in da \;
}
}
End of initialization step\;
\While{Maximum number of iteration reached}{
Construction and assessment of new candidate\;
\eIf{($rand (0,1)\leq$ cpu)}{%
Choose random no \;
\textbf {if} ($rand (0,1 ) \leq$ cpu) \\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\textbf{end if}
}{%
Evaluate fitness function a: F(a) using Eq. 17 \;
End of the construction and assessment step\;
Construction and assessment of new candidate: a \;
\eIf {(F(y) has best value than the worst member}{
Replace DA member with new candidate: a
}{%
Discard x}%
}%
End of update\;
Until a preset termination criterion is met}
\end{algorithm}

\end{document}
{"ft_lang_label":"__label__en","ft_lang_prob":0.5812678,"math_prob":0.96746695,"size":1319,"snap":"2019-35-2019-39","text_gpt3_token_len":410,"char_repetition_ratio":0.14676806,"word_repetition_ratio":0.010638298,"special_character_ratio":0.3631539,"punctuation_ratio":0.15234375,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9938101,"pos_list":[0,1,2],"im_url_duplicate_count":[null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-08-25T02:14:35Z\",\"WARC-Record-ID\":\"<urn:uuid:a72675e2-2a48-4975-9447-d83ffdc88e90>\",\"Content-Length\":\"139336\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:98d6987f-7cea-4dba-ab74-c9a00304c147>\",\"WARC-Concurrent-To\":\"<urn:uuid:0952c70f-38f7-4a80-b386-7e04aa818ba5>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://tex.stackexchange.com/questions/380674/vertical-line-for-pseudo-code\",\"WARC-Payload-Digest\":\"sha1:YZX6E62ZXKVT3MMYO6VKRWRGT4U6EHLA\",\"WARC-Block-Digest\":\"sha1:FZHE5UJ5VQG6ZXJC2YKVJCQ6NV4BSUBI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-35/CC-MAIN-2019-35_segments_1566027322170.99_warc_CC-MAIN-20190825021120-20190825043120-00201.warc.gz\"}"}