2

Why and is there a solution?

\documentclass{article}
\usepackage[utf8]{inputenc}
\inputencoding{latin1}
\usepackage{xparse}
\usepackage{etoolbox}

\ExplSyntaxOn

\tl_const:Nx \lang_and
{
  croatian=i,
  czech=a,
  hungarian=\'es,
%  romanian=\c{s}i, % ERROR: Illegal parameter number in definition of \erw_foo.
  slovak=a,
  slovenian=in
}

\ExplSyntaxOff

\begin{document}

\ifcsdef{c}{
  romanian=\c{s}i,
  }{}

\end{document}

enter image description here

Erwann
  • 2,100
  • Apparently \c{s} does not survive the \edef of \tl_const:Nx, with \tl_const:Nn there is no error. – moewe May 29 '20 at 04:11
  • Because \c is not expandable (neither is \': try \show \lang_and to see), and it explodes with x expansion. Either use \tl_const:Nn or use \exp_not:n { romanian=\c{s}i } to avoid the expansion of \c. Besides the name of \lang_and is wrong: something like \c_erwann_lang_tl would be better. – Phelype Oleinik May 29 '20 at 04:11
  • Are you defining a token list constant or rather a clist? And what's the reason for x? – egreg May 29 '20 at 08:37

2 Answers2

3

Because \c is not expandable (neither is \': try \show \lang_and to see), and it explodes with x expansion. Either use \tl_const:Nn or use \exp_not:n { romanian=\c{s}i } to avoid the expansion of \c – Phelype Oleinik

Erwann
  • 2,100
3

I can see no reason for

  1. \inputencoding{latin1} after loading utf8;
  2. a token list constant;
  3. x expansion.

Most likely you want

\prop_gset_from_keyval:Nn \g_erwann_lang_and_prop
 {
  croatian=i,
  czech=a,
  hungarian=\'es,
  romanian=\textcommabelow{s}i,
  slovak=a,
  slovenian=in
 }
egreg
  • 1,121,712
  • Thanks. Yeah, I didn't put to much thought into 1. The reasons for 2. and 3. wouldn't add value to the discussion. – Erwann May 29 '20 at 10:06