We can use another method to bold Greek letters and symbols that \mathbf
doesn't work on, but this method doesn't work on \varnothing
. However, it does work on \O
and \emptyset
.
\pmb
was the only one to work on \varnothing
but as barbara beeton pointed out it doesn't look that great. If you are okay with using \O
or \emptyset
, we can avoid the use of \pmb
\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\newcommand{\bfs}[1]{\mbox{\boldmath$#1$}}
\begin{document}
\begin{alignat*}{4}
\varnothing & \qquad\bfs{\varnothing} & \qquad \mathbf{\varnothing}
& \qquad \pmb{\varnothing}\\
\phi & \qquad\bfs{\phi} & \qquad \mathbf{\phi} & \qquad \pmb{\phi}\\
\Phi & \qquad\bfs{\Phi} & \qquad \mathbf{\Phi} & \qquad \pmb{\Phi}\\
\O & \qquad\bfs{\O} & \qquad \mathbf{\O} & \qquad \pmb{\O}\\
\emptyset & \qquad\bfs{\emptyset} & \qquad \mathbf{\emptyset}
& \qquad \pmb{\emptyset}
\end{alignat*}
\end{document}
Close up of \pmb
Close up of \newcommand
which didn't work on \varnothing
but works on the rest.
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
There is no such feature in
algorithmicx
(I suggest contacting the package author to customize this as a new package feature).Take
algpseudocode
, for example. All the keywords are defined verbatim as\textbf{<keyword>}
:You would have to redefine these to suit your needs in a very generic way. Alternatively, if you're willing to sacrifice all
\textbf
usages within thealgorithmic
environment, you can make\textbf
a no-op by adding to your document preamble:Here is a minimal example showing the output with the above change:
This is what the output would have looked like without the no-op addition/patch using
etoolbox
: