0

I would like to get the following output, but the code given below produces a different output.

Here is my code.

\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithm} \caption{This is Algo. 1} \textbf{Input: } The . \ \textbf{Output: } . \begin{algorithmic}[1] \State Here.....

\end{algorithmic}

\end{algorithm}

\floatname{algorithm}{Procedure} \begin{algorithm} \caption{\textproc This is procedure 1 }

\textbf{Input: } The.  \\
\textbf{Output: } .

\begin{algorithmic}[1]

\State Here....

\end{algorithmic}

\end{algorithm}

\begin{algorithm} \caption{This is procedure 2} \textbf{Input: } The. \ \textbf{Output: } .

\begin{algorithmic}[1]

\State Here....

\end{algorithmic}

\end{algorithm}

\begin{algorithm} \caption{This is Algo. 2} \textbf{Input: } The. \ \textbf{Output: } .

\begin{algorithmic}[1]

\State Here .....

\end{algorithmic}   

\end{algorithm}

\end{document}

projetmbc
  • 13,315
  • What is your question? – projetmbc Dec 31 '22 at 09:46
  • Welcome to TEX.SX! Can you be specific about what is your problem? – Teddy van Jerry Dec 31 '22 at 09:47
  • Sorry I have posted a screenshot with this code but it didn't appear, actually I want this order of caption in the algorithm, Algorithm 1: This is first Algo. Procedure 1: This is first procedure. Procedure 2: This is second procedure. Algorithm 2: This is second Algorithm

    But with above mention code output is like that, Algorithm 1: Procedure 2: Procedure 3: Procedure 4:

    – Learner Dec 31 '22 at 09:49
  • @Learner_104 I have edited the question. There was a typo in the raw code. – projetmbc Dec 31 '22 at 09:49
  • 1
    I think this would help (a different counter for the algorithm environment). – Teddy van Jerry Dec 31 '22 at 09:51

1 Answers1

0

You may try out the following code, by defining a new counter procedure to do the job:

\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{algorithm}
\usepackage{algpseudocode}

\newcounter{procedure} \makeatletter \newenvironment{procedure}[1][htb]{% \let\c@algorithm\c@procedure \renewcommand{\ALG@name}{Procedure}% Update algorithm name \begin{algorithm}[#1]% }{\end{algorithm} } \makeatother

\begin{document}

\begin{algorithm} \caption{This is Algo. 1} \textbf{Input: } The . \ \textbf{Output: } . \begin{algorithmic}[1] \State Here.....

\end{algorithmic}

\end{algorithm}

\begin{procedure} \caption{\textproc This is procedure 1 }

\textbf{Input: } The.  \\
\textbf{Output: } .

\begin{algorithmic}[1]

    \State Here....

\end{algorithmic}

\end{procedure}

\begin{procedure} \caption{This is procedure 2} \textbf{Input: } The. \ \textbf{Output: } .

\begin{algorithmic}[1]

\State Here....

\end{algorithmic}

\end{procedure}

\begin{algorithm} \caption{This is Algo. 2} \textbf{Input: } The. \ \textbf{Output: } .

\begin{algorithmic}[1]

\State Here .....

\end{algorithmic}   

\end{algorithm}

\end{document}

which is adapted from this answer.

Result