ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jeong Dal <haksan@me.com>
To: "list ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl
	ntg-context@ntg.nl" <ntg-context@ntg.nl>
Subject: Re: How to put title and counter of the enumeration env.	 in the FrameTitle?
Date: Tue, 08 Dec 2015 22:45:25 +0900	[thread overview]
Message-ID: <F70DE2D4-4837-4558-8ABC-888100AE3A1A@me.com> (raw)

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
___________________________________________________________________________________

             reply	other threads:[~2015-12-08 13:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 13:45 Jeong Dal [this message]
     [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

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=F70DE2D4-4837-4558-8ABC-888100AE3A1A@me.com \
    --to=haksan@me.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).