From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/46011 Path: news.gmane.org!not-for-mail From: Wolfgang Schuster Newsgroups: gmane.comp.tex.context Subject: Re: looking for equivalence to LaTeX algorithm package Date: Sun, 30 Nov 2008 20:43:28 +0100 Message-ID: <9D04864B-84A2-4064-9DA8-0106E1BFE31A@gmail.com> References: <72c60e910811300809jab384aaw2bae79960b076d7f@mail.gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1228076171 1066 80.91.229.12 (30 Nov 2008 20:16:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Nov 2008 20:16:11 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Nov 30 21:17:13 2008 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1L6sjA-00053Y-QZ for gctc-ntg-context-518@m.gmane.org; Sun, 30 Nov 2008 21:17:12 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id BCAD21FADF; Sun, 30 Nov 2008 21:16:00 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 30504-04; Sun, 30 Nov 2008 21:15:24 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id E2BD61FB30; Sun, 30 Nov 2008 20:44:16 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 71DAE1FB30 for ; Sun, 30 Nov 2008 20:44:15 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 29830-01-2 for ; Sun, 30 Nov 2008 20:43:42 +0100 (CET) Original-Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.157]) by ronja.ntg.nl (Postfix) with ESMTP id E86D81FB29 for ; Sun, 30 Nov 2008 20:43:41 +0100 (CET) Original-Received: by fg-out-1718.google.com with SMTP id l26so1568695fgb.8 for ; Sun, 30 Nov 2008 11:43:41 -0800 (PST) Original-Received: by 10.181.226.5 with SMTP id d5mr3661354bkr.116.1228074221670; Sun, 30 Nov 2008 11:43:41 -0800 (PST) Original-Received: from ?10.40.76.138? (8.121.113.82.net.de.o2.com [82.113.121.8]) by mx.google.com with ESMTPS id p17sm5495201fka.16.2008.11.30.11.43.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 30 Nov 2008 11:43:40 -0800 (PST) In-Reply-To: <72c60e910811300809jab384aaw2bae79960b076d7f@mail.gmail.com> X-Mailer: Apple Mail (2.929.2) X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:46011 Archived-At: 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 ___________________________________________________________________________________