I am currently writing an essay and I'd like to insert some kind of code. This is my first time trying such a thing so I'm very unexperienced. I found the packages algorithm, algorithmicx, algpseudocode on the internet and I think I understand what they're doing (found this). Nevertheless, I am not able to compile my document. It always says "algorithm.sty" not found when trying to compile. I think there is some error installing the package? What should I do?


\usepackage{algorithm, algpseudocode}


    \STATE S := I
    \WHILE{$\frac{h}{k} \ne \Phi(S)$}
        \IF{$\frac{h}{k} < \Phi(S)$} $S = SL$
        \ELSE $S = SR$ \ENDIF

  • if you have the storage capacity on your hard drive, install the complete TeX environment. otherwise see, if you can enable the option install missing packages on the fly – naphaneal Jun 17 '18 at 10:45

You should install the algorithm package (how, it depends on what TeX distribution you're using).

Then you have to fix the code for using algpseudocode specific commands.


\usepackage{algorithm, algpseudocode}


\State S := I
\While{$\frac{h}{k} \ne \Phi(S)$}
  \If{$\frac{h}{k} < \Phi(S)$}
    \State $S = SL$
    \State $S = SR$


enter image description here

  • I tried to install algorithms manually but it doesn't work. Entering latex algorithms.ins into the command prompt gives me the error "can't write on latex.log" This is the page I got my ideas from. – Astrid Niehues Jun 17 '18 at 19:43

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.