1

I would like to remove these braces around the comment I would like the comment to look like this //AtLeast1T Leaf as opposed to this {//AtLeast1T Leaf} and I would like to keep using the algorithmic package and not switch to the algorithmicx one.

\documentclass[10pt,conference]{IEEEtran} 
\IEEEoverridecommandlockouts


\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{graphicx}
\usepackage{changepage}



\usepackage{lipsum}
\usepackage{ctable}% http://ctan.org/pkg/ctable
\usepackage{color, colortbl}
\newcommand{\var}{\textit}
\newcommand{\proc}{\textbf}
\newcommand{\prop}{\texttt}
\newcommand{\plusplus}{{+}{+}}% Other options: 
\newcommand*\ita[1]{\textit{#1}}
\usepackage{array, booktabs, makecell, multirow}% new
\definecolor{Gray}{gray}{0.9}
\usepackage{textcomp} 
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}
\begin{algorithm}
\caption{Step 4-T Propagation}

\begin{algorithmic}[1]

    \raggedright
    \STATE boolean modified=true
    \WHILE{modified==true}
    \STATE modified=false

    \FORALL{r in Requirements}   
    \FORALL{m in Methods}   

    \IF {m.trace[r]==E \AND  
        m.XCallees.isEmpty()
        \AND m.XCallers.AtLeast1T()
    }
    \STATE m.trace[r]=T\hfill\COMMENT{//AtLeast1T Leaf}
    \STATE modified=true    \ENDIF 
    \ENDFOR 
    \ENDFOR 

    \ENDWHILE
   \end{algorithmic}
   \label{step4}
  \end{algorithm}
\end{document}
2

You have two possibilitys, depending on the way you want to write your comments in the algorithmn.

  1. You can add

    \renewcommand{\algorithmiccomment}[1]{#1} % <===========================
    

    in your preanmble (before \begin{document}) and then use the code

    hfill\COMMENT{//AtLeast1T Leaf}
    

    including your wanted // in the text of the comment or

  2. you can add

    \renewcommand{\algorithmiccomment}[1]{//#1} % <=========================
    

    including your wanted leading // for your comments in the preamble and use then

    \hfill\COMMENT{AtLeast1T Leaf} % <=============
    

    for your comments (no need to add the leading //).

Please see the following code showing both possibilities

\documentclass[10pt,conference]{IEEEtran} 
\IEEEoverridecommandlockouts

\usepackage{algorithmic}
\usepackage{algorithm}


\begin{document}

\renewcommand{\algorithmiccomment}[1]{#1} % <===========================
\begin{algorithm}
\caption{Step 4-T Propagation}\label{step4} % <=========================
\begin{algorithmic}[1]
  \raggedright
  \STATE boolean modified=true
  \WHILE{modified==true}
    \STATE modified=false

    \FORALL{r in Requirements}   
    \FORALL{m in Methods}   

    \IF {m.trace[r]==E \AND  
        m.XCallees.isEmpty()
        \AND m.XCallers.AtLeast1T()
    }
      \STATE m.trace[r]=T\hfill\COMMENT{//AtLeast1T Leaf}
      \STATE modified=true
    \ENDIF 
    \ENDFOR 
    \ENDFOR 
  \ENDWHILE
\end{algorithmic}

\end{algorithm}

\renewcommand{\algorithmiccomment}[1]{//#1} % <=========================
\begin{algorithm}
\caption{Step 4-Ta Propagation}\label{step4-1} % <======================
\begin{algorithmic}[1]
  \raggedright
  \STATE boolean modified=true
  \WHILE{modified==true}
    \STATE modified=false

    \FORALL{r in Requirements}   
    \FORALL{m in Methods}   

    \IF {m.trace[r]==E \AND  
        m.XCallees.isEmpty()
        \AND m.XCallers.AtLeast1T()
    }
      \STATE m.trace[r]=T\hfill\COMMENT{AtLeast1T Leaf} % <=============
      \STATE modified=true
    \ENDIF 
    \ENDFOR 
    \ENDFOR 
  \ENDWHILE
\end{algorithmic}

\end{algorithm}

\end{document}

with the result:

resulting algorithmns

Please see that I moved your label from the bottom of your algorithm to the top of your algorithmn following the command \caption. The command \label has to follow \caption if you want correct refferences to the algorithm ...

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.