Am 12.01.2014 um 21:47 schrieb Otared Kavian <ota...@gmail.com>:

> 
> On 12 janv. 2014, at 21:30, Wolfgang Schuster <schuster.wolfg...@gmail.com> 
> wrote:
> 
>> 
>> Am 11.01.2014 um 20:01 schrieb Otared Kavian <ota...@gmail.com>:
>> 
>>> I will put this example on the wiki, but before doing so I have another 
>>> question:
>>> can one add two automatic links at the end of each question so that one can 
>>> navigate easily to the respective hint or answer corresponding to that 
>>> question? Indeed if this were possible, one would add also two automatic 
>>> links to each hint going to its question and the corresponding answer, and 
>>> two other links to each answer going to its hint and question. One can do 
>>> this manually by adding a reference to each question, each hint and each 
>>> answer, but it would be nice to have this done automatically.
>> 
>> Not without writing your own environment where you generate a unique 
>> reference for each question, hint and answer.
> 
> If I understand well, one way might be something like (where 
> \theQuestionNumber stands for the number given by \startquestion)
> 
> \define\StartQuestion{\startquestion[Q:\theQuestionNumber]}
> \define\StartHint{\startquestion[H:\theQuestionNumber]}
> \define\StartAnswer{\startquestion[A:\theQuestionNumber]}
> \define\StopQuestion{\par\in{Hint}[H:\theQuestionNumber]\par 
> \in{Answer}[A:\theQuestionNumber]\stopquestion}
> \define\StopHint{\par\in{Question}[Q:\theQuestionNumber]\par 
> \in{Answer}[A:\theQuestionNumber]\stophint}
> \define\StopAnswer{\par\in{Question}[Q:\theQuestionNumber]\par 
> \in{Hint}[H:\theQuestionNumber]\stopquestion}
> 
> and then using \StartQuestion \StopQuestion, etc, instead of \startquestion 
> \stopquestion.
> But how can I refer to the \theQuestionNumber set by \startquestion?


When you have only questions and answers you can use the coupling key but in 
your case something like below is necessary:

\defineenumeration[Question]
\defineenumeration[Answer]

\define\startquestion
  {\increment\QuestionCounter
   \expanded{\startQuestion[reference=Question:\QuestionCounter]}}

\define\stopquestion
  {\stopQuestion
   \par
   \in{Answer}[Answer:\QuestionCounter]}

\define\startanswer
  {\expanded{\startAnswer[reference=Answer:\QuestionCounter]}}

\define\stopanswer
  {\stopAnswer
   \par
   \in{Question}[Question:\QuestionCounter]}

\setupinteraction[state=start]

\starttext

\startquestion
What is the answer to life the universe and everything?
\stopquestion

\page

\startanswer
42.
\stopanswer

\stoptext

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
___________________________________________________________________________________

Reply via email to