This question is still related to the recent thread:
https://www.mail-archive.com/lyx-users@lists.lyx.org/msg112228.html[1]


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@totc, figure@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@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@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[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 
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

--------
[1] https://www.mail-archive.com/lyx-users@lists.lyx.org/msg112228.html
[2] https://www.mail-archive.com/lyx-users@lists.lyx.org/msg100172.html
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users

Reply via email to