Aditya Mahajan (presented by Taco Hoekwater)
ConTeXt always had some basic ConTeXt support, but no support for multi line display math
When I started using ConTeXt, I made a request for multi line display math on the mailing list and Hans implemented it in a few hours!!
More request followed and more features were implemented by Hans and Taco.
ConTeXt supports a big subset of display math features of AMSTeX
But the user interface is a bit cumbersome.
Mainly because multi line math was build on top of existing interface.
I am suggesting a new interface from scratch
Currently, \startformula
...
\stopformula
is a fancy way to involve
$$
... $$
.
For someone who never completely grokked plain TeX,
$$
... $$
is one of the weirdest
TeX construct.
Automagically determines before and after skip based on the length of the previous line
Always centers the current line (macro package has to fight against this).
Does some very intelligent calculations with label
placement using \eqno
and
\leqno
ConTeXt just provides a wrapper around all this
Makes it very difficult to get predictable results
Very difficult to discourage ConTeXt to prevent page breaks before the start of a formula
Spacing around \intertext
does not follow
the same logic as spacing before and after $$
... $$
.
Suggestion: Completely get rid of
$$
... $$
.
Do the complete opposite of how Taco writes plain TeX code
This is getting weird, with Taco presenting this talk, anyway ...
Seen in a test file from Taco
$$\externalfigure[...]$$
Taco's explanation: $$
.. $$
is the easiest way to go into display mode.
Define macros \startdisplaymath
...
\stopdisplaymath
that do not use
\Ustartdisplaymath
...
\Ustopdisplaymath
After all, writing a macro that goes into display mode
is easy! \startframedtext
already does
that.
Provide hooks to configure spacing and penalties.
Need to replicate TeX model by keeping track of the width of the previous line.
Predictability
Easier configuration than
\everydisplay
.
Easy to hook the same macros in multi line display
Reimplementing TeX's algorithm at macro level is difficult. Why did Knuth not implement these features at macro level?
Reimplementing \(l)eqno
is even trickier
IIRC, TeX occasionally squeezes all the glue in a formula
to ensure that it fits in a line. If we typeset a formula
in an \hbox
to measure its width, the glue is
already frozen. Maybe some attribute magic will work.
Current interface is cumbersome.
I am suggesting an alternate interface. To avoid
confusion, I will call it \...equation
rather
than \...formula
\placeformula[label] \startformula ... \stopformula
vs
\startequation[label] ... \stopequation
and
\startformula ... \stopformula
vs
\startequation[-] ... \stopequation
\startequation[number=no] ... \stopequation
\startformula[12pt] ... \stopformula
\startformula[boldmath] ... \stopformula
vs
\startequation[style=big] ... \stopequation
\startequation[style=bold] ... \stopequation
\placeformula[ref] \startformula[12pt] ... \stopformula
vs
\startequation[ref][style=big] ... \stopequation
\startformula \startalign[n=2, align={...}] ... \stopalign \stopformula
Why have two declarations?
\startequation[n=2,align={...}] ... \stopequation
Predefined alternatives:
\definemathalignment[gather][n=1,align=middle]
\startformula \startgather ... \stopgather \stopformula
vs
\definemathalignment[gather][n=1,align=middle]
\startequation[alternative=gather] ... \stopequation
or perhaps easier(?)
\startequation[parent=gather] ... \stopequation
Sub formulas need more thought
Sorry, I have run out of time to coherently express my thoughts on sub formulas.
\placesubformula \startformula ... \stopformula
vs
\startequation[alternative=sub] ... \stopequation
or perhaps(?)
\startsubequation ... \stopsubeuqation
\NR
is
confusing. \NR
should take only one argument
(the label) and sub formula numbering should be
automatic.Current solution:
\defineconversion[main][Main Result]
\defineformlaalternative]main][conversion=main]
\startmainformula ... \stopmainformula
vs:
\startequation[tag={Main Result}] ... \stopequation
I am not convinced that this is necessary
User interface needs some thought
Outer background
+-----------------------------------------+
| |
| E = mc^2 (1) |
| |
+-----------------------------------------+
Inner background
+----------+
| E = mc^2 | (1)
+----------+
Backgrounds should work for multi line formulas
+-----------------------------------------+
| |
| E = mc^2 (1) |
| a^2 + b^2 = c^2 |
| = E/m (2) |
| |
+-----------------------------------------+
and
E = mc^2 (1)
+----------------+
|a^2 + b^2 = c^2 |
| = E/m | (2)
+----------------+
Backgrounds should break across pages!!
Parameters that need to be passed to metapost
textbackgrounds
)Or maybe, like \startTABLE
each cell should
have a separate background.
I don't know how expensive will backgrounds be. My understanding is that with mplib, they will not slow down compilation too much.
Need a \framed
equivalent for math.
\mframed
does not fit the bill. Think of
matrix
fitted with backgrounds but more
configurable.
A new key for
mathstyle=(text|display|script|subscript|auto)
A new key for cramped=(yes|no|auto)
A key for height=auto|dimen
(or perhaps
autoheight=yes|no
)
If we have two matrices side by side, the rows
should have same baseline (\startmatrix
does that)
But that is not always needed.
A key for width=auto|dimen
(or perhaps
autowidth=yes|no
)
Not sure: A key for setting column
widths, a la \startTABLE
Basically, everything can be built on top of this. I should be able to pass these above keys to any math environment.
Implement Microsoft linear math input
Not too difficult, but is that useful?
\setupmathematics[input=tex|microsoft]
Automatic line breaking of multi line display
Is there a good algorithms? Does anyone know how breqn works (not the internal details, but the algorithms).
If not, do we (the TeX community) need a Knuth-Plass line breaking algorithm for multi line math.
\setupformulas[split=<name of lua
function>]
, and let users experiment with
different line breaking algorithms in lua.
LaTeX bug database says that the spacing around
\left
and \right
is wrong. If so,
does that need to be fixed at the engine level? (It is easy
to fix it at the macro-package level).
Can the engine support \left
and
\right
splitting across lines? Why is that
difficult?
If not, should we support it at the macro level? Easy to do for inline math. Need to think of the right user interface for multi line display.
In \displaystyle \left[\sum_{i=0}^\infty
\right]
the delimiters are too larger.
\Big[ \sum_{i=0}^\infty\Big]
gives more
reasonable spacing.
Should we have a primitive \smashedlimits
such that the output of
\left[ \sum\smashedlimits_{i=0}^\infty \right]
is the same as the output of
\Big[ \sum\limits_{i=0}^\infty \Big] \vphantom{\sum\limits_{i=0}^\infty }
That is only the auto scaling of delimiters is affected, the height of the final box remains the same.
nath
does this at macro level.
Do we need a math version of \halign
? Why
do we need to go out of math mode to do alignment and then
reset all the math parameters?
Will greatly simplify the macros
\sum_{\mhalign{\hss ## \hss \cr i = 0 \cr j = i \crcr}}
vs all the trickery that \startsubstack
has
to do.
Thanks for listening to my ramblings.
Thanks to Taco for presenting this.