From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/96776 Path: news.gmane.org!.POSTED!not-for-mail From: Otared Kavian Newsgroups: gmane.comp.tex.context Subject: Re: Clickable question/answer numbers (Otared Kavian) Date: Mon, 7 Nov 2016 04:21:55 +0100 Message-ID: <611CEB51-2A92-458D-B032-F0AA6A3F4C58@gmail.com> References: <19DD2A4D-0F5B-46AF-A6E4-ABA985EB477F@me.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3253\)) Content-Type: multipart/mixed; boundary="===============5157493861873485480==" X-Trace: blaine.gmane.org 1478488958 28217 195.159.176.226 (7 Nov 2016 03:22:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 7 Nov 2016 03:22:38 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Nov 07 04:22:32 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 1c3aVx-0006CS-IO for gctc-ntg-context-518@m.gmane.org; Mon, 07 Nov 2016 04:22:29 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0B7001D3AF; Mon, 7 Nov 2016 04:22:11 +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 Yi2-IdcIOU1y; Mon, 7 Nov 2016 04:22:10 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id 339A51D3B1; Mon, 7 Nov 2016 04:22:10 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id E8EF11D3A8 for ; Mon, 7 Nov 2016 04:22:08 +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 aYj8gNpBbvdW for ; Mon, 7 Nov 2016 04:22:08 +0100 (CET) Original-Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) (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 133201D3A5 for ; Mon, 7 Nov 2016 04:21:58 +0100 (CET) Original-Received: by mail-wm0-f42.google.com with SMTP id t79so152024506wmt.0 for ; Sun, 06 Nov 2016 19:21:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:mime-version:subject:date:references:to:in-reply-to:message-id; bh=+LIA5e1RJd4o0H6uxi7CgdvDAu2HbHK5KtNyXjNpQBA=; b=rBxsVxUWvqQ8xkAThIuK+IsdxdthAhqDtQL1snf3DfZPXzICBSU5I2S4bUooAf/WBQ 0ThfWNV0CiBeMp7W49HyBY7pamQveLax74ZYWEAioBHHML1hSeL8YMTrRkJ/3sGY1ORx CLB422vKZ3AucMJXlReAligpCOZIQkh5bz2iahpDIpUwftrkEXsts1oU/hr/Rv7fd/H4 an95m944sbis3lndbfyKtwG1q9Br2J4q8TR+kjJmHOXG2s+bWVjkkqg4NQUbQ3YL7Sne 6EKyD9iM3624JQSK+rJuZ/3FLiQlihqom2ot344DNUI3BOz4AWzo9XHco6oIWZZgLCD5 1/ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:subject:date:references:to :in-reply-to:message-id; bh=+LIA5e1RJd4o0H6uxi7CgdvDAu2HbHK5KtNyXjNpQBA=; b=GyjxGfiEEGsj3cZnDpMQ/hlk985OHPuosSpTFQPvy7m+eCvCzFIqo5uGKICXli0sIn ky03RQKOfY0JOd9jvjofPvv2nc0nLJNmTe7xN8nHHMR/I8jNi4whOxpJt3oVGOpAztwO OxhIYPDJxt5gdsxjBzGuTlgo3jXTQUtZbeVCAlVfRBsg4ldKudwCvwVjo1OErKtVi4+1 LPmomfiBFY1+vcRh5i4wc7DjxOLIhuJ4ZcONzjhyjHcsxDO1H8SvKtfAo+vRFezuQM11 ChEiiFk6NyNkzsRXENeFDKjwTtt2nWtMPzWcpOix6TsmZBd4uYVOaLKyeJKpFxB363Rf QeKQ== X-Gm-Message-State: ABUngvd613cFmtEgri4vSofypujbItV+NZ5IytIcgT1prLgLSn9o7e7ySwtXkRc8vdVtKQ== X-Received: by 10.28.71.140 with SMTP id m12mr7295152wmi.125.1478488917424; Sun, 06 Nov 2016 19:21:57 -0800 (PST) Original-Received: from [192.168.0.12] (lns-bzn-44-82-249-242-4.adsl.proxad.net. [82.249.242.4]) by smtp.gmail.com with ESMTPSA id u81sm10741464wmu.21.2016.11.06.19.21.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Nov 2016 19:21:56 -0800 (PST) In-Reply-To: <19DD2A4D-0F5B-46AF-A6E4-ABA985EB477F@me.com> X-Mailer: Apple Mail (2.3253) 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:96776 Archived-At: --===============5157493861873485480== Content-Type: multipart/alternative; boundary="Apple-Mail=_D8E5673D-0A79-44DF-9691-CB435B66AC05" --Apple-Mail=_D8E5673D-0A79-44DF-9691-CB435B66AC05 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Dear Dalyoung, I guess you are typesetting the wrong file, or you have put the last = code I sent into a file which contains something of the previous = codes=E2=80=A6 Indeed in the last file I sent (which I am sending again at the end of = this reply) does not contain the command \myanswer=E2=80=A6 which = appears in your error message. Please test the code below and let me know if you encunter a problem. Best regards: OK %%%% begin interactive-question-answer.tex %%%% Here, following Wolfgang Schuster's ideas,=20 %%%% we define some macros allowing to couple %%%% Questions and Answers in an automatic way %%%% Upon clicking on an interactive title for Question or Answer %%%% one goes to the corresponding Answer or Question \setupinteraction[state=3Dstart] % We define two counters which follow the numbers % appearing in Question and Answer \newcounter\QuestionCounter \newcounter\AnswerCounter % We create two commands to be used in the % enumeration environments % Note that the check for trial typestting=20 % \doifnotmode{*trialtypesetting} % is necessary in order to avoid unwanted incrementation \define[1]\QuestionTextCommand {\doifnotmode{*trialtypesetting} {\doglobal\increment\QuestionCounter \pagereference[question:\QuestionCounter]}% \doifreferencefoundelse{answer:\QuestionCounter} {\goto{#1}[answer:\QuestionCounter]} {#1}} \define[1]\AnswerTextCommand {\doifnotmode{*trialtypesetting} {\doglobal\increment\AnswerCounter \pagereference[answer:\AnswerCounter]}% \doifreferencefoundelse{question:\AnswerCounter} {\goto{#1}[question:\AnswerCounter]} {#1}} % We define here two enumeration environments for % Questions and Answers \defineenumeration[question] [text=3DQuestion, headcommand=3D\QuestionTextCommand, number=3Dyes, prefix=3Dyes, prefixsegments=3Dchapter, coupling=3Danswer] \defineenumeration[answer] [text=3DAnswer, headcommand=3D\AnswerTextCommand, number=3Dyes, prefix=3Dyes, prefixsegments=3Dchapter, coupling=3Dquestion] % Each question is followed immediately by its answer. % The answers are put in a block which will be used later \defineblock[answer] \hideblocks[answer] % We define a command used after a =20 % Question for which no Answer is provided % Since the block commands=20 % \beginanswer ... \endanswer % cannot be used directly in a macro definition % we use a trick... % In the buffer the two counters associated to Answer % are incremented... \startbuffer[noanswer] \beginanswer \doglobal\increment\AnswerCounter \incrementcounter[answer] \endanswer \stopbuffer % ...and then the above buffer is invoked \define\noanswer {\getbuffer[noanswer]} % example of use: \starttext \startchapter[title=3DQuestions] \startquestion[q:1] Prove that ${\rm e}\sim 2.73$ is irrational. =20 This is the first question, with its own reference, for later use. \stopquestion =20 \beginanswer \startanswer This is the answer to the first question (to \in{Question}[q:1]). \stopanswer \endanswer \startquestion=20 This is the second question, without its own reference. \stopquestion =20 \beginanswer \startanswer[a:Test] This is the answer to the second question.=20 (Note that this answer has a reference named \type{a:Test}). \stopanswer \endanswer \startquestion[q:Obvious] This is the third question, an easy one, without a given solution. \stopquestion % we increment here the counters for Answer \noanswer \startquestion[q:2] This is the fourth question with its own reference. \stopquestion \beginanswer \startanswer This is the answer to the fourth question: use the result of = \in{Question}[q:1]. \stopanswer \endanswer \startquestion=20 This is the fifth question, without its own reference.=20 ({\it Hint:} look again at \in{Question}[q:Obvious]). \stopquestion =20 \beginanswer \startanswer This is the answer to the fifth question. Read again = \in{Answer}[a:Test]. \stopanswer \endanswer =20 \stopchapter % Here we say ownnumber=3D1, in order to match the prefix=20 % of numbers associated to Answer \startchapter[ownnumber=3D1,title=3DAnswers and solutions] \useblocks[answer] \stopchapter \stoptext %%%% end interactive-question-answer.tex > On 6 Nov 2016, at 23:43, Jeong Dal wrote: >=20 > Dear Otared, >=20 > Hi, > I run the given code and got an error message as following. >=20 > tex error > tex error on line 1 in file = virtual://block.answer.2: ! Undefined control = sequence >=20 > l.1 \myanswer > [Q:test] >=20 > >=20 > Would you please tell me how to avoid such an error? > It seems to me that you don=E2=80=99t have an error. >=20 > I am running minimal(beta) in OSX. >=20 > Thank you. >=20 > Best regards, >=20 > Dalyoung > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_D8E5673D-0A79-44DF-9691-CB435B66AC05 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Dear Dalyoung,

I guess you are typesetting the wrong file, or you have put = the last code I sent into a file which contains something of the = previous codes=E2=80=A6
Indeed in the last file I = sent (which I am sending again at the end of this reply) does not = contain the command \myanswer=E2=80=A6 which appears in your error = message.

Please = test the code below and let me know if you encunter a problem.

Best regards: = OK
%%%% begin = interactive-question-answer.tex
%%%% Here, = following Wolfgang Schuster's ideas, 
%%%% we = define some macros allowing to couple
%%%% = Questions and Answers in an automatic way
%%%% Upon = clicking on an interactive title for Question or Answer
%%%% one goes to the corresponding Answer or = Question

\setupinteraction[state=3Dstart]

% We define two counters which follow = the numbers
% appearing in Question and = Answer

\newcounter\QuestionCounter
\newcounter\AnswerCounter

% We create two commands to be used in = the
% enumeration environments
%= Note that the check for trial typestting 
% = \doifnotmode{*trialtypesetting}
% is necessary in = order to avoid unwanted incrementation
\define[1]\QuestionTextCommand
  = {\doifnotmode{*trialtypesetting}
    =  {\doglobal\increment\QuestionCounter
  =     \pagereference[question:\QuestionCounter]}%
  =  \doifreferencefoundelse{answer:\QuestionCounter}
    =  {\goto{#1}[answer:\QuestionCounter]}
  =    {#1}}

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

% We define here two enumeration environments for
% Questions and Answers
\defineenumeration[question]
= [text=3DQuestion,
= headcommand=3D\QuestionTextCommand,
= number=3Dyes,
prefix=3Dyes,
= prefixsegments=3Dchapter,
= coupling=3Danswer]

\defineenumeration[answer]
= [text=3DAnswer,
= headcommand=3D\AnswerTextCommand,
= number=3Dyes,
prefix=3Dyes,
= prefixsegments=3Dchapter,
= coupling=3Dquestion]

% Each question is followed immediately by its = answer.
% The answers are put in a block which will = be used later
\defineblock[answer]
\hideblocks[answer]

% We define a command used after a =  
% Question for which no Answer is = provided
% Since the block commands 
% \beginanswer ... \endanswer
% cannot = be used directly in a macro definition
% we use a = trick...
% In the buffer the two counters = associated to Answer
% are incremented...
\startbuffer[noanswer]
    = \beginanswer
    = \doglobal\increment\AnswerCounter
    = \incrementcounter[answer]
    = \endanswer
\stopbuffer

% ...and then the above buffer is = invoked
\define\noanswer
  = {\getbuffer[noanswer]}

% example of use:
\starttext
\startchapter[title=3DQuestions]

\startquestion[q:1]
Prove that ${\rm e}\sim 2.73$ is irrational.
    
This is the first = question, with its own reference, for later use.
\stopquestion
  =   
\beginanswer
\startanswer
This is the answer to the = first question (to \in{Question}[q:1]).
\stopanswer
\endanswer

\startquestion 
This is the second = question, without its own reference.
\stopquestion
  =   
\beginanswer
\startanswer[a:Test]
This is the answer = to the second question. 

(Note that this answer has a reference = named \type{a:Test}).
\stopanswer
\endanswer

\startquestion[q:Obvious]
This is the = third question, an easy one, without a given solution.
\stopquestion

% we increment here the counters for Answer
\noanswer

\startquestion[q:2]
This is the fourth = question with its own reference.
\stopquestion

\beginanswer
\startanswer
This is the answer to the fourth question: use the result of = \in{Question}[q:1].
\stopanswer
\endanswer

\startquestion 
This is the fifth = question, without its own reference. 

({\it Hint:} look again at = \in{Question}[q:Obvious]).
\stopquestion
    
\beginanswer
\startanswer
This is the answer to the = fifth question. Read again \in{Answer}[a:Test].
\stopanswer
\endanswer  

\stopchapter

% Here we say = ownnumber=3D1, in order to match the prefix 
% = of numbers associated to Answer
\startchapter[ownnumber=3D1,title=3DAnswers and = solutions]
\useblocks[answer]
\stopchapter

\stoptext
%%%% end = interactive-question-answer.tex




On 6 Nov 2016, at 23:43, Jeong = Dal <haksan@me.com> = wrote:

Dear = Otared,

Hi,
I run the given  code and got an error message as = following.

tex error       > tex error on line = 1 in file virtual://block.answer.2: ! Undefined control = sequence

l.1 = \myanswer
       =     [Q:test]
<empty = file>

Would = you please tell me how to avoid such an error?
It = seems to me that you don=E2=80=99t have an error.
I am running minimal(beta) in = OSX.

Thank = you.

Best = regards,

Dalyoung
_____________________________________= ______________________________________________
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
_______________________________________________________________= ____________________

= --Apple-Mail=_D8E5673D-0A79-44DF-9691-CB435B66AC05-- --===============5157493861873485480== 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 --===============5157493861873485480==--