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: Framedtext in a float
Date: Tue, 1 Nov 2016 00:12:37 +0100	[thread overview]
Message-ID: <CACyK-epDD0g3Tuia6ywO2L6=-_4jdhSPt8udC-E0gDxPMp7mFA@mail.gmail.com> (raw)


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

Hello,
How to make the width of framedtext automatically adapts to its contents.
Fabrice

\definefloat
   [recipe]
   [figure]

\setupfloat
   [recipe]
   [default={right,none}]

\definecolor[MyColorA][r=0.8784, g=0.8784, b=0.8784]
\definecolor[MyColorB][c=0.00,m=0.27,y=1.00,k=0.00]


\defineframedtext
  [MyFrame]
  [before={\blank},
   after={\blank},
   frame=off,
   background=MyFrame,
   width=6cm,
   height=fit]

\startuseMPgraphic{MyFrame}
 path b;
 picture p;
 p := textext.rt("\tfx\white\framedtextparameter{Title}");
 p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight);
 b := boundingbox p enlarged .3EmWidth ;
 fill OverlayBox withcolor \MPcolor{MyColorA};
 fill b withcolor \MPcolor{MyColorB} ;
 draw p ;
 setbounds currentpicture to boundingbox currentpicture enlarged 2mm ;
\stopuseMPgraphic

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

  \starttext

  \placerecipe{}{
  \startMyFrame[Title=Info]
  L'histogramme est constitué de rectangles dont les bases correspondent
aux classes et dont les aires sont proportionnelles aux effectifs ou
fréquences des classes.
  \stopMyFrame}

  \input Knuth

  \stoptext

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

[-- Attachment #2: Type: text/plain, Size: 492 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

             reply	other threads:[~2016-10-31 23:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31 23:12 Fabrice Couvreur [this message]
2016-11-01  7:51 ` Marco Patzer
2016-11-01  8:23 ` Piotr Kopszak
2016-11-01  9:47   ` Fabrice Couvreur
2016-11-01 10:17     ` Piotr Kopszak
2016-11-01 11:09       ` Fabrice Couvreur
2016-11-05 14:55         ` Wolfgang Schuster
2016-11-05 14:48       ` Alan Braslau

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-epDD0g3Tuia6ywO2L6=-_4jdhSPt8udC-E0gDxPMp7mFA@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).