This question is still related to the recent thread:[1]

I thought I got it right, but several unexpected problems came up and I'd like 
to have your 

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 
numbered things (equations, figures, theorems, examples, definitions, etc) in 
lectures to continue from the previous ones.

In order to guarantee the correct sequence, I'm loading in the preamble the 
package.  For each counter employed in a given lecture, the totcount package  
creates a 
new counter (equation@totc, figure@totc, etc), which contains the last value of 
The values of these counters are then written in a specific file (call it, 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 will not contain the last value of the counter 
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 
tinkering with in my previous thread.  Somehow I need to introduce instructions 
to read 
the file and find out if the counter thm was previously employed.  
Only if there 
is a last value of thm@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 
before the ams-theorem module defines the thm counters.  That is going to give 
It seems that as of now there is no way to choose the ordering of the 
contained in the layout InPreamble inside the document's preamble.  This is 
discussed in 
this thread:[2]

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 
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
Registered linux user # 153741

lyx-users mailing list

Reply via email to