wspr / breqn

Automatic line breaking in LaTeX equations
18 stars 2 forks source link

Declare breaking and non-breaking symbols #15

Closed svenkeidel closed 8 years ago

svenkeidel commented 8 years ago

How can I specify that a relation symbol is not available for breaking inside a formula? Furthermore, how can I specify that the punction . can be used as a breaking symbol?

Ideally I would like to write something like this:

\usepackage[breaking={.}, nonbreaking={\in}]{breqn}

Here is a minimal example formula that is indented weirdly:

\documentclass{minimal}

\usepackage{amsmath}
\usepackage{breqn}

\begin{document}
  \begin{dmath*}
     \phi = \exists x \in M. \exists y \in M. \psi
  \end{dmath*}
\end{document}

formula

wspr commented 8 years ago

Is this more than one equation? Note that, although I think the syntax is rather verbose, breqn asks for each separate equation to be placed into separate dmath environments. Apologies, but can you supply an “expected” output typeset with amsmath?

svenkeidel commented 8 years ago

These two alternatives would be fine:

  \begin{align*}
     \phi =& \exists x \in M. \\
           & \exists y \in M. \\
           & \psi
  \end{align*}

  \begin{align*}
     \phi =& \exists x \in M. \\
           & \quad \exists y \in M. \\
           & \qquad \psi
  \end{align*}

screen shot 2016-07-14 at 14 30 42

I simply want to avoid breaking formulas at \in and allow breaking formulas at .

davidcarlisle commented 8 years ago

I think here the issue isn't so much to globally stop breaks on \in but rather to mark the subterm with the type judgement as something on which not to break, if you do

\begin{dmath*}
     \phi = \exists {x \in M}. \exists {y \in M}. \psi
\end{dmath*}

Then you get a much better layout from breqn.

svenkeidel commented 8 years ago

@davidcarlisle, thanks for the advice, but the formula you suggested does allow breaking at all. The problem is that . is now breaking point:

  \begin{dmath*}
     \phi = \exists {x \in M}. \exists {x \in M}. \exists {x \in M}. \exists {x \in M}. \exists {x \in M}. \exists {x \in M}.\exists {x \in M}.\exists {x \in M}.\exists {x \in M}.\exists {x \in M}.\exists {x \in M}.\exists {x \in M}.\exists {x \in M}.\exists {x \in M}.\exists {x \in M}. \psi
  \end{dmath*}

screen shot 2016-07-14 at 15 46 50

davidcarlisle commented 8 years ago

You can declare a breakable . by making it a binary operator (probably other ways too but \mathbin seems OK for this usage)


\documentclass{minimal}

\usepackage{amsmath}

\usepackage{breqn}

\DeclareFlexSymbol{\mydot}{Bin}{OML}{3A}

\begin{document}

  \begin{dmath*}
     \phi = \exists x \in M\mydot \exists y \in M\mydot \psi
  \end{dmath*}

  \begin{dmath*}
     \phi = \exists {x \in M}\mydot \exists {y \in M}\mydot \psi
  \end{dmath*}

 \begin{dmath*}
     \phi = \exists {x \in M}\mydot \exists {x \in M}\mydot \exists {x \in M}\mydot \exists {x \in M}\mydot \exists {x \in M}\mydot \exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot \psi
  \end{dmath*}
\end{document}

it doesn't really capture the semantic nesting though

svenkeidel commented 8 years ago

This would work, if the line would break after the . and not before:

screen shot 2016-07-14 at 16 20 58

I.e. something like this:

screen shot 2016-07-14 at 16 36 03

davidcarlisle commented 8 years ago

yes I was going to comment on that, I'd need to check flexisym to see if you can specify break-after, but it's a separate issue to the original request to be able to specify in a dmath argument that "." should break (I should mention It's Will's repo (but it's rather late in Australia:-) I have no write access to the sources, just an interested bystander.

On 14 July 2016 at 15:23, Sven Keidel notifications@github.com wrote:

Also the line breaks before the . and not after:

[image: screen shot 2016-07-14 at 16 20 58] https://cloud.githubusercontent.com/assets/266500/16842808/11449e5a-49df-11e6-9d4a-8f0d4e26fb49.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wspr/breqn/issues/15#issuecomment-232680195, or mute the thread https://github.com/notifications/unsubscribe/ABNcAoJqp1uxab9Jw8Mq_FT41yenuKOTks5qVkZEgaJpZM4JMVHL .

svenkeidel commented 8 years ago

Oh, I see, but thanks for the help anyway.

wspr commented 8 years ago

On 15 Jul 2016, at 12:08 AM, David Carlisle notifications@github.com wrote:

yes I was going to comment on that, I'd need to check flexisym to see if you can specify break-after, but it's a separate issue to the original request to be able to specify in a dmath argument that "." should break (I should mention It's Will's repo (but it's rather late in Australia:-) I have no write access to the sources, just an interested bystander.

Would you like write access? :) Despite Morten’s request that the package revert to his name, I have no evidence he’s looked at the code.

Cheers, Will

svenkeidel commented 8 years ago

So, @wspr, @davidcarlisle, how can I declare the dot to be a breaking symbol without appearing at the beginning of the next line?

davidcarlisle commented 8 years ago

@svenkeidel possibly like this

\documentclass{minimal}

\usepackage{amsmath}

\usepackage{breqn}

\DeclareFlexCompoundSymbol{\mydotb}{Bin}{} 
\def\mydot{.\mydotb}

\begin{document}

  \begin{dmath*}
     \phi = \exists x \in M\mydot \exists y \in M\mydot \psi
  \end{dmath*}

  \begin{dmath*}
     \phi = \exists {x \in M}\mydot \exists {y \in M}\mydot \psi
  \end{dmath*}

 \begin{dmath*}
     \phi = \exists {x \in M}\mydot \exists {x \in M}\mydot \exists {x \in M}\mydot \exists {x \in M}\mydot \exists {x \in M}\mydot \exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot\exists {x \in M}\mydot \psi
  \end{dmath*}
\end{document}

which makes \mydot a dot followed by an empty breakable \mathbin

svenkeidel commented 8 years ago

Ah, thanks, this works. For the record, here is the result:

screen shot 2016-07-18 at 13 21 35