certik / theoretical-physics

Source code of the Theoretical Physics Reference online book
https://theoretical-physics.com
MIT License
220 stars 48 forks source link

Breaking math formulas into multiple lines (whether to repeat the sign), possibly automate it #74

Open certik opened 8 years ago

certik commented 8 years ago

I am currently following the Russian (and Czech, Polish, ...) tradition, that when a mathematical formula is broken into multiple lines, the last sign on the line (typically = or +) is repeated at the beginning of the next line. The problem with this convention is that many American readers think, that the sign left on the previous line is a typo.

Some references for this convention are e.g. here and here. In the second link, see the "Hyphenation in mathematics". In there, the convention by priority is to prefer breaking at a relational sign (<, >, =, , ...). If not possible, then at addition/subtraction sign (+, -, ±, ), and if not possible, then finally at a multiplication sign (i.e., at the position where multiplication is assumed since the explicit multiplication sign is usually skipped in mathematical expressions). Signs like *, ., /, (, [, etc. prevent formula breaking. There are some more tips there. As far as these rule go, I think the U.S. convention is similar if not identical.

The rule that is different is:

When the mathematical formula (embedded in text or as a separated block) is broken into two parts and is continued on the next line, tradition requires that we must repeat the last sign in the broken formula at the end of the first part and at the beginning of the second part placed on the next line. When a multiplication is broken, the explicit multiplication sign ‘×’ is inserted, and this sign is repeated on the next line as well.

I just checked my English edition of Landau & Lifshitz, and indeed, they repeat the + sign at the end of the line and at the beginning of the next line (but they are not always consistent, sometimes they do not repeat +). They do not seem to repeat the = sign. However, Russian books all seem to strictly repeat the sign, including =, see e.g. this page at Google books (you might need to be logged in to see it).

I was actually even wondering, if the formula breaking cannot be made automatic, just like a paragraph breaking. The reason is that for narrow displays, some of the formulas do not fit the page. For wide displays, they would. Some formulas fit nicely in html, but do not fit nicely in the pdf version of the book.

I think the algorithm would be very simple, it would try to break at relational sign, if impossible, then at addition/subtraction. I would ignore the last multiplication rule, because it's implicit, so it would be hard to implement. Then the algorithm can easily repeat the last sign, or not, depending on user preferences.