You have to carefully adjust the dimensions of your image and the number of lines the wrap figure will extend ( for example [10]
in \begin{wrapfigure}[10]{r}{5.5cm}
).
An example:
\documentclass{article}
\usepackage{graphicx,wrapfig,lipsum}
%------------------------------------------
\begin{document}
This is where the table goes with text wrapping around it. You may
embed tabular environment inside wraptable environment and customize as you like.
%------------------------------------------
\begin{wrapfigure}[10]{r}{5.5cm}
\rule{5.5cm}{7.1cm}
\caption{A wrapped figure}\label{wrap-fig:1}
\end{wrapfigure}
%------------------------------------------
This is where the table goes with text wrapping around it. You may
embed tabular environment inside wraptable environment and customize as you like. This is where the table goes with text wrapping around it. You may
embed tabular environment inside wraptable environment and customize as you like. This is where the table goes with text wrapping around it.
%
\begin{figure}[h]
\begin{minipage}{6cm}
\centering
\rule{\textwidth}{3cm}
\caption{my figure}\label{fig:2}
\end{minipage}%
\end{figure}%
\lipsum[2-3]
Figure~\ref{wrap-fig:1} is a wrapped figure.
%------------------------------------------
\end{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
That is the document default small caps font so
\textsc{FooProc}
Better would be to use the package defined command
\textproc{Fooproc}
which will do the same thing, but ensure that if you customise the fonts used in the psuedo-code, the reference will use the same font.