Oups !
There is a little error in the sample I've given : Don't read "\knuth" but "\input knuth" below !
\startMyFrame[Title=Knuth Text]
\input knuth
\stopMyFrame
\stoptext
----- Mail original -----
De: "Jean-Pierre Delange"
À: "mailing list for ConTeXt users"
Envoyé: Dimanche 5 Novembre 2017 11:40:03
Objet: Re: [NTG-context] framed with titles
Hi Javier,
As Thomas put it, it is beter to provide a minimal sample, even if it doesn't work correctly.
Given that, you can dig in this list archives, which contain few questions on the topic you are dealing with.
I am afraid that you can't achieve your goal (which is more or less a text within a frame with a title), without MP, which seems to me a good tool to draw such frame.
I remember that Fabrice Couvreur once has asked in 2016 a similar question, in order to draw a frame for a "summary" at the end of a chapter.
You need to populate the preamble of your file with something like below (you have to test it and modify it to your needs).
Pay attention ! You have to give a \start command, after the \starttext command, inside the body of your text, when you want \startMyFrame[Title=A Title], and when to stop the frame with the \stopMyFrame command.
Have a look to the code below and test it (note that the frame is red in this sample).
% Début de la définition d'un texte encadré en rouge
% Defining a framed text
\defineframedtext
[MyFrame]
[before={\blank[3*big]},
after={\blank[5*big]},
frame=off,
background=MyFrame,
%width=\textwidth,
width=max,
height=fit,
style={\setupbodyfont[9pt]}]
% Defining a label
\definelabel
[Definition]
[headstyle=\bf\smallcaps]
\startuseMPgraphic{MyFrame}
path b;
picture p;
%p := textext.rt("\white\Definition");
p := textext.rt("\white\framedtextparameter{Title}");
%p := textext.rt("\white\getvariable{text}{text1}");
p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight);
b := boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth;
fill OverlayBox withcolor lightgray; %\MPcolor{
fill b withcolor darkred;
draw bottomboundary OverlayBox withpen pencircle scaled 1pt withcolor
darkred;
draw topboundary OverlayBox withpen pencircle scaled 1pt withcolor
darkred;
draw p;
setbounds currentpicture to boundingbox currentpicture enlarged 2mm;
\stopuseMPgraphic
\defineoverlay
[MyFrame]
[\useMPgraphic{MyFrame}]
% Fin de la définition d'un texte encadré en rouge
\starttext
\startMyFrame[Title=Knuth Text]
\knuth
\stopMyFrame
\stoptext
Hope it helps !
JP
----- Mail original -----
De: "Javier M Mora"
À: ntg-context@ntg.nl
Envoyé: Dimanche 5 Novembre 2017 10:14:47
Objet: [NTG-context] framed with titles
Hi,
I'm trying to generate a frame with a title.
My first idea is something like (ASCII Art):
+- Title -------------+
| Text text text text |
| more and more text |
+----------------------+
A frame with title breaking the top line .
But I am not picky and something like beamer floating boxes (theorem,
proof, ...) for latex is good for me too.
In wiki, the frames doesn't have title and I'm not sure about if I have
to fight with overlays, with MP and this is out of my league.
Questions:
* what is the way for implement a title in the frame?
* Could you write a minimal example witch allows me to complete it for
my needs?
Thanks.
Javier M. Mora
___________________________________________________________________________________
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
___________________________________________________________________________________
___________________________________________________________________________________
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
___________________________________________________________________________________