ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Q: Keeping blocks together
@ 2001-10-25  8:45 Jose Luis Diaz
  2001-10-25  9:54 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Jose Luis Diaz @ 2001-10-25  8:45 UTC (permalink / raw)


Hello ConTeXt users,

 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)

 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?

 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.

 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)

 Thanks  in  advance, and excuse the extension of the message. I'm new
 to ConTeXt, and I have yet a lot to learn.

-- 
  Jose Luis Diaz


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

* Re: Q: Keeping blocks together
  2001-10-25  8:45 Q: Keeping blocks together Jose Luis Diaz
@ 2001-10-25  9:54 ` Hans Hagen
  2001-10-25 11:20   ` Re[2]: " Jose Luis Diaz
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2001-10-25  9:54 UTC (permalink / raw)
  Cc: ConTeXt Mailing List

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


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

* Re[2]: Q: Keeping blocks together
  2001-10-25  9:54 ` Hans Hagen
@ 2001-10-25 11:20   ` Jose Luis Diaz
  2001-10-25 12:10     ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Jose Luis Diaz @ 2001-10-25 11:20 UTC (permalink / raw)
  Cc: Hans Hagen

Hello Hans,

Thank you very much for your prompt answer.
You wrote:

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

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

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

Hans> \setupcolors[state=start]

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

Hans> \definecolumnset[twocolumns][n=2]
[...]

\definecolumnset  is not understood by my version of ConTeXt, I assume
that  is  a  new  module in development stage. Anyway, is it available
anywhere?

On  the other hand, I tried the suggested setup, without using columns
at  all,  and  (sadly) I keep getting page breaks between the Question
and  the Answer (*real* page breaks this time, not column breaks since
there  are  no  columns).  Perhaps  some  of the environments add some
vertical  space  that  prevents  the penalties to be applied? (I don't
know  if  this  has  any  sense,  I  never  really  understood the TeX
page-breaking mechanism)

-- 
Greetings,
 Jose                            mailto:jldiaz@telecable.es


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

* Re[2]: Q: Keeping blocks together
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2001-10-25 12:10 UTC (permalink / raw)
  Cc: ConTeXt Mailing List

At 01:20 PM 10/25/2001 +0200, Jose Luis Diaz wrote:

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

            before={\page[no]}

>\definecolumnset  is not understood by my version of ConTeXt, I assume
>that  is  a  new  module in development stage. Anyway, is it available
>anywhere?

www.ntg.nl

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


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

* Re[3]: Q: Keeping blocks together. New problems
  2001-10-25 12:10     ` Hans Hagen
@ 2001-10-25 16:29       ` Jose Luis Diaz
  0 siblings, 0 replies; 5+ messages in thread
From: Jose Luis Diaz @ 2001-10-25 16:29 UTC (permalink / raw)
  Cc: ConTeXt Mailing List

Hello Hans,

El jueves, 25 de octubre de 2001, a las 14:10, Hans dijo:

Hans>             before={\page[no]}

I  also  thought  that,  but  still  keep getting wrong page breaks. I
suppossed that maybe the problem was an obsolete ConTeXt version, so I
downloaded  the  latest  from  www.ntg.nl,  and re-created the cont-en
format. Still wrong page breaks.

I  also  tried  the new columnset environment which you suggested, but
context  stops  with  the fatal error: No room for a new box (which is
generated  from  Plain).  I  guess  that  the  problem is perhaps some
infinite  loop,  since  the error message also spits out several lines
containing \dodorecurse and similar things.

But  the real problems appeared when I discovered that I was unable to
compile  some  previous  work  which  compiled  fine  with my previous
ConTeXt. Fortunately I was able to trace down the command which caused
the trouble, and provisionally I suppresed it from my source.

However,  I would like to know if something was wrong with my command,
or  if it is a bug in the new ConTeXt version. What I was trying to do
was  to  typeset  the  numbers  in  a  different  color/typeface in an
enumerated  environment.  I  was  unable  to  find  which parameter of
\setupitemize  would  serve  that  purpose,  so  I decided to create a
"conversion" for doing the job. This is what I wrote:

\defineconversion[cn][\colorednumber]
\def\colorednumber#1{\color[red]{\bf{\numbers{#1}}}

\startitemize[cn,inmargin]
\item One
\item Two
\stopitemize

But I get the following error message:

 |! Undefined control sequence.
 |\do\groupedcommand ...f \dogroupedcommand
 |                                          {\ifx \next \bgroup \def \\...
 |\colornumero #1->\color [white]
 |                               {\bf \numbers {#1}}
 |\dolistitem ...mbool \s!local \itemlevel }
 |                                          }\kopsomfalse \subsomfalse ...
 |\complexdosom ...ignorespaces \dolistitem
 |                                          \ifpackeditems \stelwitruim...
 |<to be read again>
 |                   O
 |l.127   \item O
 |               ne

The  trick  worked  fine  with  the  previous  ConTeXt version. What's
happening?

Thanks again, and sorry for all these problems I'm posing.

-- 
Regards,
 Jose                            mailto:jldiaz@telecable.es


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

end of thread, other threads:[~2001-10-25 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-25  8:45 Q: Keeping blocks together Jose Luis Diaz
2001-10-25  9:54 ` Hans Hagen
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

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