TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have used these two packages for creating algorithm


But \begin{algorithm} shows as unrecognized command. Even \For, \While are shown as unrecognized. I don't understand. I'm using TexStudio as editor. Here is a sample code

\caption{Retiming Algorithm to compute Shortest Path}
 Set count = 1 \linebreak
\While{count $\le$ V}{
Set W(U,V) = $\infty$ \linebreak
Set D(U,V) = -1 \linebreak
 count $\gets$ count + 1 


If I run above code, I get no errors but \While, \begin{algorithm} are coming as unrecognized commands. I'm not good at LaTeX. I've used google as source to write this.

share|improve this question
TeXStudio is irrelevant in this context (editors usually are). Please provide a full minimal example, i.e., something that we can copy'n'paste to our own systems without having to add anything. You do not provide any information about which document class your are using. – daleif Jun 16 '14 at 10:10
Please check now – user2940249 Jun 16 '14 at 11:09
No problems here. Which LaTeX installation are you using? – daleif Jun 16 '14 at 11:36
I'm using TexStudio. even i've no errors but that shows as unrecognized command in the editor. – user2940249 Jun 16 '14 at 13:56
What do you mean by unrecognized in the editor? No editor knows about all possible macro names. – daleif Jun 16 '14 at 14:34

To recognise the commands from a package, TeXStudio needs a corresponding file with the extension .cwl. For some of the most common packages, the cwl files are provided as standard, and they can be activated as discussed in TeXStudio doesn't recognize some commands.

I don't think cwl files are provided for algorithm2e or algorithmicx, but section 1.5 of the TeXStudio User Manual explains how to create your own.

share|improve this answer
I had checked the cwl files required but it is still shown as unrecognized. – user2940249 Jun 19 '14 at 2:38
Those were probably auto generated by TeXStudio so checking them won't make a difference. You can open them and see. – nalyd88 Oct 8 '15 at 1:07

Your Answer


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.