How use scantokens at the end of environment to pass a expanded macro (or a copy) to list in xparse?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?

LaTeX: Why are digits allowed in environments, but forbidden in commands?

What typically incentivizes a professor to change jobs to a lower ranking university?

NMaximize is not converging to a solution

When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?

Java Casting: Java 11 throws LambdaConversionException while 1.8 does not

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

How much RAM could one put in a typical 80386 setup?

What doth I be?

Has there ever been an airliner design involving reducing generator load by installing solar panels?

infared filters v nd

What is the word for reserving something for yourself before others do?

Why is Minecraft giving an OpenGL error?

Are astronomers waiting to see something in an image from a gravitational lens that they've already seen in an adjacent image?

Perform and show arithmetic with LuaLaTeX

How to format long polynomial?

dbcc cleantable batch size explanation

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

Modeling an IP Address

Alternative to sending password over mail?

Can a Cauchy sequence converge for one metric while not converging for another?

meaning of に in 本当に?

What's the output of a record needle playing an out-of-speed record

Convert two switches to a dual stack, and add outlet - possible here?

What is a clear way to write a bar that has an extra beat?



How use scantokens at the end of environment to pass a expanded macro (or a copy) to list in xparse?


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.



The problem happens when trying to execute the following command:



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



at the end of the environment:



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 %
% 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
group_end:



the following error occurs



! TeX capacity exceeded, sorry [input stack size=5000].
<to be read again>
q_nil


My idea is not to occupy directly showme... and that it goes directly to the list, and only use usecontent[index]list name.



I know that the command works if you execute it out of the environment, but my idea is that the contents of macro (or a copy) are recorded in the list every time you run scontent* before the content of macro are rewritten in the next run.



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 %
% 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
group_end:

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
enddocument


An image to complement
Idea of the expected
regards









share


























    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.



    The problem happens when trying to execute the following command:



    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



    at the end of the environment:



    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 %
    % 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
    group_end:



    the following error occurs



    ! TeX capacity exceeded, sorry [input stack size=5000].
    <to be read again>
    q_nil


    My idea is not to occupy directly showme... and that it goes directly to the list, and only use usecontent[index]list name.



    I know that the command works if you execute it out of the environment, but my idea is that the contents of macro (or a copy) are recorded in the list every time you run scontent* before the content of macro are rewritten in the next run.



    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 %
    % 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
    group_end:

    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
    enddocument


    An image to complement
    Idea of the expected
    regards









    share
























      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.



      The problem happens when trying to execute the following command:



      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



      at the end of the environment:



      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 %
      % 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
      group_end:



      the following error occurs



      ! TeX capacity exceeded, sorry [input stack size=5000].
      <to be read again>
      q_nil


      My idea is not to occupy directly showme... and that it goes directly to the list, and only use usecontent[index]list name.



      I know that the command works if you execute it out of the environment, but my idea is that the contents of macro (or a copy) are recorded in the list every time you run scontent* before the content of macro are rewritten in the next run.



      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 %
      % 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
      group_end:

      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
      enddocument


      An image to complement
      Idea of the expected
      regards









      share














      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.



      The problem happens when trying to execute the following command:



      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



      at the end of the environment:



      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 %
      % 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
      group_end:



      the following error occurs



      ! TeX capacity exceeded, sorry [input stack size=5000].
      <to be read again>
      q_nil


      My idea is not to occupy directly showme... and that it goes directly to the list, and only use usecontent[index]list name.



      I know that the command works if you execute it out of the environment, but my idea is that the contents of macro (or a copy) are recorded in the list every time you run scontent* before the content of macro are rewritten in the next run.



      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 %
      % 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
      group_end:

      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
      enddocument


      An image to complement
      Idea of the expected
      regards







      macros expansion expl3 xparse





      share












      share










      share



      share










      asked 7 mins ago









      Pablo González LPablo González L

      1,0061820




      1,0061820




















          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-use-scantokens-at-the-end-of-environment-to-pass-a-expanded-macro-or-a-co%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-use-scantokens-at-the-end-of-environment-to-pass-a-expanded-macro-or-a-co%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