Math & ScienceAlgorithm

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
bobbybd
Posts: 2
Joined: Wed Oct 20, 2010 2:30 am

Algorithm

Post by bobbybd »

\usepackage {algorithm}
\usepackage {algorithmic}

\begin{document}
\begin{algorithm}
\caption{algorithm}
\begin{algorithmic}
\STATE Input n;
\STATE Calculate m;
\STATE Output m+n;
\end{algorithmic}
\end{algorithm}
\end{document}


But I have a lot of errors using package algorithm :cry:
the output is misaligned (not in the center of the page)
and each STATE doesn't have a carriage return included :evil:

Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Algorithm

Post by gmedina »

Hi,

perhaps your system is outdated. Compile the following code:

Code: Select all

\listfiles
\documentclass[10pt]{report}    
\usepackage {algorithm}
\usepackage {algorithmic}

\begin{document}

\begin{algorithm}
  \caption{algorithm}
  \begin{algorithmic}
    \STATE Input n;
    \STATE Calculate m; 
    \STATE Output m+n; 
  \end{algorithmic}
\end{algorithm}

\end{document}
go to the .log file generated after compilation and search for the section *File List*; compare your list with mine:

Code: Select all

 *File List*
  report.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
algorithm.sty    2009/08/24 v0.1 Document Style `algorithm' - floating environm
ent
   float.sty    2001/11/08 v1.3d Float enhancements (AL)
  ifthen.sty    2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
algorithmic.sty    2009/08/24 v0.1 Document Style `algorithmic'
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
 ***********
if you notice outdated packages, update your system. I attach the PDF obtained after compilation of the above code.
Attachments
b.pdf
(25.45 KiB) Downloaded 245 times
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply