Re: [NTG-context] setuphead for in-paragraph head ?
But this: \definehead [Exercise] [subsection] [after=] \starttext \startExercise [title=This is the exercise's title] The exercise's content. \stopExercise \stoptext results to: 1 This is the exercise's title The exercise's content. and I would like it to be: 1 This is the exercise's title The exercise's content. (When I can typeset that, I will see about formatting the number and so on.) I'm sorry it wasn't very clear. Now I understand that I misunderstood \startExercise{...} for \startExercise[title=...] and that's why I was confused about which newline I want to get rid of. Jean-Guillaume
Am 09.01.2014 um 14:23 schrieb Jean-Guillaume
But this:
\definehead [Exercise] [subsection] [after=] \starttext \startExercise [title=This is the exercise's title] The exercise's content. \stopExercise \stoptext
results to:
1 This is the exercise's title The exercise's content.
and I would like it to be:
1 This is the exercise's title The exercise's content.
(When I can typeset that, I will see about formatting the number and so on.)
I'm sorry it wasn't very clear. Now I understand that I misunderstood \startExercise{...} for \startExercise[title=...] and that's why I was confused about which newline I want to get rid of.
\definehead [Exercise] [subsection] [alternative=text, distance=0.5em, insidesection=\ignorespaces] Wolfgang
Hi Jean Guillaume,
I guess Marco Patzer and Wolfgang Schuster gave you already the appropriate answers.
Nevertheless, I wanted to share with you the definitions I use for the kind of work you want to do:
%%% begin example-exercise.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% defining \startexo, \stopexo as an enumeration:
\startsetups style:simple
\defineenumeration[exo]
[alternative=hanging,
width=fit,
stopper={.},
text=Exercise,
% between=,
before=,
after=\blank]
\stopsetups % style:simple
\startsetups style:textrule
\definenumber[MyExoNumber][way=bysection,sectionumber=yes]
\setuptextrules[rulecolor=darkred]
\define\ExoCommand{\incrementnumber[MyExoNumber]
\textrule[top]{Exercise \getnumber[MyExoNumber]}
\startbackground[frame=off,leftframe=on,backgroundcolor=white,
framecolor=darkred]}
\defineenumeration[exo]
[alternative=hanging,
width=fit,
text={},
number=hide,
number=no,
before={\ExoCommand},
after={\stopbackground\blank}]
\stopsetups % style:textrule
% end defining \startexo, \stopexo as an enumeration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%defining numbered questions
\defineconversion[exercise][\numbers]
%\setupitemize[packed]
\def\StartQuestions{%
\startitemize[exercise][width=2em,packed,style=bold,stopper=,right=)]}
\def\StopQuestions{\stopitemize}
\def\q{\item}
% trye each of the following
\setups[style:simple]
%\setups[style:textrule]
\starttext
\startexo
Prove that for all $a,b\in {\Bbb K}$, a field of characteristic 2, one has $(a+b)^2 = a^2 + b^2$.
\stopexo
\startexo
Prove that for all $a,b\in {\Bbb K}$, a field of characteristic 2, one has $(a+b)^4 = a^4 + b^4$.
\stopexo
\startexo
\StartQuestions
\q Prove that
\startformula
\sum_{n=1}^\infty{1 \over n^2} = {\pi^2 \over 6}.
\stopformula
\q Prove that for any $n \geq 1$ integer one has
\startformula
\sum_{k=1}^n k^3 = \left({n(n+1) \over 2}\right)^2.
\stopformula
\StopQuestions
\stopexo
\stoptext
%%% end example-exercise.tex
Best regards: OK
On 9 janv. 2014, at 14:23, Jean-Guillaume
But this:
\definehead [Exercise] [subsection] [after=] \starttext \startExercise [title=This is the exercise's title] The exercise's content. \stopExercise \stoptext
results to:
1 This is the exercise's title The exercise's content.
and I would like it to be:
1 This is the exercise's title The exercise's content.
(When I can typeset that, I will see about formatting the number and so on.)
I'm sorry it wasn't very clear. Now I understand that I misunderstood \startExercise{...} for \startExercise[title=...] and that's why I was confused about which newline I want to get rid of.
Jean-Guillaume ___________________________________________________________________________________ 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 ___________________________________________________________________________________
Hello Otared. I will throw this one... Thanx. Once I was using exercise-answer package for LaTeX. Is there anything like this to use in ConTeXt? Thanx Jaroslav Hajtmar Dne 9.1.2014 15:19, Otared Kavian napsal(a):
%%% begin example-exercise.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % defining \startexo, \stopexo as an enumeration: \startsetups style:simple \defineenumeration[exo] [alternative=hanging, width=fit, stopper={.}, text=Exercise, % between=, before=, after=\blank] \stopsetups % style:simple
\startsetups style:textrule \definenumber[MyExoNumber][way=bysection,sectionumber=yes] \setuptextrules[rulecolor=darkred] \define\ExoCommand{\incrementnumber[MyExoNumber] \textrule[top]{Exercise \getnumber[MyExoNumber]} \startbackground[frame=off,leftframe=on,backgroundcolor=white, framecolor=darkred]}
\defineenumeration[exo] [alternative=hanging, width=fit, text={}, number=hide, number=no, before={\ExoCommand}, after={\stopbackground\blank}] \stopsetups % style:textrule
% end defining \startexo, \stopexo as an enumeration %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%defining numbered questions \defineconversion[exercise][\numbers] %\setupitemize[packed] \def\StartQuestions{% \startitemize[exercise][width=2em,packed,style=bold,stopper=,right=)]} \def\StopQuestions{\stopitemize} \def\q{\item}
% trye each of the following \setups[style:simple] %\setups[style:textrule]
\starttext \startexo Prove that for all $a,b\in {\Bbb K}$, a field of characteristic 2, one has $(a+b)^2 = a^2 + b^2$. \stopexo
\startexo Prove that for all $a,b\in {\Bbb K}$, a field of characteristic 2, one has $(a+b)^4 = a^4 + b^4$. \stopexo
\startexo \StartQuestions \q Prove that \startformula \sum_{n=1}^\infty{1 \over n^2} = {\pi^2 \over 6}. \stopformula
\q Prove that for any $n \geq 1$ integer one has \startformula \sum_{k=1}^n k^3 = \left({n(n+1) \over 2}\right)^2. \stopformula \StopQuestions \stopexo
\stoptext %%% end example-exercise.tex
On 9 janv. 2014, at 15:48, Jaroslav Hajtmar
Hello Otared. I will throw this one... Thanx.
Once I was using exercise-answer package for LaTeX. Is there anything like this to use in ConTeXt?
Thanx Jaroslav Hajtmar
Hello Jaroslav, I have something like the following which was given to me by Hans a long time ago: unfortunately for some reason this does not work anymore with ConTeXt mkiv, but it is quite fine with mkii: %%% begin question-hint-answer.tex \defineblock[question] \defineblock[hint] \defineblock[answer] \defineenumeration[question][location=hanging,text={Question},stopper={.}] \defineenumeration[hint][location=hanging,text={Hint for question},stopper={.}] \defineenumeration[answer][location=hanging,text={Answer to question},stopper={.}] \hideblocks[hint] \hideblocks[answer] \starttext \section{Questions} \beginquestion \question Compute $4\times 5$. \beginhint \hint Use the fact that $2\times 5 = 10$. \endhint \beginanswer \answer $20$. \endanswer \endquestion \beginquestion \question What is the value of $100 / 10$? \beginhint \hint Remember that $10\times 10 = 100$. \endhint \beginanswer \answer $10$ \endanswer \endquestion \section{Hints} \useblocks[hint] \section{Answers} \useblocks[answer] \stoptext %%% end question-hint-answer.tex Best regards: OK
Dne 9.1.2014 15:19, Otared Kavian napsal(a):
%%% begin example-exercise.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % defining \startexo, \stopexo as an enumeration: \startsetups style:simple \defineenumeration[exo] [alternative=hanging, width=fit, stopper={.}, text=Exercise, % between=, before=, after=\blank] \stopsetups % style:simple
\startsetups style:textrule \definenumber[MyExoNumber][way=bysection,sectionumber=yes] \setuptextrules[rulecolor=darkred] \define\ExoCommand{\incrementnumber[MyExoNumber] \textrule[top]{Exercise \getnumber[MyExoNumber]} \startbackground[frame=off,leftframe=on,backgroundcolor=white, framecolor=darkred]}
\defineenumeration[exo] [alternative=hanging, width=fit, text={}, number=hide, number=no, before={\ExoCommand}, after={\stopbackground\blank}] \stopsetups % style:textrule
% end defining \startexo, \stopexo as an enumeration %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%defining numbered questions \defineconversion[exercise][\numbers] %\setupitemize[packed] \def\StartQuestions{% \startitemize[exercise][width=2em,packed,style=bold,stopper=,right=)]} \def\StopQuestions{\stopitemize} \def\q{\item}
% trye each of the following \setups[style:simple] %\setups[style:textrule]
\starttext \startexo Prove that for all $a,b\in {\Bbb K}$, a field of characteristic 2, one has $(a+b)^2 = a^2 + b^2$. \stopexo
\startexo Prove that for all $a,b\in {\Bbb K}$, a field of characteristic 2, one has $(a+b)^4 = a^4 + b^4$. \stopexo
\startexo \StartQuestions \q Prove that \startformula \sum_{n=1}^\infty{1 \over n^2} = {\pi^2 \over 6}. \stopformula
\q Prove that for any $n \geq 1$ integer one has \startformula \sum_{k=1}^n k^3 = \left({n(n+1) \over 2}\right)^2. \stopformula \StopQuestions \stopexo
\stoptext %%% end example-exercise.tex
___________________________________________________________________________________ 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 ___________________________________________________________________________________
On Thu, 9 Jan 2014, Otared Kavian wrote:
On 9 janv. 2014, at 15:48, Jaroslav Hajtmar
wrote: Hello Otared. I will throw this one... Thanx.
Once I was using exercise-answer package for LaTeX. Is there anything like this to use in ConTeXt?
Thanx Jaroslav Hajtmar
Hello Jaroslav,
I have something like the following which was given to me by Hans a long time ago: unfortunately for some reason this does not work anymore with ConTeXt mkiv, but it is quite fine with mkii:
(Untested): Change location=hanging to alternative=hanging.
%%% begin question-hint-answer.tex \defineblock[question] \defineblock[hint] \defineblock[answer]
\defineenumeration[question][location=hanging,text={Question},stopper={.}] \defineenumeration[hint][location=hanging,text={Hint for question},stopper={.}] \defineenumeration[answer][location=hanging,text={Answer to question},stopper={.}]
Aditya
Am 09.01.2014 um 16:36 schrieb Otared Kavian
On 9 janv. 2014, at 15:48, Jaroslav Hajtmar
wrote: Hello Otared. I will throw this one... Thanx.
Once I was using exercise-answer package for LaTeX. Is there anything like this to use in ConTeXt?
Thanx Jaroslav Hajtmar
Hello Jaroslav,
I have something like the following which was given to me by Hans a long time ago: unfortunately for some reason this does not work anymore with ConTeXt mkiv, but it is quite fine with mkii:
Add \keepblocks[question]. Wolfgang
Hi Wolfgang, Hi Aditya,
Thanks for your attention.
Unfortunately adding
\keepblocks[question]
the example I sent before does not work in mkiv, and changing
location=hanging
to
alternative=hanging
does not help neither…
The error message in mkiv is:
\dostopnormalblock ...meter \c!after \par \egroup
<argument> ...fact that $2\times 5 = 10$. \dostopnormalblock
\dostartnormalblock {hint}...
\dodowithpar ...dler \v!construction \endcsname #1
\csname \??constructionsto…
So I don’t know what to do if one has to use mkiv.
Best regards: OK
On 9 janv. 2014, at 18:23, Wolfgang Schuster
Am 09.01.2014 um 16:36 schrieb Otared Kavian
: On 9 janv. 2014, at 15:48, Jaroslav Hajtmar
wrote: Hello Otared. I will throw this one... Thanx.
Once I was using exercise-answer package for LaTeX. Is there anything like this to use in ConTeXt?
Thanx Jaroslav Hajtmar
Hello Jaroslav,
I have something like the following which was given to me by Hans a long time ago: unfortunately for some reason this does not work anymore with ConTeXt mkiv, but it is quite fine with mkii:
Add \keepblocks[question].
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 ___________________________________________________________________________________
Am 09.01.2014 um 18:36 schrieb Otared Kavian
Hi Wolfgang, Hi Aditya,
Thanks for your attention. Unfortunately adding \keepblocks[question] the example I sent before does not work in mkiv, and changing location=hanging to alternative=hanging does not help neither… The error message in mkiv is: \dostopnormalblock ...meter \c!after \par \egroup
<argument> ...fact that $2\times 5 = 10$. \dostopnormalblock \dostartnormalblock {hint}... \dodowithpar ...dler \v!construction \endcsname #1 \csname \??constructionsto…
So I don’t know what to do if one has to use mkiv.
When you enumerations in this form \beginanswer \answer $10$ \endanswer you have to finish the paragraph, e.g. by adding \par \beginanswer \answer $10$\par \endanswer or better use the start/stop commands for the enumeration. \beginanswer \startanswer $10$ \stopanswer \endanswer Wolfgang
Hello Wolfgang, Otared and Aditya. Thanks for your advice and treatments. It is there a complete working example? I am sorry, but I am not able to achieve the proposed modifications to make it work. Thanx. Jaroslav Hajtmar Dne 9.1.2014 18:41, Wolfgang Schuster napsal(a):
Am 09.01.2014 um 18:36 schrieb Otared Kavian
mailto:otared@gmail.com>: Hi Wolfgang, Hi Aditya,
Thanks for your attention. Unfortunately adding \keepblocks[question] the example I sent before does not work in mkiv, and changing location=hanging to alternative=hanging does not help neither… The error message in mkiv is: \dostopnormalblock ...meter \c!after \par \egroup
<argument> ...fact that $2\times 5 = 10$. \dostopnormalblock \dostartnormalblock {hint}... \dodowithpar ...dler \v!construction \endcsname #1 \csname \??constructionsto…
So I don’t know what to do if one has to use mkiv.
When you enumerations in this form
\beginanswer \answer $10$ \endanswer
you have to finish the paragraph, e.g. by adding \par
\beginanswer \answer $10$\par \endanswer
or better use the start/stop commands for the enumeration.
\beginanswer \startanswer $10$ \stopanswer \endanswer
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 ___________________________________________________________________________________
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.
Best regards: OK
On 9 janv. 2014, at 18:41, Wolfgang Schuster
[…] When you enumerations in this form
\beginanswer \answer $10$ \endanswer
you have to finish the paragraph, e.g. by adding \par
\beginanswer \answer $10$\par \endanswer
or better use the start/stop commands for the enumeration.
\beginanswer \startanswer $10$ \stopanswer \endanswer
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 ___________________________________________________________________________________
Am 11.01.2014 um 00:36 schrieb Otared Kavian
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
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
Am 11.01.2014 um 00:36 schrieb Otared Kavian
: 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 ___________________________________________________________________________________
Hello Otared and Wolfgang. Thanks for launching this example. Is there a possibility to write the answers into a more compact form (more columns, one paragraph, etc) like in any textbooks? I tried experimenting, but I was unable to put answers into a compact form. Thanks Jaroslav Hajtmar Here is my modification of answer enumeration (not working): %%%% 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, beforehead=, afterhead=, before={\startcolumns[n=4]}, after=\stopcolumns, width=0.5em, text={}, headstyle={}, 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 \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 \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 \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 Dne 11.1.2014 20:01, Otared Kavian napsal(a):
%%%% 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
Hi Jaroslav,
Actually the formatting of what you put in the block determined for example by
\beginanswer
The answer is…
\endanswer
is independent of the block mechanism: you can use whatever structure you want. In the example we exchanged on, an enumeration such as
\startanswer
\stopanswer
where this \start \stop has been defined by \defineenumeration[answer], but you can use your own compact formatting instead of this.
Best regards: OK
On 12 janv. 2014, at 11:45, Jaroslav Hajtmar
Hello Otared and Wolfgang.
Thanks for launching this example. Is there a possibility to write the answers into a more compact form (more columns, one paragraph, etc) like in any textbooks? I tried experimenting, but I was unable to put answers into a compact form. Thanks Jaroslav Hajtmar
Here is my modification of answer enumeration (not working):
%%%% 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, beforehead=, afterhead=, before={\startcolumns[n=4]}, after=\stopcolumns, width=0.5em, text={}, headstyle={}, 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
\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
\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 \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
Dne 11.1.2014 20:01, Otared Kavian napsal(a):
%%%% 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
___________________________________________________________________________________ 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 ___________________________________________________________________________________
OK. Thanx very much - for me it is a useful thing... Jaroslav Hajtmar Dne 12.1.2014 17:08, Otared Kavian napsal(a):
Hi Jaroslav,
Actually the formatting of what you put in the block determined for example by \beginanswer The answer is… \endanswer is independent of the block mechanism: you can use whatever structure you want. In the example we exchanged on, an enumeration such as \startanswer \stopanswer where this \start \stop has been defined by \defineenumeration[answer], but you can use your own compact formatting instead of this.
Best regards: OK
On 12 janv. 2014, at 11:45, Jaroslav Hajtmar
wrote: Hello Otared and Wolfgang.
Thanks for launching this example. Is there a possibility to write the answers into a more compact form (more columns, one paragraph, etc) like in any textbooks? I tried experimenting, but I was unable to put answers into a compact form. Thanks Jaroslav Hajtmar
Here is my modification of answer enumeration (not working):
%%%% 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, beforehead=, afterhead=, before={\startcolumns[n=4]}, after=\stopcolumns, width=0.5em, text={}, headstyle={}, 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
\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
\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 \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
Dne 11.1.2014 20:01, Otared Kavian napsal(a):
%%%% 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
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 ___________________________________________________________________________________
Am 11.01.2014 um 20:01 schrieb Otared Kavian
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.
Not without writing your own environment where you generate a unique reference for each question, hint and answer. Wolfgang
On 12 janv. 2014, at 21:30, Wolfgang Schuster
Am 11.01.2014 um 20:01 schrieb Otared Kavian
: 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.
Not without writing your own environment where you generate a unique reference for each question, hint and answer.
If I understand well, one way might be something like (where \theQuestionNumber stands for the number given by \startquestion) \define\StartQuestion{\startquestion[Q:\theQuestionNumber]} \define\StartHint{\startquestion[H:\theQuestionNumber]} \define\StartAnswer{\startquestion[A:\theQuestionNumber]} \define\StopQuestion{\par\in{Hint}[H:\theQuestionNumber]\par \in{Answer}[A:\theQuestionNumber]\stopquestion} \define\StopHint{\par\in{Question}[Q:\theQuestionNumber]\par \in{Answer}[A:\theQuestionNumber]\stophint} \define\StopAnswer{\par\in{Question}[Q:\theQuestionNumber]\par \in{Hint}[H:\theQuestionNumber]\stopquestion} and then using \StartQuestion \StopQuestion, etc, instead of \startquestion \stopquestion. But how can I refer to the \theQuestionNumber set by \startquestion? Thanks for your time and your attention. Best regards: OK
Am 12.01.2014 um 21:47 schrieb Otared Kavian
On 12 janv. 2014, at 21:30, Wolfgang Schuster
wrote: Am 11.01.2014 um 20:01 schrieb Otared Kavian
: 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.
Not without writing your own environment where you generate a unique reference for each question, hint and answer.
If I understand well, one way might be something like (where \theQuestionNumber stands for the number given by \startquestion)
\define\StartQuestion{\startquestion[Q:\theQuestionNumber]} \define\StartHint{\startquestion[H:\theQuestionNumber]} \define\StartAnswer{\startquestion[A:\theQuestionNumber]} \define\StopQuestion{\par\in{Hint}[H:\theQuestionNumber]\par \in{Answer}[A:\theQuestionNumber]\stopquestion} \define\StopHint{\par\in{Question}[Q:\theQuestionNumber]\par \in{Answer}[A:\theQuestionNumber]\stophint} \define\StopAnswer{\par\in{Question}[Q:\theQuestionNumber]\par \in{Hint}[H:\theQuestionNumber]\stopquestion}
and then using \StartQuestion \StopQuestion, etc, instead of \startquestion \stopquestion. But how can I refer to the \theQuestionNumber set by \startquestion?
When you have only questions and answers you can use the coupling key but in your case something like below is necessary: \defineenumeration[Question] \defineenumeration[Answer] \define\startquestion {\increment\QuestionCounter \expanded{\startQuestion[reference=Question:\QuestionCounter]}} \define\stopquestion {\stopQuestion \par \in{Answer}[Answer:\QuestionCounter]} \define\startanswer {\expanded{\startAnswer[reference=Answer:\QuestionCounter]}} \define\stopanswer {\stopAnswer \par \in{Question}[Question:\QuestionCounter]} \setupinteraction[state=start] \starttext \startquestion What is the answer to life the universe and everything? \stopquestion \page \startanswer 42. \stopanswer \stoptext Wolfgang
Hi Wolfgang,
Thanks for the tip: I’ll try to adapt what you suggest to the case of blocks and question-hint-answer, and then let you know if I succeed.
Out of curiosity, how can one access the counter associated to an enumeration or an item?
Also, if I understand correctly, the command
\increment\QuestionCounter
creates first a counter named QuestionCounter, if it does not exist yet, and then increments its value: so one does not need anymore commands such as
\newcounter\QuestionCounter
before incrementing it. Am I right?
Best regards: OK
On 12 janv. 2014, at 22:40, Wolfgang Schuster
[…] When you have only questions and answers you can use the coupling key but in your case something like below is necessary:
\defineenumeration[Question] \defineenumeration[Answer]
\define\startquestion {\increment\QuestionCounter \expanded{\startQuestion[reference=Question:\QuestionCounter]}}
\define\stopquestion {\stopQuestion \par \in{Answer}[Answer:\QuestionCounter]}
\define\startanswer {\expanded{\startAnswer[reference=Answer:\QuestionCounter]}}
\define\stopanswer {\stopAnswer \par \in{Question}[Question:\QuestionCounter]}
\setupinteraction[state=start]
\starttext
\startquestion What is the answer to life the universe and everything? \stopquestion
\page
\startanswer 42. \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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
Am 13.01.2014 um 04:41 schrieb Otared Kavian
Hi Wolfgang,
Thanks for the tip: I’ll try to adapt what you suggest to the case of blocks and question-hint-answer, and then let you know if I succeed. Out of curiosity, how can one access the counter associated to an enumeration or an item?
You can use \rawcountervalue[<name of the enumeration environment>] or \convertedcounter[<name of the environment>].
Also, if I understand correctly, the command \increment\QuestionCounter creates first a counter named QuestionCounter, if it does not exist yet, and then increments its value: so one does not need anymore commands such as \newcounter\QuestionCounter before incrementing it. Am I right?
No, you don’t need \newcounter because \increment checks if the counter exists because it tries to increase the value. The \newcounter command which creates the counter can also be used to reset the value and not only to create the counter. Wolfgang
participants (5)
-
Aditya Mahajan
-
Jaroslav Hajtmar
-
Jean-Guillaume
-
Otared Kavian
-
Wolfgang Schuster