From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HK_RANDOM_FROM,HTML_MESSAGE, MAILING_LIST_MULTI,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2895 invoked from network); 9 Sep 2023 14:01:30 -0000 Received: from cgl.ntg.nl (5.39.185.202) by inbox.vuxu.org with ESMTPUTF8; 9 Sep 2023 14:01:30 -0000 Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 0326C483075 for ; Sat, 9 Sep 2023 16:00:11 +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 4KMeI9nXLJ-q for ; Sat, 9 Sep 2023 16:00:10 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 8DE4A48308B for ; Sat, 9 Sep 2023 15:59:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 3696A482EEA for ; Sat, 9 Sep 2023 15:58:58 +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 eeU_mDx5K-P4 for ; Sat, 9 Sep 2023 15:58:57 +0200 (CEST) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 CE199482EE9 for ; Sat, 9 Sep 2023 15:58:57 +0200 (CEST) Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-26f57f02442so2293944a91.0 for ; Sat, 09 Sep 2023 06:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694267936; x=1694872736; darn=ntg.nl; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=wDKYsy2+PSDv3MfDg8Pbj9yxmV+o4BhKXEMt7uaaaAI=; b=IQcEyP6irzqeNSNwhckh3C8pv4t3xe73iv8eLyC9/DmzoRqc8oaaXCN0abSrNApMQZ x8IIcAxApbMY9USLMgJFDSkKRxiv4JTyEpnk2DWYFw5pPycg9Yfi7ZFL/GksFcQcG/pp faSOS4yuM0UDqYvJwZlnjx0RHKFY9Zm+l4Z3CbkNkNdftbuHMrsju91WFy0Wdm83uQTy L1yWhuhSNYfQnzEoKW6GoJzCuttLlQEzSNrj8ZggUvdx3H/LKeOzXgS8GFFPzmUxx6Kq XK6jgV7d5smxoICPGIl1blDPi7ZKt8fzdu+OUhHe1ck6sD4xaDmqN0U/wlp26FdQgR1R mcAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694267936; x=1694872736; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wDKYsy2+PSDv3MfDg8Pbj9yxmV+o4BhKXEMt7uaaaAI=; b=d7OfdQun1CDN96Hsn39KtDYUhejqeNsb8E/GbQQfsq9WoVIp6CEoznu4e262ulOLEs HP8TSL2EFB+15SbFUh4kOYGGDXEcqHqm5VGFRvHW6U4nVRl9rYQISufZnhZPaJGwZNYL WqVCfQQ257DFdWxlemW71mSLGHAINPHdH0FPaoEW0zKUQGHVSukeZrM8WJIgP494D1Qg 7JGiaLP+zuUZKtFErovKlpQgRJxniFwxAd3XY15BaOOTHjHS6k+1m2cLk5foDtW2YG+S BOwP1SpinZw/Qy4O1kBw379WcVbk+UmBxippkoIEAkY52vCOPpQNa1IFvoz4pUYCXCAY pw2A== X-Gm-Message-State: AOJu0YwJDcnKaKCMm0Z2ot8FHiKQv/LIPuQF7Ri56lJOtY9RZbjsXPp3 BnJWXcuYt1rJEUf9PxE7h8OLQbJ093LpGf3TVj9A9yKytG748w== X-Google-Smtp-Source: AGHT+IE2buI+hQPd7BjU8Rxi93dluO31GdRA8/1m/RpubAda1mx6t+WuIOSlNfHtUV59tb9SLab0HpKRv7tuXxLbrZE= X-Received: by 2002:a17:90b:1c0f:b0:273:ee6c:ee5c with SMTP id oc15-20020a17090b1c0f00b00273ee6cee5cmr1623254pjb.7.1694267935332; Sat, 09 Sep 2023 06:58:55 -0700 (PDT) MIME-Version: 1.0 From: Jeroen Date: Sat, 9 Sep 2023 15:58:44 +0200 Message-ID: To: mailing list for ConTeXt users Message-ID-Hash: 47EMX46PZDH67CJ2YLJFD5AEFF2X3IGO X-Message-ID-Hash: 47EMX46PZDH67CJ2YLJFD5AEFF2X3IGO X-MailFrom: contextntg@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.8 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Verbatim Textbox with Reference NUmbering List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: multipart/mixed; boundary="===============4208306098406067629==" --===============4208306098406067629== Content-Type: multipart/alternative; boundary="000000000000709c360604ed7eaa" --000000000000709c360604ed7eaa Content-Type: text/plain; charset="UTF-8" This is a longshot, but would be great to have. Below I have at MWE1 the verbatim codefragment textbox I am using. I found in the forum MWE2 which is a textbox with an automatic reference number. Is there a way to get the same for MWE1 with automatic reference numbering like 1.1, 1.2 etc for chapter 1, codefragment 1, 2 etc. with the possibility that in the text I can refer to the codefragment like \in{codefragment\space}[code:ccpsample] similar as to tables and figures? Thanks Jeroen %%%%%%%%%%%%%%%%%% % MWE1 %%%%%%%%%%%%%%%%%% \startuseMPgraphic{mpos:par:myexample} path p; for i = 1 upto nofmultipars : p := multipars[1] topenlarged 4pt bottomenlarged 4pt cornered 2mm ; fill p withcolor 0.95white ; draw p withcolor black withpen pencircle scaled \MPvar{linewidth}; endfor; \stopuseMPgraphic \definetextbackground [listingbackground] [state=start, mp=mpos:par:myexample, location=paragraph, topoffset=0.4em, leftoffset=0em, rulethickness=0.7pt] \definetyping[Listing] [option=commands] \setuptyping [Listing] [bodyfont=10pt, margin=1em, before=% {\blank[3*medium] \setupinterlinespace[line=2.4ex] \starttextbackground[listingbackground]}, after=% {\stoptextbackground \blank[4*medium]}, align={flushleft,verytolerant}] \starttext \startListing this is a code example \stopListing \stoptext %%%%%%%%%%%%%%%%%% % MWE2 %%%%%%%%%%%%%%%%%% \startuseMPgraphic{FunnyFrame} picture p ; numeric w, h, o ; p := textext.rt(\MPstring{FunnyFrame}) ; w := OverlayWidth ; h := OverlayHeight ; o := BodyFontSize ; p := p shifted (2o,h-ypart center p) ; draw p ; drawoptions (withpen pencircle scaled 1pt withcolor .625red) ; draw (2o,h)--(0,h)--(0,0)--(w,0)--(w,h)--(xpart urcorner p,h) ; draw boundingbox p ; setbounds currentpicture to unitsquare xyscaled(w,h) ; \stopuseMPgraphic \defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] \defineframedtext[FunnyText][frame=off,background=FunnyFrame] \def\FrameTitle#1% {\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut#1\hss}}} \setMPtext{FunnyFrame}{} % Add the enumeration \defineenumeration [Counter] [text=, alternative=empty, before={\FrameTitle{Counter \getnumber[Counter]} \startFunnyText}, after={\stopFunnyText}] \starttext \startCounter First example \stopCounter \startCounter Second example \stopCounter \stoptext --000000000000709c360604ed7eaa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This is a longshot, but would be great to have. Below I ha= ve at MWE1 the verbatim codefragment textbox I am using. I found in the for= um MWE2 which is a textbox with an automatic reference number. Is there a w= ay to get the same for MWE1 with automatic reference numbering like 1.1, 1.= 2 etc for chapter 1, codefragment 1, 2 etc. with the possibility that in th= e text I can refer to the codefragment like \in{codefragment\space}[code:cc= psample] similar as to tables and figures? Thanks Jeroen


%%%%%%%= %%%%%%%%%%%
% MWE1
%%%%%%%%%%%%%%%%%%

\startuseMPgraphic{mpo= s:par:myexample}
path p;
for i =3D 1 upto nofmultipars :
=C2=A0 p = :=3D multipars[1] topenlarged 4pt bottomenlarged 4pt cornered 2mm ;
=C2= =A0 fill p withcolor 0.95white ;
=C2=A0 draw p withcolor black
=C2=A0= withpen pencircle scaled \MPvar{linewidth};
=C2=A0 endfor;
\stopuseM= Pgraphic

\definetextbackground
=C2=A0 [listingbackground]
=C2= =A0 [state=3Dstart,
=C2=A0 =C2=A0mp=3Dmpos:par:myexample,
=C2=A0 =C2= =A0location=3Dparagraph,
=C2=A0 =C2=A0topoffset=3D0.4em,
=C2=A0 =C2= =A0leftoffset=3D0em,
=C2=A0 =C2=A0rulethickness=3D0.7pt]

\definet= yping[Listing]
=C2=A0 [option=3Dcommands]

\setuptyping
=C2=A0 = [Listing]
=C2=A0 [bodyfont=3D10pt,
=C2=A0 =C2=A0margin=3D1em,
=C2= =A0 =C2=A0before=3D%
=C2=A0 =C2=A0 =C2=A0{\blank[3*medium]
=C2=A0 =C2= =A0 =C2=A0 \setupinterlinespace[line=3D2.4ex]
=C2=A0 =C2=A0 =C2=A0 \star= ttextbackground[listingbackground]},
=C2=A0 =C2=A0after=3D%
=C2=A0 = =C2=A0 =C2=A0{\stoptextbackground
=C2=A0 =C2=A0 =C2=A0 \blank[4*medium]}= ,
=C2=A0 =C2=A0align=3D{flushleft,verytolerant}]
=C2=A0 =C2=A0
\st= arttext

\startListing
this is a code example
\stopListing
<= br>\stoptext


%%%%%%%%%%%%%%%%%%
% MWE2
%%%%%%%%%%%%%%%%%%=

\startuseMPgraphic{FunnyFrame}
=C2=A0 picture p ; numeric w, h,= o ;
=C2=A0 p :=3D textext.rt(\MPstring{FunnyFrame}) ;
=C2=A0 w :=3D = OverlayWidth ; h :=3D OverlayHeight ; o :=3D BodyFontSize ;
=C2=A0 p := =3D p shifted (2o,h-ypart center p) ; draw p ;
=C2=A0 drawoptions (withp= en pencircle scaled 1pt withcolor .625red) ;
=C2=A0 draw (2o,h)--(0,h)--= (0,0)--(w,0)--(w,h)--(xpart urcorner p,h) ;
=C2=A0 draw boundingbox p ;<= br>=C2=A0 setbounds currentpicture to unitsquare xyscaled(w,h) ;
\stopus= eMPgraphic

\defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}]
= \defineframedtext[FunnyText][frame=3Doff,background=3DFunnyFrame]
\def\F= rameTitle#1%
{\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut#1\hss}}= }
\setMPtext{FunnyFrame}{}

% Add the enumeration
\defineenumer= ation
=C2=A0 [Counter]
=C2=A0 [text=3D,
=C2=A0 =C2=A0alternative= =3Dempty,
=C2=A0 =C2=A0before=3D{\FrameTitle{Counter \getnumber[Counter]= }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\startFunnyText},
=C2=A0 = =C2=A0after=3D{\stopFunnyText}]

\starttext

\startCounter
F= irst example
\stopCounter

\startCounter
Second example
\sto= pCounter

\stoptext
--000000000000709c360604ed7eaa-- --===============4208306098406067629== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________ --===============4208306098406067629==--