Open main menu

Changes

add {{cmd|startformulas}}
The famous result (once more) is given by
\startplaceformula
\startformula c^2 = a^2 + b^2 \stopformula
\stopplaceformula
</context>
\item with \tex{eqref} : formula \eqref[eq:myref].
\stopitemize
</context>
 
 
= Sub-Formulae with {{cmd|startsubformulas}} and {{cmd|startalign}} =
 
To use subformula numbering, you have to use {{cmd|startsubformulas}}/{{cmd|stopsubformulas}} and {{cmd|startalign}}. For example
 
<context source="yes" text="This, when typeset, produces the following:">
The famous result (once more) is given by
 
Examples:
\definereferenceformat[eqref][left=(,right=)]
 
\startsubformulas[eq:total]
\startplaceformula
\startformula
\startalign
\NC a^2 + b^2 \NC = c^2 \NR[eq:first]
\NC a^2 + b^2 \NC = c^2 \NR[eq:second]
\stopalign
\stopformula
\stopsubformulas
\stopplaceformula
 
Formula \eqref[eq:total] states the Pythagora's Theorem twice,
once in \eqref[eq:first] and again in \eqref[eq:second].
 
You can compare without \tex{startsubformulas}:
\startplaceformula
\startformula
\startalign
\NC a^2 + b^2 \NC = c^2 \NR[eq2:first]
\NC a^2 + b^2 \NC = c^2 \NR[eq2:second]
\stopalign
\stopformula
\stopplaceformula
 
We now have references for \eqref[eq2:first] and \eqref[eq2:second].
</context>
 
 
= Combination of formulae with {{cmd|startformulas}} =
 
To use subformula numbering, you have to use {{cmd|startsubformulas}}/{{cmd|stopsubformulas}} and {{cmd|startalign}}. For example
 
<context source="yes" text="This, when typeset, produces the following:">
\definereferenceformat[eqref][left=(,right=)]
 
The famous result (once more) is given by
\startsubformulas[eq:total]
\startplaceformula
\startformulas
 
\startformula
\startalign
\NC a^2 + b^2 \NC = c^2 \NR[eq:first]
\NC a^2 + b^2 \NC = c^2 \NR[eq:second]
\stopalign
\stopformula
 
 
\startformula
\startalign
\NC a^2 + b^2 \NC = c^2 \NR[eq:third]
\NC a^2 + b^2 \NC = c^2 \NR[eq:forth]
\stopalign
\stopformula
 
\stopformulas
\stopplaceformula
\stopsubformulas
 
We now have references for \eqref[eq:forth] for example.
</context>
 
= List of Formulae with {{cmd|placelist}} =
 
Since MKIV there are two types of formulas: numbered and named. Numbered formulas have the number as a reference and caption next to the formula and are listed only with the number and pagenumber in the list of formulas. Named formulas use the name as the caption instead of a number and are referenced with the name and pagenumber in the list of formulas.
 
<context source=yes>
2 examples:
 
% no reference ==> no entry in the list of formulas
\startplaceformula
\startformula e=mc^2 \stopformula
\stopplaceformula
 
% a reference ==> entry in the list of formulas
\startplaceformula
[reference=formula:mass1] % <====== here
\startformula e=mc^2 \stopformula
\stopplaceformula
 
This is the list:
 
\placelist[formula][criterium=all,alternative=c]
</context>
 
{{cmd|startplaceformula}} comes with the following key options: bookmark, list, reference, suffix, title. The title option changes the formula to a named formula (no number).
 
<context source=yes>
3 examples:
 
% a reference + list ==> entry with number + additional text in the list
\startplaceformula
[reference=formula:mass2,
list={Mass-energy equivalence from list option}]
\startformula e=mc^2 \stopformula
\stopplaceformula
 
% a reference + title ==> entry with title text, no number
\startplaceformula
[title={Mass-energy equivalence}, % <====== here
reference=formula:mass3]
\startformula e=mc^2 \stopformula
\stopplaceformula
 
% a reference + title + list ==> entry with list text, no number
\startplaceformula
[title={Mass-energy equivalence}, % <====== here
reference=formula:mass4,
list={Mass-energy equivalence from list option}]
\startformula e=mc^2 \stopformula
\stopplaceformula
 
This is the list:
 
\placelist[formula][criterium=all,alternative=c]
</context>
= Formating with {{cmd|setupformulas}} =
== Changing format Format of numbers ==
You can use {{cmd|setupformulas}} to change the format of numbers. For example to get bold numbers inside square brackets use
</context>
== Changing Formula alignment ==
Normally a formula is centered, but in case you want to align it left or right, you can set up formulas to behave
</context>
=Sub-Formula Numbering= == Sub-Formulae numbering with {{cmd|startsubformulas}} == To use subformula numbering, you can use {{cmd|startsubformulas}}/{{cmd|stopsubformulas}}. For example  <context source="yes" text="This, when typeset, produces the following:">The famous result (once more) is given by Examples:\startsubformulas[eq:1] \startplaceformula[eq:first]\startformula c^2 = a^2 + b^2 \stopformula\stopplaceformula \startplaceformula[eq:second]\startformula c^2 = a^2 + b^2 \stopformula\stopplaceformula \stopsubformulas Formula (\in[eq:1]) states the Pythagora's Theorem twice,once in (\in[eq:first]) and again in (\in[eq:second]).</context> == The Manual Method == Sometimes, you need more fine grained control over numbering of subformulas. In that case one can make use of the optional agument of {{cmd|placeformula}} command and the related {{cmd|placesubformula}} commands which can be used to produce sub-formula numbering. For example: <table width="100%" cols="2"><tr valign="top"><td width="50%"><texcode>Examples:\placeformula{a}\startformulac^2 = a^2 + b^2\stopformula \placesubformula{b}\startformulac^2 = a^2 + b^2\stopformula</texcode></td><td><context>\setuppapersize[A5]\setuplayout[width=8cm]Examples:\placeformula{a}\startformulac^2 = a^2 + b^2\stopformula \placesubformula{b}\startformulac^2 = a^2 + b^2\stopformula</context></td></tr></table> What's going on here is simpler than it might appear at first glance. Both {{cmd|placeformula}} and {{cmd|placesubformula}} produce equation numbers with the optional tag added at the end; the sole difference is that the former increments the equation number first, while the latter does not (and thus can be used for the second and subsequent formulas that use the same formula number but presumably have different tags). This is sufficient for cases where the standard ConTeXt equation numbers suffice, and where only one equation number is needed per formula. However, there are many cases where this is insufficient, and {{cmd|placeformula}} defines {{cmd|formulanumber}} and {{cmd|subformulanumber}} commands, which provide hooks to allow the use of ConTeXt-managed formula numbers with plain TeX equation numbering. These, when used within a formula, simply return the formula number in properly formatted form, as can be seen in this simple example with plain TeX's {{cmd|eqno}}. Note that the optional tag is inherited from {{cmd|placeformula}}. <table width="100%" cols="2"><tr valign="top"><td width="50%"><texcode>More examples:\placeformula{c}\startformula\let\doplaceformulanumber\emptyc^2 = a^2 + b^2 \eqno{\formulanumber}\stopformula</texcode></td><td><context>\setuppapersize[A5]\setuplayout[width=8cm]More examples:\placeformula{c}\startformula\let\doplaceformulanumber\emptyc^2 = a^2 + b^2 \eqno{\formulanumber}\stopformula</context></td></tr></table> In order for this to work properly, we need to turn off ConTeXt's automatic formula number placement; thus the {{cmd|let}} command to empty {{cmd|doplaceformulanumber}}, which must be placed <em>after</em> the start of the formula. In many practical examples, however, this is not necessary; ConTeXt redefines {{cmd|displaylines}} and {{cmd|eqalignno}} to do this automatically. For more control over sub-formula numbering, {{cmd|formulanumber}} and {{cmd|subformulanumber}} have an optional argument parallel to that of {{cmd|placeformula}}, as demonstrated in this use of plain TeX's {{cmd|eqalignno}}, which places multiple equation numbers within one formula. <table width="100%" cols="2"><tr valign="top"><td width="50%"><texcode>\placeformula\startformula\eqalignno{ c^2 &= a^2 + b^2 &\formulanumber{a} \cr c &= \left(a^2 + b^2\right)^{\vfrac{1}{2}} &\subformulanumber{b}\cr a^2 + b^2 &= c^2 &\subformulanumber{c} \cr d^2 &= e^2 &\formulanumber\cr}\stopformula</texcode></td><td><context>\setuppapersize[A5]\setuplayout[width=8cm]\placeformula\startformula\eqalignno{ c^2 &= a^2 + b^2 &\formulanumber{a} \cr c &= \left(a^2 + b^2\right)^{\vfrac{1}{2}} &\subformulanumber{b}\cr a^2 + b^2 &= c^2 &\subformulanumber{c} \cr d^2 &= e^2 &\formulanumber\cr}\stopformula</context></td></tr></table> Note that both {{cmd|formulanumber}} and {{cmd|subformulanumber}} can be used within the same formula, and the formula number is incremented as expected. Also, if an optional argument is specified in both {{cmd|placefigure}} and {{cmd|formulanumber}}, the latter takes precedence. <table width="100%" cols="2"><tr valign="top"><td width="50%"><texcode>More examples for left-located equation number:\setupformulas[location=left]\placeformula{d}\startformula\let\doplaceformulanumber\emptyc^2 = a^2 + b^2 \leqno{\formulanumber}\stopformulaand\placeformula\startformula\leqalignno{c^2 &= a^2 + b^2 &\formulanumber{a} \cr a^2 + b^2 &= c^2 &\subformulanumber{b} \cr d^2 &= e^2 &\formulanumber\cr}\stopformula</texcode></td><td><context>\setuppapersize[A5]\setuplayout[width=8cm]More examples for left-located equation no.:\setupformulas[location=left]\placeformula{d}\startformula\let\doplaceformulanumber\emptyc^2 = a^2 + b^2 \leqno{\formulanumber}\stopformulaand\placeformula\startformula\leqalignno{c^2 &= a^2 + b^2 &\formulanumber{a} \cr a^2 + b^2 &= c^2 &\subformulanumber{b} \cr d^2 &= e^2 &\formulanumber\cr}\stopformula</context></td></tr></table> -- 23:46, 15 Aug 2005 (CEST) Prinse Wang =List of Formulas= You can have a list of the formulas contained in a document by using {{cmd|placenamedformula}} instead of {{cmd|placeformula}}. Only the formulas written with {{cmd|placenamedformula}} are not put in the list, so that you can control precisely the content of the list. {{cmd|placenamedformula}} takes as first parameter the name of the formula put in the list. The other {{cmd|placeformula}} features are still available. The list can be formatted like any other list. Example:<texcode>\subsubject{List of Formulas}\placelist[formula][criterium=text,alternative=c] \subsubject{Formulas}\placenamedformula[one]{First listed Formula}\startformula a = 1 \stopformula \endgraf \placeformula\startformula a = 2 \stopformula \endgraf \placenamedformula{Second listed Formula}{b}\startformula a = 3 \stopformula \endgraf</texcode> Gives: <context>\setuppapersize[A5]\setuplayout[width=13cm]\subsubject{List of Formulas}\placelist[formula][criterium=text,alternative=c] \subsubject{Formulas}\placenamedformula[one]{First listed Formula}\startformula a = 1 \stopformula \endgraf \placeformula\startformula a = 2 \stopformula \endgraf \placenamedformula{Second listed Formula}{b}\startformula a = 3 \stopformula \endgraf</context> == List of Formulas with MKIV/LMTX ==Since MKIV there are two types of formulas: numbered and named. Numbered formulas have the number as a reference and caption next to the formula and are listed only with the number and pagenumber in the list of formulas. Named formulas use the name as the caption instead of a number and are referenced with the name and pagenumber in the list of formulas. <context source=yes>% equivalent to \placenamedformula[formula:mass]{Mass-energy equivalence}\startplaceformula[title={Mass-energy equivalence},reference=formula:mass] \startformula e=mc^2 \stopformula\stopplaceformula % equivalent to \placeformula[formula:mass] (note: placeformula is listed in the list of formulas if it has a reference)\startplaceformula[reference=formula:mass] \startformula e=mc^2 \stopformula \stopplaceformula % equivalent to \placeformula (with no entry in the list of formulas)\startplaceformula \startformula e=mc^2 \stopformula \stopplaceformula \placelist[formula][criterium=text,alternative=c]</context> {{cmd|startplaceformula}} comes with the following key options: bookmark, list, reference, suffix, title. To name a numbered formula in the list of formulas, one can use the list option:<context source=yes>% named formula\startplaceformula[reference=formula:mass,title={Mass-energy equivalence}] \startformula e=mc^2 \stopformula\stopplaceformula % numbered formula with list text, note without a reference option the formula is just a placeformula that is not listed in the list of formulas -- needs ConTeXt latest version 2021-03-21 or later\startplaceformula[reference=formula:mass,list={Mass-energy equivalence}] \startformula e=mc^2 \stopformula \stopplaceformula \placelist[formula][criterium=text,alternative=c]</context> Note: The title option changes the formula to a named formula and will use that name in the list of formulas regardless of the list option. = Shaded background for part of a displayed equation ==
(see also [[Framed]])
To highlight part of One may define a formulaspecific framed command, you can give it a gray background using for example <tt>coloredmath<tt>, with {{cmd|mframeddefinemathframed}}: the following is the code you can use in mkii (see below what one has to do in mkiv):.
<context source="yes">
\setuppapersize[A5]\setupcolors[state=start]\def\graymath{\mframed[frame=off, background=color, backgroundcolor=gray, backgroundoffset=3pt]} \startformula \ln (1+x) =\, \graymath{x - {x^2\over2}} \A7,+ {x^3\over3}-\cdots.\stopformula</context> In mkiv the code is slightly different: one may define {{cmd|graymath}} directly using {{cmd|definemathframed}} <texcode>\setuppapersize[A5landscape]\definemathframed[graymathcoloredmath]
[
frame=off,
location=mathematics,
background=color,
backgroundcolor=lightgraylightcyan, backgroundoffset=2pt1pt
]
\starttext
Since for $|x| < 1$ we have
\startformula
\log(1+x) = \graymathcoloredmath{x- \displaystyle{x^2\over2}} + {x^3 \over 3} + \cdots
\stopformula
we may write $\log(1+x) = x + O(x^2)$.
\stoptext
</texcode>
 
The result is shown below (possibly the framed part of the formula is not aligned correctly with the remainder of the formula because the mkiv engine on Context Garden is not up to date…).
 
<context mode=mkiv>
\setuppapersize[A5]
\definemathframed[graymath]
[
frame=off,
location=mathematics,
background=color,
backgroundcolor=lightgray,
backgroundoffset=2pt
]
 
Since for $|x| < 1$ we have
\startformula
\log(1+x) = \graymath{x- \displaystyle{x^2\over2}} + {x^3 \over 3} + \cdots
\stopformula
we may write $\log(1+x) = x + O(x^2)$.
</context>
[[Category:Math]]
1,047

edits