Insert algorithm in Lyx 2.1.1 with line numbers

algorithmlatexlyx

I am able to insert algorithms directly with Lyx 2.1.1 using insert->float->algorithm , however the algorithm lines are not numbered in the generated pdf. Is there any option that can number the algorithm lines or any work around to include algorithm in Lyx with line number? I am using the built in IEEE template document in Lyx and assume it should be possible with other templates too.

Best Answer

The default algorithm insertion is just a floating environment. If you want a built-in numbered algorithm, you have to consider adding the algorithm2e module:

enter image description here

Then, also add \LinesNumbered to your Document > Settings... > LaTeX Preamble.

enter image description here

The above assumes a non-ERT approach to numbered-line algorithms. Of course, if you wish, you can go all out with LaTeX ERT to obtain line numbers in algorithms.