Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!

share|improve this question
    
Welcome to TeX.SX! –  Papiro Jul 20 '13 at 23:37
    
What would you want the interface to be, given that you want to accommodate for variable referencing? –  Werner Jul 21 '13 at 4:50

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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