I want to label a series of compounds with the lanthanides, i.e. 10la and I'm using the chemnum
package.
The manual gives some hints about this, saying you could do \newcmpdcounterformat{arabic}{\@arabic}
but it uses \int_to_<...>
. So after some looking around, I found interfaces3.pdf and copy and pasted some code from it, and then got help from the chat when it didn't work. However, I'm a bit worried by the manuals description of the function:
This is the low-level function for conversion of an integer expression into a symbolic form (often letters)
(emphasis mine)
Aren't low level things stuff that people like me are supposed to avoid? Is there a higher level way of doing this? Should I be using a more traditional method of making a list of things, like however \alpha was defined?
Here is the (working) code I came up with:
\documentclass{article}
\usepackage{chemnum}
\RequirePackage{expl3}
\ExplSyntaxOn
\cs_new:Npn \canageek_int_to_lanthanide:n #1
{
\int_to_symbols:nnn {#1} { 15 }
{
{ 1 } { La }
{ 2 } { Ce }
{ 3 } { Pr }
{ 4 } { Nd }
{ 5 } { Pm }
{ 6 } { Sm }
{ 7 } { Eu }
{ 8 } { Gd }
{ 9 } { Tb }
{ 10 } { Dy }
{ 11 } { Ho }
{ 12 } { Er }
{ 13 } { Tm }
{ 14 } { Yb }
{ 15 } { Lu }
}
}
\newcmpdcounterformat{lanthanide}{\canageek_int_to_lanthanide:n}
\ExplSyntaxOff
\labelcmpd[sub-counter-format=lanthanide]{lnwater.la,lnwater.ce,lnwater.pr,lnwater.nd,lnwater.pm,lnwater.sm,lnwater.eu,lnwater.gd,lnwater.tb,lnwater.dy,lnwater.ho,lnwater.er,lnwater.tm,lnwater.yb,lnwater.lu}
\begin{document}
\cmpd{peroxo.meoh}
\cmpd{DMSOcp}
\cmpd{lnwater.pr}
\cmpd{lnwater.{ce,la}}
\cmpd{lnwater.lu}
\end{document}
\int_to_alph:n
is defined in terms of\int_to_symbols:nnn
. All functions with no double underscore in their names are good to use.