Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass[11pt,a4paper]{article}
- \usepackage{fullpage}
- \usepackage[english]{babel}
- \usepackage{color}
- \usepackage{hyperref}
- \usepackage[nameinlink]{cleveref}
- \hypersetup{colorlinks=true, linkcolor=blue}
- \usepackage{algorithm}
- \usepackage[noend]{algpseudocode}
- \newcounter{algsubstate}
- \makeatletter
- \renewcommand{\thealgsubstate}{\arabic{ALG@line}.\alph{algsubstate}}
- \makeatother
- \newenvironment{algsubstates}
- {\setcounter{algsubstate}{0}%
- \renewcommand{\State}{%
- \refstepcounter{algsubstate}%
- \Statex {\footnotesize\alph{algsubstate}:}\space}}
- {}
- \crefname{line}{step}{steps}
- \crefname{algsubstate}{step}{steps}
- \begin{document}
- \begin{algorithm}[h!]
- \caption{Algorithm A}\label{a}
- \begin{algorithmic}[1]
- \State First operation \label{a_first}
- \State Second operation \label{a_second}
- \begin{algsubstates}
- \State Part a of second \label{a_second_a}
- \State Part b of second \label{a_second_b}
- \end{algsubstates}
- \State Third operation \label{a_third}
- \end{algorithmic}
- \end{algorithm}
- \newpage
- \begin{algorithm}[h!]
- \caption{Algorithm B}\label{b}
- \begin{algorithmic}[1]
- \State First operation \label{b_first}
- \State Second operation \label{b_second}
- \begin{algsubstates}
- \State Part a of second \label{b_second_a}
- \State Part b of second \label{b_second_b}
- \end{algsubstates}
- \State Third operation \label{b_third}
- \end{algorithmic}
- \end{algorithm}
- \newpage
- \subsubsection*{Cleveref}
- \noindent
- Algorithm A is \Cref{a}: \Cref{a_first,a_second}. Also \Cref{a_second_a,a_second_b,a_third} \\
- Algorithm B is \Cref{b}: \Cref{b_first,b_second}. Also \Cref{b_second_a,b_second_b,b_third}
- \subsubsection*{Normal}
- \noindent
- Algorithm A is Algorithm \ref{a}: Steps \ref{a_first} and \ref{a_second}. Also Steps \ref{a_second_a}, \ref{a_second_b} and \ref{a_third}. \\
- Algorithm B is Algorithm \ref{b}: Steps \ref{b_first} and \ref{b_second}. Also Steps \ref{b_second_a}, \ref{b_second_b} and \ref{b_third}.
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement