2

I would like to develop and write about algorithms directly in LyX while minimizing the use of ERTs and Tex Code while maximizing the comprehensibility of the LyX code as several people will look at the LyX text. I have been playing with several different algorithm realizations in LyX but feel unhappy with usage within LyX.

What is the best way to do Algorithms in LyX which you suggest? So far, I only have found two options that work in LyX.

  1. Using the Build-In Module in LyX, which is bare-bones: Build-In Module

  2. Paul Rubin's script (https://github.com/prubin73/algpseudocode), which looks great except that it does not do indenting (which is crucial for more complex algorithms). If one could help Paul, that would even be better. Here is how the same algorithm looks then: Paul Rubin's script

Does any of you have better solutions? I found a couple more which no longer work.

  • I have not used it myself, but the following LyX module looks very interesting: github.com/prubin73/algpseudocode – scottkosty Dec 12 '18 at 18:12
  • If you are motivated, please write an answer (although it seems strange, you are actually encouraged to write an answer to your own question). I'm sorry that you received a "-1" vote. That might be because you were not specific (i.e., instead of "unhappy" you could have said what specifically you were looking for). – scottkosty Jan 20 at 20:52
  • 1
    I don't have an answer. I have updated the question to reflect the lack of answer. Maybe there is no good answer? – Jenny Reininger Jan 21 at 13:27
1

I had the same issue and decided to code a practical solution in my own way. It might not be as sophisticated and complete as the existing library but looks way better because of the indentation. If you are planning to use it a lot, I recommend adding shortcuts.

The code and how to use it can be found here. There is no file to download or to install, just copy-paste as indicated.

Indentation is achieved in two steps (I tried to simplify but failed) by inserting indentedBox and then selecting indentedStyle. Use alt-enter to insert newlines without losing indentation.

Take into account that bolding of keywords (while, do, end, if, then, etc.) is done by hand with ctrl-b, which also means its very flexible and you can write whatever you want.

This is an example of how it looks in lyx and in pdf.

lyx-algorithm-example

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.