New Theorems Module
Udicoudco
udifoglle at gmail.com
Fri Sep 16 00:24:00 UTC 2022
On Thu, Sep 15, 2022 at 9:54 PM Paul A. Rubin <parubin73 at gmail.com> wrote:
>
> On 9/13/22 18:48, Udicoudco wrote:
>
> On Tue, Aug 30, 2022 at 10:27 AM Jürgen Spitzmüller <jspitzm at gmail.com> wrote:
>
> Am Donnerstag, dem 14.07.2022 um 14:17 +0300 schrieb Udicoudco:
>
> Hello again,
>
> Hi,
>
> Hi Jürgen,
> Thank you for the reply.
>
> Thanks for this and sorry for the late reply. Most people are busy with
> their real lifes.
>
> No apologies needed, thank you all for developing great software.
>
> I had some mistakes in the .inc file and the .lyx file. The updated
> files are attached.
>
> As I do not use theorems myself, I cannot comment on the usage and
> usefulness of thmtools and the need for a module. So you probably have
> to be even more patient until the math users are back.
>
> Well, the matter is not urgent, and I have patience :).
>
> One remark on the layout:
>
> AddToPreamble
> \usepackage{amsthm}
> \usepackage{thmtools}
> EndPreamble
>
> At least for amsthm, this should rather be
>
> Require amsthm
>
> I've fixed this issue (see the attached file). I'v also used the
> DependsOn key so that the module will call thmtools only once.
>
> I think also thmtools should be added to the packages LyX knows and
> loaded that way.
>
> I don't know how to do that.
>
> Regards,
> Udi
>
>
> Hi Udi,
>
> I've been playing a bit with your module, and I've encountered a couple of non-fatal issues. The first may sound a bit silly. If you have a list of theorems but do not have any theorem-like environments (either because you put in the list of theorems code first or because you deleted all the things that would have been listed and have not yet added new ones), the document will not compile because the thm-tools package has not been loaded. Either requiring thm-tools in the list of theorems environment or making it depend on theorems (the way claim, lemma etc. do) should cure that.
>
Hi paul,
Thank you for trying out the module. I actually made the List of
Theorems layout dependent on the Theorem layout, but it seems that LyX
does not support the key DependsOn with flex insets, so in the new
module file the List of Theorems layout loads thmtools.
> The second one is perhaps a bug in the thm-tools package itself. To reproduce it, you can follow these steps.
Actually, it is not a bug in thmtools, it is just how latex works (see
the explanation below) with aux files, toc files, etc., but I did not
think of a situation such as you described when I wrote the module.
To write all the information needed to be in aux files and such, LaTeX
checks at the end of the compilation (for example, in thmtools it is
done with \AtEndDocument) if the aux file exists, if not it will
create one and write the information in it, if yes, it will update
what it needs to update. It does that at the end of the document so
there won't be a need to open the file and close it several times,
which might prolong compilation time.
When you call a macro such as \tableofcontents, or \listoftheorems in
our case, it will try to read the toc, or loe file, and get the
contents of the list from there, and since this file has not been
written yet (as it will be created at the end) the Table of Contents
or List of Theorems will be empty after the first compilation of a tex
file.
In LyX we don't experiencing it, since it will compile a number of
times, until the toc or lot will be with the right contents (which
usually takes two compilations), all the references will have the
correct numbering and pages (which might take more than two
compilations) and there are more stuff that requires multiple
compilations.
> Open your test_thmtools_module.lyx file and compile it (which works, of course).
> Delete the claims in section 2 (so that section 2 begins with Conjecture 2.1) and recompile. When I do this, I get four undefined control sequence errors, at least three of which contain the macro \claimname. If I select "view output anyway", the document seems to display correctly.
Each layout in the module defines a macro that holds the label of the
theorem (for example, for the Claim layouts it was \claimname). Since
we can't know in which language the user will use, we must make the
label protected, so it would not expand early, and we can change it
according to the language. A side effect of that, is the fact that
this macro was written to the loe file, without being expanded, and
thus remain as \claimname. After you erased the Claim layouts,
\claimname was was never defined, and the loe file will update at the
end of the compilation, after \listoftheorems already read the loe
file, and did not know what is \claimname.
> Now it gets goofier. If I make some trivial text edit (just to force a recompilation), say adding a character to the section heading, and recompile, the document compiles correctly without the error messages.
At the second compilation, the loe file has already been updated, and
\claimname was erased from there, so the file compiled without errors.
> I did a little digging. It turns out that compilation creates both a .aux file and a .loe file in the buffer directory. After compiling the full document, both contain instances of \claimname. After deleting all claims and recompiling (producing the error messages), both are rebuilt with no references to \claimname. If, however, I delete either one after compiling the full document and before compiling the edited version, the edited version generates no error messages. So I suspect there is some sort of timing issue here, in which the first compilation of the edited document inherits some undefined instances of \claimname (missing from both .aux and .loe after they were rebuilt) whereas a recompilation does not inherit \claimname. Deleting either the .aux or .loe file may force them to rebuilt before \claimname leaks into the main document. I hope that makes sense. (If it does, please explain to me what I just wrote. :-))
I hope the explanation I gave was clear, you could try to compile a
tex file with one section and see how the table of contents only
appears correctly after two compilations.
While trying to solve this issue, I also realised that if a user would
use a bilingual document, with theorems used in two languages, he will
only see the labels (in the list of theorems) of the language at which
the list of theorems will be written.
I believe I was able to solve both bugs, the new module file is attached.
Regards,
Udi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: theorems-thmtools.module
Type: application/octet-stream
Size: 22399 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20220916/0b098991/attachment-0001.obj>
More information about the lyx-devel
mailing list