I am trying to make a command which creates automatically incrementing IDs for entries in some lists I have to manage. They have to follow a certain formatting (for example the first character has to be the first letter of the current chapter). The IDs should be compatible with cleveref also, so I can \cref the according label and a customized reference appears.

The following code compiles:


% entry counter


% chaptername tracker

% chapter number generator

% entrycode





and returns

Compiled Doc

which is basically what I want. But I dont know how to make cleveref use my "special" numbering system when referencing, so I tried to use the arrayjob package, creating an Array with the cleveref counter as an Index and my numbering as the value. But unfortunately the whole code breaks, when I try to evaluate my expression before the arrays saves the value (\expandarrayelementtrue). The same happens when I change the \def in the definition of \cmust below for a \edef but I just can't see why. Does anyone know

  • why edef or expandarrayelementtrue breaks the code?
  • if there is another way to convince cleveref to choose my style of referencing?
  • if there is an easier way to save the evaluated result of an expression rather than the evaluatable expression itself?

Thanks in advance,


  • To the best of my knowledge it is not possible to use \edef with \padzeros. – marmot Apr 28 '18 at 0:53
  • But why is this? Are there alternatives or workarounds? – Moraxno Apr 28 '18 at 1:18
  • 2
    For the cleveref part, what have you tried? The manual covers customisation of the format - both high level and lower level changes. – cfr Apr 28 '18 at 1:44
  • 2
    Depends on how you define "why". The reason why I think this is true is that it has been noted here. I also think that if you solve this problem, you will have an analogous issue with \StrLeft and \StrRight. Anyway, I fully agree with @cfr that you should use the cleveref package to adjust things to your needs. – marmot Apr 28 '18 at 2:39
  • @cfr Well, I defined an array like \newarray TheList and added a line to \cmust like \TheList(\value{globalcounter})={\entrycode} and later I defined a \crefformat{globalcounter}{#2 \TheList(#1) #3} but unfortunately these references never worked correctly, because the elements of the array where evaluated way to late and all the variables had already changed. – Moraxno Apr 28 '18 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.