ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Framed paragraph
@ 2003-04-09  9:12 Guy Worthington
  2003-04-09 10:27 ` Patrick Gundlach
  0 siblings, 1 reply; 4+ messages in thread
From: Guy Worthington @ 2003-04-09  9:12 UTC (permalink / raw)


Hello,

I think I'm using the wrong tool.  I want a description environment,
slightly narrower than the main text, and separated from the main text
by a hairlines. 

If you compile the example below, you'll see that my attempt (apart
from looking not quite balanced) will allow a page break between a
hairline and the information contained in my description.  This rules
off the bottom of the page, rather than separating the description
from the main text.

What I would like is that the description be compelled to have at
least a couple of orphan lines of the paragraph before a page break.

Is it better to use something like a framedtext to achieve this
result?

-----
\definedescription [Note]
                   [headstyle=\sc,
                    style=small,
                    width=fit,
                    distance=10pt,
                    hang=20,
                    before={\hbox to \hsize{\hairline}\startnarrower},
                    after={\stopnarrower\vskip -1 ex \noindent\thinrule}]

\starttext

\Note{important}

\input tufte\par

\blank[medium]

\dorecurse{3}{\input tufte }

\blank[big]

A line of text

\Note{warning}

\input tufte\par

\blank[medium]

\dorecurse{3}{\input tufte}

\stoptext
-----

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

* Re: Framed paragraph
  2003-04-09  9:12 Framed paragraph Guy Worthington
@ 2003-04-09 10:27 ` Patrick Gundlach
  2003-04-10  5:05   ` Guy Worthington
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick Gundlach @ 2003-04-09 10:27 UTC (permalink / raw)


Guy Worthington <guyw@multiline.com.au> writes:

Hello Guy,

> I think I'm using the wrong tool.  I want a description environment,
> slightly narrower than the main text, and separated from the main text
> by a hairlines. 

I would use the textbackground feature:

\definedescription [Note]
                   [headstyle=\sc,
                    style=small,
                    width=fit,
                    distance=10pt,
                    hang=20,
                    before={\startnarrower\starttextbackground[NoteA]},
                    after={\stoptextbackground\stopnarrower}]

\definetextbackground[NoteA][frame=off,
                             topframe=on, % does not work...
                             location=paragraph]


[...]

How to get top and bottom frame only is left as an exercise to the
reader(*).


(*) Well, I gave up on this. Perhaps we should convince Hans to make
options for this like in \framed: frame=off,topframe=on as above...
I did not feel like hacking TeX *and* metapost.

Almost there:

\startuseMPgraphic{mpos:par:columnset}
   path p;
   for i := 1 upto nofmultipars :
     p := multipars[i];
     if multilocs[i] = 1 : % top
       draw topboundary p;
     elseif multilocs [i] = 3 : %bottom
       draw bottomboundary p;
     fi
   endfor ;
\stopuseMPgraphic

(just copy this peace of code into your tex file and you'll see)


We desperately need the issplit boolean there!  :)


Patrick

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

* Re: Framed paragraph
  2003-04-09 10:27 ` Patrick Gundlach
@ 2003-04-10  5:05   ` Guy Worthington
  2003-04-10 10:09     ` Patrick Gundlach
  0 siblings, 1 reply; 4+ messages in thread
From: Guy Worthington @ 2003-04-10  5:05 UTC (permalink / raw)


Hello Patrick, 

I ran you example and it's a significant improvement on my attempt --
I knew I had the hairline in the wrong position, but didn't know how
to fix it.  

-----
\definedescription [Note]
                   [headstyle=\sc,
                    style=small,
                    width=fit,
                    distance=10pt,
                    hang=20,
                    before={\startnarrower\starttextbackground[NoteA]},
                    after={\stoptextbackground\stopnarrower}]

\definetextbackground[NoteA][frame=off,location=paragraph]

\startuseMPgraphic{mpos:par:columnset}
   path p;
   for i := 1 upto nofmultipars :
     p := multipars[i];
     if multilocs[i] = 1 : % top
       draw topboundary p;
     elseif multilocs [i] = 3 : %bottom
       draw bottomboundary p;
     fi
   endfor ;
\stopuseMPgraphic

\starttext

\Note{important}

\input tufte\par

\blank[medium]

\dorecurse{3}{\input tufte }

\blank[medium]

A line of text

\blank[medium]

\Note{warning}

\input tufte\par

\blank[medium]

\dorecurse{3}{\input tufte}

\stoptext
-----

'Time to crack open the metafun book (even though I've a sinking
feeling that I'll be as old as Mathusala before I actually understand
what you've done).  

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

* Re: Framed paragraph
  2003-04-10  5:05   ` Guy Worthington
@ 2003-04-10 10:09     ` Patrick Gundlach
  0 siblings, 0 replies; 4+ messages in thread
From: Patrick Gundlach @ 2003-04-10 10:09 UTC (permalink / raw)


Guy Worthington <guyw@multiline.com.au> writes:

Hi,

[...]

> 'Time to crack open the metafun book (even though I've a sinking
> feeling that I'll be as old as Mathusala before I actually understand
> what you've done).  

To be honest: it was mostly copy and modify some code from Giuseppe
B. - so he should get the credits ;)

Patrick

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

end of thread, other threads:[~2003-04-10 10:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-09  9:12 Framed paragraph Guy Worthington
2003-04-09 10:27 ` Patrick Gundlach
2003-04-10  5:05   ` Guy Worthington
2003-04-10 10:09     ` Patrick Gundlach

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