2

I'm using the algorithmicx package, but I would like my algorithm to look like:

Algorithm My Algo $(\lambda,\beta)$

i.e., the algorithm should accept inputs as shown. I then want refer to this algorithm from the main text as follows:

We run algorithm My Algo $(\lambda_1,\beta_1)$ and also My Algo $(\lambda_1,\beta_2)$ ...

Please suggest!

1
  • What would you want the interface to be, given that you want to accommodate for variable referencing? – Werner Jul 21 '13 at 4:50
2

The following example will do:

\documentclass{article}

\usepackage{algorithm}
\usepackage{algpseudocode}% loads algorithmicx automatically
\begin{document}

% Redefine the Algorithm number as below: Check \arabic{algorithm}
\def\thealgorithm{My Algo $(\lambda_{1},\beta_{\arabic{algorithm}})$}

\begin{algorithm}
\caption{First algorithm}\label{alg1}
\begin{algorithmic}[1]
\Procedure{Test}{$\lambda,\beta$}
\EndProcedure
\end{algorithmic}
\end{algorithm}

\begin{algorithm}
\caption{Second algorithm}\label{alg2}
\begin{algorithmic}[1]
\Procedure{Test}{$\lambda,\beta$}
\EndProcedure
\end{algorithmic}
\end{algorithm}

We run algorithm \ref{alg1} and \ref{alg2}.

\end{document}

Hope, this helps.

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.