Document Classesalgorithm, algorithmic | Remove Rules from Algorithms

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
beegii
Posts: 5
Joined: Tue Nov 09, 2010 10:29 pm

algorithm, algorithmic | Remove Rules from Algorithms

Post by beegii »

Hello,

The example given below is what I want to do. But there are three extra lines.

Code: Select all

\documentclass{article}
\usepackage[noend]{algorithmic} 
\usepackage{algorithm}

\begin{document}
\begin{algorithm}
\caption{Iterate} \label{alg:it}
\begin{algorithmic}
\STATE n = 1
\FOR { $i=1$ \TO $n$ }
   \STATE $print(i)$
\ENDFOR
\end{algorithmic}
\end{algorithm}

\end{document}
So, how to remove those hrule from algorithm package?

Thanks
Last edited by beegii on Mon Oct 03, 2011 11:38 am, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

algorithm, algorithmic | Remove Rules from Algorithms

Post by sommerfee »

The algorithm package offers options like "plain", "ruled", "boxed" etc. to specify the float style of the algorithm environment. The default one is "ruled". (The algorithm package uses the float package for this purpose.)

Code: Select all

\documentclass{article}
\usepackage[noend]{algorithmic} 
\usepackage[plain]{algorithm} % NOTE THE "plain" option HERE

\begin{document}
\begin{algorithm}
\caption{Iterate} \label{alg:it}
\begin{algorithmic}
\STATE n = 1
\FOR { $i=1$ \TO $n$ }
   \STATE $print(i)$
\ENDFOR
\end{algorithmic}
\end{algorithm}

\end{document}
beegii
Posts: 5
Joined: Tue Nov 09, 2010 10:29 pm

Re: algorithm, algorithmic | Remove Rules from Algorithms

Post by beegii »

Sommerfee thanks for the reply.
OK, I'd like to see the caption is appeared on the top left corner (exactly the same as for the "ruled" option, but without hlines).
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

algorithm, algorithmic | Remove Rules from Algorithms

Post by sommerfee »

Like this?

Code: Select all

\documentclass{article}
\usepackage[noend]{algorithmic} 
\usepackage{algorithm}
\floatstyle{plaintop}
\restylefloat{algorithm}
\usepackage{caption}
\captionsetup[algorithm]{singlelinecheck=off}

\begin{document}
\begin{algorithm}
\caption{Iterate} \label{alg:it}
\begin{algorithmic}
\STATE n = 1
\FOR { $i=1$ \TO $n$ }
   \STATE $print(i)$
\ENDFOR
\end{algorithmic}
\end{algorithm}

\end{document}
For explanation see float and caption package documentation.
beegii
Posts: 5
Joined: Tue Nov 09, 2010 10:29 pm

Re: algorithm, algorithmic | Remove Rules from Algorithms

Post by beegii »

Yes, exactly. Thank you very much :)
Post Reply