0

I want to keep track of some info of my .tex files.

More precisely, I give an id (an integer) to my math exercises and would like to keep somewhere the maximal id already given (and maybe other info). The macro is just \idExo{}.

I would like also the macro to be executable on other people's distributions without causing bugs.

Here is my plan :

  • Choose a specific hard-coded path OR write to the "texmf" folder
  • Read the maximal id in the file if it exists
  • If the current id is higher, replace it

So far, I am able to write to a file:

\def\writeToFile
{
\newwrite\myfile
\immediate\openout\myfile=\jobname.foo
\immediate\write\myfile{coucou}
\immediate\closeout\myfile
}

Is there something simplier or am I on the good track?

Colas
  • 6,772
  • 4
  • 46
  • 96
  • you are missing % and the \newwrite should be outside your macro so you only do it once (otherwise in classic tex you will not be able to write more than 12 or so times) – David Carlisle Apr 17 '18 at 12:28
  • Thanks. So, how can I close the writing? Do I have to tell it explicitly before \end{document}? – Colas Apr 17 '18 at 12:34

0 Answers0