निरंजन
I am working on a mechanism to segment a given string based on a particular character and then use it in some contexts. It is fairly okay in one case, but extending the mechanism to another case is failing mysteriously. I don't understand what is wrong with my code. Let's first have a look at the working code. Suppose I have to implement a font-loading-mechanism along with scaling specification. I want to create an option where suppose I input `KpSans-Regular.otf/0.5`, it should be interpreted as KpSans is to be loaded with `Scale=0.5` option. The following does that for me.
```
% arara: lualatex
% arara: lualatex
% arara: clean: { extensions: [ log,aux ] }
\documentclass{article}
\usepackage{kantlipsum,fontspec}
\usepackage{expkv-def}
\makeatletter
\ExplSyntaxOn
\seq_new:N \l_tmp_font_seq
\cs_new:Npn \tmp@split@use@fonts #1 {
\seq_put_right:Nn \l_tmp_font_seq { #1 }
\seq_set_split:Nnn \l_tmp_font_seq
{ / }
{ #1 }
\expandafter\newfontfamily\csname
tmp @ \tmp@field @ font
\endcsname[
Scale = {
\seq_item:Nn \l_tmp_font_seq { 2 }
}
]{
\seq_item:Nn \l_tmp_font_seq { 1 }
}
\seq_clear:N \l_tmp_font_seq
}
\ExplSyntaxOff
\ekvdefinekeys{test}{
code font = {%
\tmp@split@use@fonts{#1}%
}%
}
\NewDocumentCommand \bigkant {
O{%
font = {NewCM10-Book.otf/1}%
}
}{%
\def\tmp@field{big}%
\ekvset{test}{#1}%
\begingroup
\tmp@big@font
\kant[1-1]
\endgroup
}
\NewDocumentCommand \midkant {
O{%
font = {NewCMMono10-Book.otf/0.75}%
}
}{%
\def\tmp@field{mid}%
\ekvset{test}{#1}%
\begingroup
\tmp@mid@font
\kant[1-1]
\endgroup
}
\NewDocumentCommand \smallkant {
O{%
font = {NewCMSans10-Book.otf/0.5}%
}
}{%
\def\tmp@field{small}%
\ekvset{test}{#1}%
\begingroup
\tmp@small@font
\kant[1-1]
\endgroup
}
\makeatother
\begin{document}
\smallkant
\midkant
\bigkant
\end{document}
```
I have tried to adhere to the "standard" practices of l3, but I won't be surprised if I miss any convention. Feel free to correct me regarding that too.
Now, I use this mechanism almost identically with `\fontsize` command and there it is failing. See the following:
```
% arara: pdflatex
% arara: pdflatex
% arara: clean: { extensions: [ log,aux ] }
\documentclass{article}
\usepackage{kantlipsum}
\usepackage{expkv-def}
\makeatletter
\ExplSyntaxOn
\seq_new:N \l_tmp_size_seq
\cs_new:Npn \tmp@split@use@sizes #1 {
\seq_put_right:Nn \l_tmp_size_seq { #1 }
\seq_set_split:Nnn \l_tmp_size_seq
{ / }
{ #1 }
\expandafter\def\csname
tmp @ \tmp@field @ size
\endcsname{
\fontsize{
\seq_item:Nn \l_tmp_size_seq { 1 }
}{
\seq_item:Nn \l_tmp_size_seq { 2 }
}
\selectfont
}
% \seq_clear:N \l_tmp_size_seq % Uncommenting fails. Why?
}
\ExplSyntaxOff
\ekvdefinekeys{test}{
code size = {%
\tmp@split@use@sizes{#1}%
}%
}
\NewDocumentCommand \bigkant {
O{%
size = {10pt/11pt}%
}
}{%
\def\tmp@field{big}%
\ekvset{test}{#1}%
\begingroup
\tmp@big@size
\kant[1-1]%
\endgroup
}
\NewDocumentCommand \midkant {
O{%
size = {7.5pt/8pt}%
}
}{%
\def\tmp@field{mid}%
\ekvset{test}{#1}%
\begingroup
\tmp@mid@size
\kant[1-1]%
\endgroup
}
\NewDocumentCommand \smallkant {
O{%
size = {5pt/6pt}%
}
}{%
\def\tmp@field{small}%
\ekvset{test}{#1}%
\begingroup
\tmp@small@size
\kant[1-1]%
\endgroup
}
\makeatother
\begin{document}
\smallkant
\midkant
\bigkant
\end{document}
```
Why does `\seq_clear:N` fail now? What's the difference between the two situations?