Difference between revisions of "Equation alignment"
(Removed spam.) |
m (narrower textwidth to make math fit on a (reasonably large) screen) |
||
Line 7: | Line 7: | ||
<context> | <context> | ||
+ | \setuplayout[textwidth=8cm] | ||
This is a bit of text for purpose of example.\epar | This is a bit of text for purpose of example.\epar | ||
\startitemize | \startitemize | ||
Line 30: | Line 31: | ||
<context> | <context> | ||
+ | \setuplayout[textwidth=8cm] | ||
\setupformulas[align=left] | \setupformulas[align=left] | ||
\startformula c^2 = a^2 + b^2 \stopformula | \startformula c^2 = a^2 + b^2 \stopformula | ||
Line 41: | Line 43: | ||
<context> | <context> | ||
+ | \setuplayout[textwidth=8cm] | ||
\setupformulas[align=left] | \setupformulas[align=left] | ||
\placeformula \startformula c^2 = a^2 + b^2 \stopformula | \placeformula \startformula c^2 = a^2 + b^2 \stopformula | ||
Line 63: | Line 66: | ||
<context> | <context> | ||
+ | \setuplayout[textwidth=8cm] | ||
\tracemathtrue | \tracemathtrue | ||
\setupformulas[align=left] | \setupformulas[align=left] | ||
Line 83: | Line 87: | ||
<context> | <context> | ||
+ | \setuplayout[textwidth=8cm] | ||
\setupformulas[align=middle,strut=yes] | \setupformulas[align=middle,strut=yes] | ||
\tracemathtrue | \tracemathtrue | ||
Line 98: | Line 103: | ||
<context> | <context> | ||
+ | \setuplayout[textwidth=8cm] | ||
\tracemathtrue | \tracemathtrue | ||
\setupformulas[align=middle] | \setupformulas[align=middle] | ||
Line 119: | Line 125: | ||
<context> | <context> | ||
+ | \setuplayout[textwidth=8cm] | ||
Some example text, again, to show where the right and left margins of the text block are. | Some example text, again, to show where the right and left margins of the text block are. | ||
\tracemathtrue | \tracemathtrue | ||
Line 142: | Line 149: | ||
<context> | <context> | ||
+ | \setuplayout[textwidth=8cm] | ||
Some example text, again, to show where the right and left margins of the text block are. | Some example text, again, to show where the right and left margins of the text block are. | ||
\tracemathtrue | \tracemathtrue | ||
Line 152: | Line 160: | ||
<texcode> | <texcode> | ||
+ | \setuplayout[textwidth=8cm] | ||
\tracemathtrue | \tracemathtrue | ||
\setupformulas[align=left,distance=2em] | \setupformulas[align=left,distance=2em] | ||
Line 159: | Line 168: | ||
<context> | <context> | ||
+ | \setuplayout[textwidth=8cm] | ||
\tracemathtrue | \tracemathtrue | ||
\setupformulas[align=left,distance=2em] | \setupformulas[align=left,distance=2em] |
Revision as of 18:51, 2 December 2005
This set of math examples is taken from the comments in the core-mat.tex file, which contains most of the core ConTeXt math macros.
Normally a formula is centered, but in case you want to align it left or right, you can set up formulas to behave that way. Normally a formula will adapt its left indentation to the environment:
In the next examples we explicitly align formulas to the left (\raggedleft), center and right (\raggedright):
\setupformulas[align=left] \startformula c^2 = a^2 + b^2 \stopformula \setupformulas[align=middle] \startformula c^2 = a^2 + b^2 \stopformula \setupformulas[align=right] \startformula c^2 = a^2 + b^2 \stopformula
Or in print:
With formula numbers these formulas look as follows:
This was keyed in as:
\setupformulas[align=left] \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 \stopformula
When tracing is turned on (\tracemathtrue) you can visualize the bounding box of the formula,
As you can see, the dimensions are the natural ones, but if needed you can force a normalized line:
\setupformulas[align=middle,strut=yes] \tracemathtrue \placeformula \startformula c^2 = a^2 + b^2 \stopformula
This time we get a more spacy result. [Ed. Note: For this example equation, there appears to be no visible change.]
We will now show a couple of more settings and combinations of settings. In centered formulas, the number takes no space
\tracemathtrue \setupformulas[align=middle] \startformula c^2 = a^2 + b^2 \stopformula \placeformula \startformula c^2 = a^2 + b^2 \stopformula
You can influence the placement of the whole box with the parameters leftmargin and rightmargin.
Some example text, again, to show where the right and left margins of the text block are. \tracemathtrue \setupformulas[align=right,leftmargin=3em] \startformula c^2 = a^2 + b^2 \stopformula \placeformula \startformula c^2 = a^2 + b^2 \stopformula \setupformulas[align=left,rightmargin=1em] \startformula c^2 = a^2 + b^2 \stopformula \placeformula \startformula c^2 = a^2 + b^2 \stopformula
You can also inherit the margin from the environment.
Some example text, again, to show where the right and left margins of the text block are. \tracemathtrue \setupformulas[align=right,margin=standard] \startformula c^2 = a^2 + b^2 \stopformula \placeformula \startformula c^2 = a^2 + b^2 \stopformula
The distance between the formula and the number is only applied when the formula is left or right aligned.
\setuplayout[textwidth=8cm] \tracemathtrue \setupformulas[align=left,distance=2em] \startformula c^2 = a^2 + b^2 \stopformula \placeformula \startformula c^2 = a^2 + b^2 \stopformula