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?Pass the contents of an input command to a macroUsing an expanded macro for optional environment argumentHow to pass a macro as the argument to selectlanguageHow can I pass expanded material to a macro at definition time (context-specific macro tracker)?Xparse k argument to parse options at end of environmentHow can I define a macro with the value of a fully expanded macro?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?

Re-submission of rejected manuscript without informing co-authors

How can I fix this gap between bookcases I made?

Symmetry in quantum mechanics

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

New order #4: World

Is it wise to focus on putting odd beats on left when playing double bass drums?

Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore

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

Does a dangling wire really electrocute me if I'm standing in water?

Prime joint compound before latex paint?

When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?

aging parents with no investments

What is GPS' 19 year rollover and does it present a cybersecurity issue?

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

Patience, young "Padovan"

Hosting Wordpress in a EC2 Load Balanced Instance

Finding files for which a command fails

Need help identifying/translating a plaque in Tangier, Morocco

Can I find out the caloric content of bread by dehydrating it?

Is it legal to have the "// (c) 2019 John Smith" header in all files when there are hundreds of contributors?

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

How to move the player while also allowing forces to affect it

Why doesn't a const reference extend the life of a temporary object passed via a function?

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



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?Pass the contents of an input command to a macroUsing an expanded macro for optional environment argumentHow to pass a macro as the argument to selectlanguageHow can I pass expanded material to a macro at definition time (context-specific macro tracker)?Xparse k argument to parse options at end of environmentHow can I define a macro with the value of a fully expanded macro?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 15 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

Lioubotyn Sommaire Géographie | Histoire | Population | Notes et références | Liens externes | Menu de navigationlubotin.kharkov.uamodifier« Recensements et estimations de la population depuis 1897 »« Office des statistiques d'Ukraine : population au 1er janvier 2010, 2011 et 2012 »« Office des statistiques d'Ukraine : population au 1er janvier 2011, 2012 et 2013 »Informations officiellesCartes topographiquesCarte routièrem

Isabella Eugénie Boyer Biographie | Références | Menu de navigationmodifiermodifier le codeComparator to Compute the Relative Value of a U.S. Dollar Amount – 1774 to Present.

Mpande kaSenzangakhona Biographie | Références | Menu de navigationmodifierMpande kaSenzangakhonavoir la liste des auteursm