4

Grid typesetting works quite well in ConTeXt for single-line equations (see the first example below). However, replacing it by any number of aligned equations (including just a single "aligned" equation) causes the rest of the page not to be aligned with the grid (see the second example below). Can I get grid typesetting for aligned systems of equations?

\setuplayout
[grid=yes]

\setupindenting[yes,medium]

\definecolumnset[example][n=2]

\setupformulas[indentnext=auto] 

\starttext

\showgrid

\startcolumnset[example]
\input knuth
\input knuth
\input knuth
\startformula
x^2 + y^2 = z^2
\stopformula
\input knuth
\input knuth
\input knuth
\stopcolumnset

\stoptext

enter image description here

Replacing the formula by

\startformula
\startmathalignment
\NC x^2 + y^2 \NC = z^2\NR[+]
\NC u^2 + v^2 \NC = w^2\NR[+]
\stopmathalignment
\stopformula

I get

enter image description here

  • 1
    When you add \setupformulas[align=middle] to your document the paragraph after the formula will be on the grid but I haven’t tested if there there are side effect (e.g. changed alignment) for other formulas. – Wolfgang Schuster Jul 12 '15 at 17:50
  • @Metafox, strange, is align=middle not the standard setting? – Gaussler Jul 12 '15 at 18:31
  • P.S. Thanks! That sounds so far like the easiest and most "correct" solution. – Gaussler Jul 12 '15 at 18:32
  • The default value is align=normal. – Wolfgang Schuster Jul 12 '15 at 18:33
  • Thanks for your solution. Nevertheless, I think this can be regarded as a bug. – Gaussler Jul 12 '15 at 18:36
2

The easiest solution is to wrap your formula into a pair of startlinecorrection ... stoplinecorrection; this will disregard the grid for the formulas themselves but align the material after them on the grid, which I assume is what you want. If you need more control, have a look at chapter 4 of It's in the Details, available at the [pragma website]: 1

enter image description here

  • I looked in Details already, but there is a striking lack of coverage of multiline equations. – Gaussler Jul 11 '15 at 13:36
  • I shall accept your answer if no one can provide me with the ideal solution, the equations themselves being placed on the grid. It would seem that ConTeXt has no support for that at the moment. – Gaussler Jul 11 '15 at 14:07
2

Maybe this was a bug. In TeXlive 2017 your MWE is working just fine.

\setuplayout[grid=yes]

\setupindenting[yes,medium]

\definecolumnset[example][n=2]

\setupformulas[indentnext=auto] 

\starttext

\showgrid

\startcolumnset[example]
  \input knuth
  \input knuth
  \input knuth
  \startformula
    \startmathalignment
      \NC x^2 + y^2 \NC = z^2\NR[+]
      \NC u^2 + v^2 \NC = w^2\NR[+]
    \stopmathalignment
  \stopformula
  \input knuth
\stopcolumnset

\stoptext

enter image description here

If you are using the latest beta and you want to number these aligned formulas, use

\placeformula
\startformula
  \startmathalignment[number=auto,grid=both]
    \NC x^2 + y^2 \NC = z^2\NR
    \NC u^2 + v^2 \NC = w^2\NR
  \stopmathalignment
\stopformula
  • It is nice to see that you get back to the grid again! With your code, in the latest beta, there is an extra line after the aligned formulas. This means that the code after starts on line 22, and the formula is not aligned vertically in my opinion. What do you think? – mickep Aug 23 '17 at 6:00
  • @mickep You could add for instance grid=both. The problem with boxes in math mode and gridsnapping is that in math there is no longer a notion of lineheight. An integral for example generate a huge lineheight compared to a letter. Therefore there does not exist a canonical gridsnapping for all multiline formulas. You have to choose on each occurrence. You could also \setupmathalignment[grid=no] and hope that it looks fine if the box is just centred between the paragraphs. – Henri Menke Aug 23 '17 at 9:32
  • 1
    @mickep At some point in the future I want to write my own math integration for ConTeXt, based on amsmath and hopefully I find a way to do it right. – Henri Menke Aug 23 '17 at 9:35
  • Thanks for your explanation. The grid=both works fine in the latest beta in this case. This looks promising, and I hope that OP is satisfied. About your plans for some amsmath based math integration, it sounds interesting. It would be good if that was actually in the core, but maybe that clashes with something. – mickep Aug 23 '17 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.