TeX - LaTeX Asked on January 6, 2021
I would like to split a multiline content regarding and then split each item regarding
.
.
Then I would like to iterate over each list in parallel such as to print their items together suchas to print for example a1i b2ii c3iii
.
I am trying to pop from the left the first list to read it item by item but this doesn’t work…
I would like to see a-ok-b-ok-c
but I just see a . b . c
… An expansion problem I think…
This question is a simplifcation of the real case of use indicated in this post.
documentclass{article}
% Source : https://tex.stackexchange.com/a/475291/6880
RequirePackage{xparse}
ExplSyntaxOn
%seq_new:N l__pmbc_seq % Not useful here.
% #1 : line separator
% #2 : cell separator
% #3 : content
NewDocumentCommand{splittab}{m m +m}{
tnscalc_splittab:nnn{#1}{#2}{#3}
}
% The internal version of the general purpose macro
cs_new_protected:Nn tnscalc_splittab:nnn{
% #1 : line separator
% #2 : cell separator
% #3 : content
% A group allows nesting
group_begin:
% Split into parts
seq_set_split:Nnn l__pmbc_seq { #1 } { #3 }
%int_zero_new:N l_mbc_N_int % Not useful here.
%int_set:Nn l_mbc_N_int { seq_count:N l__pmbc_seq } % Not useful here.
%
seq_pop_left:NN l__pmbc_seq {l__temp}
seq_set_split:Nnn l__pmbc_subseq { #2 } { l__temp }
seq_use:Nn l__pmbc_subseq { -ok- }
group_end:
}
ExplSyntaxOff
begin{document}
splittab{}{.}{ a . b . c 1 . 2 . 3 i . ii . ii }
end{document}
Please, use proper naming.
documentclass{article}
% Source : https://tex.stackexchange.com/a/475291/6880
usepackage{xparse}
ExplSyntaxOn
seq_new:N l__tnscalc_splittab_seq
seq_new:N l__tnscalc_subseq_seq
int_new:N l__tnscalc_splittab_int
tl_new:N l__tnscalc_temp_tl
% #1 : line separator
% #2 : cell separator
% #3 : content
NewDocumentCommand{splittab}{m m +m}
{
tnscalc_splittab:nnn{#1}{#2}{#3}
}
% The internal version of the general purpose macro
cs_new_protected:Nn tnscalc_splittab:nnn
{
% #1 : line separator
% #2 : cell separator
% #3 : content
% A group allows nesting
group_begin:
% Split into parts
seq_set_split:Nnn l__tnscalc_splittab_seq { #1 } { #3 }
int_set:Nn l__tnscalc_splittab_int { seq_count:N l__tnscalc_splittab_seq } % why?
seq_pop_left:NN l__tnscalc_splittab_seq l__tnscalc_temp_tl
seq_set_split:NnV l__tnscalc_subseq_seq { #2 } l__tnscalc_temp_tl
seq_use:Nn l__tnscalc_subseq_seq { -ok- }
group_end:
}
ExplSyntaxOff
begin{document}
splittab{}{.}{ a . b . c 1 . 2 . 3 i . ii . ii }
end{document}
You need to split the contents of the token list where the popped item has been stored, so the right function is seq_set_split:NnV
.
It's not clear what's the function of the integer variable.
Correct answer by egreg on January 6, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP