Categories: LaTeX<< | Page list | >>
Expand newcommands into native LaTeX code that LyX can interpret on LaTeX import.
Some LaTeX files make use of user-defined \newcommands in the preamble. When importing such a file into LyX, all instances of each \newcommand are represented within LyX as a grey ERT box, and its contents is not interpreted and rendered by LyX.
However, sometimes it is desireable to have LyX render all LaTeX content. Preprocessing of the LaTeX file to expand all such instances of user-defined commands is then necessary since this is not done by the native LyX import code.
This can be done through a simple python script using the python package plasTeX. The LaTeX code formatting is also changed by plasTeX but for LyX import purposes this is irrelevant. The following python script expects the filename of the LaTeX document as a command line argument, and will output a file PlastexProcessed.tex in which all instances of \newcommands are expanded to native LaTeX code throughout the document: