Results 1 to 6 of 6

Math Help - Importing LaTeX from Lyx?

  1. #1
    Junior Member
    Joined
    Jul 2009
    Posts
    31

    Importing LaTeX from Lyx?

    I've tried using Lyx to typeset a multiline formula; viewing a .pdf of the output within Lyx is absolutely fine - everything looks as desired without any problem.

    However, when I paste the LaTeX code into the board here (with the appropriate math tags), I receive a LaTeX syntax error. Why should this be?

    Here's the code I tried to paste:

    \begin{eqnarray*} x & = & \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t)\\
    \: & = & {\rm Re}\left(ce^{\alpha+i\beta}\right)\\
    \: & = & {\rm Re}\left(ce^{\alpha}e^{i\beta}\right)\\
    \: & = & {\rm Re}\left(ce^{\alpha}\left[\cos\beta+i\sin\beta\right]\right)\\
    \: & = & ce^{\alpha}\cos\beta\\
    \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t) & = & ce^{\alpha}\sin\left(\beta+\frac{\pi}{2}\right)\en d{eqnarray*}
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member Failure's Avatar
    Joined
    Jul 2009
    From
    Zürich
    Posts
    555
    Quote Originally Posted by Harry1W View Post
    I've tried using Lyx to typeset a multiline formula; viewing a .pdf of the output within Lyx is absolutely fine - everything looks as desired without any problem.

    However, when I paste the LaTeX code into the board here (with the appropriate math tags), I receive a LaTeX syntax error. Why should this be?

    Here's the code I tried to paste:

    \begin{eqnarray*} x & = & \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t)\\
    \: & = & {\rm Re}\left(ce^{\alpha+i\beta}\right)\\
    \: & = & {\rm Re}\left(ce^{\alpha}e^{i\beta}\right)\\
    \: & = & {\rm Re}\left(ce^{\alpha}\left[\cos\beta+i\sin\beta\right]\right)\\
    \: & = & ce^{\alpha}\cos\beta\\
    \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t) & = & ce^{\alpha}\sin\left(\beta+\frac{\pi}{2}\right)\en d{eqnarray*}
    First, I see a space in the "end" of \end{eqnarray*}, but that seems to be a minor problem. Second, I don't know for sure what "environments" (like eqnarray here) are defined for LaTeX code that you insert between math-tags. One thing I can say from experience: even if perhaps eqnarray is not defined between math tags in this forum, array is defined and can be used for much the same purpose...
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Super Member flyingsquirrel's Avatar
    Joined
    Apr 2008
    Posts
    802
    Quote Originally Posted by Harry1W View Post
    However, when I paste the LaTeX code into the board here (with the appropriate math tags), I receive a LaTeX syntax error. Why should this be?
    I guess it is because of the "eqnarray" environment.

    To have your equations correctly displayed you just have to modify the first and the last line :
    Code:
    \begin{array}{rcl}
      x & = & \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t)\\
     \: & = & {\rm Re}\left(ce^{\alpha+i\beta}\right)\\
     \: & = & {\rm Re}\left(ce^{\alpha}e^{i\beta}\right)\\
     \: & = & {\rm Re}\left(ce^{\alpha}\left[\cos\beta+i\sin\beta\right]\right)\\
     \: & = & ce^{\alpha}\cos\beta\\
     \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t) & = & ce^{\alpha}\sin\left(\beta+\frac{\pi}{2}\right)
    \end{array}
    \begin{array}{rcl}<br />
  x & = & \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t)\\<br />
 \: & = & {\rm Re}\left(ce^{\alpha+i\beta}\right)\\<br />
 \: & = & {\rm Re}\left(ce^{\alpha}e^{i\beta}\right)\\<br />
 \: & = & {\rm Re}\left(ce^{\alpha}\left[\cos\beta+i\sin\beta\right]\right)\\<br />
 \: & = & ce^{\alpha}\cos\beta\\<br />
 \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t) & = & ce^{\alpha}\sin\left(\beta+\frac{\pi}{2}\right)<br />
\end{array}

    Another solution would be to use the "aligned" environment :
    Code:
    \begin{aligned}
      x   & = \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t)\\
          & = {\rm Re}\left(ce^{\alpha+i\beta}\right)\\
          & = {\rm Re}\left(ce^{\alpha}e^{i\beta}\right)\\
          & = {\rm Re}\left(ce^{\alpha}\left[\cos\beta+i\sin\beta\right]\right)\\
          & = ce^{\alpha}\cos\beta\\
     \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t) & =  ce^{\alpha}\sin\left(\beta+\frac{\pi}{2}\right)
    \end{aligned}
    \begin{aligned}<br />
   x  & = \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t)\\<br />
      & = {\rm Re}\left(ce^{\alpha+i\beta}\right)\\<br />
      & = {\rm Re}\left(ce^{\alpha}e^{i\beta}\right)\\<br />
      & = {\rm Re}\left(ce^{\alpha}\left[\cos\beta+i\sin\beta\right]\right)\\<br />
      & = ce^{\alpha}\cos\beta\\<br />
 \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t) & =  ce^{\alpha}\sin\left(\beta+\frac{\pi}{2}\right)<br />
\end{aligned}
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Super Member Failure's Avatar
    Joined
    Jul 2009
    From
    Zürich
    Posts
    555
    Quote Originally Posted by Harry1W View Post
    I've tried using Lyx to typeset a multiline formula; viewing a .pdf of the output within Lyx is absolutely fine - everything looks as desired without any problem.

    However, when I paste the LaTeX code into the board here (with the appropriate math tags), I receive a LaTeX syntax error. Why should this be?

    Here's the code I tried to paste:

    \begin{eqnarray*} x & = & \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t)\\
    \: & = & {\rm Re}\left(ce^{\alpha+i\beta}\right)\\
    \: & = & {\rm Re}\left(ce^{\alpha}e^{i\beta}\right)\\
    \: & = & {\rm Re}\left(ce^{\alpha}\left[\cos\beta+i\sin\beta\right]\right)\\
    \: & = & ce^{\alpha}\cos\beta\\
    \frac{4}{100}e^{\frac{-1}{100}t}\sin(12t) & = & ce^{\alpha}\sin\left(\beta+\frac{\pi}{2}\right)\en d{eqnarray*}
    Maybe you need to instruct Lyx that is must not assume certain LaTeX packages to be available for the generated code...
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    Jul 2009
    Posts
    31
    Thanks so much for your responses. I'll definitely investigate some more for myself; thanks for helping me to get off the ground! Hopefully this will mean the end the inefficiency of multitudes of 'math' tags!

    Other than the line spacing being noticeably different, are there any notable differences between the "aligned" and "eqnarray" environments? Also, what is the significance of the {rcl} after \begin{array}?
    Last edited by Harry1W; August 11th 2009 at 07:28 PM. Reason: Extra questions!
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Super Member Failure's Avatar
    Joined
    Jul 2009
    From
    Zürich
    Posts
    555
    Quote Originally Posted by Harry1W View Post
    Thanks so much for your responses. I'll definitely investigate some more for myself; thanks for helping me to get off the ground! Hopefully this will mean the end the inefficiency of multitudes of 'math' tags!

    Other than the line spacing being noticeably different, are there any notable differences between the "aligned" and "eqnarray" environments? Also, what is the significance of the {rcl} after \begin{array}?
    r says that the first column will be right aligned, c says that the next (second) column will be center aligned, and the final l says that the third column will be left aligned.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: December 10th 2011, 07:40 PM
  2. Importing Excel sheet into Matlab
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 20th 2011, 12:41 PM
  3. Replies: 0
    Last Post: March 7th 2010, 06:49 AM
  4. LaTex inside of LaTex
    Posted in the LaTeX Help Forum
    Replies: 2
    Last Post: November 12th 2009, 12:07 PM
  5. importing data into octave/matlab
    Posted in the Math Software Forum
    Replies: 0
    Last Post: November 5th 2008, 10:20 AM

Search Tags


/mathhelpforum @mathhelpforum