1

can anyone tell me what is wrong with my algorithm code? it adds =0 at the end when I run it. this is the algorithm:

\documentclass{article}

\usepackage{algorithm}
‎\usepackage{algorithmic}‎‎
‎\usepackage{algpseudocode}‎

\begin{document}
\begin{algorithm}                    
\caption{Dynamic programming algorithm for RRH clustering problem}      
\label{alg1}                          
\begin{algorithmic}[1]   ‎
\STATE return table[N,Capacity]‎‎
\end{algorithmic}
\end{algorithm}\end{document}‎

this is the result:

enter image description here

  • Welcome to TeX SX! What is the latin environment? – Bernard Jul 15 '18 at 09:14
  • thanks, I was writing farsi so I needed this latin package. I forgot to remove it from here. – user3223551 Jul 15 '18 at 09:18
  • @user3223551 Please, make the snippet into a compilable (minimal) document from \documentclass to \end{document} that still shows the issue. – egreg Jul 15 '18 at 09:19
  • when I write this minimal version it does not add the =0 and works fine. but in my own article, it adds it. its the same code! – user3223551 Jul 15 '18 at 09:32
  • 1
    Then this is what you have to do: Make a copy of the TeX file. Start deleting stuff until the problem goes away. Undelete the last bit you deleted. Your problem is there, somehow. Keep on deleting other stuff that does not affect it, until you're down to a minimal example (more or less). Instead of deleting, at first it may be easier to comment out stuff, so your actions are easily reversed. A bisecting method is very useful to speed this up. (Start by deleting everything after the trouble spot. Try putting the troubled code at the top of the document to save time.) – Harald Hanche-Olsen Jul 15 '18 at 09:37
  • Instead of commenting out, surrounding blocks of code by \iffalse\fi is quicker. Anyhow, I expect the problem is some code, somewhere, assigning zero to a counter, except the name of the counter got gobbled by other code. This might be caused by different packages interfering with each others' code, for example. – Harald Hanche-Olsen Jul 15 '18 at 09:38
  • I did this, the problem was the ‎\usepackage{algpseudocode}‎ part. when I remove it, the code works fine – user3223551 Jul 15 '18 at 09:45
  • 1
    please fix the example so that it generates the error. (You could post an answer yourself as well) or delete the question. As it stands no one other than you can see the problem or fix it. – David Carlisle Jul 15 '18 at 10:06
  • I added the package that was causing the problem to the question – user3223551 Jul 15 '18 at 10:31
  • @user3223551: Unrelated to the issue, but please note that your example is not compilable with the april 2018 release of LaTeX (which uses utf8 as standard input encoding). Your code contains several invisible characters: (U+200E, left-to-right-mark) in the beginning and end of the line\usepackage{algorithmic} as well as after [N,Capacity]. – leandriis Jul 15 '18 at 10:57
  • Apart from the U+200E problem, the example doesn't compile: you can't load both algorithmic and algpseudocode; the command \STATE is for the former, so I removed the latter. No issue at all. Even if I change \STATE return table[N,Capacity] into \RETURN table[N,Capacity] the output is as expected. I believe the issue has something to do with bidirectional text. Please make a real example that shows the issue. – egreg Jul 15 '18 at 11:33
  • If one removes all the U+200E characters from the example and tries to compile it, one recieves the error message ' Command \algorithmic already defined.' If one now has a look at the pdf file that is produced by this unsucessful compilation, one can see the described =0 that is added after [N,Capacity]. To conclude: Never rely on the 'output' of a compilation that yielded an error message. – leandriis Jul 15 '18 at 12:08
  • For a summary on packages that can be useful for displaying algorithms, you might also want to have a look here: algorithm, algorithmic, algorithmicx, algorithm2e, algpseudocode = confused – leandriis Jul 15 '18 at 12:08

0 Answers0