ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Verbatim Textbox with Reference NUmbering
@ 2023-09-09 13:58 Jeroen
  0 siblings, 0 replies; only message in thread
From: Jeroen @ 2023-09-09 13:58 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1.1: Type: text/plain, Size: 2404 bytes --]

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

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};





this is a code example


% MWE2

  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) ;

{\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut#1\hss}}}

% Add the enumeration
   before={\FrameTitle{Counter \getnumber[Counter]}


First example

Second example


[-- Attachment #1.2: Type: text/html, Size: 2778 bytes --]

[-- Attachment #2: Type: text/plain, Size: 495 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-09 14:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-09 13:58 [NTG-context] Verbatim Textbox with Reference NUmbering Jeroen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox