How to insert algorithm pseudocode in Lyx?
I have found the answer:
- add the
\usepackage{algorithm,algpseudocode}
into the premble - insert a algorithm block (Insert --> Floating --> Algorithm)
- insert the tex code in the algorithm block (Insert --> Tex Code)
add the following latex code
\begin{algorithmic}[1] \Require{$\rho \geq 1$} \Ensure{$X_k$} \While{not converged} \State{Solve $X_{k+1}=\min_{X} L(X,Y_k, \mu_k)$} \State{$Y_{k+1}=Y_k+\mu_k h(X_{k+1})$} \State{$\mu_{k+1}=\rho \mu_k$} \EndWhile \end{algorithmic}
LyX Version 2.3.4.3(Windows 10) (14 February 2020)
- Insert->float->Algorithm
- Change Environment choice box (in this version it is just below file menu) from Standard to LyX-code
- Type the pseudo-code inside the box as you would in an editor. Math formatting works as usual. To highlight keywords select text and press Ctrl+b.