<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">On sexta-feira, 23 de julho de 2021 14:40:38 -03 Paul A. Rubin wrote:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> I've never used the totcount package, so this may be a bit naive. For the</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> first issue, can you set the relevant counters (equation@totc) etc. to zero</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> with a \setcounter command in the preamble of the first document and, if</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> so, will that zero value get written to the file if no environments of the</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> type counted appear in the document? That would (hopefully) give you a</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> starting value for the next document.</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I thought about doing something similar, but not exactly as you suggested. </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">With the totcount package, you register the counters you'll want to keep track of with the command </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">\regtotcounter[auxfile=first.tc]{thm}</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">It will create the counter thm@totc and set it to zero.  At the end of the run, the counter is written into first.tc.  I need to inform this file name to the next lecture.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">So, inside the InPreamble, I registered all theorem counters.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Two problems resulted:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">1. I got a lot of "!Missing number, treated as zero" errors.  </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">2. If I ignore the errors and finish the processing, the total counters of the environs that are NOT used in the document are written in first.tc, all set to zero, as expected.  </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">The problem is that the counters that ARE used are again incremented every time the file is processed until all cross-references are right.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">This time, I inserted the \setcounter{defn}{\totvalue{defn}}</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">command in the *.inc file.</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> For the second issue, can you wrap your preamble code in AtBeginDocument{}</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> and, if so, does that allow ams-theorem to load first and your code to</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> execute correctly?</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">That seems to work.  Thanks for pointing out the command.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">So, I inserted </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">\regtotcounter[auxfile=\currfilebase.tc]{thm}, etc</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">in the  appropriate places in the *.inc file.  The command \currfilebase comes from the currfile package.  It just contains the base file name, without the extension.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">And then, if I know that in the next lecture the Definition and Exercise environs are used, inserting in the InPreamble</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">\AtBeginDocument{\setcounter{defn}{\totvalue{defn}} </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">    \setcounter{xca}{\totvalue{xca}} }</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">does the trick.  The counters are set after all the rest of the preamble is processed.</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Thank you.</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Incidentally, in order to create locally the *.aux and *.tc files needed for cross-referencing, I have to first export the document to LaTeX and then manually run </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">pdflatex --draftmode <doc></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Is there a way to instruct Lyx to write certain auxiliary files into the local directory, instead of in /tmp/lyx_tmpdirxxx?</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">-- </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Rudi Gaelzer</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Institute of Physics</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Federal University of Rio Grande do Sul</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">BRAZIL</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Registered linux user # 153741</p>
</body>
</html>