[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-users
Subject:    Re: How to break long equations with LyX
From:       Joel Kulesza <jkulesza () gmail ! com>
Date:       2020-06-21 4:09:24
Message-ID: CAAGOGw8KgjfwB_g7+bvDXSDTR_6h5S4tQos5ekYxWNCjgJb7Zw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Sat, Jun 20, 2020 at 12:13 PM Paul A. Rubin <parubin73@gmail.com> wrote:

> On 6/19/20 9:47 PM, list_email@icloud.com wrote:
> 
> On Jun 19, 2020, at 5:14 PM, Paul A. Rubin <parubin73@gmail.com> \
> <parubin73@gmail.com> wrote: 
> On 6/19/20 7:34 PM, list_email@icloud.com wrote:
> 
> On Jun 19, 2020, at 8:15 AM, Paul A. Rubin <parubin73@gmail.com> \
> <parubin73@gmail.com> wrote: 
> On 6/19/20 7:51 AM, list_email@icloud.com wrote:
> 
> I have tried mightily to get LyX to break long equations. I've studied multiple \
> pages at stackexchange, both LaTeX and LyX, and can't seem to get anything to work. \
>  I have had luck in the past with the second large block of code at this page:
> https://stackoverflow.com/questions/2904807/lyx-breaking-long-formula-lines
> 
> but today I have some problems with it.
> 
> First, it doesn't work if the \text command appears inside my own LaTeX code that \
> appears between \begin{dmath} and \end{dmath} or if I try to use the trick twice in \
> the same document. (That's a tentative analysis of the problem.) Specifically, LyX \
> runs at 100% CPU eventually gives me a chance to abort and then follows up with \
> this additional message: "The external program pdflatex finished with an error. It \
> is recommended you fix the cause of the external program's error (check the logs)." \
>  Plus, I now want to to apply the line breaking to a line within an aligned \
> environment (Insert -> Math -> Aligned Environment in the menu system.) This is \
> causing things to look even worse, even though I added two "aligned" lines to the \
> referenced code block. (If you look at the code you'll see the obvious places to \
> add the lines.) 
> How do LyX-ers handle this? Is there "LyX" solution to breaking long equations? I'm \
> OK with some ad hoc solution for now, or some ERT if it works. 
> Thanks,
> Jerry
> 
> 
> 
> I've never used the breqn package, but with ordinary and AMS math environments, \
> hitting Ctrl-Enter in the middle of a long formula will break it (inserting a line \
> break, \\, in the LaTeX output). If that doesn't achieve what you want, perhaps you \
> could post a minimal example and a specification of what the output should look \
> like. 
> Paul
> 
> 
> Thanks, Paul. I'm on a Mac so of course Control-Enter has no meaning. Usually this \
> translates to Mac-speak as Command-Enter. When I do Command-Enter in my equation, \
> which is unfortunately inside a align environment, it instead adds a row to the \
> matrix that represents the align environment. Ditto for Shift-Command-Enter. These \
> two commands in LyX are mapped as Insert -> Formatting -> Ragged Line Break and \
> Justified Line Break, respectively but invoking the menu commands with the cursor \
> in my equation has exactly the same effect: adding a row to the align matrix (above \
> the row where the cursor is.) When (Shift-)Command-Enter is done to a non-align \
> display equation a similar thing happens except now the non-align equation is \
> converted to an align equation with a blank new row _below_ the original equation. 
> Right now I guess I would be pretty happy with merely a way to make Command-shift \
> (Control-shift) do what is expected which is apparently break the equation instead \
> of creating a new row. 
> Jerry
> 
> 
> Jerry,
> 
> I just created an align environment with two equations, the left side of the first \
> being ridiculously long. When I put the cursor somewhere toward the middle of the \
> left side of the long equation and inserted a break (using Ctrl-Enter -- I'll get \
> to the Mac part in a minute), it broke the equation and inserted a new row. So 
> (x+x+x+x+...+x) =1
> y =2
> 
> (where the right column contained the equal signs and integers) became
> 
> (x+x+x+...
> +x+x+x+x) =1
> y =2
> 
> where the right column is empty in the first row. See the attached minimal example. \
> Is this not what you want? 
> Regarding the key mapping, if you can find an unused key combo that you have a \
> chance of remembering, you can map it to "newline-insert newline" using Tools > \
> Preferences... > Editing > Shortcuts. That's what Ctrl+Enter binds to for me. 
> Paul
> 
> Paul:
> 
> Thanks. The effect appears to work by adding another row to the matrix and filling \
> it with the partial equation. In your example the new row is on top. If the long \
> equation is moved to the RHS the new row is below. 
> I tried adding horizontal space to the second line of your broken equation but \
> Latex seems to ignore it: when I click outside the math box and the equation is \
> rendered, it is rendered without the horizontal space even though it was visible \
> while in math editing mode. 
> About Mac key mappings: According to the status line in the document window, when I \
> hit Command-Shift, it displays "(newline-insert newline;) and then icons for \
> "Command" and "new line" which is an arrow thingy. So I'm going to assume that the \
> key mapping is correct but that there is another problem, meaning… 
> …See my attached example. Attempting to break the line before the second \
> exponential (1) doesn't break the line, (2) adds a matrix row above, and (3) steals \
> the = from the now-third row and puts it on the second row. 
> The failure to break with Command-Enter does not seem to be a function of the align \
> environment since it also fails in a stand-alone equation but adding a new row \
> creates a new align environment. 
> I notice that my long equation, as rendered by LyX in the LyX window, gets \
> truncated on the right. I don't know why—this does not happen in the document \
> from which I am copying it. 
> Summary: Control-(or Command-)Shift doesn't work on my equation.
> 
> Jerry
> 
> 
> 
> 
> Jerry,
> 
> I messed with your example file and attached the result. The good news is
> that your formula is breakable. The bad news is that there is a bit of a
> PITA component to doing so.
> 
> The reason your attempt to break the formula failed was that it is
> enclosed in \left [ \right ], which apparently causes either LyX or LaTeX
> (I'm not sure which) to treat what is in between the brackets as
> unbreakable. The fix I came up with was to delete the bracketing, decide
> where I wanted to break the formula, then wrap the left half with just a
> left bracket and the right half with just a right bracket. You can do this
> using the "Insert delimiters" dialog (the "[ space ]" button on the tool
> bar), by unchecking the "Keep matched" box and then choosing the
> appropriate bracket on one side and "(None)" on the other. Once I'd done
> that, Ctrl+Return broke the line as expected.
> 
> I also put in a second version with IMO better balance, in which I did the
> same thing but moved the = sign to the left column.
> 
> Paul
> 

Jerry, Paul,

I think Paul came to the same conclusion as me with respect to how to break
equations (particularly when substantial components are within
delimiters).  The approach that Paul described is the one I use routinely,
and the "Swap and Reverse" button in the "Math Delimiter" dialog is meant
to ease some of the PITA'edness of this process.  I, too, wish there was a
better way, but if there is, I am ignorant to it.

- Joel


[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr">On Sat, Jun 20, 2020 at 12:13 PM Paul A. Rubin &lt;<a \
href="mailto:parubin73@gmail.com">parubin73@gmail.com</a>&gt; wrote:<br></div><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <div>On 6/19/20 9:47 PM,
      <a href="mailto:list_email@icloud.com" \
target="_blank">list_email@icloud.com</a> wrote:<br>  </div>
    <blockquote type="cite">
      <pre></pre>
      <blockquote type="cite">
        <pre>On Jun 19, 2020, at 5:14 PM, Paul A. Rubin <a \
href="mailto:parubin73@gmail.com" target="_blank">&lt;parubin73@gmail.com&gt;</a> \
wrote:

On 6/19/20 7:34 PM, <a href="mailto:list_email@icloud.com" \
target="_blank">list_email@icloud.com</a> wrote: </pre>
        <blockquote type="cite">
          <blockquote type="cite">
            <pre>On Jun 19, 2020, at 8:15 AM, Paul A. Rubin <a \
href="mailto:parubin73@gmail.com" target="_blank">&lt;parubin73@gmail.com&gt;</a> \
wrote:

On 6/19/20 7:51 AM, <a href="mailto:list_email@icloud.com" \
target="_blank">list_email@icloud.com</a> wrote: </pre>
            <blockquote type="cite">
              <pre>I have tried mightily to get LyX to break long equations. I've \
studied multiple pages at stackexchange, both LaTeX and LyX, and can't seem to get \
anything to work.

I have had luck in the past with the second large block of code at this page:

<a href="https://stackoverflow.com/questions/2904807/lyx-breaking-long-formula-lines" \
target="_blank">https://stackoverflow.com/questions/2904807/lyx-breaking-long-formula-lines</a>


but today I have some problems with it.

First, it doesn't work if the \text command appears inside my own LaTeX code that \
appears between \begin{dmath} and \end{dmath} or if I try to use the trick twice in \
the same document. (That's a tentative analysis of the problem.) Specifically, LyX \
runs at 100% CPU eventually gives me a chance to abort and then follows up with this \
additional message: &quot;The external program pdflatex finished with an error. It is \
recommended you fix the cause of the external program&#39;s error (check the \
logs).&quot;

Plus, I now want to to apply the line breaking to a line within an aligned \
environment (Insert -&gt; Math -&gt; Aligned Environment in the menu system.) This is \
causing things to look even worse, even though I added two "aligned" lines to the \
referenced code block. (If you look at the code you'll see the obvious places to add \
the lines.)

How do LyX-ers handle this? Is there "LyX" solution to breaking long equations? I'm \
OK with some ad hoc solution for now, or some ERT if it works.

Thanks,
Jerry


</pre>
            </blockquote>
            <pre>I&#39;ve never used the breqn package, but with ordinary and AMS \
math environments, hitting Ctrl-Enter in the middle of a long formula will break it \
(inserting a line break, \\, in the LaTeX output). If that doesn&#39;t achieve what \
you want, perhaps you could post a minimal example and a specification of what the \
output should look like.

Paul

</pre>
          </blockquote>
          <pre>Thanks, Paul. I'm on a Mac so of course Control-Enter has no meaning. \
Usually this translates to Mac-speak as Command-Enter. When I do Command-Enter in my \
equation, which is unfortunately inside a align environment, it instead adds a row to \
the matrix that represents the align environment. Ditto for Shift-Command-Enter. \
These two commands in LyX are mapped as Insert -&gt; Formatting -&gt; Ragged Line \
Break and Justified Line Break, respectively but invoking the menu commands with the \
cursor in my equation has exactly the same effect: adding a row to the align matrix \
(above the row where the cursor is.) When (Shift-)Command-Enter is done to a \
non-align display equation a similar thing happens except now the non-align equation \
is converted to an align equation with a blank new row _below_ the original equation.

Right now I guess I would be pretty happy with merely a way to make Command-shift \
(Control-shift) do what is expected which is apparently break the equation instead of \
creating a new row.

Jerry

</pre>
        </blockquote>
        <pre>Jerry,

I just created an align environment with two equations, the left side of the first \
being ridiculously long. When I put the cursor somewhere toward the middle of the \
left side of the long equation and inserted a break (using Ctrl-Enter -- I&#39;ll get \
to the Mac part in a minute), it broke the equation and inserted a new row. So

    (x+x+x+x+...+x) =1
     y =2

(where the right column contained the equal signs and integers) became

    (x+x+x+...
    +x+x+x+x) =1
     y =2

where the right column is empty in the first row. See the attached minimal example. \
Is this not what you want?

Regarding the key mapping, if you can find an unused key combo that you have a chance \
of remembering, you can map it to &quot;newline-insert newline&quot; using Tools &gt; \
Preferences... &gt; Editing &gt; Shortcuts. That&#39;s what Ctrl+Enter binds to for \
me.

Paul
</pre>
      </blockquote>
      <pre>Paul:

Thanks. The effect appears to work by adding another row to the matrix and filling it \
with the partial equation. In your example the new row is on top. If the long \
equation is moved to the RHS the new row is below.

I tried adding horizontal space to the second line of your broken equation but Latex \
seems to ignore it: when I click outside the math box and the equation is rendered, \
it is rendered without the horizontal space even though it was visible while in math \
editing mode.

About Mac key mappings: According to the status line in the document window, when I \
hit Command-Shift, it displays "(newline-insert newline;) and then icons for \
"Command" and "new line" which is an arrow thingy. So I'm going to assume that the \
key mapping is correct but that there is another problem, meaning…

…See my attached example. Attempting to break the line before the second \
exponential (1) doesn't break the line, (2) adds a matrix row above, and (3) steals \
the = from the now-third row and puts it on the second row.

The failure to break with Command-Enter does not seem to be a function of the align \
environment since it also fails in a stand-alone equation but adding a new row \
creates a new align environment.

I notice that my long equation, as rendered by LyX in the LyX window, gets truncated \
on the right. I don't know why—this does not happen in the document from which I am \
copying it.

Summary: Control-(or Command-)Shift doesn't work on my equation.

Jerry

</pre>
      <br>
      <fieldset></fieldset>
      <br>
    </blockquote>
    Jerry,<br>
    <br>
    I messed with your example file and attached the result. The good
    news is that your formula is breakable. The bad news is that there
    is a bit of a PITA component to doing so.<br>
    <br>
    The reason your attempt to break the formula failed was that it is
    enclosed in \left [ \right ], which apparently causes either LyX or
    LaTeX (I&#39;m not sure which) to treat what is in between the brackets
    as unbreakable. The fix I came up with was to delete the bracketing,
    decide where I wanted to break the formula, then wrap the left half
    with just a left bracket and the right half with just a right
    bracket. You can do this using the &quot;Insert delimiters&quot; dialog (the
    &quot;[ space ]&quot; button on the tool bar), by unchecking the &quot;Keep
    matched&quot; box and then choosing the appropriate bracket on one side
    and &quot;(None)&quot; on the other. Once I&#39;d done that, Ctrl+Return broke \
the  line as expected.<br>
    <br>
    I also put in a second version with IMO better balance, in which I
    did the same thing but moved the = sign to the left column.<br>
    <br>
    Paul<br></div></blockquote><div><br></div><div>Jerry, \
Paul,</div><div><br></div><div>I think Paul came to the same conclusion as me with \
respect to how to break equations (particularly when substantial components are \
within delimiters).   The approach that Paul described is the one I use routinely, \
and the &quot;Swap and Reverse&quot; button in the &quot;Math Delimiter&quot; dialog \
is meant to ease some of the PITA&#39;edness of this process.   I, too, wish there \
was a better way, but if there is, I am ignorant to it.</div><div><br></div><div>- \
Joel  </div></div></div>



-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic