How to expand a macro (or a copy) to save in a list at end of environment in xparse (expl3)?How can I create an oddly-delimited macro, using xparse?How do I pass an expanded optional argument using expl3/xparse?Expand macro into xparse SplitList macroWhen defining a new macro inside a new macro (in xparse) how do I make the internal map long?How to expand control sequence in argument of a macroHow to expand macro in a macro callXparse k argument to parse options at end of environmentHow to embed a command in an environment using Expl3?How can expand a counter of auxiliary file and save in list with xparse?How to use exp_not:N and exp_after:wN to prevent the expansion of input in a expl3 list?

Can the Produce Flame cantrip be used to grapple, or as an unarmed strike, in the right circumstances?

Copycat chess is back

Is this food a bread or a loaf?

How to make payment on the internet without leaving a money trail?

How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)

Was there ever an axiom rendered a theorem?

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?

"My colleague's body is amazing"

Re-submission of rejected manuscript without informing co-authors

Are objects structures and/or vice versa?

Hosting Wordpress in a EC2 Load Balanced Instance

How can I add custom success page

Prime joint compound before latex paint?

Unbreakable Formation vs. Cry of the Carnarium

Is domain driven design an anti-SQL pattern?

Can a planet have a different gravitational pull depending on its location in orbit around its sun?

I see my dog run

Where else does the Shulchan Aruch quote an authority by name?

What is the meaning of "of trouble" in the following sentence?

aging parents with no investments

Could a US political party gain complete control over the government by removing checks & balances?

Is there a way to make member function NOT callable from constructor?

Does the average primeness of natural numbers tend to zero?

How would photo IDs work for shapeshifters?



How to expand a macro (or a copy) to save in a list at end of environment in xparse (expl3)?


How can I create an oddly-delimited macro, using xparse?How do I pass an expanded optional argument using expl3/xparse?Expand macro into xparse SplitList macroWhen defining a new macro inside a new macro (in xparse) how do I make the internal map long?How to expand control sequence in argument of a macroHow to expand macro in a macro callXparse k argument to parse options at end of environmentHow to embed a command in an environment using Expl3?How can expand a counter of auxiliary file and save in list with xparse?How to use exp_not:N and exp_after:wN to prevent the expansion of input in a expl3 list?













0















I am trying to encapsulate a couple of environments to pass them to lists using xparse/expl3.
I have defined a one command and two environments and I have had a problem with one of them.



I use the environments to save notes type question/answer where the answers are stored in a list to show them at the end of the file or elsewhere in it, the issue is that sometimes need to use verbatim.



The scontent environment uses the +b argument of xparse and only Verb[...]... (from fvextra) can be used (you can not use the verbatim environment for example).



The scontent* environment is based on filecontentsdef and can use verb|...| in a line or beginverbatim environment, this generates an external file but has the facility of saving the content in a macro.



When executing beginscontent* pass the following:



  1. Save the current content in macro

  2. Copy the current contents of macro in l_my_macro_copy_tl

  3. Pass the contents of l_my_macro_copy_tl to list using
    expanddafterenvtolistexpanddafter content save in l_my_macro_copy_tl

  4. If this is the key [show-env = true] run usecontent[-1]l_scontent_env_save_tl

The problem is in the execution of



expanddafterenvtolistexpanddafterl_my_macro_copy_tl


at end of environment scontent*, I tried with the following (ugly and incorrect) lines:



% beginscontent*[...] verbatim env save in macro
% Copy a current content of macro in l_my_macro_copy_tl and pass to list
tl_new:N l_my_macro_copy_tl
NewDocumentEnvironmentscontent* !O

group_begin:
filecontentsdefjobname.tscmacro % save in macro

endfilecontentsdef %
group_end:
IfNoValueF #1 keys_set:nn scontent #1
tl_set:Nx l_my_macro_copy_tl macro
exp_after:wN envtolist exp_after:wN exp_not:N tex_newlinechar:D = 13 exp_not:N scantokens exp_after:wN l_my_macro_copy_tl %
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl



with this I eliminate the errors when compiling, but, the content is not saved in the list...How can i fix this?



My idea is not to occupy directly showme... and only use usecontent[index]list name in document.



I know that the command showme... and usecontent[index]list name works if you execute it out of the environment, but my idea is automate this when run scontent*.



This is my example file (MWE), the comments should be removed to see the error that occurs.



documentclassarticle
usepackagefilecontentsdef,etoolbox,xparse,fvextra,xcolor
usepackage[margin=0.6in,noheadfoot,papersize=8.5in,13in]geometry
setlengthparindent0pt
pagestyleempty
ExplSyntaxOn
% show content save in macro
tl_new:N l_temp_argument_tl
NewDocumentCommandshowme +m %
tl_set:Nx l_temp_argument_tl #1
tex_newlinechar:D = 13
exp_not:N scantokens exp_after:wN l_temp_argument_tl


% elementinlistname and clearlistlistname
cs_new:Npn elementin #1 seq_count:c l_savecontent_content_#1_seq
cs_new:Npn clearlist #1 seq_clear_new:c l_savecontent_content_#1_seq

% addcontentlistname#1 ...need double ...
NewDocumentCommandaddcontent m +m savecontent_add_content:nn #1 #2

% usecontent[index]listname
DeclareExpandableDocumentCommandusecontentO1m savecontent_use_content:nn #1 #2

cs_new_protected:Npn savecontent_add_content:nn #1 #2

seq_if_exist:cF l_savecontent_content_#1_seq
seq_new:c l_savecontent_content_#1_seq
__savecontent_add_content:nn #1 #2


cs_new_protected:Npn __savecontent_add_content:nn #1 #2

tl_map_inline:nn #2

seq_gput_right:cn l_savecontent_content_#1_seq ##1



cs_new:Npn savecontent_use_content:nn #1 #2 seq_item:cn l_savecontent_content_#2_seq #1

keys_define:nn scontent

save-cmd .tl_set:N = l_scontent_cmd_save_tl, save-cmd .initial:n = content,%
save-env .tl_set:N = l_scontent_env_save_tl, save-env .initial:n = content, %
show-cmd .bool_set:N = l_scontent_cmd_show_tl, show-cmd .initial:n = false, show-cmd .value_required:n = true,%
show-env .bool_set:N = l_scontent_env_show_tl, show-env .initial:n = false, show-env .value_required:n = true,%
show-all .meta:n = show-env = true , show-cmd = true ,%


NewDocumentCommandSetscontent +m keys_set:nn scontent #1

% pass to list
newrobustcmdenvtolist[1]addcontent l_scontent_env_save_tl #1

% Scontent[...]... NO verbatim env support, but Verb[...]... yes
NewDocumentCommandScontent O +m

group_begin:
IfNoValueF#1 keys_set:nn scontent #1
addcontent l_scontent_cmd_save_tl #2 % pass direct to list
IfBooleanT l_scontent_cmd_show_tl usecontent[-1] l_scontent_cmd_save_tl
group_end:


% beginscontent[...] NO verbatim env suport, but Verb[...]... yes
NewDocumentEnvironmentscontent !o +b

group_begin:
IfNoValueF #1 keys_set:nn scontent #1

expandafterenvtolistexpandafter#2
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
group_end:


% beginscontent*[...] verbatim env save in macro
tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
NewDocumentEnvironmentscontent* !O

group_begin:
IfNoValueF #1 keys_set:nn scontent #1
filecontentsdefjobname.tscmacro

endfilecontentsdef %
group_end:
% Copy macro every time in tl_var (at definition time) and pass to list
%cs_set_eq:NN l_my_macro_copy_tl macro
%expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
%IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl

ExplSyntaxOff
% set name of lists
Setscontent save-env=test-env, save-cmd=test-cmd
begindocument
sectionUsing textttscontent environment whit new texttt+b argument from textttxparse
subsectionWhit texttt[show-env=false]
Text save in verb|beginscontent[show-env=false]| (hidden)

beginscontent[show-env=false]
Some first text whit verbatim inline saved in Verbusecontent[1]test-env par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionWhit texttt[show-env=true]
Text save in verb|beginscontent[show-env=true]| (Not hidden)

beginscontent[show-env=true]
Some second text whit verbatim inline saved in Verbusecontent[2]test-env...more text par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionUsing Verbusecontent[1]test-env
Now see saved text in list:par
usecontent[2]test-envpar
usecontent[1]test-env

sectionUsing Verb*Scontent[...]...
Text save whit verb|Scontent....| (hidden)par
Scontent
using a Verb*Scontent[...]... textcolorredwhit verbatim Verb*Verb[...]...par
(by Verb*fvextra) textcolormagentainline
par

And see saved text in list using verb|usecontent[1]test-cmd| par
usecontent[1]test-cmdpar
OK
sectionUsing textttscontent* environment wraped textttfilecontentsdef using textttxparse

subsectionWhit texttt[show-env=false]
Some Text save using verb|beginscontent*[show-env=false]| save in verb|macro| (hidden)

beginscontent*[show-env=false]
Some text in whit verbatim environment ¿saved in list ...verb+usecontent[3]test-env+?(not get for now).par
beginVerbatim
This is from the verbatim environment: &%_"`´~
xxxxx
endVerbatim
endscontent*par
OK...it's posible to see verb|macro| whit verb|showmemacro|:par
showmemacropar
or pass to list using verb|Scontentshowmemacro| and see in list whit verb+usecontent[2]test-cmd+:par
Scontentshowmemacro
usecontent[2]test-cmd
subsectionThe idea whit texttt[show-env=true]
Setscontent save-cmd=test-other
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim A
beginVerbatim
verbatim environment A: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacropar
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim B
beginVerbatim
verbatim environment B: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacro
XXXXXXXXXpar
And see in reverse order:par
usecontent[2]test-otherpar
usecontent[1]test-otherpar
NOT OK,...
subsectionThe problem whit texttt[show-env=true]
beginscontent*[show-env=true]
Some text in whit verbatim C
beginVerbatim
verbatim environment C: &%_"`´~
endVerbatim
endscontent*
enddocument


An image to complement
Idea of the expected



regards










share|improve this question



















  • 1





    Could you please state clearly at the beginning what the aim is?

    – egreg
    2 days ago











  • @egreg Thanks for the comment, I added the clarification, apologies for the writing, (my english base + google translator sometimes fails). Can you give me a hand with this?

    – Pablo González L
    2 days ago















0















I am trying to encapsulate a couple of environments to pass them to lists using xparse/expl3.
I have defined a one command and two environments and I have had a problem with one of them.



I use the environments to save notes type question/answer where the answers are stored in a list to show them at the end of the file or elsewhere in it, the issue is that sometimes need to use verbatim.



The scontent environment uses the +b argument of xparse and only Verb[...]... (from fvextra) can be used (you can not use the verbatim environment for example).



The scontent* environment is based on filecontentsdef and can use verb|...| in a line or beginverbatim environment, this generates an external file but has the facility of saving the content in a macro.



When executing beginscontent* pass the following:



  1. Save the current content in macro

  2. Copy the current contents of macro in l_my_macro_copy_tl

  3. Pass the contents of l_my_macro_copy_tl to list using
    expanddafterenvtolistexpanddafter content save in l_my_macro_copy_tl

  4. If this is the key [show-env = true] run usecontent[-1]l_scontent_env_save_tl

The problem is in the execution of



expanddafterenvtolistexpanddafterl_my_macro_copy_tl


at end of environment scontent*, I tried with the following (ugly and incorrect) lines:



% beginscontent*[...] verbatim env save in macro
% Copy a current content of macro in l_my_macro_copy_tl and pass to list
tl_new:N l_my_macro_copy_tl
NewDocumentEnvironmentscontent* !O

group_begin:
filecontentsdefjobname.tscmacro % save in macro

endfilecontentsdef %
group_end:
IfNoValueF #1 keys_set:nn scontent #1
tl_set:Nx l_my_macro_copy_tl macro
exp_after:wN envtolist exp_after:wN exp_not:N tex_newlinechar:D = 13 exp_not:N scantokens exp_after:wN l_my_macro_copy_tl %
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl



with this I eliminate the errors when compiling, but, the content is not saved in the list...How can i fix this?



My idea is not to occupy directly showme... and only use usecontent[index]list name in document.



I know that the command showme... and usecontent[index]list name works if you execute it out of the environment, but my idea is automate this when run scontent*.



This is my example file (MWE), the comments should be removed to see the error that occurs.



documentclassarticle
usepackagefilecontentsdef,etoolbox,xparse,fvextra,xcolor
usepackage[margin=0.6in,noheadfoot,papersize=8.5in,13in]geometry
setlengthparindent0pt
pagestyleempty
ExplSyntaxOn
% show content save in macro
tl_new:N l_temp_argument_tl
NewDocumentCommandshowme +m %
tl_set:Nx l_temp_argument_tl #1
tex_newlinechar:D = 13
exp_not:N scantokens exp_after:wN l_temp_argument_tl


% elementinlistname and clearlistlistname
cs_new:Npn elementin #1 seq_count:c l_savecontent_content_#1_seq
cs_new:Npn clearlist #1 seq_clear_new:c l_savecontent_content_#1_seq

% addcontentlistname#1 ...need double ...
NewDocumentCommandaddcontent m +m savecontent_add_content:nn #1 #2

% usecontent[index]listname
DeclareExpandableDocumentCommandusecontentO1m savecontent_use_content:nn #1 #2

cs_new_protected:Npn savecontent_add_content:nn #1 #2

seq_if_exist:cF l_savecontent_content_#1_seq
seq_new:c l_savecontent_content_#1_seq
__savecontent_add_content:nn #1 #2


cs_new_protected:Npn __savecontent_add_content:nn #1 #2

tl_map_inline:nn #2

seq_gput_right:cn l_savecontent_content_#1_seq ##1



cs_new:Npn savecontent_use_content:nn #1 #2 seq_item:cn l_savecontent_content_#2_seq #1

keys_define:nn scontent

save-cmd .tl_set:N = l_scontent_cmd_save_tl, save-cmd .initial:n = content,%
save-env .tl_set:N = l_scontent_env_save_tl, save-env .initial:n = content, %
show-cmd .bool_set:N = l_scontent_cmd_show_tl, show-cmd .initial:n = false, show-cmd .value_required:n = true,%
show-env .bool_set:N = l_scontent_env_show_tl, show-env .initial:n = false, show-env .value_required:n = true,%
show-all .meta:n = show-env = true , show-cmd = true ,%


NewDocumentCommandSetscontent +m keys_set:nn scontent #1

% pass to list
newrobustcmdenvtolist[1]addcontent l_scontent_env_save_tl #1

% Scontent[...]... NO verbatim env support, but Verb[...]... yes
NewDocumentCommandScontent O +m

group_begin:
IfNoValueF#1 keys_set:nn scontent #1
addcontent l_scontent_cmd_save_tl #2 % pass direct to list
IfBooleanT l_scontent_cmd_show_tl usecontent[-1] l_scontent_cmd_save_tl
group_end:


% beginscontent[...] NO verbatim env suport, but Verb[...]... yes
NewDocumentEnvironmentscontent !o +b

group_begin:
IfNoValueF #1 keys_set:nn scontent #1

expandafterenvtolistexpandafter#2
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
group_end:


% beginscontent*[...] verbatim env save in macro
tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
NewDocumentEnvironmentscontent* !O

group_begin:
IfNoValueF #1 keys_set:nn scontent #1
filecontentsdefjobname.tscmacro

endfilecontentsdef %
group_end:
% Copy macro every time in tl_var (at definition time) and pass to list
%cs_set_eq:NN l_my_macro_copy_tl macro
%expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
%IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl

ExplSyntaxOff
% set name of lists
Setscontent save-env=test-env, save-cmd=test-cmd
begindocument
sectionUsing textttscontent environment whit new texttt+b argument from textttxparse
subsectionWhit texttt[show-env=false]
Text save in verb|beginscontent[show-env=false]| (hidden)

beginscontent[show-env=false]
Some first text whit verbatim inline saved in Verbusecontent[1]test-env par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionWhit texttt[show-env=true]
Text save in verb|beginscontent[show-env=true]| (Not hidden)

beginscontent[show-env=true]
Some second text whit verbatim inline saved in Verbusecontent[2]test-env...more text par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionUsing Verbusecontent[1]test-env
Now see saved text in list:par
usecontent[2]test-envpar
usecontent[1]test-env

sectionUsing Verb*Scontent[...]...
Text save whit verb|Scontent....| (hidden)par
Scontent
using a Verb*Scontent[...]... textcolorredwhit verbatim Verb*Verb[...]...par
(by Verb*fvextra) textcolormagentainline
par

And see saved text in list using verb|usecontent[1]test-cmd| par
usecontent[1]test-cmdpar
OK
sectionUsing textttscontent* environment wraped textttfilecontentsdef using textttxparse

subsectionWhit texttt[show-env=false]
Some Text save using verb|beginscontent*[show-env=false]| save in verb|macro| (hidden)

beginscontent*[show-env=false]
Some text in whit verbatim environment ¿saved in list ...verb+usecontent[3]test-env+?(not get for now).par
beginVerbatim
This is from the verbatim environment: &%_"`´~
xxxxx
endVerbatim
endscontent*par
OK...it's posible to see verb|macro| whit verb|showmemacro|:par
showmemacropar
or pass to list using verb|Scontentshowmemacro| and see in list whit verb+usecontent[2]test-cmd+:par
Scontentshowmemacro
usecontent[2]test-cmd
subsectionThe idea whit texttt[show-env=true]
Setscontent save-cmd=test-other
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim A
beginVerbatim
verbatim environment A: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacropar
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim B
beginVerbatim
verbatim environment B: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacro
XXXXXXXXXpar
And see in reverse order:par
usecontent[2]test-otherpar
usecontent[1]test-otherpar
NOT OK,...
subsectionThe problem whit texttt[show-env=true]
beginscontent*[show-env=true]
Some text in whit verbatim C
beginVerbatim
verbatim environment C: &%_"`´~
endVerbatim
endscontent*
enddocument


An image to complement
Idea of the expected



regards










share|improve this question



















  • 1





    Could you please state clearly at the beginning what the aim is?

    – egreg
    2 days ago











  • @egreg Thanks for the comment, I added the clarification, apologies for the writing, (my english base + google translator sometimes fails). Can you give me a hand with this?

    – Pablo González L
    2 days ago













0












0








0








I am trying to encapsulate a couple of environments to pass them to lists using xparse/expl3.
I have defined a one command and two environments and I have had a problem with one of them.



I use the environments to save notes type question/answer where the answers are stored in a list to show them at the end of the file or elsewhere in it, the issue is that sometimes need to use verbatim.



The scontent environment uses the +b argument of xparse and only Verb[...]... (from fvextra) can be used (you can not use the verbatim environment for example).



The scontent* environment is based on filecontentsdef and can use verb|...| in a line or beginverbatim environment, this generates an external file but has the facility of saving the content in a macro.



When executing beginscontent* pass the following:



  1. Save the current content in macro

  2. Copy the current contents of macro in l_my_macro_copy_tl

  3. Pass the contents of l_my_macro_copy_tl to list using
    expanddafterenvtolistexpanddafter content save in l_my_macro_copy_tl

  4. If this is the key [show-env = true] run usecontent[-1]l_scontent_env_save_tl

The problem is in the execution of



expanddafterenvtolistexpanddafterl_my_macro_copy_tl


at end of environment scontent*, I tried with the following (ugly and incorrect) lines:



% beginscontent*[...] verbatim env save in macro
% Copy a current content of macro in l_my_macro_copy_tl and pass to list
tl_new:N l_my_macro_copy_tl
NewDocumentEnvironmentscontent* !O

group_begin:
filecontentsdefjobname.tscmacro % save in macro

endfilecontentsdef %
group_end:
IfNoValueF #1 keys_set:nn scontent #1
tl_set:Nx l_my_macro_copy_tl macro
exp_after:wN envtolist exp_after:wN exp_not:N tex_newlinechar:D = 13 exp_not:N scantokens exp_after:wN l_my_macro_copy_tl %
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl



with this I eliminate the errors when compiling, but, the content is not saved in the list...How can i fix this?



My idea is not to occupy directly showme... and only use usecontent[index]list name in document.



I know that the command showme... and usecontent[index]list name works if you execute it out of the environment, but my idea is automate this when run scontent*.



This is my example file (MWE), the comments should be removed to see the error that occurs.



documentclassarticle
usepackagefilecontentsdef,etoolbox,xparse,fvextra,xcolor
usepackage[margin=0.6in,noheadfoot,papersize=8.5in,13in]geometry
setlengthparindent0pt
pagestyleempty
ExplSyntaxOn
% show content save in macro
tl_new:N l_temp_argument_tl
NewDocumentCommandshowme +m %
tl_set:Nx l_temp_argument_tl #1
tex_newlinechar:D = 13
exp_not:N scantokens exp_after:wN l_temp_argument_tl


% elementinlistname and clearlistlistname
cs_new:Npn elementin #1 seq_count:c l_savecontent_content_#1_seq
cs_new:Npn clearlist #1 seq_clear_new:c l_savecontent_content_#1_seq

% addcontentlistname#1 ...need double ...
NewDocumentCommandaddcontent m +m savecontent_add_content:nn #1 #2

% usecontent[index]listname
DeclareExpandableDocumentCommandusecontentO1m savecontent_use_content:nn #1 #2

cs_new_protected:Npn savecontent_add_content:nn #1 #2

seq_if_exist:cF l_savecontent_content_#1_seq
seq_new:c l_savecontent_content_#1_seq
__savecontent_add_content:nn #1 #2


cs_new_protected:Npn __savecontent_add_content:nn #1 #2

tl_map_inline:nn #2

seq_gput_right:cn l_savecontent_content_#1_seq ##1



cs_new:Npn savecontent_use_content:nn #1 #2 seq_item:cn l_savecontent_content_#2_seq #1

keys_define:nn scontent

save-cmd .tl_set:N = l_scontent_cmd_save_tl, save-cmd .initial:n = content,%
save-env .tl_set:N = l_scontent_env_save_tl, save-env .initial:n = content, %
show-cmd .bool_set:N = l_scontent_cmd_show_tl, show-cmd .initial:n = false, show-cmd .value_required:n = true,%
show-env .bool_set:N = l_scontent_env_show_tl, show-env .initial:n = false, show-env .value_required:n = true,%
show-all .meta:n = show-env = true , show-cmd = true ,%


NewDocumentCommandSetscontent +m keys_set:nn scontent #1

% pass to list
newrobustcmdenvtolist[1]addcontent l_scontent_env_save_tl #1

% Scontent[...]... NO verbatim env support, but Verb[...]... yes
NewDocumentCommandScontent O +m

group_begin:
IfNoValueF#1 keys_set:nn scontent #1
addcontent l_scontent_cmd_save_tl #2 % pass direct to list
IfBooleanT l_scontent_cmd_show_tl usecontent[-1] l_scontent_cmd_save_tl
group_end:


% beginscontent[...] NO verbatim env suport, but Verb[...]... yes
NewDocumentEnvironmentscontent !o +b

group_begin:
IfNoValueF #1 keys_set:nn scontent #1

expandafterenvtolistexpandafter#2
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
group_end:


% beginscontent*[...] verbatim env save in macro
tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
NewDocumentEnvironmentscontent* !O

group_begin:
IfNoValueF #1 keys_set:nn scontent #1
filecontentsdefjobname.tscmacro

endfilecontentsdef %
group_end:
% Copy macro every time in tl_var (at definition time) and pass to list
%cs_set_eq:NN l_my_macro_copy_tl macro
%expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
%IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl

ExplSyntaxOff
% set name of lists
Setscontent save-env=test-env, save-cmd=test-cmd
begindocument
sectionUsing textttscontent environment whit new texttt+b argument from textttxparse
subsectionWhit texttt[show-env=false]
Text save in verb|beginscontent[show-env=false]| (hidden)

beginscontent[show-env=false]
Some first text whit verbatim inline saved in Verbusecontent[1]test-env par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionWhit texttt[show-env=true]
Text save in verb|beginscontent[show-env=true]| (Not hidden)

beginscontent[show-env=true]
Some second text whit verbatim inline saved in Verbusecontent[2]test-env...more text par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionUsing Verbusecontent[1]test-env
Now see saved text in list:par
usecontent[2]test-envpar
usecontent[1]test-env

sectionUsing Verb*Scontent[...]...
Text save whit verb|Scontent....| (hidden)par
Scontent
using a Verb*Scontent[...]... textcolorredwhit verbatim Verb*Verb[...]...par
(by Verb*fvextra) textcolormagentainline
par

And see saved text in list using verb|usecontent[1]test-cmd| par
usecontent[1]test-cmdpar
OK
sectionUsing textttscontent* environment wraped textttfilecontentsdef using textttxparse

subsectionWhit texttt[show-env=false]
Some Text save using verb|beginscontent*[show-env=false]| save in verb|macro| (hidden)

beginscontent*[show-env=false]
Some text in whit verbatim environment ¿saved in list ...verb+usecontent[3]test-env+?(not get for now).par
beginVerbatim
This is from the verbatim environment: &%_"`´~
xxxxx
endVerbatim
endscontent*par
OK...it's posible to see verb|macro| whit verb|showmemacro|:par
showmemacropar
or pass to list using verb|Scontentshowmemacro| and see in list whit verb+usecontent[2]test-cmd+:par
Scontentshowmemacro
usecontent[2]test-cmd
subsectionThe idea whit texttt[show-env=true]
Setscontent save-cmd=test-other
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim A
beginVerbatim
verbatim environment A: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacropar
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim B
beginVerbatim
verbatim environment B: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacro
XXXXXXXXXpar
And see in reverse order:par
usecontent[2]test-otherpar
usecontent[1]test-otherpar
NOT OK,...
subsectionThe problem whit texttt[show-env=true]
beginscontent*[show-env=true]
Some text in whit verbatim C
beginVerbatim
verbatim environment C: &%_"`´~
endVerbatim
endscontent*
enddocument


An image to complement
Idea of the expected



regards










share|improve this question
















I am trying to encapsulate a couple of environments to pass them to lists using xparse/expl3.
I have defined a one command and two environments and I have had a problem with one of them.



I use the environments to save notes type question/answer where the answers are stored in a list to show them at the end of the file or elsewhere in it, the issue is that sometimes need to use verbatim.



The scontent environment uses the +b argument of xparse and only Verb[...]... (from fvextra) can be used (you can not use the verbatim environment for example).



The scontent* environment is based on filecontentsdef and can use verb|...| in a line or beginverbatim environment, this generates an external file but has the facility of saving the content in a macro.



When executing beginscontent* pass the following:



  1. Save the current content in macro

  2. Copy the current contents of macro in l_my_macro_copy_tl

  3. Pass the contents of l_my_macro_copy_tl to list using
    expanddafterenvtolistexpanddafter content save in l_my_macro_copy_tl

  4. If this is the key [show-env = true] run usecontent[-1]l_scontent_env_save_tl

The problem is in the execution of



expanddafterenvtolistexpanddafterl_my_macro_copy_tl


at end of environment scontent*, I tried with the following (ugly and incorrect) lines:



% beginscontent*[...] verbatim env save in macro
% Copy a current content of macro in l_my_macro_copy_tl and pass to list
tl_new:N l_my_macro_copy_tl
NewDocumentEnvironmentscontent* !O

group_begin:
filecontentsdefjobname.tscmacro % save in macro

endfilecontentsdef %
group_end:
IfNoValueF #1 keys_set:nn scontent #1
tl_set:Nx l_my_macro_copy_tl macro
exp_after:wN envtolist exp_after:wN exp_not:N tex_newlinechar:D = 13 exp_not:N scantokens exp_after:wN l_my_macro_copy_tl %
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl



with this I eliminate the errors when compiling, but, the content is not saved in the list...How can i fix this?



My idea is not to occupy directly showme... and only use usecontent[index]list name in document.



I know that the command showme... and usecontent[index]list name works if you execute it out of the environment, but my idea is automate this when run scontent*.



This is my example file (MWE), the comments should be removed to see the error that occurs.



documentclassarticle
usepackagefilecontentsdef,etoolbox,xparse,fvextra,xcolor
usepackage[margin=0.6in,noheadfoot,papersize=8.5in,13in]geometry
setlengthparindent0pt
pagestyleempty
ExplSyntaxOn
% show content save in macro
tl_new:N l_temp_argument_tl
NewDocumentCommandshowme +m %
tl_set:Nx l_temp_argument_tl #1
tex_newlinechar:D = 13
exp_not:N scantokens exp_after:wN l_temp_argument_tl


% elementinlistname and clearlistlistname
cs_new:Npn elementin #1 seq_count:c l_savecontent_content_#1_seq
cs_new:Npn clearlist #1 seq_clear_new:c l_savecontent_content_#1_seq

% addcontentlistname#1 ...need double ...
NewDocumentCommandaddcontent m +m savecontent_add_content:nn #1 #2

% usecontent[index]listname
DeclareExpandableDocumentCommandusecontentO1m savecontent_use_content:nn #1 #2

cs_new_protected:Npn savecontent_add_content:nn #1 #2

seq_if_exist:cF l_savecontent_content_#1_seq
seq_new:c l_savecontent_content_#1_seq
__savecontent_add_content:nn #1 #2


cs_new_protected:Npn __savecontent_add_content:nn #1 #2

tl_map_inline:nn #2

seq_gput_right:cn l_savecontent_content_#1_seq ##1



cs_new:Npn savecontent_use_content:nn #1 #2 seq_item:cn l_savecontent_content_#2_seq #1

keys_define:nn scontent

save-cmd .tl_set:N = l_scontent_cmd_save_tl, save-cmd .initial:n = content,%
save-env .tl_set:N = l_scontent_env_save_tl, save-env .initial:n = content, %
show-cmd .bool_set:N = l_scontent_cmd_show_tl, show-cmd .initial:n = false, show-cmd .value_required:n = true,%
show-env .bool_set:N = l_scontent_env_show_tl, show-env .initial:n = false, show-env .value_required:n = true,%
show-all .meta:n = show-env = true , show-cmd = true ,%


NewDocumentCommandSetscontent +m keys_set:nn scontent #1

% pass to list
newrobustcmdenvtolist[1]addcontent l_scontent_env_save_tl #1

% Scontent[...]... NO verbatim env support, but Verb[...]... yes
NewDocumentCommandScontent O +m

group_begin:
IfNoValueF#1 keys_set:nn scontent #1
addcontent l_scontent_cmd_save_tl #2 % pass direct to list
IfBooleanT l_scontent_cmd_show_tl usecontent[-1] l_scontent_cmd_save_tl
group_end:


% beginscontent[...] NO verbatim env suport, but Verb[...]... yes
NewDocumentEnvironmentscontent !o +b

group_begin:
IfNoValueF #1 keys_set:nn scontent #1

expandafterenvtolistexpandafter#2
IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl
group_end:


% beginscontent*[...] verbatim env save in macro
tl_new:N l_my_macro_copy_tl % tl_var to copy macro at definition time
NewDocumentEnvironmentscontent* !O

group_begin:
IfNoValueF #1 keys_set:nn scontent #1
filecontentsdefjobname.tscmacro

endfilecontentsdef %
group_end:
% Copy macro every time in tl_var (at definition time) and pass to list
%cs_set_eq:NN l_my_macro_copy_tl macro
%expandafterenvtolistexpandaftershowmel_my_macro_copy_tl
%IfBooleanT l_scontent_env_show_tl usecontent[-1] l_scontent_env_save_tl

ExplSyntaxOff
% set name of lists
Setscontent save-env=test-env, save-cmd=test-cmd
begindocument
sectionUsing textttscontent environment whit new texttt+b argument from textttxparse
subsectionWhit texttt[show-env=false]
Text save in verb|beginscontent[show-env=false]| (hidden)

beginscontent[show-env=false]
Some first text whit verbatim inline saved in Verbusecontent[1]test-env par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionWhit texttt[show-env=true]
Text save in verb|beginscontent[show-env=true]| (Not hidden)

beginscontent[show-env=true]
Some second text whit verbatim inline saved in Verbusecontent[2]test-env...more text par
We have coded this in LaTeX: both $E=mc^2$.
endscontent

OK
subsectionUsing Verbusecontent[1]test-env
Now see saved text in list:par
usecontent[2]test-envpar
usecontent[1]test-env

sectionUsing Verb*Scontent[...]...
Text save whit verb|Scontent....| (hidden)par
Scontent
using a Verb*Scontent[...]... textcolorredwhit verbatim Verb*Verb[...]...par
(by Verb*fvextra) textcolormagentainline
par

And see saved text in list using verb|usecontent[1]test-cmd| par
usecontent[1]test-cmdpar
OK
sectionUsing textttscontent* environment wraped textttfilecontentsdef using textttxparse

subsectionWhit texttt[show-env=false]
Some Text save using verb|beginscontent*[show-env=false]| save in verb|macro| (hidden)

beginscontent*[show-env=false]
Some text in whit verbatim environment ¿saved in list ...verb+usecontent[3]test-env+?(not get for now).par
beginVerbatim
This is from the verbatim environment: &%_"`´~
xxxxx
endVerbatim
endscontent*par
OK...it's posible to see verb|macro| whit verb|showmemacro|:par
showmemacropar
or pass to list using verb|Scontentshowmemacro| and see in list whit verb+usecontent[2]test-cmd+:par
Scontentshowmemacro
usecontent[2]test-cmd
subsectionThe idea whit texttt[show-env=true]
Setscontent save-cmd=test-other
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim A
beginVerbatim
verbatim environment A: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacropar
XXXXXXXXXpar
beginscontent*[show-env=false]
Some text in whit verbatim B
beginVerbatim
verbatim environment B: &%_"`´~
endVerbatim
endscontent*
Scontent[show-cmd=true]showmemacro
XXXXXXXXXpar
And see in reverse order:par
usecontent[2]test-otherpar
usecontent[1]test-otherpar
NOT OK,...
subsectionThe problem whit texttt[show-env=true]
beginscontent*[show-env=true]
Some text in whit verbatim C
beginVerbatim
verbatim environment C: &%_"`´~
endVerbatim
endscontent*
enddocument


An image to complement
Idea of the expected



regards







macros expansion expl3 xparse






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 18 mins ago







Pablo González L

















asked Apr 6 at 1:45









Pablo González LPablo González L

1,0061820




1,0061820







  • 1





    Could you please state clearly at the beginning what the aim is?

    – egreg
    2 days ago











  • @egreg Thanks for the comment, I added the clarification, apologies for the writing, (my english base + google translator sometimes fails). Can you give me a hand with this?

    – Pablo González L
    2 days ago












  • 1





    Could you please state clearly at the beginning what the aim is?

    – egreg
    2 days ago











  • @egreg Thanks for the comment, I added the clarification, apologies for the writing, (my english base + google translator sometimes fails). Can you give me a hand with this?

    – Pablo González L
    2 days ago







1




1





Could you please state clearly at the beginning what the aim is?

– egreg
2 days ago





Could you please state clearly at the beginning what the aim is?

– egreg
2 days ago













@egreg Thanks for the comment, I added the clarification, apologies for the writing, (my english base + google translator sometimes fails). Can you give me a hand with this?

– Pablo González L
2 days ago





@egreg Thanks for the comment, I added the clarification, apologies for the writing, (my english base + google translator sometimes fails). Can you give me a hand with this?

– Pablo González L
2 days ago










0






active

oldest

votes












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483453%2fhow-to-expand-a-macro-or-a-copy-to-save-in-a-list-at-end-of-environment-in-xp%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483453%2fhow-to-expand-a-macro-or-a-copy-to-save-in-a-list-at-end-of-environment-in-xp%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How should I use the fbox command correctly to avoid producing a Bad Box message?How to put a long piece of text in a box?How to specify height and width of fboxIs there an arrayrulecolor-like command to change the rule color of fbox?What is the command to highlight bad boxes in pdf?Why does fbox sometimes place the box *over* the graphic image?how to put the text in the boxHow to create command for a box where text inside the box can automatically adjust?how can I make an fbox like command with certain color, shape and width of border?how to use fbox in align modeFbox increase the spacing between the box and it content (inner margin)how to change the box height of an equationWhat is the use of the hbox in a newcommand command?

Doxepinum Nexus interni Notae | Tabula navigationis3158DB01142WHOa682390"Structural Analysis of the Histamine H1 Receptor""Transdermal and Topical Drug Administration in the Treatment of Pain""Antidepressants as antipruritic agents: A review"

Haugesund Nexus externi | Tabula navigationisHaugesund pagina interretialisAmplifica