# [Tex/LaTex] Can Lyx syntax files override document class defaults

conversiondocument-classeslyxtools

I'm editing a client's Latex file in Lyx, where the client has used a document class not supported by Lyx.

In these cases, I use tex2lyx with either -c article or -c report to ensure Lyx can import the file, and look at the difference (using wdiff) between the provided Latex file and that which Lyx exports to assemble a list of misunderstood syntax, which I can create a syntax file from to pass to tex2lyx using the -s \$SYNTAXFILE option.

All well and good, but if the document classes conflict in their syntax (e.g., passing optional arguments to such commands as \author or environments such as {enumerate}) then Lyx ignores what the syntax file says and so misparses the imported Latex file.

I have a workaround for this case, namely putting the definition \let\lyxtexblock=\relax in the Latex preamble and a line \lyxtexblock{} in the syntax file, and surrounding any misunderstood Latex with it. But I wonder if there is a more principled solution, something less time-consuming than hacking up a new layout file.

I'm using Lyx 1.6.8, but I'm interested to hear of solutions for Lyx 2.

## Motivation

While it is possible to edit someone else's Latex manuscript by directly editing the source file, and use wdiff/texdiff/latexdiff to document the changes made, this tends to be a relatively inefficient way of working when there are many edits (say 1 000 edits on a 9 000 word manuscript). The change tracking features of Word, Open Office Writer and Lyx all offer the following features, among others, which I call the change-tracking minimum:

1. Comments associated with changed text, ideally over arbitrary extents of text or particular edits;
2. A UI that allows changes to be worked through one at a time, and accepted, rejected, or the text modified;
3. A UI that allows all changes in some selected portion of text to either accepted or rejected, and likewise all comments in a slected area be deleted;

Point one is possible with wdiff/texdiff/latexdiff. Neither points 2 or 3 are, with any software I have seen. Anything less than all three points will cause a big increase in the time it takes for a client of mine to work through the kind of edits I produce. I believe the lack of good editing tools for Latex, such as the above, is the principal reason why many publishers do not want to work within Latex.

1. I technically do create an own layout file, but do not put any effort into it. I just take a copy of article.layout (or one of its descendants) and edit the class file inside the copy and that's all.
The issue with ERT boxes is that changes inside them are not tracked by LyX's change tracking system. However, in my experience (with classes for scientific articles) most, if not all, incompatibilities to the standard classes affect only the front matter, that is, macros such as \title, \author, \thanks and so on. So I usually end up with one big ERT box at the beginning that contains a verbatim copy of the front matter from the LaTeX source and use tex2lyx to convert only the body of the article. As edits to the front matter are relatively rare, this is an acceptable low-effort workaround.