Hi everyone, I read carefully the two 'My Way' from Aditya regarding math alignment (thank you for those, they were extremely useful to me, and should maybe get even more visibility on the wiki), and I have some questions about it: 1) Is there a way to modify interline spacing in 'cases' environment? I find it a bit short when using the displaystyle option. 2) I noticed that the interline spacing is not the same in the 'align' and 'aligned' environment (it's larger in 'align'). Is there a way to make 'aligned' use the spacing of align? It looks better with displaystyle maths. 3) Aditya, I saw your remark in your 'My Way' concerning the 'multline' environment. I must admit I would really be glad to see it appear in ConTeXt! I'm afraid I'm not able to implement it myself... I use it a lot with amsmath: when a formula is just too long for one line, I put it on two with multline. The first part of the formula is left aligned on the first line, and the second part is right aligned on the second line. It seems impossible to get the same result with only 'align'. Would it be difficult to make it available in ConTeXt? Best regards, Morgan
On Thu, 13 Mar 2008, Morgan Brassel wrote:
Hi everyone,
I read carefully the two 'My Way' from Aditya regarding math alignment (thank you for those, they were extremely useful to me, and should maybe get even more visibility on the wiki), and I have some questions about it:
1) Is there a way to modify interline spacing in 'cases' environment? I find it a bit short when using the displaystyle option.
There is no clean way to do this at the moment. You can force a looser interline by adding \noalign{\vskip ...} after \NR.
2) I noticed that the interline spacing is not the same in the 'align' and 'aligned' environment (it's larger in 'align'). Is there a way to make 'aligned' use the spacing of align? It looks better with displaystyle maths.
I do not like the definition of aligned using matrices that I have presented in the 'My Way'. Matrices try very hard to have a compact interline spacing, while in a aligned environment you need the opposite. At some point, I played with some of the internals of core-mat, and had a working definition of aligned. I cannot find it at the moment :(
3) Aditya, I saw your remark in your 'My Way' concerning the 'multline' environment. I must admit I would really be glad to see it appear in ConTeXt! I'm afraid I'm not able to implement it myself... I use it a lot with amsmath: when a formula is just too long for one line, I put it on two with multline. The first part of the formula is left aligned on the first line, and the second part is right aligned on the second line. It seems impossible to get the same result with only 'align'. Would it be difficult to make it available in ConTeXt?
No, multline is probably the simplest of all math environments. I do not really understand what all features it should have. If you can explain everything you want from a multiline environment, I can give a shot at trying to implement that, and Hans and Taco could polish it up. Aditya
Le Thursday 13 March 2008 13:23:06 Aditya Mahajan, vous avez écrit :
On Thu, 13 Mar 2008, Morgan Brassel wrote:
Hi everyone,
I read carefully the two 'My Way' from Aditya regarding math alignment (thank you for those, they were extremely useful to me, and should maybe get even more visibility on the wiki), and I have some questions about it:
1) Is there a way to modify interline spacing in 'cases' environment? I find it a bit short when using the displaystyle option.
There is no clean way to do this at the moment. You can force a looser interline by adding \noalign{\vskip ...} after \NR.
Ok, I'll do that. This is the \needspace command described in your 'My Way', isn't it? I should have remembered it!
2) I noticed that the interline spacing is not the same in the 'align' and 'aligned' environment (it's larger in 'align'). Is there a way to make 'aligned' use the spacing of align? It looks better with displaystyle maths.
I do not like the definition of aligned using matrices that I have presented in the 'My Way'. Matrices try very hard to have a compact interline spacing, while in a aligned environment you need the opposite. At some point, I played with some of the internals of core-mat, and had a working definition of aligned. I cannot find it at the moment :(
Maybe another solution would be to add left and right options directly to the align environment. But of course I have no idea if it is possible... Anyway, if you find your new definition back, I would be glad to test it!
3) Aditya, I saw your remark in your 'My Way' concerning the 'multline' environment. I must admit I would really be glad to see it appear in ConTeXt! I'm afraid I'm not able to implement it myself... I use it a lot with amsmath: when a formula is just too long for one line, I put it on two with multline. The first part of the formula is left aligned on the first line, and the second part is right aligned on the second line. It seems impossible to get the same result with only 'align'. Would it be difficult to make it available in ConTeXt?
No, multline is probably the simplest of all math environments. I do not really understand what all features it should have. If you can explain everything you want from a multiline environment, I can give a shot at trying to implement that, and Hans and Taco could polish it up.
Aditya
Concerning multline, I only read the specification given in amsldoc.pdf: "3.3 Split equations without alignment". Multline does not support alignment, so you can't put '&' inside it, only '\\'. All it does is cut the equation into several lines: the first is left aligned, the last is right aligned, and all the intermediate are centered. I don't if this is sufficient as an explanation. Please let me know if I can help or test. And thank you for your time! Morgan
On Thu, 13 Mar 2008, Morgan Brassel wrote:
Concerning multline, I only read the specification given in amsldoc.pdf: "3.3 Split equations without alignment". Multline does not support alignment, so you can't put '&' inside it, only '\\'. All it does is cut the equation into several lines: the first is left aligned, the last is right aligned, and all the intermediate are centered. I don't if this is sufficient as an explanation. Please let me know if I can help or test. And thank you for your time!
So, will this user interface be enough: \startformula \startmultline \NC line 1 \FR \NC line 2 \MR \NC line 3 \LR \stopmultline \stopformula Lines with \FR are flush left, lines with \MR are centered, and lines with \LR are right flushed. (First row, middle row, last row; as in tables). multline also has \pushleft and \pushright with go against the ConTeXt way of things. It is also possible to just have \NR at each row, and let ConTeXt figure out the correct flushing. That will involve a two-pass algorithm, and I will give that a try. The other thing is placement of equation numbers. It is easy to implement multline so that equation number is always centered. I am not sure if the current ConTeXt mechanism allows for equation number to be placed on the bottom (similar to tbtags options). Aditya
Le Friday 14 March 2008 00:48:55 Aditya Mahajan, vous avez écrit :
So, will this user interface be enough:
\startformula \startmultline \NC line 1 \FR \NC line 2 \MR \NC line 3 \LR \stopmultline \stopformula
Lines with \FR are flush left, lines with \MR are centered, and lines with \LR are right flushed. (First row, middle row, last row; as in tables). multline also has \pushleft and \pushright with go against the ConTeXt way of things.
It seems great to me. Would it be possible to use \FR ou \LR for intermediate lines? It could be a way to get the same result as \pushleft and \pushright in amsmath. Anyway, I'm not sure this is a very useful feature: centered lines in the middle is clearly the best choice (at least for me!).
It is also possible to just have \NR at each row, and let ConTeXt figure out the correct flushing. That will involve a two-pass algorithm, and I will give that a try.
If the use of \FR and \LR can address the problem of \pushleft and \pushright, the first solution would be more powerful... And maybe it's more coherent with ConTeXt tables.
The other thing is placement of equation numbers. It is easy to implement multline so that equation number is always centered. I am not sure if the current ConTeXt mechanism allows for equation number to be placed on the bottom (similar to tbtags options).
Aditya
As multline is supposed to be used to typeset one only equation, I guess the choice made in amsmath is the best for tag placement: last line if placed right and first line if placed left. But if it's not possible currently, a centered tag would not hurt me at all... Morgan
On Thu, 13 Mar 2008 19:48:55 -0400 (EDT)
Aditya Mahajan
On Thu, 13 Mar 2008, Morgan Brassel wrote:
Concerning multline, I only read the specification given in amsldoc.pdf: "3.3 Split equations without alignment". Multline does not support alignment, so you can't put '&' inside it, only '\\'. All it does is cut the equation into several lines: the first is left aligned, the last is right aligned, and all the intermediate are centered. I don't if this is sufficient as an explanation. Please let me know if I can help or test. And thank you for your time!
So, will this user interface be enough:
\startformula \startmultline \NC line 1 \FR \NC line 2 \MR \NC line 3 \LR \stopmultline \stopformula
I would change myself the name for the environment from multline to multiline, we don't have to rely on the short command names as old TeX packages did for many macros.
Lines with \FR are flush left, lines with \MR are centered, and lines with \LR are right flushed. (First row, middle row, last row; as in tables). multline also has \pushleft and \pushright with go against the ConTeXt way of things.
It is also possible to just have \NR at each row, and let ConTeXt figure out the correct flushing. That will involve a two-pass algorithm, and I will give that a try.
I think you should use NR at the end of a line and not different commands for the first, the last and all other lines. You could change the alignment of each line with \NC[align=...], this will fit to the normal commands for tables.
The other thing is placement of equation numbers. It is easy to implement multline so that equation number is always centered. I am not sure if the current ConTeXt mechanism allows for equation number to be placed on the bottom (similar to tbtags options).
Wolfgang
On Fri, 14 Mar 2008, Wolfgang Schuster wrote:
On Thu, 13 Mar 2008 19:48:55 -0400 (EDT) Aditya Mahajan
wrote: On Thu, 13 Mar 2008, Morgan Brassel wrote:
Concerning multline, I only read the specification given in amsldoc.pdf: "3.3 Split equations without alignment". Multline does not support alignment, so you can't put '&' inside it, only '\\'. All it does is cut the equation into several lines: the first is left aligned, the last is right aligned, and all the intermediate are centered. I don't if this is sufficient as an explanation. Please let me know if I can help or test. And thank you for your time!
So, will this user interface be enough:
\startformula \startmultline \NC line 1 \FR \NC line 2 \MR \NC line 3 \LR \stopmultline \stopformula
I would change myself the name for the environment from multline to multiline, we don't have to rely on the short command names as old TeX packages did for many macros.
Yes, of course. I never really understood the stange naming conventions of amstex.
Lines with \FR are flush left, lines with \MR are centered, and lines with \LR are right flushed. (First row, middle row, last row; as in tables). multline also has \pushleft and \pushright with go against the ConTeXt way of things.
It is also possible to just have \NR at each row, and let ConTeXt figure out the correct flushing. That will involve a two-pass algorithm, and I will give that a try.
I think you should use NR at the end of a line and not different commands for the first, the last and all other lines. You could change the alignment of each line with \NC[align=...], this will fit to the normal commands for tables.
This will also make it easier to implement ;) Aditya
On Thu, 13 Mar 2008, Morgan Brassel wrote:
3) Aditya, I saw your remark in your 'My Way' concerning the 'multline' environment. I must admit I would really be glad to see it appear in ConTeXt! I'm afraid I'm not able to implement it myself... I use it a lot with amsmath: when a formula is just too long for one line, I put it on two with multline. The first part of the formula is left aligned on the first line, and the second part is right aligned on the second line. It seems impossible to get the same result with only 'align'. Would it be difficult to make it available in ConTeXt?
Here is my first attempt. Completely bare-bones right now, but short enough to show what needs to be done. \unprotect \def\startmathlines {\def\stop@math{$} \def\NC{} \def\NR{\def\NC{\cr}} % Hack for number. Should be done by measuring the width of the number \scratchdimen\dimexpr\displaywidth-4em \relax \vbox \bgroup \halign\bgroup \hbox to \scratchdimen {\hfil \strut $\mathsurround\zeropoint\displaystyle{}## \stop@math \hfil}% \crcr \hfilneg} \def\stopmathlines {\hfilneg \crcr \egroup \egroup} \protect \starttext \placeformula \startformula \startmathlines \NC f(x) = (a+b)^n \NR \NC = a^n + n \cdot a^{n-1} b + \cdots + n \cdot a b^{n-1} + b^n \NR \NC = a^n + n \cdot a^{n-1} b + \cdots + n \cdot a b^{n-1} + b^n \NR \stopmathlines \stopformula \stoptext Taking care of [align=left|right] should be easy. This version will not break across pages. I cannot figure out how to get rid of the outer \vbox. Any suggestions? Aditya
On Sun, 23 Mar 2008, Aditya Mahajan wrote:
On Thu, 13 Mar 2008, Morgan Brassel wrote:
3) Aditya, I saw your remark in your 'My Way' concerning the 'multline' environment. I must admit I would really be glad to see it appear in ConTeXt! I'm afraid I'm not able to implement it myself... I use it a lot with amsmath: when a formula is just too long for one line, I put it on two with multline. The first part of the formula is left aligned on the first line, and the second part is right aligned on the second line. It seems impossible to get the same result with only 'align'. Would it be difficult to make it available in ConTeXt?
Here is my first attempt. Completely bare-bones right now, but short enough to show what needs to be done.
\unprotect \def\startmathlines {\def\stop@math{$} \def\NC{} \def\NR{\def\NC{\cr}} % Hack for number. Should be done by measuring the width of the number \scratchdimen\dimexpr\displaywidth-4em \relax \vbox \bgroup \halign\bgroup \hbox to \scratchdimen {\hfil \strut $\mathsurround\zeropoint\displaystyle{}## \stop@math \hfil}% \crcr \hfilneg}
\def\stopmathlines {\hfilneg \crcr \egroup \egroup} \protect
\starttext
\placeformula \startformula \startmathlines \NC f(x) = (a+b)^n \NR \NC = a^n + n \cdot a^{n-1} b + \cdots + n \cdot a b^{n-1} + b^n \NR \NC = a^n + n \cdot a^{n-1} b + \cdots + n \cdot a b^{n-1} + b^n \NR \stopmathlines \stopformula
\stoptext
Taking care of [align=left|right] should be easy. This version will not break across pages. I cannot figure out how to get rid of the outer \vbox. Any suggestions?
Aditya
Sorry that I can't help you with the implementation, Aditya... I just want to confirm that your new macro perfectly fits my needs. I hope it will make it into the core, it really is useful! As always, a big thanks for your time and patience! Morgan
Morgan Brassel wrote:
Sorry that I can't help you with the implementation, Aditya... I just want to confirm that your new macro perfectly fits my needs. I hope it will make it into the core, it really is useful!
once aditya is confident that it makes sense and works as expected it will probably end up in the core, but as usual i'll wait till he sends me an updated core file Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Mon, 24 Mar 2008, Hans Hagen wrote:
Morgan Brassel wrote:
Sorry that I can't help you with the implementation, Aditya... I just want to confirm that your new macro perfectly fits my needs. I hope it will make it into the core, it really is useful!
once aditya is confident that it makes sense and works as expected it will probably end up in the core, but as usual i'll wait till he sends me an updated core file
It will be a while before I am able to get all the bells and whistles (take care of where the formula number is to be placed, and how how the formula is to be aligned). Aditya
Is there any progress on this? I notice it is not yet in the core. I'm in
need of an AMSL split-like environment but the above doesn't work entirely
as expected. Below is an example.
Any ideas?
Thanks, Dave
\placeformula
\startformula \startalign
\NC \sigma_{L_s}^2
\NC= E\left\{ \eps_L^2 \right\} \NR
\NC \NC= \startmathlines
\NC E\left\{ \left( \frac{1}{L_{\ref}^2(\nu)}
\Re{\eps_{\pth}+\eps_{\off}}\,\cos\left(\phi(\nu)\right) +
\Im{\eps_{\pth}+\eps_{\off}}\,\sin\left(\phi(\nu)\right)
\right)^2 \right\} - \NR
\NC E\left\{ \frac{2}{L_{\ref}^2(\nu)} \,
\frac{L_{\pth}(\nu)}{L_{\ref}(\nu)}
\left(
\Re{\eps_{\pth} +
\eps_{\off}}\,\cos\left(\phi(\nu)\right) +
\Im{\eps_{\pth} +
\eps_{\off}}\,\sin\left(\phi(\nu)\right)
\right) \NR
\NC \left(
\Re{\eps_{\ref} +
\eps_{\off}}\,\cos\left(\phi(\nu)\right) +
\Im{\eps_{\ref} +
\eps_{\off}}\,\sin\left(\phi(\nu)\right) +
\right)
\right\} + \NR
\NC E\left\{ \frac{1}{L_{\ref}^2(\nu)} \,
\frac{L_{\pth}^2(\nu)}{L_{\ref}^2(\nu)}
\left(
\Re{\eps_{\ref} +
\eps_{\off}}\,\cos\left(\phi(\nu)\right) +
\Im{\eps_{\ref} +
\eps_{\off}}\,\sin\left(\phi(\nu)\right)
\right)^2 \right\} \NR
\stopmathlines \NR
\NC \NC= \frac{1}{L_{\ref}^2} \, \left( \sigma_{\pth}^2 +
\left(\frac{L_{\pth}}{L_{\ref}} - 1\right)^2 \sigma_{\off}^2 +
\left(\frac{L_{\pth}}{L_{\ref}}\right)^2 \sigma_{\ref}^2 \right)
\NR[eq:SpcTransVarC2]
\stopalign \stopformula
On Mon, Mar 24, 2008 at 7:17 AM, Aditya Mahajan
On Mon, 24 Mar 2008, Hans Hagen wrote:
Morgan Brassel wrote:
Sorry that I can't help you with the implementation, Aditya... I just want to confirm that your new macro perfectly fits my needs. I hope it will make it into the core, it really is useful!
once aditya is confident that it makes sense and works as expected it will probably end up in the core, but as usual i'll wait till he sends me an updated core file
It will be a while before I am able to get all the bells and whistles (take care of where the formula number is to be placed, and how how the formula is to be aligned).
Aditya
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
___________________________________________________________________________________
This can be corrected by changing the \vbox in the definition of \startmathlines to \vtop. This can be made configurable by adding a location key. Here is a complete example \unprotect \def\startmathlines {\def\stop@math{$} \def\NC{} \def\NR{\def\NC{\cr}} % Hack for number. Should be done by measuring the width of the number \scratchdimen\dimexpr\displaywidth-4em \relax \vbox \bgroup \halign\bgroup \hbox to \scratchdimen {\hfil \strut $\mathsurround\zeropoint\displaystyle{}## \stop@math \hfil}% \crcr \hfilneg} \def\stopmathlines {\hfilneg \crcr \egroup \egroup} \protect Once I understand the new experimental code, I will start playing around with aligned math support. Aditya On Sat, 17 Jan 2009, Dave wrote:
Is there any progress on this? I notice it is not yet in the core. I'm in need of an AMSL split-like environment but the above doesn't work entirely as expected. Below is an example. Any ideas? Thanks, Dave
\placeformula \startformula \startalign \NC \sigma_{L_s}^2 \NC= E\left\{ \eps_L^2 \right\} \NR \NC \NC= \startmathlines \NC E\left\{ \left( \frac{1}{L_{\ref}^2(\nu)}
\Re{\eps_{\pth}+\eps_{\off}}\,\cos\left(\phi(\nu)\right) +
\Im{\eps_{\pth}+\eps_{\off}}\,\sin\left(\phi(\nu)\right) \right)^2 \right\} - \NR \NC E\left\{ \frac{2}{L_{\ref}^2(\nu)} \, \frac{L_{\pth}(\nu)}{L_{\ref}(\nu)} \left( \Re{\eps_{\pth} + \eps_{\off}}\,\cos\left(\phi(\nu)\right) + \Im{\eps_{\pth} + \eps_{\off}}\,\sin\left(\phi(\nu)\right) \right) \NR \NC \left( \Re{\eps_{\ref} + \eps_{\off}}\,\cos\left(\phi(\nu)\right) + \Im{\eps_{\ref} + \eps_{\off}}\,\sin\left(\phi(\nu)\right) + \right) \right\} + \NR \NC E\left\{ \frac{1}{L_{\ref}^2(\nu)} \, \frac{L_{\pth}^2(\nu)}{L_{\ref}^2(\nu)} \left( \Re{\eps_{\ref} + \eps_{\off}}\,\cos\left(\phi(\nu)\right) + \Im{\eps_{\ref} + \eps_{\off}}\,\sin\left(\phi(\nu)\right) \right)^2 \right\} \NR \stopmathlines \NR \NC \NC= \frac{1}{L_{\ref}^2} \, \left( \sigma_{\pth}^2 + \left(\frac{L_{\pth}}{L_{\ref}} - 1\right)^2 \sigma_{\off}^2 + \left(\frac{L_{\pth}}{L_{\ref}}\right)^2 \sigma_{\ref}^2 \right) \NR[eq:SpcTransVarC2] \stopalign \stopformula
On Mon, Mar 24, 2008 at 7:17 AM, Aditya Mahajan
wrote: On Mon, 24 Mar 2008, Hans Hagen wrote:
Morgan Brassel wrote:
Sorry that I can't help you with the implementation, Aditya... I just want to confirm that your new macro perfectly fits my needs. I hope it will make it into the core, it really is useful!
once aditya is confident that it makes sense and works as expected it will probably end up in the core, but as usual i'll wait till he sends me an updated core file
It will be a while before I am able to get all the bells and whistles (take care of where the formula number is to be placed, and how how the formula is to be aligned).
Aditya
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
___________________________________________________________________________________
participants (6)
-
Aditya Mahajan
-
Dave
-
Hans Hagen
-
Morgan Brassel
-
Morgan Brassel
-
Wolfgang Schuster