I am trying a way to number algorithms 1a, 1b, 1c, 2a, 2b, 2c, etc. As I understand from the documentation of the algorithms
package here, I can number them after the part, chapter, section and so on. In this related topic they discuss how to customize the number. But I don't want the number, I would like to also have letters: for example, in the following MWE, I would like to have the two algorithms numbered (and therefore referenced to as) 1a and 1b.
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
Algorithm~\ref{MyAlg} does things in a way. Algorithm~\ref{MyOtherAlg} does things in some other way.
\begin{algorithm}\caption{My algorithm}\label{MyAlg}
\begin{algorithmic}[1]
\State Do stuff.
\end{algorithmic}
\end{algorithm}
\begin{algorithm}\caption{My other algorithm}\label{MyOtherAlg}
\begin{algorithmic}[1]
\State Do stuff differently.
\end{algorithmic}
\end{algorithm}
\end{document}
Any idea on how to achieve this?
Best Answer
All you have to do is to redefine the command
\thealgorithm
which controls the representation for the algorithm counter. For example, to number them using alphabetic lower-case characters and to prepend the section number you would doAssuming that you want the counter to reset at every section, you will also need
A complete example.
The result:
Update:
Same idea if a user-defined counter is to be used:
or to have the numbering with upper-case alphabetical characters:
The result: