Im very new to latex and I want to write an algorithm like the picture below:

How can I write the Function of the algorithm like so? I saw alternatives such as \Procedure or \function but they give me the words "Function" Or "Procedure" in front. How can I achieve the headers' results as below for my function wrapper?

Is there another tag for this?

enter image description here

Below is an example of the latex code im using

\Function{recursiveAlgo}{$mst, path, currentNode, drilled$}
\State stop <- false
\If{currentNode.childNumber != 0}{
    \For {$i=0$ to currentNode.childNumber - 1}
        \State      drilled ++
        \State      path.push\_back(currentNode.coord, currentNode.child[i].coord)
        \State      recursiveAlgo(path, currentNode.child[i])
\State \Return path;

What I want to is to change the results of:

\Function{recursiveAlgo}{$mst, path, currentNode, drilled$}

Which appear as:

enter image description here

How do I show the function name without its type declared and the name in bold like the example in the first picture?

  • 3
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – DG' Apr 30 '20 at 23:31
  • @DG' Hi, Thank you for your suggestion, I've edited my question to include some MWE and clarify further what i want – Michael24 May 1 '20 at 8:17
  • 1
    You code is still not compilable, but it's a good start. – DG' May 1 '20 at 10:13
  • 1
    Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – DG' May 1 '20 at 10:21

According to the manual, you can change the keywords:

3.1.10 Changing command names

One common thing for a pseudocode is to change the command names. Many people use many different kind of pseudocode command names. In algpseudocode all keywords are declared as \algorithmic<keyword>.

If you want to change the keyword for \Function you have to declare:


enter image description here

And you can leave it empty, of course:


enter image description here

  • Many thanks and thank you for your time! – Michael24 May 1 '20 at 10:33

In algpseudocode.sty function was called like

   [2]{\algorithmicfunction\ \textproc{#1}\ifthenelse{\equal{#2}{}}{}{(#2)}}%
   {\algorithmicend\ \algorithmicfunction}

Change to

   [2]{\algorithmicfunction\ \textproc{}\ifthenelse{\equal{}{}}{}{()}}%
   {\algorithmicend\ \algorithmicfunction}

in your tex file at preamble

  • 1
    Hi, Thank you for your answer although it's having the opposite effect of what i need. The results im getting now is just the words "Function" in bold without the name. To clarify, I hope to have just the name of the function shown in bold – Michael24 May 1 '20 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.