# Math Help - display an algorithm in latex

1. ## display an algorithm in latex

i want to type an algorithm in latex
i have a mac and i am using texshop

i want to display the algorithm as seen in the attachment

i need a step by step guide here!

2. You could specify the algorithm exactly as written between
\begin{verbatim}

my algorithm here

\end{verbatim}

however it does not seem to work here but works fine in TeXnic Center under Windows.

3. when you use verbatim does it retain the spaces and allow you to type special symbols and subscripts?

because it types it "verbatim" for me.

4. ## help- typo? i'm losing my mind!

I can not get this to display properly, i kee running into a problem on the bolded line....
can anyone tell me when my "error" is?

\documentclass[11 pt]{article}
\author{Emily}
\title{An Algorithm for Computing Gr\"obner Bases}
\renewcommand{\baselinestretch}{1.5}
\newtheorem{ex}{Example}[section]
\newtheorem{thm}{Theorem}[section]
\newtheorem{deff}{Definition}[section]
\usepackage{algorithm}
\usepackage{algorithmic}

\begin{document}
\maketitle
\section{Algorithm}

\begin{algorithm}
\caption{Buchberger's Algorithm}
\begin{algorithmic}
\REQUIRE A polynomial set $F = \{f_1, \dots ,f_n\}$, that generates an ideal $I$
\ENSURE A Gr\"obner basis $G = \{g_1, \dots , g_t\}$, that generates the same ideal $I$ with $F \subset G$
\STATE $G := F$
\STATE $M := \{f_i, f_j\} | f_i, f_j \in G$ and $f_i \neq f_j\} \REPEAT \STATE$\{p, q\} :=$a pair in$M$\STATE$M := M – \{\{p, q\}\}$\STATE$S := Spoly(p, q)$\STATE$h := NormalForm(S, G)$\IF{$h \neq 0$} \STATE$M := M \cup \{\{ g , h \}\} \forall g\in G \}$\ENDIF \UNTIL{M=0} \end{algorithmic} \end{algorithm} \end{document} 5. Originally Posted by mlemilys I can not get this to display properly, i kee running into a problem on the bolded line.... can anyone tell me when my "error" is? When LaTeX stops compiling at line $n$ it does not mean that there is an error on line $n$, it means that there is an error before line $n$. You just forgot the closing$ at the end of line #24, two lines before the bolded one.
Code:
\STATE $G := F$
\STATE $M := \{f_i, f_j\} | f_i, f_j \in G$ and $f_i \neq f_j\}$
\REPEAT
\STATE $\{p, q\} :=$ a pair in $M$