Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I received a .tex file from a user and tried to open this up in Lyx 2.0.2 on Win. After importing it into LyX, the document has ampersand characters everywhere in the equations as though LyX didn't parse the file correctly. I think this might be related to the IEEEeqnarray found throughout the document. I can't seem to figure out how to get IEEEeqnarray portions of the document to render in LyX, rather than have the IEEEeqnarray portions display as TeX code in LyX.

When I produce the PDF in LyX, all the ampersands "&" can be seen in the PDF.

I'm fairly new to LaTeX, so I appreciate any advice.

share|improve this question
    
Welcome to TeX.sx! I removed the thanks in your question. This is just the style here. Thanks is best expressed by up voting answers that help you. –  qubyte Jan 25 '12 at 2:36
add comment

1 Answer

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

Import .tex with \documentclass{IEEEtran} into LyX

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

Incorrect output in LyX

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:

  1. If the document is small enough, you need to manually copy the incorrectly imported code from the .tex source into a LyX ERT environment:

    Manual insertion of ERT content in LyX

    which then delivers the desired output*:

    Correct output of ERT content in LyX

  2. 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.