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-con...).
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)!
Best regards, Mikael
\definecolor[contrastcolor][darkred]
\defineintermediatecolor[contrastbgcolor][0.6,contrastcolor,white]
\setupinteraction[state=start,color=,contrastcolor=,style=]
\defineblock[answer]
\hideblocks[answer]
\def\myanswer[#1]{\inleft{\in[#1]\reference[A:#1]{\in[#1]}}}
\def\myheadcommand#1{\goto{Question #1}[A:\currentconstructionreference]}
\defineenumeration[question][
text=,
title=yes,
titlestyle=,
titlecolor=black,
headcommand={\myheadcommand},
headstyle={\sc},
headcolor=contrastcolor,
style=,
alternative=serried,
width=fit,
number=yes,
prefix=yes,
prefixsegments=chapter,
way=bychapter,
indentnext=no,
indenting=yes,
before={\testpage[2]\blank[big]},
after={\blank[big,samepage]},
]
\starttext
\section{A section with questions}
\startquestion[Q:test]{This is a title}
This is a question with title.
\stopquestion
\beginanswer
\myanswer[Q:test]
This is an answer
\endanswer
\startquestion[Q:test2]
This is a question without title.
\startformula
(a+b)^2=a^2+ab+ba+b^2.
\stopformula
\stopquestion
\beginanswer
\myanswer[Q:test2]
This is an answer.
\endanswer
\startquestion
This is a question without reference. It cannot have any answer.
\stopquestion
\page[yes]
\subject{Answers}
\useblocks[answer]
\stoptext
On Fri, Nov 4, 2016 at 12:50 PM, Wolfgang Schuster
Mikael P. Sundqvist 3. November 2016 um 16:14 Dear Otared (and others),
while waiting for Hans reply on the \namedenumerationparameter and \enumerationparameter, this is the best I could do. Now, only "Question" is clickable and not the number, but I think I could live with that if no other solution show up.
The reference value is set in a group and can only be accessed within this group but you can use \currentconstructionreference to access it.
\setupinteraction[state=start]
\define[1]\QuestionTextCommand
{\doifreferencefoundelse{answer:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}}
{\goto{#1}[answer:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}]} {#1}}
\define[1]\AnswerTextCommand
{\doifreferencefoundelse{question:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}}
{\goto{#1}[question:\cldcontext{lpeg.match(lpeg.secondofsplit(":"),"\currentconstructionreference")}]} {#1}}
\defineenumeration [question] [text=Question,headcommand=\QuestionTextCommand] \defineenumeration [answer] [text=Answer,headcommand=\AnswerTextCommand]
\starttext
\startquestion[question:knuth] \input knuth \stopquestion
\page
\startanswer[answer: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 ___________________________________________________________________________________