Changes

Jump to navigation Jump to search
3,060 bytes added ,  22:50, 21 March 2021
m
→‎List of Formulas with MKIV/LMTX: update list option requirement for MKIV latest
< [[Math]]|
 
= Display Math =
<table width="100%" cols="2" cellpadding="5"><tr valign="top"><td width="50%">
<texcode>
\setupformulas[conversionnumberconversion=Character]
</texcode>
</td>
\setuppapersize[A5]
\setuplayout[width=8cm]
\setupformulas[conversionnumberconversion=Character]
\placeformula
\startformula
\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 a formula, you can give it a gray background using {{cmd|mframed}}: the following is the code you can use in mkii (see below what one has to do in mkiv):
<context source="yes">
\stopformula
</context>
 
In mkiv the code is slightly different: one may define {{cmd|graymath}} directly using {{cmd|definemathframed}}
 
<texcode>
\setuppapersize[A5]
\definemathframed[graymath]
[
frame=off,
location=mathematics,
background=color,
backgroundcolor=lightgray,
backgroundoffset=2pt
]
\starttext
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)$.
\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]]
174

edits

Navigation menu