On 31/08/10 19:35, Uwe Stöhr wrote:
> Am 31.08.2010 18:35, schrieb Torquil Macdonald Sørensen:
>
>> My goal was to import a LaTeX file into LyX, but LyX was not able to
>> understand all the \newcommands in the document, and therefore I wanted
>> to preprocess the LaTeX file first.
>
> What do you mean with LyX doesn't understand? LyX should import them as
> TeX-code and when you view it as PDF, you should see a PDF. If this is
> not the case and you get LaTeX-errors instead, you found a bug in LyX's
> TeX import program. If so, can you please provide a _small_ TeX testfile
> to be able to test?
Sorry if you get two of these... I forgot to use "Reply to all" in my email
client and my have already sent on copy just to you. This should go to the list
as well.
Let me try to explain better what I meant. I don't want those grey boxes of tex
code for each instance where a user-defined command is executed in the latex
document. I want my LyX file to look as if I had written everything in LyX
without use of any \newcommand.
The following LaTeX file captures the essence of the file I just had the
misfortune to work with:
\documentclass{article}
\newcommand{\bea}{\begin{equation}}
\newcommand{\eea}{\end{equation}}
\begin{document}
\bea
\int f(x) dx = 0
\eea
\end{document}
Importing this file into LyX results in a file where the math is not "rendered",
but instead the bare LaTeX math code is displayed between two grey boxes,
representing \bea and \eea.
>> I used a python package called plasTeX for this. It is able to parse
>> LaTeX files and will automatically expand the user-defined \newcommands
>> that are used throughout the document.
>
> What is done by "expanding"? I mean one only uses \newcommand once and
> then use the defined command several times. Therefore you can safely put
> all \newcommands either at the beginning of the document, or better, at
> the end of the document preamble.
By "expanding", I mean that "my" plasTeX script (if you can call it that when it
is just a few lines) will process the above latex file and essentially create this:
\documentclass{article}
\begin{document}
\begin{equation}
\int f(x) dx = 0
\end{equation}
\end{document}
When this is imported into LyX, the equation is interpreted correctly and
rendered in the usualy fasion as mathematics, with no grey boxes.
Torquil