Equation alignment

From Wiki
Revision as of 02:04, 9 September 2005 by 60.176.193.250 (talk)
Jump to navigation Jump to search

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.

\tracemathtrue
\setupformulas[align=left,distance=2em]
\startformula c^2 = a^2 + b^2 \stopformula
\placeformula \startformula c^2 = a^2 + b^2 \stopformula

中央吸尘新风系统 杭州通诚投资公司成人用品 成人用品杭州婚庆屏蔽器 手机信号屏蔽器网站建设 杭州网络公司 网站建设虚拟主机域名注册 网站推广企业邮箱域名申请 物流电子IC 网站建设 虚拟主机 域名注册 网站推广 企业邮局癌症 vi设计 网页设计 杭州婚庆 杭州婚庆司仪杭州婚庆主持 腰带 平面设计 标志设计 手机信号屏蔽器 屏蔽器