# Math Help - Importing LaTeX from Lyx?

1. ## 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*}

2. Originally Posted by Harry1W
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...

3. Originally Posted by Harry1W
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}
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}$

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}
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}

4. Originally Posted by Harry1W
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...

5. 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}?

6. Originally Posted by Harry1W
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.