Discussion:
looking for equivalence to LaTeX algorithm package
Zhaopeng Xing
2008-11-30 16:09:01 UTC
Permalink
Hi,

Does anyone know how to describe algorithm procedures in similar way as
LaTeX algorithmic and algorithm packages? I tried to search it on wiki but
found nothing. Thanks.
--
Zhaopeng XING

Tinbergen Institute
Mohamed Bana
2008-11-30 17:26:25 UTC
Permalink
Maybe you could typeset the page with (Xe)LaTeX and include the pdf as
page in your ConTeXt doc.
Post by Zhaopeng Xing
Hi,
Does anyone know how to describe algorithm procedures in similar way as
LaTeX algorithmic and algorithm packages? I tried to search it on wiki
but found nothing. Thanks.
--
Zhaopeng XING
Tinbergen Institute
------------------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
Wolfgang Schuster
2008-11-30 19:43:28 UTC
Permalink
Post by Zhaopeng Xing
Hi,
Does anyone know how to describe algorithm procedures in similar way
as LaTeX algorithmic and algorithm packages? I tried to search it on
wiki but found nothing. Thanks.
Feel free to write your own module.

\definefloat[algorithm][algorithms]

\definestartstop
[algorithm]
[before=\startlines,
after=\stoplines,
commands=\directsetup{algorithm}]

\startsetups algorithm

\def\STATE {\hskip1em}
\def\REQUIRE {{\bf Require: }}
\def\ENSURE {{\bf Ensure: }}
\def\IF ##1{\bgroup\doadaptleftskip{1em}{\bf if} ##1 {\bf then}}
\def\ENDIF {{\bf end if}\par\egroup}
\def\WHILE ##1{\bgroup\doadaptleftskip{1em}{\bf while} ##1 {\bf do}}
\def\ENDWHILE {{\bf end while}\par\egroup}

\definecomplexorsimple\ELSE

\def\simpleELSE {{\bf else}}
\def\complexELSE[##1]{{\bf else} $//$ ##1}

\stopsetups

%\setuplines[before=,after=]

\starttext

\startbuffer[algorithm]
\startalgorithm
\REQUIRE $n \geq 0 \vee x \neq 0$
\ENSURE $y = x^n$
\STATE $y \Leftarrow 1$
\IF{$n < 0$}
\STATE $X \Leftarrow 1 / x$
\STATE $N \Leftarrow -n$
\ELSE
\STATE $X \Leftarrow x$
\STATE $N \Leftarrow n$
\ENDIF
\WHILE{$N \neq 0$}
\IF{$N$ is even}
\STATE $X \Leftarrow X \times X$
\STATE $N \Leftarrow N / 2$
\ELSE[$N$ is odd]
\STATE $y \Leftarrow y \times X$
\STATE $N \Leftarrow N - 1$
\ENDIF
\ENDWHILE
\stopalgorithm
\stopbuffer

\typebuffer \getbuffer

%\placealgorithm
% {Calculate $y = x^n$}
% {\framed[frame=off,align=right,width=fit,strut=no]
{\getbuffer[algorithm]}}

\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
Wolfgang Schuster
2008-12-01 11:09:58 UTC
Permalink
Post by Zhaopeng Xing
Hi,
Does anyone know how to describe algorithm procedures in similar way as
LaTeX algorithmic and algorithm packages? I tried to search it on wiki but
found nothing. Thanks.
\starttext

\setuplines[space=yes]

\startlines
$sum \leftarrow 0$
\bold{for} $i \leftarrow 1,n$ \bold{do}
$sum \leftarrow sum + i$
\bold{end for}
\stoplines

\stoptext

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
Zhaopeng Xing
2008-12-01 12:09:53 UTC
Permalink
Thank you, Walfgang. I will try. It is a good exercise.
Post by Wolfgang Schuster
Post by Zhaopeng Xing
Hi,
Does anyone know how to describe algorithm procedures in similar way as
LaTeX algorithmic and algorithm packages? I tried to search it on wiki
but
Post by Zhaopeng Xing
found nothing. Thanks.
\starttext
\setuplines[space=yes]
\startlines
$sum \leftarrow 0$
\bold{for} $i \leftarrow 1,n$ \bold{do}
$sum \leftarrow sum + i$
\bold{end for}
\stoplines
\stoptext
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
--
Zhaopeng XING

Tinbergen Institute
Richard Rascher-Friesenhausen
2008-12-01 13:34:40 UTC
Permalink
Post by Zhaopeng Xing
Hi,
Does anyone know how to describe algorithm procedures in similar way
as LaTeX algorithmic and algorithm packages? I tried to search it on
wiki but found nothing. Thanks.
--
Zhaopeng XING
Tinbergen Institute
------------------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
Hello,

I once tried to copy the LaTeX environment to ConTeXt. And this is, what
came out of it: *t-algorithmic.tex* It works for me, but i'm open to new
and better implementations...

richard rascher-friesenhausen
--
==============================================================================
Dr. Richard Rascher-Friesenhausen
Hochschule Bremerhaven, Studiengang Medizintechnik
An der Karlstadt 8
27568 Bremerhaven

und

MeVis Research GmbH
Universitaetsallee 29
D-28359 Bremen

Amtsgericht Bremen, HRB 16222
GeschÀftsfÌhrer: Prof. Dr. Heinz-Otto Peitgen

email: ***@mevis.de, richard.rascher-***@hs-bremerhaven.de
www : http://www.mevis-research.de/, http://www.hs-bremerhaven.de/
fon : +49 - 421 - 218 7707 (mevis)
fax : +49 - 421 - 218 4236 (mevis)
==============================================================================
Wolfgang Schuster
2008-12-03 16:18:55 UTC
Permalink
Post by Richard Rascher-Friesenhausen
Post by Zhaopeng Xing
Hi,
Does anyone know how to describe algorithm procedures in similar
way as LaTeX algorithmic and algorithm packages? I tried to search
it on wiki but found nothing. Thanks.
Hello,
I once tried to copy the LaTeX environment to ConTeXt. And this is,
what came out of it: *t-algorithmic.tex* It works for me, but i'm
open to new and better implementations...
It's ok for a private module but before you can put it on
the garden a few things can be done better.

- define the commands (IF, WHILE etc.) local and use protected
names in the code, users can user similiar names in their
documents and you have to take care of this

- you can use \doadaptleftskip to increase/decrease the left
margin with each \IF/\ENDIF ... pair

- you can define \Algorithm with \defineframedtext[Algorithm]

Thanks for sharing it with the rest of the community.

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
Wolfgang Schuster
2008-12-15 10:37:36 UTC
Permalink
Post by Zhaopeng Xing
Hi,
Does anyone know how to describe algorithm procedures in similar way as
LaTeX algorithmic and algorithm packages? I tried to search it on wiki but
found nothing. Thanks.
xml based solution by Hans:

http://archive.contextgarden.net/message/20050125.164829.e244f458.en.html

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
Loading...