[Tex/LaTex] Questions about algpseudocode

algorithmsformattingmacrospseudocode

I'm using the following packages:

\usepackage{algpseudocode}
\usepackage{algorithm}

but I don't understand what package is algpseudocode, since I can't find the documentation. I have followed this page. What's the difference between it and algorithmicx?

Also, how do I make calls inside a function (e.g. a recursion?) without using \text{...} (the font will be different and it does not look like a function). Here is an example:

\begin{algorithm}
\begin{algorithmic}[1]
\Function {foo}{$a$}
...
\State \Return \text{foo($a-1$)}
\EndFunction
\end{algorithmic}
\end{algorithm}

And how do I make a new line (for instance if a \text{...} is too long)?

Finally, how do I define a \TRUE macro (like the algorithmic package)?

Thanks in advance.

Best Answer

Thanks to the help of texenthusiast and karlkoeller I solved everything.
algpseudocode is part of algorithmicx package (documentation).
For nested function I just did

\begin{algorithm}
\begin{algorithmic}[1]
\Function {foo}{$a$}
...
\State \Return \Call{foo}{$a-1$}
\EndFunction
\end{algorithmic}
\end{algorithm}

To split a long line

\State \parbox[t]{.7\linewidth}{a very very very very very very very very very very very long line}

And for the \True macro I added \algnewcommand\True{\textbf{true}\space} at the beginning of the document.

Here's a fully compilable code:

\documentclass{report}
\usepackage[noend]{algpseudocode}
\usepackage{algorithm}
\algnewcommand\True{\textbf{true}\space}
\algnewcommand\False{\textbf{false}\space}
\begin{document}
\begin{algorithm}
\begin{algorithmic}[1]
\Function {foo}{$a$}
\State \parbox[t]{.7\linewidth}{a very very very very very very very very very very very long line}
\State \Return \Call{foo}{$a-1$}
\EndFunction
\end{algorithmic}
\end{algorithm}
\end{document}
Related Question