Hi Wolfgang, Hi Mikael,

Thank you both for your great inputs!

I tried to modify the code each of you sent yesterday in order to « couple » 
automatically each question with its answer, using the keyword « coupling=… », 
but somehow I am unable to create automatic references by extracting the number 
of each question or that of each answer, for example by using \rawcountervalue,
or \currentconstructionnumber. Strangely the latter gives the name of the 
construction and not a number: is it on purpose?

The solution Wolfgang proposes today, using the new keyword referenceprefix, is 
almost perfect: however would it possible to create a version of
« currentconstructionreference » which creates a reference named for instance
answer:NumberOfCurentConstruction

The reason for which I need such a construction is that in a document with 
hundreds or more exercise —> hint —> solution, it would be handy to avoid 
creating each time a manual reference, and then one would navigate from a 
Question to its Hint and then  back to the Question or go to its Answer.

Best regards: OK


> On 5 Nov 2016, at 13:38, Wolfgang Schuster <schuster.wolfg...@gmail.com> 
> wrote:
> 
>> Mikael P. Sundqvist <mailto:mic...@gmail.com> 4. November 2016 um 16:33
>> Thank you very much Wolfgang!
>> 
>> Now I can get exactly what I need, see the example below (also tested
>> with my larger document, available at
>> http://www.maths.lth.se/matematiklth/personal/mickep/analysB2ht16/analys-context.pdf
>>  
>> <http://www.maths.lth.se/matematiklth/personal/mickep/analysB2ht16/analys-context.pdf>).
>> 
>> I'm very happy about this solution. Also, thanks to Hans for giving us
>> this very nice tool (I usually only write to the list when I have
>> problems, sorry)!
> With the new beta you can set a default prefix for enumeration references,
> i.e. you can write \startquestion[knuth] in your document without the need
> to add a question or answer prefix.
> 
> \setupinteraction[state=start]
> 
> \define[1]\QuestionTextCommand
>   {\doifreferencefoundelse{answer:\currentconstructionreference}
>      {\goto{#1}[answer:\currentconstructionreference]}
>      {#1}}
> 
> \define[1]\AnswerTextCommand
>   {\doifreferencefoundelse{question:\currentconstructionreference}
>      {\goto{#1}[question:\currentconstructionreference]}
>      {#1}}
> 
> \defineenumeration
>   [question]
>   [text=Question,
>    headcommand=\QuestionTextCommand,
>    referenceprefix=question]
> 
> \defineenumeration
>   [answer]
>   [text=Answer,
>    headcommand=\AnswerTextCommand,
>    referenceprefix=answer]
> 
> \starttext
> 
> \startquestion[knuth]
> \input knuth
> \stopquestion
> 
> \page
> 
> \startanswer[knuth]
> \input knuth
> \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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to