Problems related to custom AMS theorem module
Paul A. Rubin
parubin73 at gmail.com
Fri Jul 23 17:40:38 UTC 2021
On 7/23/21 12:14 PM, Rudi Gaelzer wrote:
>
> This question is still related to the recent thread:
>
> https://www.mail-archive.com/lyx-users@lists.lyx.org/msg112228.html
> <https://www.mail-archive.com/lyx-users@lists.lyx.org/msg112228.html>
>
>
> I thought I got it right, but several unexpected problems came up and
> I'd like to have your opinion.
>
>
> What I want to do is the following: I'm preparing a series of lectures
> that will employ theorem-like environments.
>
> Several lectures are related to the same subject and so I want the
> enumeration of numbered things (equations, figures, theorems,
> examples, definitions, etc) in subsequent lectures to continue from
> the previous ones.
>
>
> In order to guarantee the correct sequence, I'm loading in the
> preamble the totcount package. For each counter employed in a given
> lecture, the totcount package creates a new counter (equation at totc,
> figure at totc, etc), which contains the last value of the counter.
>
> The values of these counters are then written in a specific file (call
> it previous.tc), which can be read in the subsequent lecture.
> Finally, by using
>
> \setcounter{<counter>}{<last value>}
>
> I can guarantee the desired continuation of the enumeration of things.
>
>
> For the native LaTeX counters (equation, figure, etc), I've been
> including all the necessary commands in an ERT with the layout InPreamble.
>
> For the native counters, this works all right because the counters are
> defined with the class and class packages, which are read before
> user-specific definitions incuded with the InPreamble layout.
>
>
> However, for the theorem-like environments, the implementation is more
> involved. The problems that are coming up are:
>
>
> 1. Say a given environment like theorem is only introduced from the
> second lecture. In this case, the file previous.tc will not contain
> the last value of the counter thm at totc, because there was no theorem
> in the first lecture. Hence, I cannot issue a \setcounter{thm}{<last
> value>} because in this case the number of the first theorem gets
> increased for each LyX/LaTeX compilation.
>
> This complicates the implementation of the custom theorem-bytpe module
> I've been tinkering with in my previous thread. Somehow I need to
> introduce instructions to read the previous.tc file and find out if
> the counter thm was previously employed. Only if there is a last
> value of thm at totc that I can \setvalue the counter.
>
> I'm not sure what will be the best way to implement this. Several
> posts I've been browsing through suggest the use of TeX natives like
> \newread, \openin \read, etc, and then use some package (like xstring)
> that identifies specific strings in each line read. Seems too much
> trouble for me.
>
>
> 2. Then I decided to dumb down my approach. I will only use \setvalue
> for those counters that I know are employed in the previous lecture,
> as I was doing so far with the native LaTeX counters.
>
> The problem now is that with the layout InPreamble, those instructions
> will be written before the ams-theorem module defines the thm
> counters. That is going to give errors.
>
> It seems that as of now there is no way to choose the ordering of the
> instructions contained in the layout InPreamble inside the document's
> preamble. This is discussed in this thread:
>
> https://www.mail-archive.com/lyx-users@lists.lyx.org/msg100172.html
> <https://www.mail-archive.com/lyx-users@lists.lyx.org/msg100172.html>
>
>
> Therefore, the only solution that I can imagine is to write the
> necessary instructions in the user-defined preamble accessible in
>
> Document Settings -> LaTeX Preamble
>
> This way, I guarantee the correct ordering of the instructions.
>
>
> Anyway, I just wanted to vent out my frustration that I was not smart
> enough to somehow automatize this process. This is an admittedly very
> specific problem, and I don't know if you think this can be of
> interest to the larger community.
>
>
> --
>
> Rudi Gaelzer
>
> Institute of Physics
>
> Federal University of Rio Grande do Sul
>
> BRAZIL
>
> Registered linux user # 153741
>
>
I've never used the totcount package, so this may be a bit naive. For
the first issue, can you set the relevant counters (equation at totc) etc.
to zero with a \setcounter command in the preamble of the first document
and, if so, will that zero value get written to the file if no
environments of the type counted appear in the document? That would
(hopefully) give you a starting value for the next document.
For the second issue, can you wrap your preamble code in
AtBeginDocument{} and, if so, does that allow ams-theorem to load first
and your code to execute correctly?
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-users/attachments/20210723/01d3735b/attachment-0001.html>
More information about the lyx-users
mailing list