Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > Math Resources > LaTex Help
Reply
 
Thread Tools Display Modes
  #1  
Old August 11th, 2009, 11:01 AM
Junior Member
 
Join Date: Jul 2009
Posts: 31
Thanks: 12
Thanked 4 Times in 3 Posts
Harry1W is on a distinguished road
Default 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*}
Reply With Quote
Advertisement
 
  #2  
Old August 11th, 2009, 11:33 AM
Failure's Avatar
Member
 
Join Date: Jul 2009
Posts: 131
Country:
Thanks: 0
Thanked 70 Times in 65 Posts
Failure will become famous soon enough
Default

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...
Reply With Quote
The following users thank Failure for this useful post:
Donate to MHF
  #3  
Old August 11th, 2009, 11:36 AM
flyingsquirrel's Avatar
Super Member
 
Join Date: Apr 2008
Posts: 799
Thanks: 153
Thanked 437 Times in 366 Posts
flyingsquirrel is a glorious beacon of lightflyingsquirrel is a glorious beacon of lightflyingsquirrel is a glorious beacon of lightflyingsquirrel is a glorious beacon of lightflyingsquirrel is a glorious beacon of light
Default

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}  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}
Reply With Quote
The following users thank flyingsquirrel for this useful post:
Donate to MHF
  #4  
Old August 11th, 2009, 11:47 AM
Failure's Avatar
Member
 
Join Date: Jul 2009
Posts: 131
Country:
Thanks: 0
Thanked 70 Times in 65 Posts
Failure will become famous soon enough
Default

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...
Reply With Quote
The following users thank Failure for this useful post:
Donate to MHF
  #5  
Old August 11th, 2009, 07:23 PM
Junior Member
 
Join Date: Jul 2009
Posts: 31
Thanks: 12
Thanked 4 Times in 3 Posts
Harry1W is on a distinguished road
Default

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!
Reply With Quote
  #6  
Old August 11th, 2009, 09:07 PM
Failure's Avatar
Member
 
Join Date: Jul 2009
Posts: 131
Country:
Thanks: 0
Thanked 70 Times in 65 Posts
Failure will become famous soon enough
Default

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.
Reply With Quote
The following users thank Failure for this useful post:
Donate to MHF
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 08:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2009 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.