# Bold some part of algorithm in overleaf, latex

\begin{algorithm}
\FOR{$1\leq i \leq M$}
\WHILE{$x)>x_1$}
Hello world
\ENDWHILE
\STATE Set y=2
\ENDFOR


Hello everyone, I have a question regarding the algorithm in the latex. I want to bold the text

hello world

in the above algorithm. I want to italic the font of

For

and

While

and only

hello world

should be bold. could any one help me? Thank you so much.

• it would be helpful to give the complete MWE starting from documentclass and finishing at enddocument – js bibra Feb 16 '20 at 4:33

For Bold

Simply enclose in braces and use command textbf

\textbf{Hello world}


For Italics

Put the following line in the preamble for italics and bold For

\renewcommand{\algorithmicfor}{\textit{\textbf{for}}}


Put the following line in the preamble for italics and bold While

\renewcommand{\algorithmicwhile}{\textit{\textbf{while}}}