Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to have the following output using algorithmic package:

for i = 1 : z do // number of rows
   x = 1 
end for

I use the following tex code:

\begin{algorithmic}
    \FOR{$p=1:r$} // number of rows
        \STATE $x=1$
    \ENDFOR
\end{algorithmic}

It doesn't work. I couldn't find any way to put the comments to the same line with for. Is there any way to do that with the algorithmic package?

EDIT

1.

Code:

\FOR[// loop over all puppies]{$p=1:r$}
    \STATE $x=1$
\ENDFOR

Result:

for i = 1 : z do {// number of rows}
   x = 1 
end for

2.

Code:

\FOR{$p=1:r$ \COMMENT{// number of rows}}
    \STATE $x=1$
\ENDFOR

Result:

for i = 1 : z {// number of rows} do
   x = 1 
end for

Is there any way to get rid of these curly brackets?

share|improve this question
    
Would tex.stackexchange.com/questions/3813/… help you? –  Caramdir Jul 1 '12 at 17:21
    
@Caramdir: I use algorithm and algorithmic packages. –  celebisait Jul 1 '12 at 17:25
    
@Caramdir: I edited the original post. –  celebisait Jul 1 '12 at 17:34

1 Answer 1

up vote 1 down vote accepted

the package defines

  \newcommand{\algorithmiccomment}[1]{\{#1\}}

so if you go

\renewcommand{\algorithmiccomment}[1]{#1}

the braces will be gone.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.