Here's one possibility:
\documentclass[conference]{IEEEtran}
\usepackage[ruled]{algorithm}
\usepackage{algpseudocode}
%\usepackage{subfigure}
\usepackage[demo]{graphicx}
\usepackage{times}
\usepackage{amssymb}
\usepackage{url}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{wrapfig}
\newcounter{tmp}
\begin{document}
\title{xxx}
\maketitle
\begin{figure*}
\centering
\begin{minipage}[t]{0.32\textwidth}
\centering
\raisebox{-\height}{\includegraphics[width=1\textwidth]{xx.eps}}
\vspace{-0.4cm}%
\caption{THis is figure xx}\label{fig:xx}
\end{minipage}\hfill
\begin{minipage}[t]{0.32\textwidth}
\centering
\raisebox{-\height}{\includegraphics[width=1\textwidth]{yy.eps}}
\vspace{-0.4cm}%
\caption{This is figure yy.}\label{fig:yy}
\end{minipage}\hfill
\begin{minipage}[t]{0.32\textwidth}
\alglanguage{pseudocode}
\renewcommand\figurename{Algorithm}
\setcounter{tmp}{\value{figure}}
\setcounter{figure}{\value{algorithm}}
\small
\caption{\small Insert item into Hash Table (with mCBF and aCBF)}
\label{Algorithm:insert_mCBF_aCBF}
\begin{algorithmic}[1]
\Procedure{$\mathbf{InsertItem}$}{item $x$}
\For {$i = 1 \to k$}
\State $mCBF.C_{f_i(x)\%N}$ ++
\EndFor
\State $C_{min} = MAX\_VALUE$
%\Comment{Get minimum value of $k$ counters in mCBF}
\For {$i = 1 \to k$}
\If {$C_{min} > mCBF.C_{f_i(x)\%N}$}
\State $C_{min} \gets mCBF.C_{f_i(x)\%N}$
\State $j \gets f_i(x)\%N$
\State $m \gets i$
\EndIf
\EndFor
%\State $C_{min} = min\{mCBF.C_{f_1(x)\%N},\cdot\cdot\cdot,mCBF.C_{f_k(x)\%N}\}$
%\State $i = \textbf{SubscriptOf}(C_{min})$
\State $B_j = B_j \cup x$
\Comment \emph{Insert $x$ into $B_j$}
\For {$i = 1 \to k$}
\State $aCBF_m.C_{f_i(x)\%\textbf{LengthOf}(aCBF_m)}$ ++
\EndFor
\EndProcedure
\Statex
\end{algorithmic}
\end{minipage}
\setcounter{figure}{\value{tmp}}
\end{figure*}
\end{document}
The demo
option for graphicx
simply replaces actual figures with black rectangles; do not use that option in your actual document.
Is this what you are trying to achieve?
This is the MWE:
\documentclass{article}
\usepackage[plain]{algorithm}
\usepackage{algpascal}
\begin{document}
\algrenewcommand\textkeyword{\textrm}
\algdef{SE}{For}{End}[2]{%
\textkeyword{for} \(#1\) \textkeyword{to} \(#2\) \textkeyword{do begin}}{%
\textkeyword{end}}
\begin{algorithm}
\begin{algorithmic}[1]
\State Assign an ordering $A_{1}, ..., A_{n}$ to the nonterminals of the grammar.
\For{i = 1}{n}
\For{j = 1}{i-1}
\State for each production of the form $A_{i} \rightarrow A_{j} \alpha$
\End
\End
\end{algorithmic}
\caption{Paull's algorithm}
\end{algorithm}
\end{document}
Explanation
To match your first two requests, I've redefined the behavior of for
to have an end
statement by adding the lines:
\algdef{SE}{For}{End}[2]{%
\textkeyword{for} \(#1\) \textkeyword{to} \(#2\) \textkeyword{do begin}}{%
\textkeyword{end}}
To match your last request, it suffices to add the line:
\algrenewcommand\textkeyword{\textrm}
which redefines the font for keywords to be \textrm
instead of \textbf
.
In regards of your 3rd request, there are two ways.
If you want the algorithm to behave as an algorithm, simply load the algorithm
package with the option plain
as in the above MWE:
\usepackage[plain]{algorithm}
If you want the algorithm to behave as a figure, there is no need to load the algorithm
package, simply insert the algorithmic
environment inside a figure
, i.e. replace the lines
\begin{algorithm}
\begin{algorithmic}[1]
...
\end{algorithmic}
\caption{Paull's algorithm}
\end{algorithm}
with
\begin{figure}
\begin{algorithmic}[1]
...
\end{algorithmic}
\caption{Paull's algorithm}
\end{figure}
and you will have
Addendum
This is the complete implementation of the algorithm in the figure:
\documentclass{article}
\usepackage[plain]{algorithm}
\usepackage{algpascal}
\begin{document}
\algrenewcommand\textkeyword{\textrm}
\algdef{SE}{For}{End}[2]{%
\textkeyword{for} \(#1\) \textkeyword{to} \(#2\) \textkeyword{do begin}}{%
\textkeyword{end}}
\algdef{SE}{ForEach}{End}[1]{%
\textkeyword{for each} #1 \textkeyword{do begin}}{%
\textkeyword{end}}
\begin{algorithm}
\begin{algorithmic}[1]
\State Assign an ordering $A_{1}, \dots, A_{n}$ to the nonterminals of the grammar.
\For{i := 1}{n}
\For{j := 1}{i-1}
\ForEach{production of the form $A_{i} \rightarrow A_{j} \alpha$}
\State remove $A_{i} \rightarrow A_{j} \alpha$ from the grammar
\ForEach{production of the form $A_{j} \rightarrow \beta$}
\State add $A_{i} \rightarrow \beta\alpha$ to the grammar
\End
\End
\End
\State transform the $A_{i}$-productions to eliminate direct left recursion
\End
\end{algorithmic}
\caption{Paull's algorithm}
\end{algorithm}
\end{document}
There is the need to define a new command \ForEach
:
\algdef{SE}{ForEach}{End}[1]{%
\textkeyword{for each} #1 \textkeyword{do begin}}{%
\textkeyword{end}}
Note that I've defined \ForEach
so to take one "text" argument, because it seemed to me the best way to define it.
If you want it to take a "math" argument, then define it as
\algdef{SE}{ForEach}{End}[1]{%
\textkeyword{for each} \(#1\) \textkeyword{do begin}}{%
\textkeyword{end}}
and use it as follows (amsmath
is needed for the command \text
):
\ForEach{\text{production of the form }A_{i} \rightarrow A_{j} \alpha}
Best Answer
For correct referencing of of figures you could use the
caption
package which provides\captionof{figure}{<caption>}
. This typesets the caption<caption>
as that of afigure
environment even though you have not declared the contents within afigure
environment. This is of great help since typesetting afigure
(or float) inside aminipage
(a non-float) is not allowed. Additionally, thelistings
package typesets a large body of languages verbatim and can be expanded to incorporate your own touch of formatting.Here is a small example that shows the construction, as well as the referencing capability, if needed.
In order to use a more pseudo-code listing, you may be interested in the [
algorithmicx
package][algorithmicx-pkg]. However, for this to function fully as above, you also need the [algorithm
package][algorithm-pkg] which defines thealgorithm
float (and associated float counter). Now you can use\captionof{algorithm}{<caption>}
. Here is a similar example:lipsum
provided some dummy text, whilegeometry
was merely used to increase the text block size (viamargin=1in
). Dummy figures are represented by black rectangular boxes, although you would be interested in thegraphicx
package for inserting your images.Adjustment of the vertical alignment is also possible, depending on the size of algorithm or figures.