ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Conditional text
@ 2002-03-07 18:49 Giuseppe Bilotta
  2002-03-07 22:54 ` Hans Hagen
  0 siblings, 1 reply; 13+ messages in thread
From: Giuseppe Bilotta @ 2002-03-07 18:49 UTC (permalink / raw)


Hello,

I'd like to separate two blocks of text with some stuff which
depending on wether the two blocks are on the same page or not.

Example one: two paragraph are separate by a \blank of space, but
if there is a page change, then three starts are inserted on top
of the next page.

Example two: sections start without creating a new page, but if
they stay on the same page, then a line is drawn before them.

The nicest thing would be a command (to be used after a \blank)
like \ifstillonsamepageelse{do something}{do something else}.

Do I have to go through the referencing mechanism or is there
something built-in already?

--
Giuseppe "Oblomov" Bilotta


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

* Re: Conditional text
  2002-03-07 18:49 Conditional text Giuseppe Bilotta
@ 2002-03-07 22:54 ` Hans Hagen
  2002-03-08 11:15   ` Re[2]: " Giuseppe Bilotta
  2002-03-11  0:21   ` Daniel Pittman
  0 siblings, 2 replies; 13+ messages in thread
From: Hans Hagen @ 2002-03-07 22:54 UTC (permalink / raw)
  Cc: ntg-context

At 07:49 PM 3/7/2002 +0100, Giuseppe Bilotta wrote:
>Hello,
>
>I'd like to separate two blocks of text with some stuff which
>depending on wether the two blocks are on the same page or not.
>
>Example one: two paragraph are separate by a \blank of space, but
>if there is a page change, then three starts are inserted on top
>of the next page.
>
>Example two: sections start without creating a new page, but if
>they stay on the same page, then a line is drawn before them.
>
>The nicest thing would be a command (to be used after a \blank)
>like \ifstillonsamepageelse{do something}{do something else}.
>
>Do I have to go through the referencing mechanism or is there
>something built-in already?

Ah, another example of italian typesetting:

\setuplayout[height=12cm]

\starttext

\xypos{b1}\input tufte\xypos{e1}

\doifpositionsonsamepageelse{e1,b2}{yes}{no}

\xypos{b2}\input tufte\xypos{e2}

\doifpositionsonsamepageelse{e2,b3}{yes}{no}

\xypos{b3}\input tufte\xypos{e3} \page

\doifpositionsonsamepageelse{e3,b4}{yes}{no}

\xypos{b4}\input tufte\xypos{e4}

\stoptext

Unfortunately i found out that there is a circular call in the macro (will 
send you the patch)

[beware: such playing with spacing may influence the process and you can 
end up in cycles, so, make sure to start without a tuo file, and only move 
forward, not back]

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
-------------------------------------------------------------------------
                                   fall-back web server: 
www.pragma-ade.nl
-------------------------------------------------------------------------


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

* Re[2]: Conditional text
  2002-03-07 22:54 ` Hans Hagen
@ 2002-03-08 11:15   ` Giuseppe Bilotta
  2002-03-08 13:23     ` Re[3]: " Giuseppe Bilotta
  2002-03-11  0:21   ` Daniel Pittman
  1 sibling, 1 reply; 13+ messages in thread
From: Giuseppe Bilotta @ 2002-03-08 11:15 UTC (permalink / raw)
  Cc: ntg-context

Thursday, March 07, 2002 Hans Hagen wrote:

HH> At 07:49 PM 3/7/2002 +0100, Giuseppe Bilotta wrote:

>>I'd like to separate two blocks of text with some stuff which
>>depending on wether the two blocks are on the same page or not.

[snip]

HH> Ah, another example of italian typesetting:

Well, I don't know if that' a typographical rule here in Italy
but, yes, I've seen it in Italian books. :-)

HH> \setuplayout[height=12cm]

HH> \starttext

HH> \xypos{b1}\input tufte\xypos{e1}

HH> \doifpositionsonsamepageelse{e1,b2}{yes}{no}

HH> \xypos{b2}\input tufte\xypos{e2}

HH> \doifpositionsonsamepageelse{e2,b3}{yes}{no}

HH> \xypos{b3}\input tufte\xypos{e3} \page

HH> \doifpositionsonsamepageelse{e3,b4}{yes}{no}

HH> \xypos{b4}\input tufte\xypos{e4}

HH> \stoptext

HH> Unfortunately i found out that there is a circular call in the macro (will 
HH> send you the patch)

Thank you very much. I'll give it a try.

--
Giuseppe "Oblomov" Bilotta


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

* Re[3]: Conditional text
  2002-03-08 11:15   ` Re[2]: " Giuseppe Bilotta
@ 2002-03-08 13:23     ` Giuseppe Bilotta
  2002-03-08 15:35       ` Hans Hagen
  0 siblings, 1 reply; 13+ messages in thread
From: Giuseppe Bilotta @ 2002-03-08 13:23 UTC (permalink / raw)


Friday, March 08, 2002 Giuseppe Bilotta wrote:

HH>> \doifpositionsonsamepageelse{e1,b2}{yes}{no}

Ok, it works! :-)

--
Giuseppe "Oblomov" Bilotta


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

* Re[3]: Conditional text
  2002-03-08 13:23     ` Re[3]: " Giuseppe Bilotta
@ 2002-03-08 15:35       ` Hans Hagen
  2002-03-08 16:46         ` Re[4]: " Giuseppe Bilotta
  0 siblings, 1 reply; 13+ messages in thread
From: Hans Hagen @ 2002-03-08 15:35 UTC (permalink / raw)
  Cc: ntg-context

At 02:23 PM 3/8/2002 +0100, Giuseppe Bilotta wrote:

>Friday, March 08, 2002 Giuseppe Bilotta wrote:
>
>HH>> \doifpositionsonsamepageelse{e1,b2}{yes}{no}
>
>Ok, it works! :-)

guess what: i tried it before sending you the code

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
-------------------------------------------------------------------------
                                   fall-back web server: 
www.pragma-ade.nl
-------------------------------------------------------------------------


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

* Re[4]: Conditional text
  2002-03-08 15:35       ` Hans Hagen
@ 2002-03-08 16:46         ` Giuseppe Bilotta
  0 siblings, 0 replies; 13+ messages in thread
From: Giuseppe Bilotta @ 2002-03-08 16:46 UTC (permalink / raw)
  Cc: ntg-context

Friday, March 08, 2002 Hans Hagen wrote:

HH> At 02:23 PM 3/8/2002 +0100, Giuseppe Bilotta wrote:

>>Friday, March 08, 2002 Giuseppe Bilotta wrote:
>>
>>HH>> \doifpositionsonsamepageelse{e1,b2}{yes}{no}
>>
>>Ok, it works! :-)

HH> guess what: i tried it before sending you the code

I thought as, much considering the patch that followed :-)

Now I'll put this together with whatever comes from the thread
about the \filbreak (How to: get TeX to warn me ...)

--
Giuseppe "Oblomov" Bilotta


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

* Re: Conditional text
  2002-03-07 22:54 ` Hans Hagen
  2002-03-08 11:15   ` Re[2]: " Giuseppe Bilotta
@ 2002-03-11  0:21   ` Daniel Pittman
  1 sibling, 0 replies; 13+ messages in thread
From: Daniel Pittman @ 2002-03-11  0:21 UTC (permalink / raw)


On Thu, 07 Mar 2002, Hans Hagen wrote:
> At 07:49 PM 3/7/2002 +0100, Giuseppe Bilotta wrote:
>>Hello,
>>
>>I'd like to separate two blocks of text with some stuff which
>>depending on wether the two blocks are on the same page or not.

[...]

> \xypos{b1}\input tufte\xypos{e1}
> 
> \doifpositionsonsamepageelse{e1,b2}{yes}{no}

[...]

> Unfortunately i found out that there is a circular call in the macro
> (will send you the patch)

Since this patch doesn't seem to have made it into the 2002.3.4 beta of
ConTeXt, would you also be able to send it to me?  This xypos/doif
combination is something that I would also like to use so that I can
detect page breaks where I don't want them to be. :)

Thanks,
        Daniel

-- 
Making art is quite therapeutic, like chopping vegetables, it calms me and
keeps me off the streets. If I wasn't making photographs or films, I would be
going around slashing tires with a butcher's knife.
        -- Tracey Moffatt


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

* Re: Conditional Text
  2003-01-24 22:24   ` Johannes Hüsing
@ 2003-01-24 22:24     ` Hans Hagen
  0 siblings, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2003-01-24 22:24 UTC (permalink / raw)


At 11:24 PM 1/24/2003 +0100, you wrote:
>On Mon, Jan 20, 2003 at 10:07:45AM +0100, Hans Hagen wrote:
> > At 05:06 PM 1/18/2003 -0700, you wrote:
> > >Greetings!
> > >
> > >  Is it possible to have parts of the ConTeXt file
> > >processed conditionally? I'm hoping to be able to do
> > >something like:
> > >
> > >(in ConTeXt file)
> > >
> > >Question: What is the derivative of $e^{sqrt{x}}$\\
> > >\some-command-start
> > >Answer: $\frac{d}{dx} e^{sqrt{x}} ... $
> > >\some-command-end
> > >
>
>[...]
> >
> > \defineblock [answer]
> >
>
>Interesting: Three of your users suggest using modes instead. I would
>have too.

well, nowadays there is setups as well (more on that in some new styles)

>What made you choose blocks over modes here?

(1) no argument grabbing and therefore catcode save, which means that 
verbatim and so will work
(2) they keep track of numbering, so that when you call them up later (say 
in appendix) you can get similar numbers; say that you want a summary of 
formula's: put them in blocks, tag them (with optional arg you cna group 
them in subblocks), then, when you call such a subgroup you get proper 
numbers; also, refs in such recalled blocks know from which 
chapter/section/etc they come, so they will be prefixed accordingly
(3) hooks and local variables
(4) nesting is possible

[btw a pretty old mechanism, one of the reasons for context being there]

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
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

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

* Re: Conditional Text
  2003-01-20  9:07 ` Hans Hagen
@ 2003-01-24 22:24   ` Johannes Hüsing
  2003-01-24 22:24     ` Hans Hagen
  0 siblings, 1 reply; 13+ messages in thread
From: Johannes Hüsing @ 2003-01-24 22:24 UTC (permalink / raw)


On Mon, Jan 20, 2003 at 10:07:45AM +0100, Hans Hagen wrote:
> At 05:06 PM 1/18/2003 -0700, you wrote:
> >Greetings!
> >
> >  Is it possible to have parts of the ConTeXt file
> >processed conditionally? I'm hoping to be able to do
> >something like:
> >
> >(in ConTeXt file)
> >
> >Question: What is the derivative of $e^{sqrt{x}}$\\
> >\some-command-start
> >Answer: $\frac{d}{dx} e^{sqrt{x}} ... $
> >\some-command-end
> >

[...]
> 
> \defineblock [answer]
> 

Interesting: Three of your users suggest using modes instead. I would 
have too. 

What made you choose blocks over modes here?

Greetings


Johannes
-- 
Johannes Hüsing   There is something fascinating about science. One gets
hannes@ruhrau.de  such wholesale returns of conjecture from such a 
                  trifling investment of fact.                Mark Twain

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

* Re: Conditional Text
  2003-01-19  0:06 Conditional Text Lazycode
  2003-01-19  0:12 ` Patrick Gundlach
  2003-01-19 22:11 ` John Culleton
@ 2003-01-20  9:07 ` Hans Hagen
  2003-01-24 22:24   ` Johannes Hüsing
  2 siblings, 1 reply; 13+ messages in thread
From: Hans Hagen @ 2003-01-20  9:07 UTC (permalink / raw)


At 05:06 PM 1/18/2003 -0700, you wrote:
>Greetings!
>
>   Is it possible to have parts of the ConTeXt file
>processed conditionally? I'm hoping to be able to do
>something like:
>
>(in ConTeXt file)
>
>Question: What is the derivative of $e^{sqrt{x}}$\\
>\some-command-start
>Answer: $\frac{d}{dx} e^{sqrt{x}} ... $
>\some-command-end
>
>So that, in the command line, if I run
>
>"texexec --pdf quiz01.tex"  then it will NOT include
>the answer section, but if I run
>"texexec --pdf quiz01.tex -some-other-command"
>it WILL also include the answer section.
>
>I'm confident this can be done through an if or if-defined
>construct. However, I could not find such commands/macros
>in the ConTeXt manuals (both the beginners and the detailed
>manual).

\defineblock [answer]

% \hideblocks[answer]

\starttext

% \useblocks[answer]

question

\beginanswer
answer
\endanswer

\stoptext
-------------------------------------------------------------------------
                                   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
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

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

* Re: Conditional Text
  2003-01-19  0:06 Conditional Text Lazycode
  2003-01-19  0:12 ` Patrick Gundlach
@ 2003-01-19 22:11 ` John Culleton
  2003-01-20  9:07 ` Hans Hagen
  2 siblings, 0 replies; 13+ messages in thread
From: John Culleton @ 2003-01-19 22:11 UTC (permalink / raw)


On Sunday 19 January 2003 00:06, Lazycode wrote:
> Greetings!
>
>   Is it possible to have parts of the ConTeXt file
> processed conditionally? I'm hoping to be able to do
> something like:
>
> (in ConTeXt file)
>
> Question: What is the derivative of $e^{sqrt{x}}$\\
> \some-command-start
> Answer: $\frac{d}{dx} e^{sqrt{x}} ... $
> \some-command-end
>
> So that, in the command line, if I run
>
> "texexec --pdf quiz01.tex"  then it will NOT include
> the answer section, but if I run
> "texexec --pdf quiz01.tex -some-other-command"
> it WILL also include the answer section.
>
> I'm confident this can be done through an if or if-defined
> construct. However, I could not find such commands/macros
> in the ConTeXt manuals (both the beginners and the detailed
> manual).
>
>
> Thanks in advance,
> --tk
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context

In context there is a mode command that handles conditional text. 
See page 19 of the manual.

HTH
-- 

John Culleton
Able Indexers and Typesetters 
Rowse Reviews
Culleton Editorial Services
http://wexfordpress.com

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

* Re: Conditional Text
  2003-01-19  0:06 Conditional Text Lazycode
@ 2003-01-19  0:12 ` Patrick Gundlach
  2003-01-19 22:11 ` John Culleton
  2003-01-20  9:07 ` Hans Hagen
  2 siblings, 0 replies; 13+ messages in thread
From: Patrick Gundlach @ 2003-01-19  0:12 UTC (permalink / raw)


Lazycode <lazycode@linuxkungfu.org> writes:

Hello,

> Is it possible to have parts of the ConTeXt file
> processed conditionally? 


Yes, see the manual (cont-eni.pdf or cont-enp.pdf) and search for
\doifmodeelse. That is probably exactly what you need. It is chapter
2.6 "Modes" in "my" manual.

> in the ConTeXt manuals (both the beginners and the detailed
> manual).

it is in the detailed manual.


Patrick

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

* Conditional Text
@ 2003-01-19  0:06 Lazycode
  2003-01-19  0:12 ` Patrick Gundlach
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Lazycode @ 2003-01-19  0:06 UTC (permalink / raw)


Greetings!

  Is it possible to have parts of the ConTeXt file
processed conditionally? I'm hoping to be able to do
something like:

(in ConTeXt file)

Question: What is the derivative of $e^{sqrt{x}}$\\
\some-command-start
Answer: $\frac{d}{dx} e^{sqrt{x}} ... $
\some-command-end

So that, in the command line, if I run 

"texexec --pdf quiz01.tex"  then it will NOT include
the answer section, but if I run
"texexec --pdf quiz01.tex -some-other-command"
it WILL also include the answer section.

I'm confident this can be done through an if or if-defined
construct. However, I could not find such commands/macros
in the ConTeXt manuals (both the beginners and the detailed
manual).


Thanks in advance,
--tk

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

end of thread, other threads:[~2003-01-24 22:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-07 18:49 Conditional text Giuseppe Bilotta
2002-03-07 22:54 ` Hans Hagen
2002-03-08 11:15   ` Re[2]: " Giuseppe Bilotta
2002-03-08 13:23     ` Re[3]: " Giuseppe Bilotta
2002-03-08 15:35       ` Hans Hagen
2002-03-08 16:46         ` Re[4]: " Giuseppe Bilotta
2002-03-11  0:21   ` Daniel Pittman
2003-01-19  0:06 Conditional Text Lazycode
2003-01-19  0:12 ` Patrick Gundlach
2003-01-19 22:11 ` John Culleton
2003-01-20  9:07 ` Hans Hagen
2003-01-24 22:24   ` Johannes Hüsing
2003-01-24 22:24     ` Hans Hagen

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