6

I was reading

another breqn problem. Extra letters show up in title with cprotect package

And the answer says:

In an upcoming version ConTeXt MKIV will introduce automatic linebreaking for formulas which will probably be much more robust because parsing is done on the Lua level and thus avoids confusions with catcodes and such.

But the link given does not work. The above 6 years old.

I googled and could not find something relevant.

My question is: does context now have better automatic equation breaking than breqn in Latex? I thought someone here might know.

but can you please define better?

As I mentioned in comment, I do not have specific examples. But I searched and found one, where a Latex expert in this forum said breqn output can be improved.

Code below from How convert equation environment to dmath environment automatically?

\documentclass[12pt,notitlepage]{article}

\usepackage{amsmath}
\usepackage{breqn}

\begin{document} 

No tag here, normal numbering
\begin{dmath}
-\eta\omega_{y}+\left(  -3y' \xi_{y}-2\xi_{x}+\eta_{y}\right)
\omega-\xi\omega_{x}+\left(  -y' \eta_{y}+\left(  y'\right)
^{2}\xi_{y}+y' \xi_{x}-\eta_{x}\right)  \omega_{y'}+\eta
_{xx}+\eta_{yy}\left(  y' \right)  ^{2}-
\xi_{yy}\left(  y' \right)^{3}-2\xi_{yx}\left(  y'\right)  ^{2}+2\eta_{yx}y'-\xi_{xx} y'=0
\end{dmath}

Tag at the beginning
\begin{dmath}[number=1A]
-\eta\omega_{y}+\left(  -3y' \xi_{y}-2\xi_{x}+\eta_{y}\right)
\omega-\xi\omega_{x}+\left(  -y' \eta_{y}+\left(  y'\right)
^{2}\xi_{y}+y' \xi_{x}-\eta_{x}\right)  \omega_{y'}+\eta
_{xx}+\eta_{yy}\left(  y' \right)  ^{2}-
\xi_{yy}\left(  y' \right)^{3}-2\xi_{yx}\left(  y'\right)  ^{2}+2\eta_{yx}y'-\xi_{xx} y'=0
\end{dmath}

No \verb|\left| and \verb|\right|
\begin{dmath}
-\eta\omega_{y}+(  -3y' \xi_{y}-2\xi_{x}+\eta_{y})
\omega-\xi\omega_{x}+(  -y' \eta_{y}+(  y')
^{2}\xi_{y}+y' \xi_{x}-\eta_{x})  \omega_{y'}+\eta
_{xx}+\eta_{yy}(  y' )  ^{2}-
\xi_{yy}(  y' )^{3}-2\xi_{yx}(  y')  ^{2}+2\eta_{yx}y'-\xi_{xx} y'=0
\end{dmath}

\end{document}

enter image description here

2
  • 1
    I guess the answer is yes, but can you please define better? What do you need? I'm teaching now but I can shoe some examples later...
    – mickep
    Oct 2 at 7:06
  • 1
    @mickep I do not really have specific examples at hand. But two issues here: one is that breqn package causes lots of problem with other packages and settings when used in lualatex due to conflicts. Second issue is quality of its own output. I am not expert on the second one. But I will post an example now will a latex expert thinks its output is not ideal. This can be used to compare with what context produces?
    – Nasser
    Oct 2 at 8:35

1 Answer 1

6

The automatic setting of formulas will never be completely fine. Let me show your example, done in a few ways below. A few comments:

  • All formulas are by default breaking over lines (they are essentially paragraphs).
  • The line breaking is controlled by penalties (see how we change the default for binary, something that is on the todo to do by default)
  • Delimiters automatically break over lines (first formula).
  • Multiline formulas are numbered "bottom right" or "top left", not by a number inbetween formula lines.

I think you need to ask something more specific to get a better reply.

\setuppapersize[A5]
\setuplayout[tight]

\showframe

\starttext

\startbuffer[formula]
  - \eta \omega_{y} 
  + \left(-3y' \xi_{y}
      - 2\xi_{x}
      + \eta_{y}
    \right) \omega
  - \xi\omega_{x}
  + \left[
      - y' \eta_{y}
      + \left(y'\right)^{2}\xi_{y} 
      + y' \xi_{x}
      - \eta_{x}
    \right] \omega_{y'}
  + \eta_{xx} 
  + \eta_{yy}\left(y' \right)^{2}
  - \xi_{yy} \left(y' \right)^{3} 
  - 2\xi_{yx}\left(y' \right)^{2} 
  + 2\eta_{yx}y' 
  - \xi_{xx} y'
  = 0
\stopbuffer

Just setting the formula.

\startformula
  \getbuffer[formula]
\stopformula

Modifying the penalties.

\startbuffer
\setmathdisplayprepenalty  \mathbinarycode 0
\setmathdisplaypostpenalty \mathbinarycode 1000
\stopbuffer

\typebuffer
\getbuffer

\startformula
  \getbuffer[formula]
\stopformula

Adding a formula number.

\startplaceformula
  [reference=eq:foo1]
  \startformula
    \getbuffer[formula]
  \stopformula
\stopplaceformula

Using a subformula number.

\startsubformulas
  \startplaceformula
    [reference=eq:foo2]
    \startformula
      \getbuffer[formula]
    \stopformula
  \stopplaceformula

Decreasing the \typ{numberdistance} to make the label fit.

  \startplaceformula
    [reference=eq:foo3]
    \startformula
      [numberdistance=1em]
      \getbuffer[formula]
    \stopformula
  \stopplaceformula
\stopsubformulas

No stretching of fences (\typ{\F0}).

\startplaceformula
  \startformula
    \F0
    \getbuffer[formula]
  \stopformula
\stopplaceformula

\stoptext

resulting formulas

2
  • 1
    Thanks. But why did you change parentheses change from () to [] ? is it just for display purposes only? All output looks nice and consistent.
    – Nasser
    Oct 2 at 10:14
  • 2
    I forgot to say, I just did that to the only one that was growing, for no obvious reason. Use ( and ).
    – mickep
    Oct 2 at 10:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .