My question is about algorithmic package. I have an algorithm which I called A1.

\caption{\bf A1:}

I have something like this:

Algorithm 1 A1

How can I make that I will get

Algorithm A1

And another question how I can labelling so that when I use \ref{algorithm-A1}, then link will appear as A1 in a text.

  • 1
    While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. While solving problems is fun, setting them up is not. Then those trying to help can simply cut and paste your MWE and get started on solving problem. Nov 14 '12 at 4:04
  • Using \renewcommand{\thealgorithm}{A\arabic{algorithm}} should modify the \label-\ref you're using. However, the bigger question is the use of {\bf A1}. What does this represent?
    – Werner
    Nov 14 '12 at 4:11

The following works for me, note in particular the line


which @Werner mentioned in his comment. Note also that this code is an example of a MWE

enter image description here




    \caption{Euclid’s algorithm}
        \Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
        \State $r\gets a\bmod b$
        \While{$r\not=0$}\Comment{We have the answer if r is 0}
        \State $a\gets b$
        \State $b\gets r$
        \State $r\gets a\bmod b$
        \State \textbf{return} $b$\Comment{The gcd is b}

Test reference: \ref{alg:euclid}

  • could please comments why does it work. I want to understand what should I change so that I will have various numeration like "Algorihtm A0", "Algorihtm A0M". thank you!
    – ashim
    Nov 15 '12 at 7:26

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.