ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: How to put title and counter of the enumeration env.  in the FrameTitle?
@ 2015-12-08 13:45 Jeong Dal
  0 siblings, 0 replies; 3+ messages in thread
From: Jeong Dal @ 2015-12-08 13:45 UTC (permalink / raw)
  To: list ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl
	ntg-context@ntg.nl

Dear all,


After searching ConTeXt wiki and googling, I got what I want using the attached code.
It can be modified in nicer way which I don’t know.
There are so many hidden commands in ConTeXt for me.
It is absolutely convenient to use the “\defineenumeration” if I don’t use FunnyFrame.

Thanks Hans and other developers of ConTeXt.

Best regards,

Dalyoung

%%%%%%%%%
\definenumber[ThmNumber][way=bychapter, prefix=no]
\setnumber[ThmNumber][1]

\startuseMPgraphic{FunnyFrame} 
picture p ; numeric o ; path a, b ; pair c ; 
p := textext.rt(\MPstring{ThmTitle}) ; 
o := BodyFontSize ; 
a := unitsquare xyscaled (OverlayWidth,OverlayHeight) ; 
p := p shifted (2o,OverlayHeight-ypart center p) ; 
drawoptions (withpen pencircle scaled 1pt withcolor .625red) ; 
b := a superellipsed .95 ; 
draw b ; 
b := (boundingbox p) superellipsed .95 ; 
fill b withcolor .85white ; 
draw b ; 
draw p withcolor black ;
setbounds currentpicture to a ; 
\stopuseMPgraphic 

\defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] 

\defineframedtext[Thm]
[frame=off,
background=FunnyFrame,
offset=\bodyfontsize, 
%increment=yes,
width=\textwidth,
before={\blank[big]},
after={\incrementnumber[ThmNumber]\blank}]

\def\FrameTitle#1% 
{\setMPtext{ThmTitle}{\hbox spread 1em{\hss\strut\ss\bf #1 \namedheadnumber{chapter}.\getnumber[ThmNumber]\hss}}} 

\starttext

\startchapter[title={First Chapter}]
\setnumber[ThmNumber][1]

{\FrameTitle{Proposition}
\startThm
	First theorem in chapter 1.\par
\stopThm}
\input Zapf
{\FrameTitle{Lemma}
\startThm
	Second theorem in chapter 1.\par
\stopThm}
\blank
{\FrameTitle{Theorem}
\startThm
	$3^{\text{rd}}$ theorem in chapter 1.\par
\stopThm}

\stopchapter

\startchapter[title={Second Chapter}]
\setnumber[ThmNumber][1]

{\FrameTitle{Theorem}  
\startThm
	$1^{\text{st}}$ theorem in chapter 2.\par
\stopThm}

\input knuth

{\FrameTitle{Corollary}
\startThm
	Second theorem in chapter 2.\par
\stopThm}

{\FrameTitle{Proposition}  
\startThm
	Third theorem in chapter 2.\par
\stopThm}

\stopchapter

\stoptext



___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to put title and counter of the enumeration env. in the FrameTitle?
       [not found] <mailman.187.1449199309.31294.ntg-context@ntg.nl>
@ 2015-12-05  0:14 ` Jeong Dal
  0 siblings, 0 replies; 3+ messages in thread
From: Jeong Dal @ 2015-12-05  0:14 UTC (permalink / raw)
  To: ntg-context

Dear all,

I found a partial solution for my former question which still have problems.

1. I set a new counter “ThmNumber” and use it in the FrameTitle. Its output is similar to what I want. 
2. insert “after={\doglobal\increment\ThmNumber}” in the enumeration environment.
3. But the Initial value of ThmNumber is 0 even though \setcounter\ThmNumber1.

Please enhance the sample code which works nicer way.
Also, where can I find good explanation on “counter”?

Thank you for reading.

Best regards,

Dalyoung


%%%%%
\newcounter\ThmNumber
\setcounter\ThmNumber1
\increment\ThmNumber

\startuseMPgraphic{FunnyFrame} 
picture p ; numeric o ; path a, b ; pair c ; 
p := textext.rt(\MPstring{FunnyFrame}) ; 
o := BodyFontSize ; 
a := unitsquare xyscaled (OverlayWidth,OverlayHeight) ; 
p := p shifted (2o,OverlayHeight-ypart center p) ; 
drawoptions (withpen pencircle scaled 1pt withcolor .625red) ; 
b := a superellipsed .95 ; 
draw b ; 
b := (boundingbox p) superellipsed .95 ; 
fill b withcolor .85white ; 
draw b ; 
draw p withcolor black ;
setbounds currentpicture to a ; 
\stopuseMPgraphic 

\defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] 

\defineframedtext[Thm]
[frame=off,
background=FunnyFrame,
offset=\bodyfontsize, 
increment=yes,
width=\textwidth,
after={\doglobal\increment\ThmNumber}]%\overlaywidth]%

\def\FrameTitle#1% 
{\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut\ss\bf #1\hss}}} 

\starttext
This is a test for Framed Theorem.

I'd like to put \quote{Theorem \#1(Some Title)} in a small frame and the main text in the big frame.

\blank[big]

{\FrameTitle{Theorem \ThmNumber} 
\startThm
	First theorem\par
	\input knuth
\stopThm}

{\FrameTitle{Theorem \ThmNumber} 
\startThm
	First theorem\par
	\input knuth
\stopThm}

\stoptext
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* How to put title and counter of the enumeration env. in the FrameTitle?
@ 2015-12-03 22:44 Jeong Dal
  0 siblings, 0 replies; 3+ messages in thread
From: Jeong Dal @ 2015-12-03 22:44 UTC (permalink / raw)
  To: list ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl
	ntg-context@ntg.nl


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

Hi,

I use the FunnyFrame and FrameTitle in the metafun book to display theorems.
Thanks ConTeXt and MetaFun, it looks nice!
For better output,  I try to put “Theorem + number” in the FrameTitle instead of putting in the main text. But I couldn’t make it.
I found a similar question and answers by Hans in the list (2015. 8.6-7) under the title 
“Some questions about an environment (Metafun)”

It works fine but I want to put number too. I think that I want to much.

Thanks for reading.

Best regards,

Dalyoung

I am using the following code.

%%%%%%%%%%%%
\defineenumeration[Theorem]
   [%text=Theorem ,
    style=,
%    title=yes,
    prefix=yes,
    prefixsegments=chapter,
    way=bychapter,
    number=yes,
    before={\blank[big]},
    after=\blank]

\defineenumeration[Definition]
   [text=Definition,
    style=,
%    title=yes,
    prefix=yes,
    prefixsegments=chapter,
    way=bychapter,
    number=yes,
    before={\blank[big]},
    after=\blank]

\startuseMPgraphic{FunnyFrame} 
picture p ; numeric o ; path a, b ; pair c ; 
p := textext.rt(\MPstring{FunnyFrame}) ; 
o := BodyFontSize ; 
a := unitsquare xyscaled (OverlayWidth,OverlayHeight) ; 
p := p shifted (2o,OverlayHeight-ypart center p) ; 
drawoptions (withpen pencircle scaled 1pt withcolor .625red) ; 
b := a superellipsed .95 ; 
%fill b withcolor .85white ; 
draw b ; 
b := (boundingbox p) superellipsed .95 ; 
fill b withcolor .425green;%.85white ; 
draw b ; 
draw p withcolor black ;
setbounds currentpicture to a ; 
\stopuseMPgraphic 

\defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] 
\defineframedtext[FunnyText][frame=off,background=FunnyFrame, offset=\bodyfontsize, width=\textwidth]%\overlaywidth]%
\def\StTheorem{\startFunnyText\startTheorem} 
\def\SpTheorem {\stopTheorem\stopFunnyText } 
\def\FrameTitle#1% 
{\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut\ss\bf\white #1\hss}}} 

\starttext
This is a test for Framed Theorem.

\StTheorem
This is a theorem in the Funny Frame. 
\SpTheorem


I'd like to put \quote{Theorem \#1(Some Title)} in a small frame and the main text in the big frame.

\blank[big]

{\FrameTitle{Theorem 2(Title of Theorem)} 
\StTheorem
I want to show the main text without \quote{Theorem 2} in this frame.
\SpTheorem

\stoptext

%%%%%%%%%%%%%%%%%%


[-- Attachment #1.2: Type: text/html, Size: 5601 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-08 13:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-08 13:45 How to put title and counter of the enumeration env. in the FrameTitle? Jeong Dal
     [not found] <mailman.187.1449199309.31294.ntg-context@ntg.nl>
2015-12-05  0:14 ` Jeong Dal
  -- strict thread matches above, loose matches on Subject: below --
2015-12-03 22:44 Jeong Dal

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