Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

algorithm/algorithmic fonts

6,380 views
Skip to first unread message

John Smith

unread,
Jun 24, 2010, 8:13:07 AM6/24/10
to
Hi,
I'm using the 'algorithm' and 'algorithmic' packages.
Some of the numbered lines have a variable-width sized
font while other lines have a teletype font. Could
someone pls inform me about how to change all the lines
to the variable-width sized fonts.

thx.,
glen

Uwe Ziegenhagen

unread,
Jun 25, 2010, 12:54:48 AM6/25/10
to

Can you prepare a small document showing the behaviour?

Uwe

John Smith

unread,
Jun 26, 2010, 10:31:41 AM6/26/10
to
The code below outputs "The quick brown fox ..." with a variable width
font and "a man a plan panama" with a teletype font.
-------------------------------------------------------------------------------------------------------
\begin{algorithm}
{\fontsize{10pt}{10pt}\selectfont
\caption {The Example algorithm.}
\label {algorithm:ex1}
\begin{algorithmic}[1]
\Procedure {ExampleProcedure} {}
\State {The quick brown fox jumped over the lazy dog.}
\Repeat
\State {Step 1 - aaaa}
\State {Step 2 - bbbb}
\State {Step 3 - cccc}
\State {Step 4 - dddd}
\State {Step 5 - eeee}
\State {Step 6 - ffff}
\Until {\tt (curr = max)}
\EndProcedure
\State {A man a plan panama.}
\end{algorithmic}
}
\end{algorithm}

Bob Tennent

unread,
Jun 26, 2010, 12:41:58 PM6/26/10
to

Give us a complete document. I can figure out from the OP that
algorithm.sty and algorithmic.sty are needed but it seems something else
is defining \Procedure.

John Smith

unread,
Jun 26, 2010, 2:22:03 PM6/26/10
to
\documentclass[10pt,dvips,twocolumn]{article}
\topmargin -0.50in
\textheight 8.5in
\textwidth 6.25in
\oddsidemargin -0.010in
\usepackage{times}
\usepackage{courier}
\usepackage{epsfig}
\usepackage{psfig,latexsym}
\usepackage{ulem}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage{ccaption}
\usepackage{hyphenat}
\usepackage{fancyhdr}
\usepackage{url}
\usepackage{array}
\usepackage{setspace}
\usepackage{enumitem}

\newlength{\minipagesize}
\setlength{\minipagesize}{2.9in}
\newlength{\minipagetextsize}
\setlength{\minipagetextsize}{2.8in}
\newlength{\twocolpagesize}
\setlength{\twocolpagesize}{3.00in}
\newlength{\algofontsize}
\setlength{\algofontsize}{6pt}
\newlength{\algofontsize}
\setlength{\algofontsize}{6pt}
\def\protect{\noexpand\protect\noexpand}
\edef\tt{\tt \hyphenchar\font=45 }
\let\protect\relax
\newcommand{\figurecaption}{% always use below the figure
\setlength{\abovecaptionskip}{2mm}%
\setlength{\belowcaptionskip}{0pt}%
\caption%
}
\newenvironment{packed_enum}{
\begin{enumerate}
\setlength{\itemsep}{1pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}{\end{enumerate}}
\newenvironment{packed_enum2}{
\begin{enumerate}
\setlength{\itemsep}{3pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}{\end{enumerate}}
\newenvironment{packed_enum3}{
\begin{enumerate}[leftmargin=4mm]
\setlength{\itemsep}{1pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}{\end{enumerate}}
\newenvironment{packed_enum4}{
\begin{enumerate}[leftmargin=4mm]
\setlength{\itemsep}{1pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}{\end{enumerate}}
\newenvironment{packed_itemize}{
\begin{itemize}
\setlength{\itemsep}{1pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}{\end{itemize}}
\begin{document}
\fancyhead[R]{}
\addtocounter{secnumdepth}{1}
\captionnamefont{\fontsize{8pt}{8pt}\selectfont}
\captiontitlefont{\fontsize{8pt}{8pt}\selectfont}
\renewcommand{\figurename}{Fig.}
\setlength{\belowcaptionskip}{0.00in}
\setlength{\abovecaptionskip}{2mm}
\renewcommand{\topfraction}{.99}
\renewcommand{\bottomfraction}{.99}
\renewcommand{\textfraction}{.05}
\renewcommand*{\floatpagefraction}{0.3}
%
\renewcommand{\floatpagefraction}{0.7}
\begin{center}


\begin{algorithm}
{\fontsize{10pt}{10pt}\selectfont
\caption {The Example algorithm.}
\label {algorithm:ex1}
\begin{algorithmic}[1]
\Procedure {ExampleProcedure} {}
\State {The quick brown fox jumped over the lazy dog.}
\Repeat
\State {Step 1 - aaaa}
\State {Step 2 - bbbb}
\State {Step 3 - cccc}
\State {Step 4 - dddd}
\State {Step 5 - eeee}
\State {Step 6 - ffff}
\Until {\tt (curr = max)}
\EndProcedure
\State {A man a plan panama.}
\end{algorithmic}
}
\end{algorithm}

\end{center}
\end{document}

Bob Tennent

unread,
Jun 26, 2010, 5:05:26 PM6/26/10
to
A *minimal* complete document.

Rogério Brito

unread,
Jun 27, 2010, 5:12:25 AM6/27/10
to
Hi, John.

On 06/26/2010 03:22 PM, John Smith wrote:
> \usepackage{algorithm}
> \usepackage{algorithmicx}
> \usepackage{algpseudocode}

(...)

The subject of this message says that you are using algorithm and algorithmic,
but you use algoritmicx instead (note the extra trailing x). I maintain
algorithms and algorithmic, but I have no idea what the other packages you use mean.

> \Until {\tt (curr = max)}

I don't really know a thing about the packages that you mention, but, perhaps,
you could try putting the \tt and the text that is should apply to within braces.


Regards,

--
Rog�rio Brito : rbrito@{ime.usp.br,gmail.com} : GPG key 1024D/7C2CAEB8
http://rb.doesntexist.org : Packages for LaTeX : algorithms.berlios.de
DebianQA: http://qa.debian.org/developer.php?login=rbrito%40ime.usp.br

John Smith

unread,
Jun 27, 2010, 10:05:48 AM6/27/10
to
I couldn't find the manual for the algorithmic package. The
algorithmicx manual said to use the
algpseudocode.sty. Also, I'd like to make the line 'a man a plan
panama' to be variable-width.
-------------------------------------------------------------------------------------------------------------------------------------------

\documentclass[10pt,dvips,twocolumn]{article}
\topmargin -0.50in
\textheight 8.5in
\textwidth 6.25in
\oddsidemargin -0.010in
\usepackage{times}
\usepackage{courier}
\usepackage{algorithm}
\usepackage{algpseudocode}

\newlength{\algofontsize}
\setlength{\algofontsize}{6pt}

\begin{document}


\begin{algorithm}
{\fontsize{10pt}{10pt}\selectfont
\caption {The Example algorithm.}
\label {algorithm:ex1}
\begin{algorithmic}[1]
\Procedure {ExampleProcedure}{}
\State {The quick brown fox jumped over the lazy dog.}
\Repeat
\State {Step 1 - aaaa}
\State {Step 2 - bbbb}
\State {Step 3 - cccc}
\State {Step 4 - dddd}
\State {Step 5 - eeee}
\State {Step 6 - ffff}
\Until {\tt (curr = max)}
\EndProcedure
\State {A man a plan panama.}
\end{algorithmic}
}
\end{algorithm}

\end{document}

Bob Tennent

unread,
Jun 27, 2010, 8:12:30 PM6/27/10
to
On Sun, 27 Jun 2010 07:05:48 -0700 (PDT), John Smith wrote:

Change

> \Until {\tt (curr = max)}

to

\Until \mbox{\tt (curr = max)}

Bob T.

John Smith

unread,
Jul 3, 2010, 4:27:40 PM7/3/10
to
Success! Putting a mbox before the {\tt ...} worked.

Bob Tennent

unread,
Jul 3, 2010, 5:54:43 PM7/3/10
to
On Sat, 3 Jul 2010 13:27:40 -0700 (PDT), John Smith wrote:
> Success! Putting a mbox before the {\tt ...} worked.

You're welcome.

0 new messages