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: framed with titles
Date: Sun, 03 Dec 2017 08:11:04 +0900	[thread overview]
Message-ID: <8BD8B063-EBE9-4B66-8299-5AB4B75B99EC@me.com> (raw)
In-Reply-To: <mailman.976.1509919382.1988.ntg-context@ntg.nl>


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

Hi,

Some days ago, I asked a method to put theorem numbers in a framed title.
Recently, Wolfgang gave me a solution which worked very well.

Although the first one is much simpler than the second, I’d like to show two samples made by his suggestion. 
I hope that it may help someone who has the similar problem.

Thanks Wolfgang again.

Best regards,

Dalyoung

%%%%%%%%%% first method
%1. use \enumerationparameter{text} and add “text=Theorem” in \defineenumeration.
%%%%%%%%%%%
\defineframed
  [FunnyFramed]
  [frame=off,
   loffset=1ex,
   roffset=1ex,
   foregroundstyle=\ssbf]

\startuseMPgraphic{FunnyFrame}
    picture p ; numeric o ; path a, b ; pair c ;
    p := textext.rt("\FunnyFramed{\enumerationparameter{text} \convertedcounter[Theorem]}") ;
    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
  [FunnyText]
  [frame=off,
   background=FunnyFrame,
   before={\blank[line,halfline]},
   after={\blank[line]},
   offset=\bodyfontsize,
   width=\textwidth]

\defineenumeration[Theorem]
  [title=no,
  text=Theorem,
   prefix=yes,
   prefixsegments=chapter,
   way=bychapter,
   alternative=command,
   headcommand=\gobbleoneargument,
   before=\startFunnyText,
   after=\stopFunnyText]

\defineenumeration[Lemma]
  [title=no,
  text=Lemma,
   prefix=yes,
   prefixsegments=chapter,
   way=bychapter,
   alternative=command,
   counter=Theorem,
   headcommand=\gobbleoneargument,
   before=\startFunnyText,
   after=\stopFunnyText]
   
\defineenumeration[Coro]
  [title=no,
  text=Corollary,
   prefix=yes,
   prefixsegments=chapter,
   way=bychapter,
   alternative=command,
   counter=Theorem,
   headcommand=\gobbleoneargument,
   before=\startFunnyText,
   after=\stopFunnyText]
\starttext

\dorecurse{3}
{\chapter{Chapter Title}
    

\startLemma
    Fort's space is a compact and Hausdorff topological space.
\stopLemma

\startTheorem
    Fort's space is a compact and Hausdorff topological space.
\stopTheorem


\startTheorem
Let $X$ be a uncountable set. Let $\infty$ is a fixed point of $X$. Let $\mathcal T$ be the family of subsets $G$ such that either (i) $\infty \notin G$ or (ii) $\infty \in G \text{ and } G^c$ is finite. The space $(X, {\mathcal T} )$ is called {\bf Fort's space}.
\stopTheorem

\startLemma
    Fort's space is a compact and Hausdorff topological space.
\stopLemma

\startCoro
    Fort's space is a compact and Hausdorff topological space.
\stopCoro
}

\stoptext
    
%%%%% 2nd method
%2. use \MPvar{} and define 3 different backgrounds, 3 different framedtexts like
%	\defineoverlay[FunnyFrameT][\useMPgraphic{FunnyFrame}{what=Theorem}] 	
%%%%%

\defineframed
  [FunnyFramed]
  [frame=off,
   loffset=1ex,
   roffset=1ex,
   foregroundstyle=\ssbf]

\startuseMPgraphic{FunnyFrame}
    picture p ; numeric o ; path a, b ; pair c ;
    p := textext.rt("\FunnyFramed{\MPvar{what} \convertedcounter[Theorem]}") ;                   
    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[FunnyFrameT][\useMPgraphic{FunnyFrame}{what=Theorem}] 
\defineoverlay[FunnyFrameL][\useMPgraphic{FunnyFrame}{what=Lemma}] 
\defineoverlay[FunnyFrameC][\useMPgraphic{FunnyFrame}{what=Corollary}] 

\defineframedtext
  [FunnyTheorem]
  [frame=off,
   background=FunnyFrameT,
   before={\blank[line,halfline]},
   after={\blank[line]},
   offset=\bodyfontsize,
   width=\textwidth]

\defineframedtext
  [FunnyLemma]
  [frame=off,
   background=FunnyFrameL,
   before={\blank[line,halfline]},
   after={\blank[line]},
   offset=\bodyfontsize,
   width=\textwidth]

\defineframedtext
  [FunnyCoro]
  [frame=off,
   background=FunnyFrameC,
   before={\blank[line,halfline]},
   after={\blank[line]},
   offset=\bodyfontsize,
   width=\textwidth]

\defineenumeration[Theorem]
  [title=no,
   prefix=yes,
   prefixsegments=chapter,
   way=bychapter,
   alternative=command,
   headcommand=\gobbleoneargument,
   before=\startFunnyTheorem,
   after=\stopFunnyTheorem]

\defineenumeration[Lemma]
  [title=no,
   prefix=yes,
   prefixsegments=chapter,
   way=bychapter,
   alternative=command,
   counter=Theorem,
   headcommand=\gobbleoneargument,
   before=\startFunnyLemma,
   after=\stopFunnyLemma]

\defineenumeration[Coro]
  [title=no,
   prefix=yes,
   prefixsegments=chapter,
   way=bychapter,
   alternative=command,
   counter=Theorem,
   headcommand=\gobbleoneargument,
   before=\startFunnyCoro,
   after=\stopFunnyCoro]

\starttext

\dorecurse{3}
{\chapter{Chapter Title}
    

\startLemma
    Fort's space is a compact and Hausdorff topological space.
\stopLemma

\startTheorem
    Fort's space is a compact and Hausdorff topological space.
\stopTheorem


\startTheorem
Let $X$ be a uncountable set. Let $\infty$ is a fixed point of $X$. Let $\mathcal T$ be the family of subsets $G$ such that either (i) $\infty \notin G$ or (ii) $\infty \in G \text{ and } G^c$ is finite. The space $(X, {\mathcal T} )$ is called {\bf Fort's space}.
\stopTheorem

\startLemma
    Fort's space is a compact and Hausdorff topological space.
\stopLemma

\startCoro
    Fort's space is a compact and Hausdorff topological space.
\stopCoro
}

\stoptext
    
    
    

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

  parent reply	other threads:[~2017-12-02 23:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.976.1509919382.1988.ntg-context@ntg.nl>
2017-11-14  7:29 ` Jeong Dal
2017-12-02 23:11 ` Jeong Dal [this message]
2017-12-03  7:27   ` Pablo Rodriguez
     [not found] <mailman.1513.1512287889.1988.ntg-context@ntg.nl>
2017-12-03 14:42 ` Jeong Dal
     [not found] <mailman.1.1510657201.29599.ntg-context@ntg.nl>
2017-11-14 14:13 ` Jeong Dal
     [not found] <mailman.1.1509879601.14103.ntg-context@ntg.nl>
2017-11-05 12:23 ` Jeong Dal
2017-11-05  9:14 Javier M Mora
2017-11-05  9:32 ` Schmitz Thomas A.
2017-11-05 10:40 ` Jean-Pierre Delange
2017-11-05 10:49   ` Jean-Pierre Delange

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=8BD8B063-EBE9-4B66-8299-5AB4B75B99EC@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).