ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Framed Text with Chapter Numbers as Counter
@ 2023-09-16 20:28 Jeroen
  2023-09-17 15:27 ` [NTG-context] " Bruce Horrocks
  2023-09-17 18:35 ` Wolfgang Schuster
  0 siblings, 2 replies; 4+ messages in thread
From: Jeroen @ 2023-09-16 20:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

This MWE has a framed text for some verbatim text (code) with as title ref.
a counter 1, 2, etc.. Is there a way to change this frame text title as
following with the chapter number and a sequential number and the title.

Code Fragment 1.1 (The First Title)
Code Fragment 1.2 (The Second Title)
Code Fragment 2.1 (The Third Title)

MWE:

\startuseMPgraphic{CountFrame}
  picture p; numeric w, h, o;
  p := textext.rt("\wrappedcurrentconstruction");
  w := OverlayWidth; h := OverlayHeight; o := BodyFontSize;
    p := p shifted (2o,h-ypart center p);
    draw p;
    path b;
    b := boundingbox p enlarged (o/10);
    drawoptions (withpen pencircle scaled 1pt withcolor black);
    draw (2o,h)--(0,h)--(0,0)--(w,0)--(w,h)--(xpart urcorner b,h);
    draw b;
    setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\defineoverlay
  [CountFrame]
  [\useMPgraphic{CountFrame}]

\defineframedtext
  [CountFramedText]
  [frame=off,
   background=CountFrame,
   offset=\bodyfontsize,
   width=\textwidth,
%   style={\switchtobodyfont[11pt,tt]}]
   bodyfont=11pt,
   style={\tt},
   ]

\def\FrameTitle#1%
  {\setMPtext{CountFrame}
  {\hbox spread 1em{\hss\strut#1\hss}}}\setMPtext{CountFrame}
  {}

\defineenumeration
  [Counter]
  [title=yes,
   alternative=empty,
   before=\startCountFramedText,
   after=\stopCountFramedText]

\starttext

\startchapter
  [title=first]

\startCounter
  [title={The First Title},
   reference={tit1}]
   Some verbatim text
\stopCounter

\startCounter
  [title={The Second Title},
   reference={tit2}]
   Some verbatim text
\stopCounter

Refer to \in{code fragment}[tit1] bla

\stopchapter

\startchapter
  [title=second]

\startCounter
  [title={The Third Title},
   reference={tit3}]
   Some verbatim text
\stopCounter

\stopchapter

\stoptext

[-- Attachment #1.2: Type: text/html, Size: 2346 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] 4+ messages in thread

* [NTG-context] Re: Framed Text with Chapter Numbers as Counter
  2023-09-16 20:28 [NTG-context] Framed Text with Chapter Numbers as Counter Jeroen
@ 2023-09-17 15:27 ` Bruce Horrocks
  2023-09-17 18:19   ` Jeroen
  2023-09-17 18:35 ` Wolfgang Schuster
  1 sibling, 1 reply; 4+ messages in thread
From: Bruce Horrocks @ 2023-09-17 15:27 UTC (permalink / raw)
  To: ntg-context mailing list



> On 16 Sep 2023, at 21:28, Jeroen <contextntg@gmail.com> wrote:
> 
> This MWE has a framed text for some verbatim text (code) with as title ref. a counter 1, 2, etc.. Is there a way to change this frame text title as following with the chapter number and a sequential number and the title.

Amemd the \defineenumeration as follows:

\defineenumeration
  [Counter]
  [title=yes,
   alternative=empty,
   before=\startCountFramedText,
   after=\stopCountFramedText,
   left={\somenamedheadnumber{chapter}{current}:}]

—
Bruce Horrocks
Hampshire, UK

___________________________________________________________________________________
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] 4+ messages in thread

* [NTG-context] Re: Framed Text with Chapter Numbers as Counter
  2023-09-17 15:27 ` [NTG-context] " Bruce Horrocks
@ 2023-09-17 18:19   ` Jeroen
  0 siblings, 0 replies; 4+ messages in thread
From: Jeroen @ 2023-09-17 18:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

That works fine except that the following line does only issue the
sequential number and not the chapter number.

Refer to \in{code fragment}[tit1] bla

MWE:

\startuseMPgraphic{CountFrame}
  picture p; numeric w, h, o;
  p := textext.rt("\wrappedcurrentconstruction");
  w := OverlayWidth;
  h := OverlayHeight;
  o := BodyFontSize;
  p := p shifted (2o,h-ypart center p);
  draw p;
  path b;
  b := boundingbox p enlarged (o/10);
  path a;
  a := (2o,h)--(0,h)--(0,0)--(w,0)--(w,h)--(xpart urcorner b,h);
  drawoptions (withpen pencircle scaled 1pt withcolor black);
  draw a;
  draw b;
  setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\defineoverlay
  [CountFrame]
  [\useMPgraphic{CountFrame}]

\defineframedtext
  [CountFramedText]
  [frame=off,
   background=CountFrame,
   offset=\bodyfontsize,
   width=\textwidth,
%  style={\switchtobodyfont[11pt,tt]}]
   bodyfont=11pt,
   style={\tt}]

\defineenumeration
  [Code]
  [title=yes,
   alternative=empty,
   before=\startCountFramedText,
   after=\stopCountFramedText,
   left={\somenamedheadnumber{chapter}{current}.}]

\starttext

\startchapter
  [title=first]

\startCode
  [title={The First Title},
   reference={tit1}]
   Some verbatim text
\stopCode

\startCode
  [title={The Second Title},
   reference={tit2}]
   Some verbatim text
\stopCode

Refer to \in{code fragment}[tit1] bla

\stopchapter

\startchapter
  [title=second]

\startCode
  [title={The Third Title},
   reference={tit3}]
   Some verbatim text
\stopCode

\stopchapter

\stoptext

Op zo 17 sep 2023 om 17:31 schreef Bruce Horrocks <ntg@scorecrow.com>:

>
>
> > On 16 Sep 2023, at 21:28, Jeroen <contextntg@gmail.com> wrote:
> >
> > This MWE has a framed text for some verbatim text (code) with as title
> ref. a counter 1, 2, etc.. Is there a way to change this frame text title
> as following with the chapter number and a sequential number and the title.
>
> Amemd the \defineenumeration as follows:
>
> \defineenumeration
>   [Counter]
>   [title=yes,
>    alternative=empty,
>    before=\startCountFramedText,
>    after=\stopCountFramedText,
>    left={\somenamedheadnumber{chapter}{current}:}]
>
> —
> Bruce Horrocks
> Hampshire, UK
>
>
> ___________________________________________________________________________________
> 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
>
> ___________________________________________________________________________________

[-- Attachment #1.2: Type: text/html, Size: 3972 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] 4+ messages in thread

* [NTG-context] Re: Framed Text with Chapter Numbers as Counter
  2023-09-16 20:28 [NTG-context] Framed Text with Chapter Numbers as Counter Jeroen
  2023-09-17 15:27 ` [NTG-context] " Bruce Horrocks
@ 2023-09-17 18:35 ` Wolfgang Schuster
  1 sibling, 0 replies; 4+ messages in thread
From: Wolfgang Schuster @ 2023-09-17 18:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Jeroen

Jeroen schrieb am 16.09.2023 um 22:28:
> This MWE has a framed text for some verbatim text (code) with as title 
> ref. a counter 1, 2, etc.. Is there a way to change this frame text 
> title as following with the chapter number and a sequential number and 
> the title.
> 
> Code Fragment 1.1 (The First Title)
> Code Fragment 1.2 (The Second Title)
> Code Fragment 2.1 (The Third Title)
> 
> MWE:
> 
> [...]
> 
> \defineenumeration
>    [Counter]
>    [title=yes,
>     alternative=empty,
>     before=\startCountFramedText,
>     after=\stopCountFramedText]

\defineenumeration
   [Counter]
   [      title=yes,
    alternative=empty,
           text=Code Fragment,
            way=bychapter,
         prefix=yes,
         before=\startCountFramedText,
          after=\stopCountFramedText]

Wolfgang
___________________________________________________________________________________
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] 4+ messages in thread

end of thread, other threads:[~2023-09-17 18:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-16 20:28 [NTG-context] Framed Text with Chapter Numbers as Counter Jeroen
2023-09-17 15:27 ` [NTG-context] " Bruce Horrocks
2023-09-17 18:19   ` Jeroen
2023-09-17 18:35 ` Wolfgang Schuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).