ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Resetting references or local references?
@ 2011-11-27 22:27 Otared Kavian
  2011-11-27 23:10 ` Wolfgang Schuster
  0 siblings, 1 reply; 4+ messages in thread
From: Otared Kavian @ 2011-11-27 22:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear all,

Is it possible to have a sort of « local references for formulas » or else to clear previous references to formulas at a certain point?
In a chapter where a certain number of exercices and formulas are to be numbered, assume I have the following minimal example

%%%%%%%%% begin
\starttext

Exercice 1. Prove that if $ab=ba$ and $2ab=0$ then
\placeformula[eq:1]
\startformula
(a+b)^2 = a^2 + b^2.
\stopformula
Using the identity (\in[eq:1]) prove that $(a=b)^{2n} = a^{2n} + b^{2n}$.

\blank[big]
\hrule
\blank[big]

Exercice 2. Prove that for any integer $n$
\resetnumber[formula]
%\reset[formulas][references]
\placeformula[eq:2] % I would like the reference to be [eq:1]
\startformula
(\cos(x) + {\rm i}\sin(x))^n = \cos(nx) + {\rm i} \sin(nx).
\stopformula
Using the identity (\in[eq:2]) % I would like here to say [eq:1]
 compute $\cos{3x}$.

\stoptext
%%%%%%%%% end

I would like to be able to have the equations numbered within each exercise (which is in fact defined through an enumeration environment), and be able to have the reference to each formula « local » within that exercise.
The resaon is that the execises and problems may have several equations which are referenced to with [eq:1] through [eq:10] (say…), and have been prepared and given previously to students on independent sheets. When I want to give out a booklet of all the exercises, then it would be handy to have such a feature.

I understand that I am not being very clear… Hope someone would understand what I mean and need :-)

Best regards: OK
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Resetting references or local references?
  2011-11-27 22:27 Resetting references or local references? Otared Kavian
@ 2011-11-27 23:10 ` Wolfgang Schuster
  2011-11-28  9:18   ` Otared Kavian
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Schuster @ 2011-11-27 23:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 27.11.2011 um 23:27 schrieb Otared Kavian:

> Dear all,
> 
> Is it possible to have a sort of « local references for formulas » or else to clear previous references to formulas at a certain point?
> In a chapter where a certain number of exercices and formulas are to be numbered, assume I have the following minimal example
> 
> %%%%%%%%% begin
> \starttext
> 
> Exercice 1. Prove that if $ab=ba$ and $2ab=0$ then
> \placeformula[eq:1]
> \startformula
> (a+b)^2 = a^2 + b^2.
> \stopformula
> Using the identity (\in[eq:1]) prove that $(a=b)^{2n} = a^{2n} + b^{2n}$.
> 
> \blank[big]
> \hrule
> \blank[big]
> 
> Exercice 2. Prove that for any integer $n$
> \resetnumber[formula]
> %\reset[formulas][references]
> \placeformula[eq:2] % I would like the reference to be [eq:1]
> \startformula
> (\cos(x) + {\rm i}\sin(x))^n = \cos(nx) + {\rm i} \sin(nx).
> \stopformula
> Using the identity (\in[eq:2]) % I would like here to say [eq:1]
> compute $\cos{3x}$.
> 
> \stoptext
> %%%%%%%%% end
> 
> I would like to be able to have the equations numbered within each exercise (which is in fact defined through an enumeration environment), and be able to have the reference to each formula « local » within that exercise.
> The resaon is that the execises and problems may have several equations which are referenced to with [eq:1] through [eq:10] (say…), and have been prepared and given previously to students on independent sheets. When I want to give out a booklet of all the exercises, then it would be handy to have such a feature.
> 
> I understand that I am not being very clear… Hope someone would understand what I mean and need :-)

Look at page 168: http://pragma-ade.com/general/manuals/cont-enp.pdf

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Resetting references or local references?
  2011-11-27 23:10 ` Wolfgang Schuster
@ 2011-11-28  9:18   ` Otared Kavian
  2011-11-28 10:24     ` Wolfgang Schuster
  0 siblings, 1 reply; 4+ messages in thread
From: Otared Kavian @ 2011-11-28  9:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 4598 bytes --]

Hi Wolfgang,

Many thanks for your attention and the link you sent.
I looked up the chapter on references of the main manuel written by Hans, but unfortunately I could not find a solution, or could not adapt what is said there. 
It can be that I have to change my approach of defining my « exercises », for instance by defining each exercise as a section or subsection? 
Up to now I have two ways of defining an « exercise »: 
	• one is with \defineenumeration[Exo] (when using mkii), 
	• the other one is with \defineannotation[Exo] and your annotation module when using mkiv.

In neither case the command
	\setupreferencing[prefix=+]
or
	\setupannotation[Exo][prefix=+]
seems to generate local tags. 

Just in case, below is a minimal file, which shows how I use the annotation module.

Best regards: OK
%%%%%%%%%% begin
\setupinteraction[state=start]

\usemodule[annotation] % Wolfgang's module

\define[2]\ExoSetup
	{\resetnumber[formula]
	\setupframedtext[
		width=\textwidth,
		frame=off,
		leftframe=on]
	 \textrule{#1}%
	 \startframedtext
	 #2%
	 \stopframedtext}
	 
\defineannotation[Exo]
	[alternative=command,
	command=\ExoSetup,
	text=Exercise ,
	number=yes,
	headcolor=darkred,
	]

% \setupannotation[Exo][prefix=+]
\setupreferencing[prefix=+]

\starttext

\startExo[exo:CharacTwo] Prove that if $ab=ba$ and $2ab=0$ then
\placeformula[eq:1]
\startformula
(a+b)^2 = a^2 + b^2.
\stopformula
Using the identity (\in[eq:1]) prove that $(a=b)^{2n} = a^{2n} + b^{2n}$.
\stopExo

\page

\startExo[exo:Moivre]{Moivre's formula} Prove that for any integer $n$
\placeformula[eq:2] % I would like the reference to be [eq:1]
\startformula
(\cos(x) + {\rm i}\sin(x))^n = \cos(nx) + {\rm i} \sin(nx).
\stopformula
Using the identity (\in[eq:2]) % I would like here to say [eq:1]
 compute $\cos{3x}$.
\stopExo

\stoptext
%%%%%%%%%% end

On 28 nov. 2011, at 00:10, Wolfgang Schuster wrote:

> 
> Am 27.11.2011 um 23:27 schrieb Otared Kavian:
> 
>> Dear all,
>> 
>> Is it possible to have a sort of « local references for formulas » or else to clear previous references to formulas at a certain point?
>> In a chapter where a certain number of exercices and formulas are to be numbered, assume I have the following minimal example
>> 
>> %%%%%%%%% begin
>> \starttext
>> 
>> Exercice 1. Prove that if $ab=ba$ and $2ab=0$ then
>> \placeformula[eq:1]
>> \startformula
>> (a+b)^2 = a^2 + b^2.
>> \stopformula
>> Using the identity (\in[eq:1]) prove that $(a=b)^{2n} = a^{2n} + b^{2n}$.
>> 
>> \blank[big]
>> \hrule
>> \blank[big]
>> 
>> Exercice 2. Prove that for any integer $n$
>> \resetnumber[formula]
>> %\reset[formulas][references]
>> \placeformula[eq:2] % I would like the reference to be [eq:1]
>> \startformula
>> (\cos(x) + {\rm i}\sin(x))^n = \cos(nx) + {\rm i} \sin(nx).
>> \stopformula
>> Using the identity (\in[eq:2]) % I would like here to say [eq:1]
>> compute $\cos{3x}$.
>> 
>> \stoptext
>> %%%%%%%%% end
>> 
>> I would like to be able to have the equations numbered within each exercise (which is in fact defined through an enumeration environment), and be able to have the reference to each formula « local » within that exercise.
>> The resaon is that the execises and problems may have several equations which are referenced to with [eq:1] through [eq:10] (say…), and have been prepared and given previously to students on independent sheets. When I want to give out a booklet of all the exercises, then it would be handy to have such a feature.
>> 
>> I understand that I am not being very clear… Hope someone would understand what I mean and need :-)
> 
> Look at page 168: http://pragma-ade.com/general/manuals/cont-enp.pdf
> 
> 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
> ___________________________________________________________________________________

%%%%%%%%%%%%%%%%%%
Otared Kavian
Département de Mathématiques
Université de Versailles Saint-Quentin
Bâtiment Fermat
45 avenue des Etats Unis
78035 Versailles cedex

Téléphone: +33 1 39 25 46 42
Secrétariat: +33 1 39 25 46 44 
Secrétariat: +33 1 39 25 46 46

e-mail: Otared.Kavian@math.uvsq.fr





[-- Attachment #1.2: Type: text/html, Size: 8935 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Resetting references or local references?
  2011-11-28  9:18   ` Otared Kavian
@ 2011-11-28 10:24     ` Wolfgang Schuster
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Schuster @ 2011-11-28 10:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 28.11.2011 um 10:18 schrieb Otared Kavian:

> Hi Wolfgang,
> 
> Many thanks for your attention and the link you sent.
> I looked up the chapter on references of the main manuel written by Hans, but unfortunately I could not find a solution, or could not adapt what is said there. 
> It can be that I have to change my approach of defining my « exercises », for instance by defining each exercise as a section or subsection? 
> Up to now I have two ways of defining an « exercise »: 
> 	• one is with \defineenumeration[Exo] (when using mkii), 
> 	• the other one is with \defineannotation[Exo] and your annotation module when using mkiv.
> 
> In neither case the command
> 	\setupreferencing[prefix=+]
> or
> 	\setupannotation[Exo][prefix=+]
> seems to generate local tags. 
> 
> Just in case, below is a minimal file, which shows how I use the annotation module.

There are a few fixes needed in the mechanism but as you can see below it works when you know what’s wrong
but to complete the function for MkIV Hans needs a shorter example.

\setupinteraction[state=start]

\usemodule[annotation]

\define[2]\ExoSetup
  {%doifsomething{\annotationparameter{prefix}}{\setupreferencing[prefix=\annotationparameter{prefix}]}%
   \doifsomething{\annotationparameter{prefix}}{\setupreferenceprefix[\annotationparameter{prefix}]}%
   \doifsomething{\annotationparameter{prefix}}{\setupformulas[referenceprefix=\annotationparameter{prefix}]}%
   \resetnumber[formula]
   \textrule{#1}%
   \startframedtext[width=\textwidth,frame=off,leftframe=on]%
   #2%
   \stopframedtext}
	 
\defineannotation
  [Exo]
  [alternative=command,
   command=\ExoSetup,
   text=Exercise ,
   number=yes,
   headcolor=darkred]

\starttext

\startExo[prefix=CharacTwo] Prove that if $ab=ba$ and $2ab=0$ then
\placeformula[eq:1]
\startformula
(a+b)^2 = a^2 + b^2.
\stopformula
Using the identity (\in[eq:1]) prove that $(a=b)^{2n} = a^{2n} + b^{2n}$.
\stopExo

\page

\startExo[prefix=Moivre]{Moivre's formula} Prove that for any integer $n$
\placeformula[eq:1]
\startformula
(\cos(x) + {\rm i}\sin(x))^n = \cos(nx) + {\rm i} \sin(nx).
\stopformula
Using the identity (\in[eq:1]) compute $\cos{3x}$.
\stopExo

\page

\starttabulate[|Tl|l|]
\NC eq:1           \NC \in{Equation}[eq:1]                                \NC\NR
\NC CharacTwo:eq:1 \NC \in{Equation}[CharacTwo eq:1]                      \NC\NR
\NC CharacTwo:eq:1 \NC \def\referenceprefix{CharacTwo}\in{Equation}[eq:1] \NC\NR
\NC Moivre:eq:1    \NC \in{Equation}[Moivre eq:1]                         \NC\NR
\NC Moivre:eq:1    \NC \def\referenceprefix{Moivre}\in{Equation}[eq:1]    \NC\NR
\stoptabulate

\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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-28 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-27 22:27 Resetting references or local references? Otared Kavian
2011-11-27 23:10 ` Wolfgang Schuster
2011-11-28  9:18   ` Otared Kavian
2011-11-28 10:24     ` Wolfgang Schuster

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).