I want to use the same font style of a previously defined function in an algorithm environment when I call it in a different algorithm environment.
Below is a minimal working example. I want the same font style displayed for the IntPlus function when I call it in the second function MultPlus.
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{document}
\begin{algorithm}
\caption{Adding two integers $a$ by $b$.}
\begin{algorithmic}[1]
\Require{$a, b$ are integers.}
\Ensure{$c$ an integer.}
\Statex
\Function{IntPlus}{$a, b$}
\State {$c \gets a + b$}
\State \Return {$c$}
\EndFunction
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{Distributive property.}
\begin{algorithmic}[1]
\Require{$a, b, c$ are integers.}
\Ensure{$d$ an integer.}
\Statex
\Function{MultPlus}{$a, b, c$}
\State {$g \gets (a \times b) $}
\State {$d \gets \text{IntPlus}(g, c)$ } % I want the font style of IntPlus to be the same when first defined.
\State \Return {$c$}
\EndFunction
\end{algorithmic}
\end{algorithm}
\end{document}
Best Answer
Use
\Call{<function name>}{<arguments>}
.\Call
is designed for\Procedure
calls, but\Function
s share the same syntax. I'm sure @egreg will let me know if this usage is unwise. :-)