Le 14/09/2022 à 02:28, Udicoudco a écrit :
Hello Lyx Developers,

Recently I've been trying to understand more thoroughly how theorems modules are implemented in LyX, and I think I've come across some bugs, and some redundant modules (but I might have misunderstood a few things).

Hello Udi,

Thanks for looking at that.

The first thing I've noticed is that all AMS theorems related modules load the packages amsmath and amsthm even if the use did not use any layout.  I could not understand why, as amsthm does not depend on amsmath.  I've tried to compile a lyx file containing all the layouts defined in Theorem (AMS), but i erased the line "Require amsmath,amsthm" from the module, and the file compiled (as amsthm is loaded by the layouts, there is no really a need to load the package if the user did not use any layout).

This looks like a bug indeed.

The second thing I've noticed, there is no difference between the files theorems.inc and theorems-ams.inc. In the description of the file theorems-std.module, which uses theorems.inc it is said that the module "Defines some theorem environments for use with non-AMS classes", but the module uses amsthm, and he is compilable with AMS classes.

This is indeed surprising. In the old days, non-ams theorem modules did not use amsthm. But for some reason it was changed when modularizing the layouts. I am not sure whether we can revert this decision 14 years later (see below). If we don't, the two types of theorems should be merged indeed.

The culprit is:

commit f5a5be4d188a20ee2a5c0213ee11bf64c0908841
Author: Richard Heck <rgh...@comcast.net>
Date:   Thu Jan 10 04:58:20 2008 +0000

Modularization of the AMS classes, and the theorem environments generally.

This is Part I: The changes to the layout files and modules. Part II, still to come, will involve lyx2lyx to help people who were using the older classes.


The only difference I've found between theorems.inc and theorems-ams.inc, is the list of layouts the files provide at the beginning of the files (but they provide the same layouts, with the exact same definitions. I've used text comparison software to verify that).

Because of that, I've concluded that the only differences between theorems-std.module and theorems-ams.module is that in theorems-std.module there are no unnumbered theorems (as theorems-ams.module  includes theorems-starred.inc, but theorems-std.module  does not), theorems-std.module does not load amsmath, and loads amsthm only if the user has used a layout that is not the proof layout, and the definition of the proof layout.

And there is a NextNoIndent difference between the two that if probably wrong in one of the instances.

I did not understand the purpose of the file theorems-proof-std.inc. This file is included in theorems-std.module, and it appears that this file is defining the proof environment (but the definition is quite different from the usual one), if it is not defined. Since amsthm defines the proof environment,  if i will compile a file using Theorems module, the appearance of my proofs will depend if i used another layout provided by the module. Wont it be more reasonable to add to the proof layout defined in theorems-proof.inc the line "Require amsthm" and use this layout? if there is a theorems module that does not use amsthm (and currently i don't think there is one like that), it could include theorems-proof-std.inc.

It made sense when plain theorems did not use amsthm.

Another problem with the fact that the proof layout in theorems-proof.inc does not require amsthm, is with the module Theorems (Unnumbered). This module only loads amsthm if the user use one of the theorems layouts. if one would simply use the proof layout with this module, and no other layout from the module, with non-AMS class (as these classes also defines the proof environment), he will get the error "LaTeX Error: Environment proof undefined.".

Could you give an example file for that issue?

Another inquiry I have about the module Theorems (Unnumbered) is the file theorems-starred-equivalents.inc. This file only copies the starred theorems layouts but gives the new layout a name without a star, e.g., it defines a Theorem layout exactly as Theorem* layout (and this files misses the Fact layout).

The comment at the top implies that this sorts the layouts. I do not know whether it is still true.

For all these reasons i believe that with a little bi of modification to the non AMS modules (which actually use amsthm), the AMS modules are redundent, and it is probably wise to add the line "Require amsthm" to the proof layout.

If this suggestion seems reasonable to everybody, i could start work on the matter, and send the relevent files after editing them as mentioned.

I wonder if we could get rid of theorems.module, and add a theorem-plain that use plain LaTeX commands as "theorems.module" used to do. Then files using "theorems.module" could be updated by lyx2lyx to use theorems-ams instead, and we would have the old functionality back.

Just for clerification, all the modules files i've mentioned are the ones that comes with LyX2.3.6.1.

It would be nice to check the situation in master, as we are not going to fix this (except aybe proof) in 2.3.

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

Reply via email to