Open main menu

Changes

= Display Math First {{cmd|startformula}} =
Display math is enclosed in a {{cmd|startformula}} / {{cmd|stopformula}} pair. Thus
<table widthcontext source="100%yes" colstext="2This, when typeset, produces the following:"><tr valign="top"><td width="50%"><texcode>
The famous result (once more) is given by
\startformula
c^2 = a^2 + b^2.
\stopformula
</texcodecontext></td><td>This, when typeset, produces the following:
= Numbering Formulae {{cmd|startformula}} = ConTeXt provides an easy way to number the display maths equations. Simply, insert the {{cmd|startformula}} in the {{cmd|startplaceformula}} environment, and you will get numbered equations.  <contextsource="yes" text="This, when typeset, produces the following:">\setuppapersize[A5]\setuplayout[width=8cm]
The famous result (once more) is given by
\startplaceformula\startformulac^2 = a^2 + b^2.\stopformula\stopformulastopplaceformula
</context>
</td></tr></table>
The {{cmd|startplaceformula}} command is optional, and produces the equation number; leaving it off produces an unnumbered equation. = Numbering Formulae Referencing formulae {{cmd|in}} and {{cmd|at}}=
ConTeXt provides an easy way Equations can be referred to by simply adding a label to number the display maths equations. Simply, insert the formula in the {{cmd|startplaceformula}} environmentand using command for referencing :* {{cmd|ref}} (note that it expects two arguments, and therefore you will get numbered equations. Thusneed the brackets twice),* {{cmd|in}} (a kind of <tt>\ref[number][TheRef]</tt>,* {{cmd|at}} (a kind of <tt>\ref[page][TheRef]<table width="100%" cols="3"/tt>. <tr valigncontext source="topyes"><td widthtext="48%This, when typeset, produces the following:"><texcode>\setupinteraction[state=start]
The famous result (once more) is given by
 \startplaceformula[eq:myref] % <===== here\startformulac^2 = a^2 + b^2.\stopformula
\stopplaceformula
</texcode>
<td></td>
<td width="48%">
This, when typeset, produces the following:
And now we can refer to its number by several ways,\startitemize\item with \tex{in} : formula \in[eq:myref] or \in{formula}{}[eq:myref] \item with \tex{at} : formula \in[eq:myref] \at{page}[eq:myref]\item with \tex{ref} : formula \ref[number] [eq:myref] page \ref[number] [eq:myref]\stopitemize</context> By default, only the formula number appears as a reference. This can be changed by using {{cmd|definereferenceformat}}. For example, to create a command <code>\eqref</code> which shows the formula number in brackets, use <contextsource="yes" text="This, when typeset, produces the following:">\setuppapersizesetupinteraction[A5state=start] \setuplayoutdefinereferenceformat[widtheqref][left=8cm(,right=)
The famous result (once more) is given by
\startplaceformula[eq:myref]\startformulac^2 = a^2 + b^2.\stopformula
\stopplaceformula
 
And now we can refer to its number by several ways,
\startitemize
\item with \tex{in} : formula \in[eq:myref] or \in{formula}{}[eq:myref],
\item with \tex{at} : formula \in[eq:myref] \at{page}[eq:myref],
\item with \tex{ref} : formula \ref[number] [eq:myref] page \ref[number] [eq:myref],
\item with \tex{eqref} : formula \eqref[eq:myref].
\stopitemize
</context>
</td></tr></table>
The = Formating with {{cmd|placeformulasetupformulas}} command is optional, and produces the equation number; leaving it off produces an unnumbered equation.=
== Changing format of numbers ==
You can use {{cmd|setupformulas}} to change the format of numbers. For example to get bold numbers inside square brackets use
<table widthcontext source="100%yes" colstext="2" cellpadding="5"><tr valign="top"><td width="50%This, when typeset, produces the following:"><texcode>The famous result (once more) is given by \setupformulas [left={[}, right={]}, numberstyle=bold]</texcode>\startplaceformula\startformula c^2 = a^2 + b^2 \stopformula\stopplaceformula</tdcontext>
To get equations also numbered by section, use the command {{cmd|setupnumbering}} <tdcode>which gives\setupnumbering[way=bysection]</code> in the preamble of your document.This means that the section number preceeds the formula number.Add also {{cmd|setupnumber}} <code>\setupnumber[formula][way=bysection]</code> to reset with each new section.
<context>\setuppapersize[A5]\setuplayout[widthsource=8cm]\setupformulas[left"yes" text={[}"This,right={]}when typeset,numberstyle=bold]produces the following:">
The famous result (once more) is given by
\placeformulasetupformulas [left={[}, right={]}, numberstyle=bold] \setupnumbering [way=bysection] % to add the section number to the formula number\setupnumber [formula] [way=bysection] % to reset with each new section \startsection[title=First title]\startplaceformula\startformulac^2 = a^2 + b^2 \stopformula\stopplaceformula\stopsection \startsection[title=Second title]\startplaceformula\startformula c^2 = a^2 + b^2.\stopformula\stopplaceformula\stopformulastopsection
</context>
</td></tr></table>
To get equations also numbered by sectionalphabets instead of numbers, add the command:<texcode> \setupnumber[formula][way=bysection] </texcode>To the start of your document.use again {{cmd|setupformulas}}
To get alphabets instead of numbers, use<table widthcontext source="100%yes" colstext="2" cellpadding="5"><tr valign="top"><td width="50%This, when typeset, produces the following:"><texcode>The famous result (once more) is given by
\setupformulas[numberconversion=Character]
</texcode></td>\startplaceformula<td>which gives<context>\startformula c^2 = a^2 + b^2 \stopformula\setuppapersize[A5]stopplaceformula\setuplayout[width=8cm]\setupformulas[numberconversion=Charactercharacter] \placeformulastartplaceformula\startformulac^2 = a^2 + b^2\stopformula\stopformulastopplaceformula
</context>
</td></tr></table>
== Changing Formula alignment ==
that way. Normally a formula will adapt its left indentation to the environment:
<contextsource="yes">\setuppapersize[A5]\setuppapersize[A5]\setuplayout[textwidth=8cm]This is a bit of text for purpose of example.\epar
\startitemize
\item This is some other example text.\epar \placeformula startplaceformula \startformula c^2 = a^2 + b^2 \stopformula\stopplaceformula\item This is yet other example text.\epar
\stopitemize
This is a bit more text for other purpose of example.\epar
</context>
In the next examples we explicitly align formulas to the left ({{cmd|raggedleft}}), center and right ({{cmd|raggedright}}):
In the next examples we explicitly align formulas with {{cmd|setupformulas}}, to the left (<code>raggedleft</code>), center (<code>middle</code>, and right (<code>raggedright</code>): <context source="yes" text="Or in print:">
\setuppapersize[A5]
\setuplayout[textwidth=8cm]
With formula numbers the code is:
<context source="yes" text="And the formulas look like:">\setuppapersize[A5A7,landscape]
\setuplayout[textwidth=8cm]
\starttext\setupformulas[align=leftflushleft]\placeformula startplaceformula\startformula c^2 = a^2 + b^2 \stopformula\stopplaceformula  
\setupformulas[align=middle]
\placeformula startplaceformula \startformula c^2 = a^2 + b^2 \stopformula\stopplaceformula  \setupformulas[align=rightflushright]\placeformula startplaceformula \startformula c^2 = a^2 + b^2 \stopformula\stopplaceformula \stoptext
</context>
When tracing is turned on ({{cmd|tracemathtrueshowboxes}}) you can visualize the bounding box of the formula,
<contextsource="yes" text="This, when typeset, produces the following:">\setuppapersize[A5]The famous result (once more) is given by\setuplayout[textwidth=8cm]showboxes\tracemathtruestartplaceformula \setupformulas[align=left]startformula\placeformula \startformula c^2 = a^2 + b^2 \stopformula\setupformulas[align=middle]\placeformula \startformula c^2 = a^2 + b^2 \stopformula\setupformulas[align=right]\placeformula \startformula c^2 = a^2 + b^2 \stopformulastopplaceformula
</context>
As you can see, the dimensions are the natural ones, but if needed you can force a normalized line:
<context source="yes" text="This time we get a more spacy result. [Ed. Note: For this example equation, there appears to be no visible change.]">\setuppapersize[A5]The famous result (once more) is given by\setuplayout[textwidth=8cm]showboxes
\setupformulas[align=middle,strut=yes]
\tracemathtruestartplaceformula \placeformula \startformula c^2 = a^2 + b^2 \stopformula\stopplaceformula
</context>
We will now show a couple You can influence the placement of more settings the whole box with the parameters <tt>leftmargin</tt> and combinations of settings<tt>rightmargin</tt>. In centered formulas, the number takes no space
<context source="yes">
\setuppapersize[A5]The famous result (once more) is given by\setuplayout[textwidth=8cm]\tracemathtrueshowboxes\setupformulas[align=middleright,leftmargin=1em]\startplaceformula
\startformula c^2 = a^2 + b^2 \stopformula
\placeformula \startformula c^2 = a^2 + b^2 \stopformula</context>stopplaceformula
You can influence the placement of the whole box with the parameters <tt>leftmargin</tt> and <tt>rightmargin</tt>.
 
<context source="yes">
\setuppapersize[A5]
\setuplayout[textwidth=8cm]
Some example text, again, to show where the right and left margins of the text block are.
\tracemathtrue
\setupformulas[align=right,leftmargin=3em]
\startplaceformula
\startformula c^2 = a^2 + b^2 \stopformula
\placeformula \startformula c^2 = a^2 + b^2 \stopformulastopplaceformula
\setupformulas[align=left,rightmargin=1em]
\startplaceformula
\startformula c^2 = a^2 + b^2 \stopformula
\placeformula \startformula c^2 = a^2 + b^2 \stopformulastopplaceformula
</context>
<context source="yes">
\setuppapersize[A5]
\setuplayout[textwidth=8cm]
Some example text, again, to show where the right and left margins of the text block are.
\tracemathtrueshowboxes \setupformulas[align=right]\startplaceformula \startformula c^2 = a^2 + b^2 \stopformula\stopplaceformula  
\setupformulas[align=right,margin=standard]
\startplaceformula
\startformula c^2 = a^2 + b^2 \stopformula
\placeformula \startformula c^2 = a^2 + b^2 \stopformulastopplaceformula  
</context>
<context source="yes">
\setuppapersize[A5]\setuplayout[textwidth=8cm]Some example text, again, to show where the right and left margins of the text block are.\tracemathtrueshowboxes
\setupformulas[align=left,distance=2em]
\startplaceformula
\startformula c^2 = a^2 + b^2 \stopformula
\placeformula \startformula c^2 = a^2 + b^2 \stopformulastopplaceformula
</context>
= Referencing formulae Sub-Formula Numbering=Equations can be referred to by simply adding a label to {{cmd|placeformula}} and using {{cmd|ref}} to create the reference:
<table width="100%" cols="2" cellpaddingSub-Formulae numbering with {{cmd|startsubformulas}} ="5"><tr valign="top"><td width="50%"><texcode>The famous result (and again) is given by\placeformula[formulalabel]\startformulac^2 = a^2 + b^2.\stopformulaAnd now we can refer to formula \ref[][formulalabel].</texcode></td><td>This, when typeset, produces the following:
<context>\setuppapersize[A5]\setuplayout[width=8cm]The famous result (and again) is given by\placeformula[formulalabel]\startformulac^2 = a^2 + b^2To use subformula numbering, you can use {{cmd|startsubformulas}}/{{cmd|stopsubformulas}}.\stopformulaFor example
And now we can refer to formula \ref[][formulalabel].
</context>
</td></tr></table>
Note<context source="yes" text="This, that {{cmd|ref}} expects two argumentswhen typeset, therefore you need produces the brackets twice.following:">The famous result (once more) is given by
By default, only the formula number appears as a reference. This can be changed by using {{cmd|definereferenceformat}}. For example, to create a command <code>\eqref</code> which shows the formula number in brackets, use<texcode>Examples:\definereferenceformat[eqref][left=(,right=)]</texcode>See startsubformulas[[References]eq:total] for more examples of {{cmd|definereferenceformat}}.
\startplaceformula[eq:first]\startformula c^2 =Sub-Formula Numbering=a^2 + b^2 \stopformula\stopplaceformula
== Automatic Sub-Formula Numbering == To use subformula numbering, you can use {{cmd|startsubformulas}}/{{cmd|stopsubformulas}}. For example <table width="100%" cols="2"><tr valign="top"><td width="50%"><texcode>Examples:\startsubformulasstartplaceformula[eq:1]\placeformula[eq:firstsecond]\startformula c^2 = a^2 + b^2\stopformula\stopformulastopplaceformula
\placeformula[eq:second]
\startformula
c^2 = a^2 + b^2
\stopformula
\stopsubformulas
Formula (\in[eq:1]) states
the Pythagora's Theorem twice,
once in (\in[eq:first]) and
again in (\in[eq:second]).
</texcode>
</td><td>
<context>
\setuppapersize[A5]
\setuplayout[width=8cm]
Examples:
\startsubformulas[eq:1]
\placeformula[eq:first]
\startformula
c^2 = a^2 + b^2
\stopformula
\placeformula[eq:second]\startformulac^2 = a^2 + b^2\stopformula\stopsubformulasFormula (\in[eq:1total]) states the Pythagora's Theorem twice, once in (\in[eq:first]) and again in (\in[eq:second]).
</context>
</td></tr></table>
 
== The Manual Method ==
1,031

edits