Re: [NTG-context] Defining commands in \start ... \stop

2014-03-30 Thread Xan
This:

\defineblock[question]
\defineblock[answer]

\defineenumeration[question][text={Question}]
\defineenumeration[answer]  [text={Answer}]

\keepblocks[question]
\hideblocks[answer]


\def\mynewcommand{\dosingleempty\doMyNewCommand}
\def\doMyNewCommand[#1]#2{%
 \iffirstargument
 \beginquestion
   \startquestion #2%
   \stopquestion
 \endquestion
   \beginanswer \startanswer #1%
   \stopanswer \endanswer
 \else
 \beginquestion
   \startquestion #2%
   \stopquestion
 \endquestion
   \incrementcounter[answer]
 \fi
}


\starttext

\chapter{Question}

\beginquestion
\startquestion
Question 1.
\stopquestion
\endquestion

\beginanswer
\startanswer
Answer 1.
\stopanswer
\endanswer

\beginquestion
\startquestion
Question 2.
\stopquestion
\endquestion

\beginanswer
\incrementcounter[answer]
\endanswer

\beginquestion
\startquestion
Question 3.
\stopquestion
\endquestion

\beginanswer
\startanswer
Answer 3.
\stopanswer
\endanswer

\mynewcommand{Question 5}

\mynewcommand[Resposta 6]{Question 6}

\chapter{Answers}

\useblocks[answer]

\stoptext

does not work
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Defining commands in \start ... \stop

2014-03-30 Thread Wolfgang Schuster

Am 30.03.2014 um 19:28 schrieb Xan dxpubl...@telefonica.net:

 This:
 
 \defineblock[question]
 \defineblock[answer]
 
 \defineenumeration[question][text={Question}]
 \defineenumeration[answer]  [text={Answer}]
 
 \keepblocks[question]
 \hideblocks[answer]
 
 
 \def\mynewcommand{\dosingleempty\doMyNewCommand}
 \def\doMyNewCommand[#1]#2{%
 \iffirstargument
 \beginquestion
   \startquestion #2%
   \stopquestion
 \endquestion
   \beginanswer \startanswer #1%
   \stopanswer \endanswer
 \else
 \beginquestion
   \startquestion #2%
   \stopquestion
 \endquestion
   \incrementcounter[answer]
 \fi
 }
 
 
 \starttext
 
 \chapter{Question}
 
 \beginquestion
   \startquestion
   Question 1.
   \stopquestion
 \endquestion
 
 \beginanswer
   \startanswer
   Answer 1.
   \stopanswer
 \endanswer
 
 \beginquestion
   \startquestion
   Question 2.
   \stopquestion
 \endquestion
 
 \beginanswer
   \incrementcounter[answer]
 \endanswer
 
 \beginquestion
   \startquestion
   Question 3.
   \stopquestion
 \endquestion
 
 \beginanswer
   \startanswer
   Answer 3.
   \stopanswer
 \endanswer
 
 \mynewcommand{Question 5}
 
 \mynewcommand[Resposta 6]{Question 6}
 
 \chapter{Answers}
 
 \useblocks[answer]
 
 \stoptext
 
 does not work

The block commands use a buffer to store the content and buffers can’t be used 
in commands.

Wolfgang

___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Defining commands in \start ... \stop

2014-03-30 Thread Xan
And so? This has not [mathematical] solution ;-)

Xan.

 The block commands use a buffer to store the content and buffers can’t be 
 used in commands.

Wolfgang
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] defining commands

2010-02-06 Thread Wolfgang Werners-Lucchini
Hallo,

  btw, i'm sure that you've seen
 
  \starttexdefinition blabla #1 #2
 
  which like setups ignores spaces so one can have readable
 macros
  i was the one who requested the parameterless version
 
  \starttexdefinition commandonly

I experimented a little with this:


\starttexdefinition BIS #1 #2
[#1 \ldots\ #2]
\stoptexdefinition

\starttext
\BIS1 23

\BIS{10}{20}30

\BIS {10}{20}30

\BIS{10} {20}30

\BIS{10}{20} 30

\BIS {10} {20}30

\BIS{10} {20} 30

\BIS {10} {20} 30
\stoptext


and get this:


[1 ... 2]3
[102030 ...
][102030 ...
][10 ...  20]30
[1020 ... 3]0
[10 ... 20]30
[10 ... 20] 30
[10 ... 20] 30


So it seems, that the first blank between command and #1 is optional. 
But the second between #1 and #2 is NEEDED. A last blank after #2 is 
not needed and not eaten.

Wolfgang
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] defining commands

2010-02-05 Thread Wolfgang Schuster

Am 05.02.10 09:03, schrieb Marius:

Hello all,

How do I define the \setuptitlepage and \placetitlepage commands in the
environment file? These commands are used as shown in the example below.


Since you do not explain what do you expect from both commands it's not 
possible to give you an answer but you can find on the wiki [1] a 
example for a \setuptitle and \placetitle command which can be copied 
and used in your document.


[1] 
http://wiki.contextgarden.net/Document_Titles#In_ConTeXt:_A_more_advanced_solution


Wolfgang
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] defining commands

2010-02-05 Thread Marius
Thank you for the link, the answer to my question was as in the example you
gave, but with a single argument. The solution to my problem given below
works, but I can't find the answer to the following question. What is the
difference between \dosingleempty and \dosingleargument ?

%%%
\unprotect

\definesystemvariable {dt}

\def\setuptitle
  {\dosingleempty\dosetuptitle}

\def\dosetuptitle[#1]%
  {\def\dodosetuptitle##1%
 {\getparameters[\??dt][#1]}%
  \processcommalist[#1]\dodosetuptitle}

\def\placetitle
  {\startalignment[\v!middle]
   \blank[\v!force,2*\v!big]
   \@@dttitle
   \blank[3*\v!medium]
   \@@dtauthor
   \blank[2*\v!medium]
   \@@dtdate
   \blank[3*\v!medium]
   \stopalignment}

\setuptitle
  [\c!title=,
   \c!author=,
   \c!date=\currentdate]

\protect


On Fri, Feb 5, 2010 at 11:29 AM, Wolfgang Schuster 
schuster.wolfg...@googlemail.com wrote:

 Am 05.02.10 09:03, schrieb Marius:

  Hello all,

 How do I define the \setuptitlepage and \placetitlepage commands in the
 environment file? These commands are used as shown in the example below.


 Since you do not explain what do you expect from both commands it's not
 possible to give you an answer but you can find on the wiki [1] a example
 for a \setuptitle and \placetitle command which can be copied and used in
 your document.

 [1]
 http://wiki.contextgarden.net/Document_Titles#In_ConTeXt:_A_more_advanced_solution

 Wolfgang
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] defining commands

2010-02-05 Thread Hans Hagen

On 5-2-2010 14:57, Marius wrote:

Thank you for the link, the answer to my question was as in the example you
gave, but with a single argument. The solution to my problem given below
works, but I can't find the answer to the following question. What is the
difference between \dosingleempty and \dosingleargument ?


the first one does not complain when no argument is given

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] defining commands

2010-02-05 Thread Hans Hagen

On 5-2-2010 10:29, Wolfgang Schuster wrote:

Am 05.02.10 09:03, schrieb Marius:

Hello all,

How do I define the \setuptitlepage and \placetitlepage commands in the
environment file? These commands are used as shown in the example below.


Since you do not explain what do you expect from both commands it's not
possible to give you an answer but you can find on the wiki [1] a
example for a \setuptitle and \placetitle command which can be copied
and used in your document.

[1]
http://wiki.contextgarden.net/Document_Titles#In_ConTeXt:_A_more_advanced_solution


using no macros ... wikifyable ...

\startsetups titlepage
\startstandardmakeup
\definedfont[SerifBold at 40pt]
\setupinterlinespace
\getvariable{document}{title}
\vfill
\definedfont[SerifBold at 20pt]
\setupinterlinespace
\getvariable{document}{author}
\stopstandardmakeup
\stopsetups

\setvariables
[document]
[title=Whatever,
 author=Not Me]

\setvariables
[whatever]
[set={\setup[whateverpage]}]

\startsetups whateverpage
\startstandardmakeup
\definedfont[SerifBold at 40pt]
\setupinterlinespace
\getvariable{whatever}{title}
\vfill
\stopstandardmakeup
\stopsetups

\starttext
\setups[titlepage]
\setvariables[whatever][title=One]
\setvariables[whatever][title=Two]
\stoptext

in the whatever case each setvariables will trigger a setup, so one has 
a sort of macro with key/value support



-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] defining commands

2010-02-05 Thread Wolfgang Schuster

Am 05.02.10 18:53, schrieb Hans Hagen:

\setvariables
[whatever]
[set={\setup[whateverpage]}]

nice feature for setvariables lovers :)

Wolfgang

___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] defining commands

2010-02-05 Thread Hans Hagen

On 5-2-2010 19:08, Wolfgang Schuster wrote:

Am 05.02.10 18:53, schrieb Hans Hagen:

\setvariables
[whatever]
[set={\setup[whateverpage]}]

nice feature for setvariables lovers :)


yes, for those getting the creeps of #1 an dso

btw, i'm sure that you've seen

\starttexdefinition blabla #1 #2

which like setups ignores spaces so one can have readable macros

Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] defining commands

2010-02-05 Thread Wolfgang Schuster

Am 05.02.10 19:19, schrieb Hans Hagen:

btw, i'm sure that you've seen

\starttexdefinition blabla #1 #2

which like setups ignores spaces so one can have readable macros

i was the one who requested the parameterless version

\starttexdefinition commandonly

Wolfgang

___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] defining commands

2010-02-05 Thread Hans Hagen

On 5-2-2010 19:21, Wolfgang Schuster wrote:

Am 05.02.10 19:19, schrieb Hans Hagen:

btw, i'm sure that you've seen

\starttexdefinition blabla #1 #2

which like setups ignores spaces so one can have readable macros

i was the one who requested the parameterless version

\starttexdefinition commandonly


ah, seems i need a memory upgrade

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___