I wish to assign a \crefname
with dynamical strings. With \exp_args_generate:n { xVV }
, I ended up with something like:
\exp_args:NxVV \crefname {\__my_countername: }
{\csname my@cref@\__my_countername:\csname\languagename ABBR\endcsname @name\endcsname}
{\csname my@cref@\__my_countername:\csname\languagename ABBR\endcsname @name@plural\endcsname}
Here \__my_countername:
is the counter's name, such as theorem
. \csname\languagename ABBR\endcsname
is a conversion from string like english
to EN
.
However, this expands the arguments too deeply that the strings are no longer dynamic with respect to the context. To be clear, I wish the arguments to be expanded to:
\crefname {theorem }
{\csname my@cref@theorem\csname\languagename ABBR\endcsname @name\endcsname}
{\csname my@cref@theorem\csname\languagename ABBR\endcsname @name@plural\endcsname}
That is, to make \__my_countername:
expanded while keeping \csname\languagename ABBR\endcsname
untouched, since it should receive \languagename
from the context. Would that be possible?
I tried to use \noexpand
, but probably misused, which leads to an error with no warning text.
(Please forgive my terrible mixture of expl3 and LaTeX2e code, I'm not familiar with expl3 and it would be much easier for me to use a little LaTeX2e code for some tasks)
\csname
once, it expands and collects everything up to the (matching)\endcsname
, so all macros (including\languagename
) are expanded. There is not much you can do here, because both the inside and outside\csname
s vary with\languagename
, so you should probably leave that unexpanded.V
expansion works on a single token/variable. Feeding it multiple tokens (\csname...\endcsname
) is wrong and works by pure chance. The correct form here would be withv
(but then it expands the\csname
, which you don't want):\exp_args:Nxvv \crefname {\__my_countername: } { my@cref@\__my_countername:\csname\languagename ABBR\endcsname @name } { my@cref@\__my_countername:\csname\languagename ABBR\endcsname @name@plural }
. Thev
expansion is short forc
thenV
.\__my_countername:
? If it is not expanded, an error would occur, though I don't know the exact reason.x
-expand\__my_countername:
, then\exp_args:Nx \crefname { \__my_countername: } { ...
\__my_countername:
in the last two arguments get expanded (and leave everything else untouched). Would that be possible?