From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from cgl.ntg.nl (Cgl.ntg.nl [5.39.185.202]) by inbox.vuxu.org (Postfix) with ESMTP id 23C692F08E for ; Mon, 21 Oct 2024 22:29:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id DA4234855E7 for ; Mon, 21 Oct 2024 22:28:21 +0200 (CEST) Authentication-Results: cgl.ntg.nl (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=ntg.nl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntg.nl; h= content-transfer-encoding:content-type:content-type :list-unsubscribe:list-subscribe:list-post:list-owner:list-help :list-archive:archived-at:list-id:subject:subject:reply-to :precedence:content-language:in-reply-to:mime-version:user-agent :date:date:message-id:from:from:references:received:received :received:received:received:received:received; s=cgl; t= 1729542501; x=1732134502; bh=DMfIYWUMGiPA5H4TOgBXRaQfL/U6eEX2rrP OLXkp7k8=; b=Krv2a61DlonXwr8PlIh2GSuFqYspS45e7GDwQZy9021vaAE+grj dd90QXdjU98zcsyai9UdYZioxAbb/8fOwwcYOcL82AAS56j+puSYV3isxUWF3bzL cJ9Ypfx2QC+h7SPGo/D/sQU7ngpXieyjmHGFMVIy6YP9HwtSjx6sRJrg= X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Authentication-Results: cgl.ntg.nl (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=gmail.com Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S9h09hUmfCXs for ; Mon, 21 Oct 2024 22:28:21 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id C8FEC4851D9 for ; Mon, 21 Oct 2024 22:27:46 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 0E6EC4851D4 for ; Mon, 21 Oct 2024 22:27:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nn7bLRp8rovb for ; Mon, 21 Oct 2024 22:27:25 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.208.46; helo=mail-ed1-f46.google.com; envelope-from=wolfgang.schuster.lists@gmail.com; receiver= Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cgl.ntg.nl (Postfix) with ESMTPS id 9F4F34851CE for ; Mon, 21 Oct 2024 22:27:25 +0200 (CEST) Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5c9693dc739so6411654a12.3 for ; Mon, 21 Oct 2024 13:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729542445; x=1730147245; darn=ntg.nl; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject:from:to:cc :subject:date:message-id:reply-to; bh=Tg1hpu+ITrt3KXj2kk+JUa8hHDRx/a/CirtP1vbwP3U=; b=RFnyvKV0b0Ftztp8n89i5C2MCNyXujC+HEIkznPyHCSi8xNQ2aFLb/wJrjGahxu/dA TmUdshqmoN2AoD9JOMhgMIs53zB2f8pglpzNE/MVvU4j21owup8yTauyk6SPLixTyb+r 9yz1SO2tTihdfyEhUNUWCIzX5pbFUFXZHcvR8IiphCqSqNvbP/+7eQ1TwcjeXdh/SZSP KEs/o8qnw9pEfnZoDXikzAVLTbNOSrnc7EClZ4q91VV8PHRmRg9Mw2nWZoNco4DPweaD 7eG5niLeZzrB5fnPT3Zvk4Z+xePzpwUruPcM7mvE9qBUGlfvLFUonbKi6Xytr/02u0Jj lwVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729542445; x=1730147245; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Tg1hpu+ITrt3KXj2kk+JUa8hHDRx/a/CirtP1vbwP3U=; b=QZBYHCLb+P/YHvjQx6dM4NovgJ9clAKCo8l6ytvxtwr9rjjn/vkCccv56EK7fNyBT6 R2KX5ZTBxSNYcdTF+G6O2QEInGPzZvGBRE6T837k5EGtvQAA08b+8WzgJMX8AwsSlyzc XBG6XNeAlOEPXFp+0KH+xJkkjsSHML/MalRqdkr4QaUW9wOFkQS55qurFFm/qNrlEA39 K8Zx7bfjbPONN7ixSewoEqghn6jJKt+sBNoSs21gSu9dE7fZV82cMrxD5iKHdRIbOzBQ IFIYGxOK/CeMCptm993+6Zo6DD/CVaUHK8OKidAWvDDTvrlcrvaQD3izSG+nHrl6xSVR mczw== X-Gm-Message-State: AOJu0Yw+CiY/APPseNEdYydf7vPQVcNUDr0fCV3n5fUdaXf8xy5aUJnY Gi+PLWApc/qKpKny03sbKq3lUtQBqoKX4zNYF+/BAVeK38YMGukW X-Google-Smtp-Source: AGHT+IFdJs/VWwETQp9PNIwexLqEJfMAPIjxLcmjUSmmIJWyfoScyivr469uQoS/fXkRMMwub1NQHw== X-Received: by 2002:a17:907:9711:b0:a99:ff79:51a5 with SMTP id a640c23a62f3a-a9a69772b2emr1348462766b.3.1729542444566; Mon, 21 Oct 2024 13:27:24 -0700 (PDT) Received: from ?IPv6:2a02:810d:a8bf:e1a8::4b99? ([2a02:810d:a8bf:e1a8::4b99]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a91370e54sm247847866b.102.2024.10.21.13.27.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Oct 2024 13:27:24 -0700 (PDT) To: mailing list for ConTeXt users , ai2472206007@yeah.net References: <172953158287.1601626.2482296264759389824@cgl.ntg.nl> From: Wolfgang Schuster Message-ID: <3a6bd5a4-0948-52b8-60da-af7824f2891e@gmail.com> Date: Mon, 21 Oct 2024 22:27:21 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 PostboxApp/7.0.64 MIME-Version: 1.0 In-Reply-To: <172953158287.1601626.2482296264759389824@cgl.ntg.nl> Content-Language: en-US Message-ID-Hash: PS5AZLP5KMR6XED24LCQEJDIEKW2MTZV X-Message-ID-Hash: PS5AZLP5KMR6XED24LCQEJDIEKW2MTZV X-MailFrom: wolfgang.schuster.lists@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Re: Why didn't I get the correct ordinal number, after defining an environment via command "installcounterassociation". List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii"; format="flowed" Content-Transfer-Encoding: 7bit ai2472206007@yeah.net schrieb am 21.10.2024 um 19:26: > hi, everyone > > I defined a command to unite counters by > the method of defining counters that I saw on other posts. > When I wanted to modify the start parameter of the counter, > I found that it did not inherit the settings of the current environment, > but inherited the settings of the previous environment. > > For example, > in the first chapter, > I set the counter for the environment to start counting from 5, > but it inherited the original count of 9, > > and in the second chapter, > it inherited the setting from the first chapter, > and its counter became 5. > > The same happens in Chapter 3. Pls can someone fix this? > > Since the command to unite with the counter is > what I found through previous posts and source files, > I don't know exactly how it is used. > If my question or the mistake I made was too stupid, > be sure to let me know. When you change the start value of a counter you have to reset the counter, in your case the reset happened at the start of the following chapter which explains the delay. You can try the following example with and without the reset mode. %%%% begin example \definecounter[xxx][way=bychapter,prefix=no] \startbuffer[increment] \incrementcounter[xxx] \convertedcounter[xxx] \stopbuffer %\enablemode[reset] \starttext \dorecurse{2}{\getbuffer[increment]\blank} \startchapter [title={Setting counter value after \tex{chapter}}] \setupcounter[xxx][start=6] \doifmode{reset}{\resetcounter[xxx]} \dorecurse{2}{\getbuffer[increment]\blank} \stopchapter \startchapter [title={Dummy \tex{chapter}}] \dorecurse{2}{\getbuffer[increment]\blank} \setupcounter[xxx][start=4] \doifmode{reset}{\resetcounter[xxx]} \stopchapter \startchapter [title={Setting counter value before \tex{chapter}}] \dorecurse{2}{\getbuffer[increment]\blank} \stopchapter \startchapter [title={Dummy \tex{chapter}}] \dorecurse{2}{\getbuffer[increment]\blank} \stopchapter \stoptext %%%% end example > Many thanks. > > Muyik. > > %%%% example > %%%% I've cut out other parts of the environment that aren't relevant to this issue. > \unprotect > \installnamespace {material} > \installcommandhandler \????material {material} \????material > \installcounterassociation {material} > \appendtoks > \registermaterialcounter\currentmaterial > \definecounter[\currentmaterial]% > \to \everydefinematerial > \appendtoks > \synchronizematerialcounters > \to \everysetupmaterial > > \definematerial [material] > \definematerial [number] > > \setupmaterial [\c!title=, > \c!author=, > \c!source=, > \c!start=8,] There is no need to set keys which take empty value because \materialparameter takes care of this and handles keys which haven't been set as empty. > \setupmaterial [\c!number] [\c!before={(},\c!after={)}, > \c!prefix=no,\c!start=9, > \c!numberconversion=n, > \c!way=\v!by\v!chapter] > > \def\material_counter_parameter#1% > {\begingroup > \def\currentmaterial{#1}% > \usematerialstyleandcolor\c!style\c!color > \namedmaterialparameter\currentmaterial\c!before > \convertedcounter[\currentmaterial]% > \incrementcounter[\currentmaterial]% > \namedmaterialparameter\currentmaterial\c!after > \endgroup} Increment counter value before you output the value and set the start value always 1 below the first number, other counters in ConTeXt use this system and it's good style to follow it. > \def\startmaterial{\begingroup\dosingleempty\startmaterial_indeed} > \def\startmaterial_indeed[#1]{% > \iffirstargument\setupcurrentmaterial[#1]\fi You can use the tolerant mechanism to skip the two-step-process to create a command with an optional argument and don't forget to assign a value to \currentmaterial at the start of the environment. \tolerant\protected\def\startmaterial[#1]% {\begingroup \lettonothing\currentmaterial \ifarguments\or \setupcurrentmaterial[#1]% \fi ... Wolfgang ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________