ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Cc: ConTeXt Mailing List <ntg-context@ntg.nl>
Subject: Re: Q: Keeping blocks together
Date: Thu, 25 Oct 2001 11:54:03 +0200	[thread overview]
Message-ID: <5.1.0.14.1.20011025114951.02fe8b20@server-1> (raw)
In-Reply-To: <12163019177.20011025104530@telecable.es>

At 10:45 AM 10/25/2001 +0200, Jose Luis Diaz wrote:

>  I want to have two kind of blocks typeset with different format, but
>  disallowing  a  page break inbetween. For example, assume that I have
>  pairs  Question/Answer,  and  I  never  want  a  page break after the
>  Question,  but  a  page  break  after  the answer is desirable. To be
>  precise,  I'm  working  in  a multicolumn environment (3 columns) and
>  what I want to allow/disallow are the column breaks.
>  I tried the following:
>
>  \defineblock[Question,Answer]
>  \setupblock[Question]
>     [before={\startitemize[2]\item},
>      after={\stopitemize\page[no]},
>     ]
>  \setupblock[Answer]
>     [before={\startframedtext[width=\textwidth]\startcolor[red]},
>      after={\stopcolor\stopframedtext\page[preference]},
>     ]
>
>  (BTW, I need to put a comma at the end of the "after" line, why?)
>  This  code  doesn't  work.  I  keep getting column breaks between the
>  question and the answer (surprisingly, it appears that a column break
>  is indeed *prefered* in that position, since I get a lot of them)

columns are rather rigged and have their own ideas about page breaks

>  What  I'm  doing  wrong?  I even tried resorting to the TeX primitive
>  \penalty,  instead  of  using  \page.  Are  penalties  ignored  when
>  typesetting in columns?

indeed, the kind of get lost in the balancing process (when trying not to 
let the left col be shorter than the right one etc)

>  Anothe question. While testing the above code, I tried the following
>  main text:
>
>\starttext
>\dorecurse{10}{
>   \beginQuestion
>   \input tufte
>   \endQuestion
>   \beginAnswer
>     I don't know the answer.
>   \endAnswer
>  }
>  \stoptext
>
>  But I get no text in the output.

this is because buffered material cannot be used in macros (a simple

\startbuffer
  ...
\stopbuffer

\dorecurse{10}{\getbuffer}

would have worked.

>  And  a  last  question.  It  is "philosophically" correct to use text
>  blocks  for  the  stated purpose? As far as I understand, text blocks
>  are  provided  for  "hidding" the text until an adecuate place in the
>  output,  but  in  my case I need no hidding. There is another way for
>  defining start/stop pairs? (something like the LaTeX \newenvironment)

you may play with the following:

% this way you get no interference between color, spacing and penalties

\definestartstop
   [Question]
   [before={\startitemize[2]\item},
    after={\stopitemize\page[no]}]

\defineframedtext
   [Answer]
   [foregroundcolor=red,
    width=\textwidth,
    after={\page[preference]}]

\setupcolors[state=start]

combined with column sets (work in progresss, so it has bugs)

\definecolumnset[twocolumns][n=2]

\starttext

\startcolumnset[twocolumns]

\dorecurse{10}
   {\placefigure[rlbt]{}{\framed{another test}}
    \startQuestion
      \input tufte \par
      \placefigure[here]{}{\framed{this is just a test}}
      \input tufte \par
    \stopQuestion
    \startAnswer
       I don't know the answer.
    \stopAnswer}

\stopcolumnset

\stoptext

btw, "rlbt" means as much as "try to place from right to left and top to 
bottom"

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


  reply	other threads:[~2001-10-25  9:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-25  8:45 Jose Luis Diaz
2001-10-25  9:54 ` Hans Hagen [this message]
2001-10-25 11:20   ` Re[2]: " Jose Luis Diaz
2001-10-25 12:10     ` Hans Hagen
2001-10-25 16:29       ` Re[3]: Q: Keeping blocks together. New problems Jose Luis Diaz

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=5.1.0.14.1.20011025114951.02fe8b20@server-1 \
    --to=pragma@wxs.nl \
    --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).