I am trying to add an algorithm in pseudocode within LyX in version 2.3.2 as described here.
- Add the
\usepackage{algorithm,algpseudocode}
into the preamble - 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}
Which delivers the following result:
According to other answers I have read, the algorithmic[1]
command should number every line and not start at line 3 within the pseudocode.
How can I fix this and number all lines from the beginning e.g. starting from \Require{$\rho \geq 1$}
in this example?
\State abc
, not\State{abc}
. Similarly for\Require
and\Ensure
.