ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Fabrice Couvreur <fabrice1.couvreur@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Some questions about an environment (Metafun)
Date: Thu, 6 Aug 2015 23:38:01 +0200	[thread overview]
Message-ID: <CACyK-erqMFioTD65As1sz+88gynXjS=B6nggA9iUSeAhJJiaJA@mail.gmail.com> (raw)
In-Reply-To: <CACyK-epTeYOiCKShhWrO4921T5ApWgcVu6XM1WsyBfz_6s=PDA@mail.gmail.com>


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

Hi,
The following code (Metafun documentation, thanks again Hans !) is fully
understood and works very well. Sorry if I insist, but can we create a
counter to avoid writing \FrameTitle{Définition 1},
\FrameTitle{Définition 2}... ?
Thus, the only invocation \startMyText ... \stopMyText,  \startMyText ... \
stopMyText ... this return Définition 1, Définition 2 ...
Thank you,
Fabrice


\setupbodyfont [palatino,11pt]

\setupcolors[state=start,cmyk=yes]

\definecolor[MyColor][c=0.00, m=0.10, y=0.20, k=0.00]
\definecolor[myColor][c=0.00, m=0.62, y=1.00, k=0.00]

\defineoverlay[MyFrame][\useMPgraphic{MyFrame}]

\defineframedtext
   [MyText]
   [frame=off,
    background=MyFrame,
    width=\textwidth,
    location=right]

\defineoverlay[MyFrame][\useMPgraphic{MyFrame}]

\def\StartFrame{\startMyText}
\def\StopFrame{\startMyText}

\def\FrameTitle#1{\setMPtext{MyFrame}{\hbox spread
1em{\hss\strut{\bf\feature[+][f:smallcaps]}#1\hss}}}

\setMPtext{MyFrame}{}

\startuseMPgraphic{MyFrame}
path a ;
path b ;
picture p ;
o := BodyFontSize ;
p :=textext.rt(\MPstring{MyFrame}) ;
p := p shifted (2o,OverlayHeight-ypart center p) ;
a := unitsquare xyscaled (OverlayWidth,OverlayHeight) ;
fill a withcolor \MPcolor{MyColor} ;
b := boundingbox p ;
fill b withcolor \MPcolor{myColor} ;
draw p withcolor white ;
\stopuseMPgraphic
\starttext
\FrameTitle{Définition 1}
\startMyText
\input knuth
\stopMyText
\FrameTitle{Définition 2}
\startMyText
\input knuth
\stopMyText
\stoptext


2015-08-04 21:30 GMT+02:00 Fabrice Couvreur <fabrice1.couvreur@gmail.com>:

> Hi Aditya,
> Thank you, I have already thought of this solution, but I do not know to
> use with the environment that I created.
> Fabrice
>
> 2015-08-04 18:02 GMT+02:00 Aditya Mahajan <adityam@umich.edu>:
>
>> On Tue, 4 Aug 2015, Fabrice Couvreur wrote:
>>
>> How to have Definition 1, Definition 2, Definition 3 ... ?
>>>
>>
>> \defineenumeration[definition][text=Definition]
>>
>> Aditya
>>
>> ___________________________________________________________________________________
>> 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  : http://foundry.supelec.fr/projects/contextrev/
>> wiki     : http://contextgarden.net
>>
>> ___________________________________________________________________________________
>
>
>

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

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

___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2015-08-06 21:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-04 15:04 Fabrice Couvreur
2015-08-04 16:02 ` Aditya Mahajan
2015-08-04 19:30   ` Fabrice Couvreur
2015-08-06 21:38     ` Fabrice Couvreur [this message]
2015-08-07 12:26       ` Hans Hagen
2015-08-07 15:11         ` Fabrice Couvreur
2015-08-04 18:08 ` Hans Hagen
2015-08-04 19:26   ` Fabrice Couvreur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACyK-erqMFioTD65As1sz+88gynXjS=B6nggA9iUSeAhJJiaJA@mail.gmail.com' \
    --to=fabrice1.couvreur@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).