6

I am relatively new to LaTeX. If I use standard algorithm and algorithmic environment for my algorithm listings I'm getting the borders displayed around the table with the pseudocode. How to remove them? I also want to have the caption of the algorithm below the pseudocode - it is currently above. I believe the problem is extremely easy but googling didn't give me any hints for that.

0

1 Answer 1

7

If you are using the algorithm package, it is enough to use the plain option:

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

\begin{document}

\begin{algorithm}
\begin{algorithmic}
  \STATE $sum\gets 0$
  \STATE $i\gets 1$
  \WHILE{$i\le n$}
  \STATE $sum\gets sum+i$
  \STATE $i\gets i+1$
  \ENDWHILE
\end{algorithmic}
\caption{Calculate $y = x^n$}
\label{alg:test}
\end{algorithm}

\end{document}

enter image description here

4
  • Yes, this is it! I knew it must be a fast hack :-)
    – Jamie
    Jun 3, 2011 at 19:47
  • 1
    @Jamie: It isn't a fast hack. It is reading the documentation. Aug 31, 2011 at 17:12
  • 5
    Can this option plain be set locally for a specific algorithm, leaving other algorithms with borders?
    – hengxin
    Oct 30, 2014 at 13:36
  • For reference, the answer to hengxin's question is no. The package documentation states this only as a global option. We can get a solution by wrapping our algorithmic environment in an unnamed figure. If we want any of the lines, we can use \hrulefill to add these.
    – RasmusWL
    Feb 28, 2017 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.