From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/96764 Path: news.gmane.org!.POSTED!not-for-mail From: Wolfgang Schuster Newsgroups: gmane.comp.tex.context Subject: Re: Clickable question/answer numbers Date: Sat, 05 Nov 2016 19:14:27 +0100 Message-ID: <581E2183.6050600@gmail.com> References: <72F9D2F7-1726-42EF-B764-32A8168D3AC4@gmail.com> <75102198-e5ea-c9b7-1979-a5e3d6c6c042@wxs.nl> <581C7610.9060501@gmail.com> <581DD2DC.8000302@gmail.com> <6255F7AC-396B-486E-B560-F5E42188F559@gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5820660723829246414==" X-Trace: blaine.gmane.org 1478369723 26293 195.159.176.226 (5 Nov 2016 18:15:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 5 Nov 2016 18:15:23 +0000 (UTC) User-Agent: Postbox 5.0.5 (Macintosh/20161020) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Nov 05 19:15:19 2016 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c35UY-0004DU-6A for gctc-ntg-context-518@m.gmane.org; Sat, 05 Nov 2016 19:14:58 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 6920C1C929; Sat, 5 Nov 2016 19:14:45 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v7QfqhdXU11D; Sat, 5 Nov 2016 19:14:44 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id ACB0B1C63C; Sat, 5 Nov 2016 19:14:44 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 41DE41C58B for ; Sat, 5 Nov 2016 19:14:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4jm0JZau8aC4 for ; Sat, 5 Nov 2016 19:14:41 +0100 (CET) Original-Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 4E9CD1C54B for ; Sat, 5 Nov 2016 19:14:31 +0100 (CET) Original-Received: by mail-wm0-f46.google.com with SMTP id a197so108878301wmd.0 for ; Sat, 05 Nov 2016 11:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to; bh=RJgbV3IXvCgyhK8fQDiGG8eztpo3o/mfpiW43DXs4qE=; b=Jqu4Mjvs+Y1ig4AtmaAk8o+lFJpZneByLkZVoOT8hUEPc4dEmSaCG+r2nJ+xeU3kIV F6Cix8FKNSlWg0qbmT39QQCzErKlm/YflPFoFANT5ZlNPz6mX6wfZ7SIcgICI1YHVZNJ NQmZYG0IeyTZxEX9qEVFhq2QIvIZ1w2tzCYSJIcccgJRfYBX3/d64q/TR4zq+f2Q2NSr kiEdebwdaX9RkFX3Qvq32HqL0jFLoWZJWqVzfYoESVvQ5/o1tR8irqhdu+k4n/Gq+v7r SS7nvowI6kjktB0coj10a2Hftq4vOaBldCMyyXGAYUDQV9xoPwP+9hcAGGZ8fNpVh2bQ 9v6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to; bh=RJgbV3IXvCgyhK8fQDiGG8eztpo3o/mfpiW43DXs4qE=; b=Tv0Jy4KHo04g0JskC/RwDi9sYMWj3cuydhcxrrw9N3my6bbY9fsaUtksW/epsfrsCj HJp9qFpXKBoemhyyDno35/EK37k+Bob2gwe8yCfoq01gh+dmYMHc+BqNkJtp76JYMwXL ST/ab/V7KdFSdO69SRUZHuIZfUGf/4WtpRd5obX2BIC6VCd2xX2o4ckkjS8Flnn2GF3O S2lR9opjvJeB66Qy933Hv6KMQIFoQBlJLCng6mfHigP6mtu/E1tUTECj6+ntDQPacu1O UkNhPpdM5TXSuRxiPGwsiI+fjOd4BD/8goPJ2zKWnZsPFisgYYytpqngbCfFaMC31GX5 KvbQ== X-Gm-Message-State: ABUngveo0hjrBrPSmYBz+ks+N7HDOhQaJNxHqok18u57DbjoWxKbjMdmRMhVi8L1LFdWmA== X-Received: by 10.28.165.2 with SMTP id o2mr2270423wme.38.1478369670719; Sat, 05 Nov 2016 11:14:30 -0700 (PDT) Original-Received: from keima.localdomain (x2f26f05.dyn.telefonica.de. [2.242.111.5]) by smtp.gmail.com with ESMTPSA id j6sm8409783wjk.25.2016.11.05.11.14.29 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 Nov 2016 11:14:30 -0700 (PDT) In-Reply-To: <6255F7AC-396B-486E-B560-F5E42188F559@gmail.com> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:96764 Archived-At: This is a multi-part message in MIME format. --===============5820660723829246414== Content-Type: multipart/alternative; boundary="------------080009050602090902010806" This is a multi-part message in MIME format. --------------080009050602090902010806 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit > Otared Kavian > 5. November 2016 um 18:34 > 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 \currentconstructionnumber command contains the name of the counter but getting the counter value won’t help because it comes too late. > 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 referenceprefix key is only usefull when you set the reference by hand. > 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. When you always all three elements (question, hint and answer) you can increment a counter at the begin of each element and create a page reference which contains the value of the counter. Below is a modified version of my previous example for this method. %%%% begin example \setupinteraction[state=start] \define[1]\QuestionTextCommand {\doglobal\increment\QuestionCounter \pagereference[question:\QuestionCounter]% \doifreferencefoundelse{answer:\QuestionCounter} {\goto{#1}[answer:\QuestionCounter]} {#1}} \define[1]\AnswerTextCommand {\doglobal\increment\AnswerCounter \pagereference[answer:\AnswerCounter]% \doifreferencefoundelse{question:\AnswerCounter} {\goto{#1}[question:\AnswerCounter]} {#1}} \defineenumeration [question] [text=Question, headcommand=\QuestionTextCommand] \defineenumeration [answer] [text=Answer, headcommand=\AnswerTextCommand] \defineblock[answer] \startbuffer % \startquestion \input knuth \stopquestion % \beginanswer \startanswer \input knuth \stopanswer \endanswer % \stopbuffer \starttext \dorecurse{10}{\getbuffer} \page \useblocks[answer] \stoptext %%%% end example Wolfgang --------------080009050602090902010806 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
5. November 2016 um 18:34
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 \currentconstructionnumber command contains the name of the counter but getting the counter value won’t help because it comes too late.
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 referenceprefix key is only usefull when you set the reference by hand.
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.
When you always all three elements (question, hint and answer) you can increment
a counter at the begin of each element and create a page reference which contains
the value of the counter.

Below is a modified version of my previous example for this method.

%%%% begin example
\setupinteraction[state=start]

\define[1]\QuestionTextCommand
  {\doglobal\increment\QuestionCounter
   \pagereference[question:\QuestionCounter]%
   \doifreferencefoundelse{answer:\QuestionCounter}
     {\goto{#1}[answer:\QuestionCounter]}
     {#1}}

\define[1]\AnswerTextCommand
  {\doglobal\increment\AnswerCounter
   \pagereference[answer:\AnswerCounter]%
   \doifreferencefoundelse{question:\AnswerCounter}
     {\goto{#1}[question:\AnswerCounter]}
     {#1}}

\defineenumeration
  [question]
  [text=Question,
   headcommand=\QuestionTextCommand]

\defineenumeration
  [answer]
  [text=Answer,
   headcommand=\AnswerTextCommand]

\defineblock[answer]

\startbuffer
    %
    \startquestion
    \input knuth
    \stopquestion
    %
    \beginanswer
        \startanswer
        \input knuth
        \stopanswer
    \endanswer
    %
\stopbuffer

\starttext

\dorecurse{10}{\getbuffer}

\page

\useblocks[answer]

\stoptext
%%%% end example

Wolfgang
--------------080009050602090902010806-- --===============5820660723829246414== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f --===============5820660723829246414==--