Sorry if this is obvious, but I've been searching for quite a while without
luck. Basically I would like to use Lyx and edit pseudocode using packages
algorithm/algorithmic/algpseudocode. Preferably the notation using arrows
for assignment, as demonstrated in the .tex file.
This .tex file works fine using LaTeX but when importing the file into LyX,
and creating a pdf preview, LyX complains:
-----------------------------------------------------
LaTeX Error: Something's wrong--perhaps a missing item.
...uclid} \begin{algorithmic}{[}1] \Procedure
{Euclid}{$a,b$}\Comment{The
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
-----------------------------------------------------
The link that might offer help in this similar issue is broken.
http://www.mail-archive.com/lyx-users@lists.lyx.org/msg06574.html
Can anyone help and show how to do this within LyX?
Thanks,
Erwin
---------------------------------
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{graphicx}
\begin{document}
\title{Introduction to \LaTeX{}}
\author{Author's Name}
\maketitle
\begin{abstract}
The abstract text goes here.
\end{abstract}
\section{Introduction}
Here is the text of your introduction.
\begin{equation}
\label{simple_equation}
\alpha = \sqrt{ \beta }
\end{equation}
\subsection{Subsection Heading Here}
Write your subsection text here.
\section{Conclusion}
Write your conclusion here.
\begin{algorithm}
\caption{Euclid's algorithm}\label{euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\If {$r\not=0$}
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\EndIf
\State \textbf{return} $b$\Comment{The g.c.d. is b}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}