From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/41990 Path: news.gmane.org!not-for-mail From: "Wolfgang Schuster" Newsgroups: gmane.comp.tex.context Subject: Re: Total number of figures/tables, etc. Date: Mon, 30 Jun 2008 08:45:36 +0200 Message-ID: <115224fb0806292345k436711d3j96fcac4f0fc81872@mail.gmail.com> References: <48675790.5060608@mail.ru> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1214808467 11429 80.91.229.12 (30 Jun 2008 06:47:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Jun 2008 06:47:47 +0000 (UTC) To: "mailing list for ConTeXt users" Original-X-From: ntg-context-bounces@ntg.nl Mon Jun 30 08:48:33 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 1KDDBP-0004iG-1E for gctc-ntg-context-518@m.gmane.org; Mon, 30 Jun 2008 08:48:15 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 610781FD79; Mon, 30 Jun 2008 08:47:20 +0200 (CEST) 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 25945-01; Mon, 30 Jun 2008 08:46:38 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 8004F1FD38; Mon, 30 Jun 2008 08:46:37 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 9FB421FCDE for ; Mon, 30 Jun 2008 08:46:29 +0200 (CEST) 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 24828-02-7 for ; Mon, 30 Jun 2008 08:45:51 +0200 (CEST) Original-Received: from yw-out-1718.google.com (yw-out-1718.google.com [74.125.46.157]) by ronja.ntg.nl (Postfix) with ESMTP id 0DDF81FCD0 for ; Mon, 30 Jun 2008 08:45:49 +0200 (CEST) Original-Received: by yw-out-1718.google.com with SMTP id 5so878489ywm.74 for ; Sun, 29 Jun 2008 23:45:37 -0700 (PDT) Original-Received: by 10.150.136.6 with SMTP id j6mr7835614ybd.139.1214808336948; Sun, 29 Jun 2008 23:45:36 -0700 (PDT) Original-Received: by 10.150.96.3 with HTTP; Sun, 29 Jun 2008 23:45:36 -0700 (PDT) In-Reply-To: Content-Disposition: inline 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:41990 Archived-At: On Sun, Jun 29, 2008 at 5:45 PM, Aditya Mahajan wrote: > On Sun, 29 Jun 2008, Oleg Kolosov wrote: > >> Hi! >> >> Is there are an easy way to get total number of pages/tables/figures >> etc.? \getnumber[table] of \getnumber[figure] returns 0, >> \getnumber[page] gives some irrelevant number. I've found command >> \totalnumberofpages, is there are something similar for others? It would >> be great to also automatically change the following word as in: >> >> 1 figure, but 2 figures >> >> Is there support for that in ConTeXt? > > No, but it is easy to define this on your own. To Hans: Is > reading utilities not implemented in mkiv? The following works fine with > mkii but not with mkiv. > > \def\noffigures {1} > > \def\savenoffigures > {\savecurrentvalue{\noffigures}{\getnumber[figure]}} > > \appendtoks \savenoffigures \to \everystoptext > > \def\shownoffigures > {\noffigures\ % > \doifelse{\noffigures}{1}{figure}{figures}} > > \starttext > > This text has \shownoffigures. > > \dorecurse{10}{\placefigure{something}{} \input knuth \endgraf } > > \stoptext As Hans explained the information is load earlier than in MkII but I can show you why your definition can also fail in MkII. \startcomponent myfile \def\noffigures{1} \def\savenoffigures {\savecurrentvalue{\noffigures}{\getnumber[figure]}} \appendtoks \savenoffigures \to \everystoptext \def\shownoffigures{\noffigures} This text has \shownoffigures. \dorecurse{10}{\placefigure{something}{figure}} \stopcomponent This results always in 1 for the total number of figures. A better definition for the countervalue is: \def\shownoffigures {\doifdefinedelse{noffigures}{\noffigures}{0}} without the initial value for \noffigures. Regards 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 ___________________________________________________________________________________