ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Otared Kavian <otared@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: setuphead for in-paragraph head ?
Date: Sat, 11 Jan 2014 20:01:31 +0100	[thread overview]
Message-ID: <1CEEA7A0-3472-47A6-9AE9-C7D14CB379D4@gmail.com> (raw)
In-Reply-To: <7528AB5C-EF48-4393-869C-8DD3AA6D8C38@gmail.com>

Hi Wolfgang,

Many thanks for your attention and insight.
With your code everything works as expected. In case others would be interested, I give here a slight modification of what you sent, which works very well with mkiv: I only added 
	\setupblock[question][before={\startquestion},after={\stopquestion}]
so that one can just say \beginquestion \endquestion without having to enter each time \startquestion \stopquestion. I don’t know whether this is a good idea or not, as it may have side effects…

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.

Best regards: OK
PS: here is the complete example for question-hint-answer:

%%%% begin question-hint-answer-blocks.tex
\defineblock[question]
\defineblock[hint]
\defineblock[answer]

\defineenumeration[question]
	[alternative=hanging,
	width=2.5cm,
	text={Question},
	headstyle={\bi},
	stopper={.}]
	
\defineenumeration[hint]
	[alternative=hanging,
	width=4cm,
	text={Hint for question},
	headstyle={\bi},
	stopper={.}]

\defineenumeration[answer]
	[alternative=hanging,
	width=4.5cm,
	text={Answer to question},
	headstyle={\bi},
	stopper={.}]

\setupblock[question][before={\startquestion},after={\stopquestion}]
\setupblock[hint][before={\starthint},after={\stophint}]
\setupblock[answer][before={\startanswer},after={\stopanswer}]

\keepblocks[question]
\hideblocks[hint]
\hideblocks[answer]

\starttext

\section{Questions}

\beginquestion
  Compute $4\times 5$.
\endquestion

\beginhint
  Use the fact that $2\times 5 = 10$.
\endhint

\beginanswer
  $20$.
\endanswer

\beginquestion
  What is the value of $100 / 10$?
\endquestion

\beginhint
Remember that $10\times 10 = 100$.
\endhint

\beginanswer
$10$
\endanswer

\section{Hints to all questions}

\useblocks[hint]

\section{Answers to all questions}

\useblocks[answer]

\stoptext
%%%% end question-hint-answer-blocks.tex


On 11 janv. 2014, at 10:12, Wolfgang Schuster <schuster.wolfgang@gmail.com> wrote:

> 
> Am 11.01.2014 um 00:36 schrieb Otared Kavian <otared@gmail.com>:
> 
>> Hi Wolfgang,
>> 
>> In mkiv, even using \startanswer, \stopanswer (and the same syntax with questions and hints) the blocks mechanism seems to be broken.
>> The error message is still the following:
>> 
>> \dostopnormalblock ...meter \c!after \par \egroup 
>>                                                   
>> <argument> ...fact that $2\times 5 = 10$. \dostopnormalblock 
>>                                                   \dostartnormalblock {hint}...
>> \dodowithpar ...dler \v!construction \endcsname #1
>>                                                   \csname \??constructionsto...
>> 
>> When I understand a little bit more about that mechanism I’ll do other testings and eventually ask Hans about what has been changed regarding blocks.
> 
> You have to convert the question, hint and answer environment.
> 
> What the block environment does is to save the content from the begin to the end block and hides it when you use \hideblocks[…]. To output the content of the environments you can use \useblocks[…].
> 
> 
> \defineblock[question]
> \defineblock[hint]
> \defineblock[answer]
> 
> \defineenumeration[question][alternative=hanging,text={Question},stopper={.}]
> \defineenumeration[hint]    [alternative=hanging,text={Hint for question},stopper={.}]
> \defineenumeration[answer]  [alternative=hanging,text={Answer to question},stopper={.}]
> 
> \keepblocks[question]
> \hideblocks[hint]
> \hideblocks[answer]
> 
> \starttext
> 
> \section{Questions}
> 
> \beginquestion
> 
> \startquestion
>   Compute $4\times 5$.
> \stopquestion
> 
> \beginhint
> \starthint
>   Use the fact that $2\times 5 = 10$.
> \stophint
> \endhint
> 
> \beginanswer
> \startanswer
>   $20$.
> \stopanswer
> \endanswer
> 
> \endquestion
> 
> \beginquestion
> 
> \startquestion
>   What is the value of $100 / 10$?
> \stopquestion
> 
> \beginhint
> \starthint
> Remember that $10\times 10 = 100$.
> \stophint
> \endhint
> 
> \beginanswer
> \startanswer
> $10$
> \stopanswer
> \endanswer
> 
> \endquestion
> 
> \section{Hints}
> 
> \useblocks[hint]
> 
> \section{Answers}
> 
> \useblocks[answer]
> 
> \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
> ___________________________________________________________________________________

___________________________________________________________________________________
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	other threads:[~2014-01-11 19:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-09 13:23 Jean-Guillaume
2014-01-09 13:24 ` Wolfgang Schuster
2014-01-09 14:19 ` Otared Kavian
2014-01-09 14:48   ` Jaroslav Hajtmar
2014-01-09 15:36     ` Otared Kavian
2014-01-09 17:12       ` Aditya Mahajan
2014-01-09 17:23       ` Wolfgang Schuster
2014-01-09 17:36         ` Otared Kavian
2014-01-09 17:41           ` Wolfgang Schuster
2014-01-10  6:56             ` Jaroslav Hajtmar
2014-01-10 23:36             ` Otared Kavian
2014-01-11  9:12               ` Wolfgang Schuster
2014-01-11 19:01                 ` Otared Kavian [this message]
2014-01-12 10:45                   ` Jaroslav Hajtmar
2014-01-12 16:08                     ` Otared Kavian
2014-01-12 19:29                       ` Jaroslav Hajtmar
2014-01-12 20:30                   ` Wolfgang Schuster
2014-01-12 20:47                     ` Otared Kavian
2014-01-12 21:40                       ` Wolfgang Schuster
2014-01-13  3:41                         ` Otared Kavian
2014-01-13 10:07                           ` Wolfgang Schuster
  -- strict thread matches above, loose matches on Subject: below --
2014-01-09 12:44 Jean-Guillaume
2014-01-09 13:03 ` Marco Patzer
2014-01-09  9:43 Jean-Guillaume
2014-01-09 11:27 ` Marco Patzer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1CEEA7A0-3472-47A6-9AE9-C7D14CB379D4@gmail.com \
    --to=otared@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).