On 6/11/23 07:05, Enrico Forestieri wrote:
On Sun, Jun 11, 2023 at 04:30:34AM -0400, Scott Kostyshak wrote:

Thanks, Enrico, I like it! I see two options, one nice and one not nice:

1. Do lyx2lyx. I think we would just need to copy the LyX box to the LaTeX box when the LaTeX box is empty.

I don't think this is a good idea. The LyX representation may be different from the TeX definition. The right lyx2lyx behavior should be simply removing the macro definition if the TeX part is empty but not the LyX part. One would loose the nice representation but everything still works.

2. Commit the patch as is and claim it was a bug that LyX included the definition even when the LaTeX box was empty. I did not check if the current behavior is documented.

It is not strictly a bug because one might want to simply remove the argument of the macro. The point is that in this case it is simpler to define the macro in the preamble (\def\name{}) rather than cluttering the main text. I bet nobody has ever defined a math macro with an empty definition in the body of the text. But even in this case the solution would be inserting "{}" in the definition rather than leaving it empty.

I suppose (1) is the best? I wonder if some users rely on the current behavior for the case where they want the LyX and LaTeX boxes to be the same, because this way when they change the macro, they just need to change it in one place (the LyX display), instead of needing to make sure their LaTeX def and LyX def are in sync.

Yes, (1) seems to be the best but because it guarantees backward compatibility (in the sense that exporting to older versions produces still working documents). However, no round-trip is possible, unless recording the macro definition in a TeX comment in the preamble and then restoring it when converting forward.

Committed the patch along with the lyx2lyx.

Thanks, Enrico. I really needed this, actually.

Riki


--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to