Re: [NTG-context] looking for equivalence to LaTeX algorithm package

2008-12-15 Thread Wolfgang Schuster
On Sun, Nov 30, 2008 at 5:09 PM, Zhaopeng Xing zpx...@gmail.com wrote:
 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-context@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
___


Re: [NTG-context] looking for equivalence to LaTeX algorithm package

2008-12-03 Thread Wolfgang Schuster

Am 01.12.2008 um 14:34 schrieb Richard Rascher-Friesenhausen:

 Zhaopeng Xing schrieb:
 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-context@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
___


Re: [NTG-context] looking for equivalence to LaTeX algorithm package

2008-12-01 Thread Wolfgang Schuster
On Sun, Nov 30, 2008 at 5:09 PM, Zhaopeng Xing [EMAIL PROTECTED] wrote:
 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-context@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
___


Re: [NTG-context] looking for equivalence to LaTeX algorithm package

2008-12-01 Thread Zhaopeng Xing
Thank you, Walfgang. I will try. It is a good exercise.

2008/12/1 Wolfgang Schuster [EMAIL PROTECTED]

 On Sun, Nov 30, 2008 at 5:09 PM, Zhaopeng Xing [EMAIL PROTECTED] wrote:
  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-context@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

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

maillist : ntg-context@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
___


Re: [NTG-context] looking for equivalence to LaTeX algorithm package

2008-12-01 Thread Richard Rascher-Friesenhausen

Zhaopeng Xing schrieb:

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!

maillist : ntg-context@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
___
  

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: [EMAIL PROTECTED], [EMAIL PROTECTED]
www  : http://www.mevis-research.de/, http://www.hs-bremerhaven.de/
fon  : +49 - 421 - 218 7707 (mevis)
fax  : +49 - 421 - 218 4236 (mevis)
==

% output=pdf
%===
% begin of file *t-algorithmic.tex*
%===
% [EMAIL PROTECTED] (c) 2003, 2004, 2005

%D \module
%D   [   file=algorithmic.tex,
%Dversion=2005.02.12,
%D  title=Environments for algorithms,
%D author=richard rascher friesenhausen,
%D   date=\currentdate,
%D  [EMAIL PROTECTED]

%D algorithmic defs
\definefloat[algorithm][algorithms]
\setupfloat[algorithm][location=middle]
\setuplabeltext[de][algorithm={Algorithmus\,}]

\define[1]\Algorithm{%
\startframedtext[frame=off,%leftframe=on,%bottomframe=on,
 framecolor=darkyellow,
 background=screen,offset=none]
%  \setuplinenumbering[location=intext]
%  \startlinenumbering 
#1 
%  \stoplinenumbering
\stopframedtext
}

%D names
\def\algorithmicend{{\bf end}}
\def\algorithmicif{{\bf if}}
\def\algorithmicthen{{\bf then}}
\def\algorithmicelse{{\bf else}}
\def\algorithmicelseif{\algorithmicelse\algorithmicif}
\def\algorithmicendif{\algorithmicend{\bf.}\algorithmicif}

\def\algorithmicfor{{\bf for}}
\def\algorithmicendfor{\algorithmicend{\bf.}\algorithmicfor}
\def\algorithmicforall{{\bf for all}}
\def\algorithmicdo{{\bf do}}

\def\algorithmicwhile{{\bf while}}
\def\algorithmicendwhile{\algorithmicend{\bf.}\algorithmicwhile}

\def\algorithmicrepeat{{\bf repeat}}
\def\algorithmicuntil{{\bf until}}

%D macros
\newdimen\algorithmicindent \algorithmicindent=0cm
\newdimen\algorithmicskip   \algorithmicskip=.5cm
\newcount\algorithmicline   \algorithmicline=0
\def\startIF{\advance\algorithmicindent by  \algorithmicskip}
\def\stopIF {\advance\algorithmicindent by -\algorithmicskip}

\let\startFOR=\startIF
\let\stopFOR =\stopIF

\let\startWHILE=\startIF
\let\stopWHILE =\stopIF

\let\startREPEAT=\startIF
\let\stopREPEAT =\stopIF

\def\algorithmiclineintro{%
  \inframed[width=.5cm,frame=off,offset=none,
background=color,backgroundcolor=darkyellow]
{\strut\hfill\color[black]{\the\algorithmicline}\,}\quad
  \hskip\algorithmicindent%
}
%D if then elseif else endif
\def\IF#1{%
  \advance\algorithmicline by 1
  \hbox{%
\algorithmiclineintro
\algorithmicif\ #1\ \algorithmicthen
  }\par
  \startIF
}
\def\ENDIF{%
  \stopIF
  \advance\algorithmicline by 1
  \hbox{%
\algorithmiclineintro
%  \the\algorithmicline\ \hskip\algorithmicindent%
\algorithmicendif
  }\par
}
\def\ELSE{%
  \stopIF
  \advance\algorithmicline by 1
  \hbox{%
\algorithmiclineintro
%  \the\algorithmicline\ \hskip\algorithmicindent%
\algorithmicelse
  }\par
  \startIF
}

\def\ELSEIF#1{%
  \stopIF
  \advance\algorithmicline by 1
  \hbox{%
\algorithmiclineintro  
\algorithmicelseif\ #1\ \algorithmicthen
  }\par
  \startIF
}

%D for forall do endfor
\def\FOR#1{%
  \advance\algorithmicline by 1
  \hbox{%
\algorithmiclineintro
\algorithmicfor\ #1\ \algorithmicdo
  }\par
  \startFOR
}
\def\FORALL#1{%
  \advance\algorithmicline by 1
  \hbox{%
\algorithmiclineintro
\algorithmicforall\ #1\ \algorithmicdo
  }\par
  \startFOR
}
\def\ENDFOR{%
  \stopFOR
  \advance\algorithmicline by 1
  \hbox{%
\algorithmiclineintro
\algorithmicendfor
  }\par
}

%D while do endwhile
\def\WHILE#1{%
  \advance\algorithmicline by 1
  \the\algorithmicline\ 

[NTG-context] looking for equivalence to LaTeX algorithm package

2008-11-30 Thread 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!

maillist : ntg-context@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
___


Re: [NTG-context] looking for equivalence to LaTeX algorithm package

2008-11-30 Thread Mohamed Bana
Maybe you could typeset the page with (Xe)LaTeX and include the pdf as 
page in your ConTeXt doc.

Zhaopeng Xing wrote:
 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!
 
 maillist : ntg-context@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
 ___

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

maillist : ntg-context@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
___


Re: [NTG-context] looking for equivalence to LaTeX algorithm package

2008-11-30 Thread Wolfgang Schuster

Am 30.11.2008 um 17:09 schrieb 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-context@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
___