dryabov / rmathbr

Repeating of math hyphenation mark in inline equations
http://d-ryabov.livejournal.com/723.html
8 stars 0 forks source link

Request: add option to break the minus symbol asymmetrically #9

Open typomaster2 opened 3 years ago

typomaster2 commented 3 years ago

Would it be possible to add a new feature to the package rmathbr? Namely, currently expressions like a – b are broken up symmetrically, i.e. as a – on the previous line and – b on the new line.

BUT there is currently no option to break a – b asymmetrically, with a – on the previous line and + b on the new line. (Or the other way around).

Q: Could this be option be added in the future? Perhaps something like [brokenminus=-+] for a – and + b, and [brokenminus=+-] for a + and – b would be good syntax.

dryabov commented 3 years ago
  1. -+ is possible, but +- requires temporary switching to text mode (like it is done for changing \cdot to \times on break). The latter is quote complicated and may lead to some other issues.
  2. It cannot be added to the current codebase easily, but there is a dirty hack you can use in preamble (not sure about compatibility with unicode-math package):
    \makeatletter
    \def\minus@char{\mathchar8704}
    \def\plus@char{\mathchar8235}
    \def\rmathbr@selector#1{%
    \def\x@char{#1}%
    \ifx\x@char\minus@char\def\x@char{\plus@char}\fi%
    \mathchoice
    {\discretionary{}{\hbox{$\m@th\displaystyle\x@char$}}{}}
    {\discretionary{}{\hbox{$\m@th\textstyle\x@char$}}{}}
    {\discretionary{}{\hbox{$\m@th\scriptstyle\x@char$}}{}}
    {\discretionary{}{\hbox{$\m@th\scriptscriptstyle\x@char$}}{}}%
    }
    \makeatother
typomaster2 commented 3 years ago

Thank you for commenting, and for providing the dirty fix! Based on initial testing, the solution you provide works great.

As far as I am concerned, we may consider this issue resolved (closed). But if you should choose to keep the issue open because you plan to try to add it to the package codebase in the future, that's OK too. Thank you very much once more!