Hi!

I figured out a way to preprocess LaTeX files in order to eliminate dependency on \newcommands, using Python and plasTeX.

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.

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. After the parsing, it can print the resulting LaTeX code back to a file. The resulting LaTeX file has very long lines, but can be imported into LyX very nicely! The resulting file still contains all the \newcommands at the top, but they are not actually used in the rest of the document, so they can simply be deleted manually.

In this case it saved me a lot of hours time of manual editing within LyX if I had just imported the original LaTeX file.

I'm I right in that such functionality is not built into LyX a the moment, and that there are no scripts on the lyx Wiki that accomplishes this? If this already exists, I'd want to know how to do it without plasTeX.

If so, perhaps I should upload the script to the Wiki so that others can use it if they have to import a latex file into lyx which has a lot of \newcommands?

Opinions?

I have seen other requests for such functionality, e.g. here:
http://www.latex-community.org/forum/viewtopic.php?f=5&t=4680

-Torquil

Reply via email to