I have a LaTeX code which looks similar to the following example.
\documentclass{article}
\usepackage{amsmath,algorithm,algpseudocode}
\begin{document}
\begin{algorithm}
\caption{My Algo.}
\label{alg:myalgo}
\begin{algorithmic}[1]
\Function{CallA}{$a$} \label{alg:a}
\State \Call{CalcSquare}{$a$}
\EndFunction
\Statex
\Function{CalcSquare}{$b$} \label{alg:b}
\State \Return $b\times b$
\EndFunction
\end{algorithmic}
\end{algorithm}
The \ref{alg:a} function calls \ref{alg:b} inside.
\end{document}
How can I make \ref{alg:a}
show the name of function instead of line number?
It is desired to appear "The CallA function calls CalcSquare inside", but what it actually looks like is
"The 1 function calls 4 inside".
Best Answer
You can define a new command, say
\funclabel
for storing the function name. Then you can retrieve it with the usual\ref
.