Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Looking for \eqalign

  1. Dec 29, 2015 #1

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    My first thread ! :smile: Couldn't even post it at first: "thread title must be more than one word" sic ! grmpfff....


    I'm unhappy with the look of sets of equations. In displaymode they are all centered, when I in fact want the = to line up nicely. I forgot how to do this.

    In the same ball park: if you want to add equation numbers and line them up nicely at the right, how do you do that ?

    And now that I'm asking anyway: is there a way to increase the spacing between \\ lines ? I tried \mathstrut but couldn't get it to work. Same with other glue goodies.

    Basically I know next to nothing of LaTeX and forgot 90% of what I once knew about real TeX.

    Haven't seen any examples of what I'm after in PF, so perhaps it can't be done. Worth asking, though.

    --
     
  2. jcsd
  3. Dec 29, 2015 #2
    \\[12pt] works on text area.
     
  4. Dec 29, 2015 #3

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Thanks for trying, but perhaps you mean something else than I ?Testing a=b \\ \\[12pt] \\[12pt] \\[12pt] \\c=d : $$a=b \\ \\[12pt] \\[12pt] \\[12pt] \\c=d$$ I don't see empty lines in between ...
     
  5. Dec 30, 2015 #4

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    This isn't my private notebook, but just in case someone sees this: \eqalign is available in MathJax and so is \hfil.

    Within \equalign you can skip lines:

    Code (LaTeX):
     \eqalign { awertwertr & = 5 & \qquad (1) \\ \\ b& =5 & \hfil (2)}
    $$ \eqalign { awertwertr & = 5 & \qquad (1) \\ \\ b& =5 & \hfil (2)}$$

    It's not the summit of elegance, but it suits my purpose.

    Haven't found \vspace --
     
  6. Jan 15, 2016 #5

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Found (*) an alternative I didn't know about (I only know TeX and am 'new' to LaTeX):
    Code (LaTeX):

    \begin{equation}
    y'''-y''=u
    \end{equation
    }
     
    gives (only in display mode) $$
    \begin{equation}
    y'''-y''=u
    \end{equation}$$The numbering is automatic


    Haven't found how to tame the counter (it doesn't always start off at 1 and it looks as if it increments with each preview !?), so I feel forced to use symbolic referencing:
    Code (LaTeX):

    equation ##\eqref{eq:sample}## shows $$

    \begin{equation}
      \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
      \label{eq:sample}
    \end{equation
    }$
    $
     
    equation ##\eqref{eq:sample}## shows $$

    \begin{equation}
    \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
    \label{eq:sample}
    \end{equation}$$
    (*) in a thread by @Linder88 - with thanks !
     
    Last edited: Jan 15, 2016
  7. Jan 18, 2016 #6

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    More exploits:
    • You need unique equation labels per page (not just per post), otherwise you get references like ##\eqref{eq:nonexistent}## and the TeX source appears seemingly correct in a framed box. Probably has to do with the order of processing by MatJax and the browser
    I suppose this automatic numbering and referencing of named equations then won't work across pages -- and PF splits up long pages :rolleyes:

    Not to mention what can happen when people start quoting stuff... disaster!
    So post #4 workaround is probably a lot safer -- more control
     
  8. Jan 18, 2016 #7

    Fredrik

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    The align environment makes it easy to align equations. Hit the reply button to see how I'm doing this. The asterisk (*) prevents automatic numbering of the equations. So if you want them numbered, just type align instead of align*.
    \begin{align*}
    x^2+y^2 &= 1\\
    x+y &=1
    \end{align*}
     
  9. Jan 18, 2016 #8

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Thanks, Fredrik !

    So we have the \eqalign { ... } and we have the \begin{align*} or {align} environment
    Code (LaTeX):
     $$ \eqalign { xyz & = 5 & \qquad (1) \\ \\ b& =5 & \hfil (2)} $$
    $
    $ \begin{align*}   x^2+y^2 &= 1  \\  x+y &=1  \end{align*} $$
    $
    $ \begin{align}    x^2+y^2 &= 1  \\  x+y &=1  \end{align} $
    $
     
    $$ \eqalign { xyz & = 5 & \qquad (1) \\ \\ b& =5 & \hfil (2)}
    $$ $$ \begin{align*} x^2+y^2 &= 1\\ x+y &=1 \end{align*}
    $$ $$ \begin{align} x^2+y^2 &= 1 \\ x+y &=1 \end{align}
    $$
    And if you make a mistake you get
    upload_2016-1-18_20-37-48.png

    It seems to work, provided you keep them enclosed in separate ##\$\$## ... ##\$\$ ## -- and wait patiently for the post processor to show the equations after a while.

    And previewing gives you ever-increasing equation numbers, but the final numbers start at a lower value.
    How about referencing these numbers in \begin{align} ?

    I still feel like I'm venturing ouside the comfort zone with this...
     
    Last edited: Jan 18, 2016
  10. Feb 8, 2016 #9

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Found another gem (note the [5mm] incantation !) :
    Code (LaTeX):

    \begin{equation}
      \begin{aligned}
        A &= B &\qquad C &= D \\
          &= E &&= F \\
          &= G &&= H \\[5mm]
        I &= J & K &= L \\
          &= M &&= N \\
          &= O &&= P
      \end{aligned}
    \end{equation
    }
    $$\begin{equation}\begin{aligned} A &= B &\qquad C &= D \\&= E &&= F \\&= G &&= H \\[5mm] I &= J & K &= L \\&= M &&= N \\&= O &&= P \end{aligned}\end{equation}$$
    Re-do post #3:
    Testing a=b \\[12pt] \\[12pt] \\[12pt] \\c=d : $$a=b \\[12pt] \\[12pt] \\[12pt] \\c=d
    $$ Testing a=b \\[5mm] c=d : $$a=b \\[5mm]c=d
    $$ Testing a=b \\[12pt]\\ c=d : $$a=b \\[12pt]\\c=d
    $$ Can someone explain that to me ?
     
  11. Feb 9, 2016 #10
    I guess it throws a warning if you use it with a compiler that shows them.
    In WYSIWYG editors like word you often use a double return to space the text.
    In LaTeX you can't use \\ twice in a row without a character in between (I've had my fair share of these warnings :-) ).
    You can use \vspace or \\[height] instead.

    Code (LaTeX):

    $$
    \text{Text with newline}\\
    \text{And now a line in between}\\
    \\
    \text{doesn't work
    }
    $
    $
     
    $$
    \text{Text with newline}\\
    \text{And now a line in between}\\
    \\
    \text{doesn't work}
    $$
     
  12. Feb 9, 2016 #11

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Quite ! Thanks. That's why \\ \\[12mm] doesn't work.
    I don't know if I can get to see the TeX processor warnings -- MathJaX is a post-processor, so they come after the page is already presented and replace the source (which you can actually see happening if things go slowly enough).

    But in PF LaTeX \vspace isn't recognized, so we have to make do with \\[height]
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Looking for \eqalign
Loading...