Re: Paste cells into table with Math

2010-11-23 Thread Ken
Perhaps the subject of this thread should be: "External Copy then Paste with
math content"

The idea would be for generating a string like:
"The result is $\beta=2$"
in some external program would when copied and pasted into LyX would
automatically know to format the LaTeX part as math content?  

LyX could offer options to paste the string literally or to paste the string and
then find/replace the LaTeX parts.  In a more complicated example, perhaps the
contents of an entire table could be copied and pasted where some cells are text
and others are math (or partial math).

In any case, would something like this be useful to others?  Is this something I
should suggest on the Trac bug/enhancement tracker?  Or do users have better
ways of copying and pasting results tables from software like Matlab into a LyX
report?

Thanks,
Ken




Re: Paste cells into table with Math

2010-11-21 Thread Ken
Paul Rubin  msu.edu> writes:

> 
> I can't answer the context-aware pasting question, but I'll point out that if
> you paste the math content in as ordinary text, you can highlight it and hit
> ctrl-M to turn it into a math inset.  (This works anywhere in the document, 
> and
> in both directions -- you can also turn a math inset into plain text.)
> 
> /Paul
> 
> 

Hi Paul,

Thanks for your reply.  Yes, I could highlight and manually switch the selection
to math insets but this is very slow/tedious if there are many fields which
require editing.  If I were to go down this route I think I would rather copy
and paste latex code into an ERT which, on restarting LyX, should give me the
tables and correct formats.  It would really be nicer if I could simply paste
content into LyX and have the math values recognised.  Does anyone else have any
ideas?

Thanks,
Ken




Paste cells into table with Math

2010-11-21 Thread Ken
Hi. When I wish to copy results from Matlab into a LyX document I
generate a tab-delimited string and then paste it into a LyX table.

For example,in Matlab I might have a cell of results like:
test = {'A' 'dog' 200; 'B' 'cat' 99.3}
which looks like
test =

   'A'    'dog'    [200]
   'B'    'cat'    [99.3]

If I convert this to a string by substituting new cells by tab
character sprintf('\t') and newlines by sprintf('\t') I get something
like:
str =

A dog 200.
B cat 99.3000

Using the Matlab command clipboard('copy',str) this can easily be
pasted into a LyX table using Ctrl+Shft+V, or "Plain Text, Join
Lines".  This is a nice, easy way to generate tables of results...

...however, this pastes the contents into the LyX table as text only.
Is there a way of pasting cells where some of them are in math mode?
For instance, what if I have the matlab cell:
test = {'\alpha' 'dog' 200; '\beta' 'cat' 99.3}
I wish to paste this into a LyX table where the cells \alpha and \beta
and the numbers are not pasted as text, but as math (i.e. as greek
letters)?  Is there an easy way to do this? Adding $...$ around data
does not change the behaviour when pasted.

I would guess there is some way of formatting the copied string so
that LyX knows when to swap into and out of math mode.  This obviously
happens when one copies and pastes tables within LyX.  But I need help
trying to add this to the text string which I generate in Matlab and
paste in LyX.  Any ideas?

Thanks,
Ken


Re: Paste cells into table with Math

2010-11-21 Thread Paul Rubin
I can't answer the context-aware pasting question, but I'll point out that if
you paste the math content in as ordinary text, you can highlight it and hit
ctrl-M to turn it into a math inset.  (This works anywhere in the document, and
in both directions -- you can also turn a math inset into plain text.)

/Paul



Re: Paste cells into table with Math

2010-11-21 Thread Ken
I am guessing one reason why LyX is able to copy and paste cells or tables while
retaining the distinction between text and math cells or math within a cell has
to do with clipboard locales.

My understanding is that the clipboard might retain the copied content in
different formats.
http://msdn.microsoft.com/en-us/library/ms649013%28VS.85%29.aspx

So my question might be, is there a way of generating a string which can be
pasted into LyX where math mode is recognized and applied?  For instance, is
there a way to paste the string
"The result is $\beta=2$."
into LyX where LyX automatically knows to use math mode for $\beta=2$ and not
simply paste is as a string?

Thanks,
Ken