When you select File
>Import
>LaTeX (plain)...
for a file myfile.tex
, LyX executes
tex2lyx -f myfile.tex myfile.lyx
The -f
flag forces overwriting of myfile.lyx
if it already exists, but that's not important. According to the tex2lyx
man page:
The purpose of tex2lyx
is to translate well-behaved LaTeX2e into
LyX. If your LaTeX file doesn't compile - or if you do weird things,
like redefining standard LaTeX commands - it may choke.
This is indeed what's happening here. Moreover, importing of files is highly dependent on so-called .layout
files, which document how the import formatting occurs, and depends solely on the \documentclass
given. If the .layout
file is out-dated, or does not include all possible definitions, they are "lost in translation". Consider, by means of example, the following code for (say) myfile.tex
(perhaps a very minimal version of what you received):
\documentclass{IEEEtran}
\begin{document}
Here is some text.
\begin{IEEEeqnarray}{rCl}
a & = & b + c + d + e + f + g + h + i + j \nonumber\\
&& +\: k + l + m + n + o
\end{IEEEeqnarray}
Here is some more text.
\end{document}
Importing it into LyX shows

which is clearly wrong, and also produces the clearly incorrect output

LyX was only able to correctly identify the control sequences since they are escaped with \
, as well as the grouping braces {
...}
since they define macro/command arguments.
You have two options to correct this behaviour:
If the document is small enough, you need to manually copy the incorrectly imported code from the .tex
source into a LyX ERT environment:

which then delivers the desired output*:

Create a new or modify the existing layout associated with IEEEtran
. Again, from the tex2lyx
documentation:
By default, when tex2lyx
sees a \documentclass{foo}
command, it creates a file of textclass foo
and reads the LyX layout file for that class (something like /usr/local/share/lyx/layouts/foo.layout
OR HOME/.lyx/layouts/foo.layout
).
The specific file in question here would be IEEEtran.layout
. To understand the contents of the .layout
file, consider reading section 5 Installing New Document Classes, Layouts, and Templates (under Help
>Customization
). Specifically, section 5.3 The layout file format contains detailed information on this type of customizations.
* The additional vertical spacing (or skip) can be removed by "joining" the first paragraph with the IEEEeqnarray
ERT, but the layout in LyX is horrible.