I have a lot of code from R, and I'm working on a research project where I need to write down the pseudocode, is there any way to convert these codes into latex?

  • 3
    R code is different from pseudocode, because it is real code. If you want to write pseudocode then you cannot convert it but you need to write the pseudocode from scratch, writing down only the important steps of your algorithm and leaving out all practical implementation details. For such a task you can use packages like algorithm2e or algorithmicx. If you want to print actual code then you can use listings or minted. – Marijn Nov 8 '20 at 22:23
  • Both can be useful (pseudocode and real code), but by definition you cannot convert one into the other. – Marijn Nov 8 '20 at 22:24
  • Pretty good answer, thank you @Marijn – Felipe Augusto Nov 8 '20 at 22:39
  • 1
    Why pseudocode? You can write real code in LaTeX, and show it highlighted and/or execute it. Do you know knitr? A simple example here – Fran Nov 12 '20 at 22:06
  • @Fran good tip! In some cases can be applied, but for mine the code is very big and for those who don't know R it's harder to understand than pseudocode. – Felipe Augusto Nov 14 '20 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.