Extract more than nine arguments that occur periodically in a sentence to use in macros in order to typsetHow to define a command that takes more than 9 argumentsmacros that won't accept other macros as argumentsusing more than 2 arguments in a pgfplots styleUsing mathpalette with macros that take more argumentsUsing forcsvlist with macros that take more than one argumentHow to define a command that takes more than 18 argumentsHow to create a macro that creates other macros (that takes arguments)?How to create a table macro that takes more than 10 argumentsMacro with more than 9 argumentsDifferent command definitions with more than one optional arguments arguments

Is there a way to get `mathscr' with lower case letters in pdfLaTeX?

Lowest total scrabble score

What if you are holding an Iron Flask with a demon inside and walk into Antimagic Field?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

It grows, but water kills it

How to explain what's wrong with this application of the chain rule?

Does Doodling or Improvising on the Piano Have Any Benefits?

Biological Blimps: Propulsion

How do I delete all blank lines in a buffer?

Does the UK parliament need to pass secondary legislation to accept the Article 50 extension

How to say when an application is taking the half of your screen on a computer

Invalid date error by date command

What are the balance implications behind making invisible things auto-hide?

Does the Linux kernel need a file system to run?

Mimic lecturing on blackboard, facing audience

Can I still be respawned if I die by falling off the map?

Did arcade monitors have same pixel aspect ratio as TV sets?

Using substitution ciphers to generate new alphabets in a novel

What should you do when eye contact makes your subordinate uncomfortable?

Terse Method to Swap Lowest for Highest?

Why does a simple loop result in ASYNC_NETWORK_IO waits?

Temporarily disable WLAN internet access for children, but allow it for adults

What is going on with 'gets(stdin)' on the site coderbyte?

PTIJ: Haman's bad computer



Extract more than nine arguments that occur periodically in a sentence to use in macros in order to typset


How to define a command that takes more than 9 argumentsmacros that won't accept other macros as argumentsusing more than 2 arguments in a pgfplots styleUsing mathpalette with macros that take more argumentsUsing forcsvlist with macros that take more than one argumentHow to define a command that takes more than 18 argumentsHow to create a macro that creates other macros (that takes arguments)?How to create a table macro that takes more than 10 argumentsMacro with more than 9 argumentsDifferent command definitions with more than one optional arguments arguments













3















What is a good way to write a definition of the type fun below



funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ...



where the number of arguments is not known in advance, may be 1, or may be more than 9, like 12, and the result is as below



abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ...




Assume for answers form is same type as newcommandform[1]emph#1. But delay expansion until the end. Just in case.




Probably requires several nested def cases taking two variables each and a if to decide when to halt the loop ... like when allowing more than 9 arguments to a macro? Or use etoolbox for something better?



If separator words efg jkl are not the same from one place to the next, certain they they are of some specific length, assume efg jkl <=> always 9 characters separating one input from the next. While abc EDF xyz are of different lengths possibly, but always three separate words.




CLARIFICATION: The xyz can be arbitrary. But the sentence is periodic in that the 3rd, 8th, 13th, 18th word is form wrapped. If it exists. At least 3 words exists. But can be 3, and if not 3 then 8, and if not 8 then 13, as long as needed, ends when no separator behind three words which can all differ ... The separator " efg jkl " does repeat with certainty however and can be caught to parse.











share|improve this question
























  • funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 and funabc1 EDF1 xyz1 and funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... efg jkl abc12 EDF12 xyz12, etc, equally possible. Some kind of loop required. But note that there would not appear any numbers in the input phrase; the numbers are here to illustrate how long happens to be the list. Just the list is always entered as a specific kind of sentence.

    – Guido Jorg
    1 hour ago












  • Splitting such an input at spaces is easy, and testing for some regular expression too (with expl3) but your description is a bit confusing.

    – Ulrike Fischer
    1 hour ago











  • Without knowing the rules for applying form it's really difficult to answer.

    – egreg
    1 hour ago











  • Suppose it's emph but delayed expansion until abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... stage reached is preferred. If not possible, then simply assume emph strictly speaking and can be expanded during each loop, though not as general.

    – Guido Jorg
    1 hour ago











  • @GuidoJorg I'm not asking what form should do, but to which parts it should be applied. Some real world examples might help to understand. As the question stands, it's impossible to guess.

    – egreg
    1 hour ago
















3















What is a good way to write a definition of the type fun below



funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ...



where the number of arguments is not known in advance, may be 1, or may be more than 9, like 12, and the result is as below



abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ...




Assume for answers form is same type as newcommandform[1]emph#1. But delay expansion until the end. Just in case.




Probably requires several nested def cases taking two variables each and a if to decide when to halt the loop ... like when allowing more than 9 arguments to a macro? Or use etoolbox for something better?



If separator words efg jkl are not the same from one place to the next, certain they they are of some specific length, assume efg jkl <=> always 9 characters separating one input from the next. While abc EDF xyz are of different lengths possibly, but always three separate words.




CLARIFICATION: The xyz can be arbitrary. But the sentence is periodic in that the 3rd, 8th, 13th, 18th word is form wrapped. If it exists. At least 3 words exists. But can be 3, and if not 3 then 8, and if not 8 then 13, as long as needed, ends when no separator behind three words which can all differ ... The separator " efg jkl " does repeat with certainty however and can be caught to parse.











share|improve this question
























  • funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 and funabc1 EDF1 xyz1 and funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... efg jkl abc12 EDF12 xyz12, etc, equally possible. Some kind of loop required. But note that there would not appear any numbers in the input phrase; the numbers are here to illustrate how long happens to be the list. Just the list is always entered as a specific kind of sentence.

    – Guido Jorg
    1 hour ago












  • Splitting such an input at spaces is easy, and testing for some regular expression too (with expl3) but your description is a bit confusing.

    – Ulrike Fischer
    1 hour ago











  • Without knowing the rules for applying form it's really difficult to answer.

    – egreg
    1 hour ago











  • Suppose it's emph but delayed expansion until abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... stage reached is preferred. If not possible, then simply assume emph strictly speaking and can be expanded during each loop, though not as general.

    – Guido Jorg
    1 hour ago











  • @GuidoJorg I'm not asking what form should do, but to which parts it should be applied. Some real world examples might help to understand. As the question stands, it's impossible to guess.

    – egreg
    1 hour ago














3












3








3


1






What is a good way to write a definition of the type fun below



funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ...



where the number of arguments is not known in advance, may be 1, or may be more than 9, like 12, and the result is as below



abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ...




Assume for answers form is same type as newcommandform[1]emph#1. But delay expansion until the end. Just in case.




Probably requires several nested def cases taking two variables each and a if to decide when to halt the loop ... like when allowing more than 9 arguments to a macro? Or use etoolbox for something better?



If separator words efg jkl are not the same from one place to the next, certain they they are of some specific length, assume efg jkl <=> always 9 characters separating one input from the next. While abc EDF xyz are of different lengths possibly, but always three separate words.




CLARIFICATION: The xyz can be arbitrary. But the sentence is periodic in that the 3rd, 8th, 13th, 18th word is form wrapped. If it exists. At least 3 words exists. But can be 3, and if not 3 then 8, and if not 8 then 13, as long as needed, ends when no separator behind three words which can all differ ... The separator " efg jkl " does repeat with certainty however and can be caught to parse.











share|improve this question
















What is a good way to write a definition of the type fun below



funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ...



where the number of arguments is not known in advance, may be 1, or may be more than 9, like 12, and the result is as below



abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ...




Assume for answers form is same type as newcommandform[1]emph#1. But delay expansion until the end. Just in case.




Probably requires several nested def cases taking two variables each and a if to decide when to halt the loop ... like when allowing more than 9 arguments to a macro? Or use etoolbox for something better?



If separator words efg jkl are not the same from one place to the next, certain they they are of some specific length, assume efg jkl <=> always 9 characters separating one input from the next. While abc EDF xyz are of different lengths possibly, but always three separate words.




CLARIFICATION: The xyz can be arbitrary. But the sentence is periodic in that the 3rd, 8th, 13th, 18th word is form wrapped. If it exists. At least 3 words exists. But can be 3, and if not 3 then 8, and if not 8 then 13, as long as needed, ends when no separator behind three words which can all differ ... The separator " efg jkl " does repeat with certainty however and can be caught to parse.








macros tex-core parsing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago







Guido Jorg

















asked 1 hour ago









Guido JorgGuido Jorg

1,14931344




1,14931344












  • funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 and funabc1 EDF1 xyz1 and funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... efg jkl abc12 EDF12 xyz12, etc, equally possible. Some kind of loop required. But note that there would not appear any numbers in the input phrase; the numbers are here to illustrate how long happens to be the list. Just the list is always entered as a specific kind of sentence.

    – Guido Jorg
    1 hour ago












  • Splitting such an input at spaces is easy, and testing for some regular expression too (with expl3) but your description is a bit confusing.

    – Ulrike Fischer
    1 hour ago











  • Without knowing the rules for applying form it's really difficult to answer.

    – egreg
    1 hour ago











  • Suppose it's emph but delayed expansion until abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... stage reached is preferred. If not possible, then simply assume emph strictly speaking and can be expanded during each loop, though not as general.

    – Guido Jorg
    1 hour ago











  • @GuidoJorg I'm not asking what form should do, but to which parts it should be applied. Some real world examples might help to understand. As the question stands, it's impossible to guess.

    – egreg
    1 hour ago


















  • funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 and funabc1 EDF1 xyz1 and funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... efg jkl abc12 EDF12 xyz12, etc, equally possible. Some kind of loop required. But note that there would not appear any numbers in the input phrase; the numbers are here to illustrate how long happens to be the list. Just the list is always entered as a specific kind of sentence.

    – Guido Jorg
    1 hour ago












  • Splitting such an input at spaces is easy, and testing for some regular expression too (with expl3) but your description is a bit confusing.

    – Ulrike Fischer
    1 hour ago











  • Without knowing the rules for applying form it's really difficult to answer.

    – egreg
    1 hour ago











  • Suppose it's emph but delayed expansion until abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... stage reached is preferred. If not possible, then simply assume emph strictly speaking and can be expanded during each loop, though not as general.

    – Guido Jorg
    1 hour ago











  • @GuidoJorg I'm not asking what form should do, but to which parts it should be applied. Some real world examples might help to understand. As the question stands, it's impossible to guess.

    – egreg
    1 hour ago

















funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 and funabc1 EDF1 xyz1 and funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... efg jkl abc12 EDF12 xyz12, etc, equally possible. Some kind of loop required. But note that there would not appear any numbers in the input phrase; the numbers are here to illustrate how long happens to be the list. Just the list is always entered as a specific kind of sentence.

– Guido Jorg
1 hour ago






funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 and funabc1 EDF1 xyz1 and funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... efg jkl abc12 EDF12 xyz12, etc, equally possible. Some kind of loop required. But note that there would not appear any numbers in the input phrase; the numbers are here to illustrate how long happens to be the list. Just the list is always entered as a specific kind of sentence.

– Guido Jorg
1 hour ago














Splitting such an input at spaces is easy, and testing for some regular expression too (with expl3) but your description is a bit confusing.

– Ulrike Fischer
1 hour ago





Splitting such an input at spaces is easy, and testing for some regular expression too (with expl3) but your description is a bit confusing.

– Ulrike Fischer
1 hour ago













Without knowing the rules for applying form it's really difficult to answer.

– egreg
1 hour ago





Without knowing the rules for applying form it's really difficult to answer.

– egreg
1 hour ago













Suppose it's emph but delayed expansion until abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... stage reached is preferred. If not possible, then simply assume emph strictly speaking and can be expanded during each loop, though not as general.

– Guido Jorg
1 hour ago





Suppose it's emph but delayed expansion until abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... stage reached is preferred. If not possible, then simply assume emph strictly speaking and can be expanded during each loop, though not as general.

– Guido Jorg
1 hour ago













@GuidoJorg I'm not asking what form should do, but to which parts it should be applied. Some real world examples might help to understand. As the question stands, it's impossible to guess.

– egreg
1 hour ago






@GuidoJorg I'm not asking what form should do, but to which parts it should be applied. Some real world examples might help to understand. As the question stands, it's impossible to guess.

– egreg
1 hour ago











3 Answers
3






active

oldest

votes


















2














documentclassarticle
usepackagexparse

ExplSyntaxOn
NewDocumentCommandfunm

% split the input at the spaces
seq_set_split:Nnn l_tmpa_seq ~ #1
% use a counter for knowing where we are
int_zero:N l_tmpa_int
% map the sequence
seq_map_inline:Nn l_tmpa_seq
% one more step
int_incr:N l_tmpa_int
int_compare:nTF int_mod:nn l_tmpa_int - 3 5 = 0
% if we're at the 3rd, 5th, 8th, 13th, ... item, apply form
form ##1

% otherwise just deliver the item
##1

% if not at the last, add a space
int_compare:nT l_tmpa_int < seq_count:N l_tmpa_seq ~


ExplSyntaxOff

NewDocumentCommandformmemph#1

begindocument

raggedright

funNon eram nescius Brute cum quae summis ingeniis exquisitaque
doctrina philosophi Graeco sermone tractavissent ea Latinis
litteris mandaremus fore ut hic noster labor in varias
reprehensiones incurreret Nam quibusdam et iis quidem non
admodum indoctis totum hoc displicet philosophari Quidam
autem non tam id reprehendunt si remissius agatur sed tantum
studium tamque multam operam ponendam in eo non arbitrantur
Erunt etiam et ii quidem eruditi Graecis litteris contemnentes
Latinas qui se dicant in Graecis legendis operam malle consumere
Postremo aliquos futuros suspicor qui me ad alias litteras
vocent genus hoc scribendi etsi sit elegans personae tamen
et dignitatis esse negent

enddocument


enter image description here






share|improve this answer






























    2














    The listofitems package can grab these inputs very easily, preserving the original tokens without expansion.



    documentclassarticle
    usepackage[T1]fontenc
    usepackagelistofitems,tabto
    newcommandform[1]emph#1
    newcommandfun[1]%
    setsepchar %
    readlistfunlist#1%
    foreachitemxinfunlist[]%
    Argument xcnt istabto1.3in``detokenizeexpandafterx'':
    tabto2.5inxpar
    %

    begindocument
    funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
    efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
    EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
    EDF2 formxyz4 ...
    enddocument


    enter image description here



    If you need multi-layer parsing, say that efg jkl is the trigger to separate larger subgroups of arguments, then we have the following (note: efg jkl is not considered an argument, but an argument separator):



    documentclassarticle
    usepackage[T1]fontenc
    usepackagelistofitems,tabto
    newcommandform[1]emph#1
    newcommandfun[1]%
    setsepcharefg jkl/ %
    readlist*funlist#1%
    foreachitemxinfunlist[]%
    foreachitemyinfunlist[xcnt]%
    Group xcnt sub-argument ycnt istabto2in``detokenize
    expandafterexpandafterexpandafterfunlist[xcnt,ycnt]'':
    tabto3.2infunlist[xcnt,ycnt]par
    %

    begindocument
    funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
    efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
    EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
    EDF2 formxyz4 ...
    enddocument


    enter image description here






    share|improve this answer

























    • Can you say how to get a sentence in one line to occur, rather than a list? Of the rightmost list in the image? (Also for learning how to write such macros, how does listofitems pull this off, can you suggest? I assume it checks ifx style whether the argument separator occurs or not to decide to loop and relies on a def that that takes one argument and has two cases ... Or calls a package with check for ifempty?)

      – Guido Jorg
      1 hour ago












    • @GuidoJorg To learn about the package: ctan.org/pkg/listofitems

      – Steven B. Segletes
      1 hour ago











    • @GuidoJorg As to your request, to make a sentence of the right hand column is not really to parse the list at all, but just to typeset the argument. So could you clarify what you are asking?

      – Steven B. Segletes
      1 hour ago












    • The result looking for is what would be printed had abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... been entered manually. When in fact funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... was entered manually. Though the knowledge of how to parse the list completely is useful to know, as is the package, didn't know about it :)

      – Guido Jorg
      1 hour ago












    • @GuidoJorg If I understand what you are asking, the macro looks for anything starting with the letters xyz in order to decide whether or not to apply form to it??

      – Steven B. Segletes
      1 hour ago


















    2














    Here's a LuaLaTeX-based solution. It employs Lua's powerful string.gsub function to the argument of the fun macro, to encase the third word of each group of five words -- where "word" is any combination of characters and digits delimited by whitespace -- in the argument of fun in a form... "wrapper".



    Because luastringN (where N stands for "no expansion") is used in the argument of fun, the argument of fun is not expaneded prior to being passed to the Lua function that does all of the work.



    enter image description here



    % !TEX TS-program = lualatex
    documentclassarticle
    usepackageluacode % for 'luacode' env. and `luastringN` macro

    %% Lua-side code
    beginluacode


    function do_fun ( s )
    tex.sprint ( ( s:gsub (
    "(%w+%s*%w+%s*)(%w+)(%s*%w+%s*%w+%s-)" ,
    "%1\form%2%3" ) ) )
    end


    endluacode

    %% TeX-side code
    newcommandfun[1]directluado_fun(luastringN#1)
    newcommandform[1]emph#1

    begindocument

    noindent
    funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl
    abc4 EDF4 xyz4 efg jkl abc5 EDF5 xyz5 efg jkl abc6 EDF6 xyz6 efg jkl
    abc7 EDF7 xyz7 efg jkl abc8 EDF8 xyz8 efg jkl abc9 EDF9 xyz9 efg jkl
    abc10 EDF10 xyz10 efg jkl abc11 EDF11 xyz11 efg jkl abc12 EDF12 xyz12 efg jkl
    abc13 EDF13 xyz13 efg jkl abc14 EDF14 xyz14 efg jkl abc15 EDF15 xyz15 efg jkl
    abc16 EDF16 xyz16 efg jkl abc17 EDF17 xyz17 efg jkl
    enddocument





    share|improve this answer

























    • Probably cannot use for a journal but LuaLaTex solutions are very elegant. I will look at LuaTex some more for personal use, have not used it much before.

      – Guido Jorg
      1 hour ago











    • @GuidoJorg - Some, but certainly not all, journals by now allow LuaLaTeX in addition to pdfLaTeX.

      – Mico
      44 mins ago










    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%2f480991%2fextract-more-than-nine-arguments-that-occur-periodically-in-a-sentence-to-use-in%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    documentclassarticle
    usepackagexparse

    ExplSyntaxOn
    NewDocumentCommandfunm

    % split the input at the spaces
    seq_set_split:Nnn l_tmpa_seq ~ #1
    % use a counter for knowing where we are
    int_zero:N l_tmpa_int
    % map the sequence
    seq_map_inline:Nn l_tmpa_seq
    % one more step
    int_incr:N l_tmpa_int
    int_compare:nTF int_mod:nn l_tmpa_int - 3 5 = 0
    % if we're at the 3rd, 5th, 8th, 13th, ... item, apply form
    form ##1

    % otherwise just deliver the item
    ##1

    % if not at the last, add a space
    int_compare:nT l_tmpa_int < seq_count:N l_tmpa_seq ~


    ExplSyntaxOff

    NewDocumentCommandformmemph#1

    begindocument

    raggedright

    funNon eram nescius Brute cum quae summis ingeniis exquisitaque
    doctrina philosophi Graeco sermone tractavissent ea Latinis
    litteris mandaremus fore ut hic noster labor in varias
    reprehensiones incurreret Nam quibusdam et iis quidem non
    admodum indoctis totum hoc displicet philosophari Quidam
    autem non tam id reprehendunt si remissius agatur sed tantum
    studium tamque multam operam ponendam in eo non arbitrantur
    Erunt etiam et ii quidem eruditi Graecis litteris contemnentes
    Latinas qui se dicant in Graecis legendis operam malle consumere
    Postremo aliquos futuros suspicor qui me ad alias litteras
    vocent genus hoc scribendi etsi sit elegans personae tamen
    et dignitatis esse negent

    enddocument


    enter image description here






    share|improve this answer



























      2














      documentclassarticle
      usepackagexparse

      ExplSyntaxOn
      NewDocumentCommandfunm

      % split the input at the spaces
      seq_set_split:Nnn l_tmpa_seq ~ #1
      % use a counter for knowing where we are
      int_zero:N l_tmpa_int
      % map the sequence
      seq_map_inline:Nn l_tmpa_seq
      % one more step
      int_incr:N l_tmpa_int
      int_compare:nTF int_mod:nn l_tmpa_int - 3 5 = 0
      % if we're at the 3rd, 5th, 8th, 13th, ... item, apply form
      form ##1

      % otherwise just deliver the item
      ##1

      % if not at the last, add a space
      int_compare:nT l_tmpa_int < seq_count:N l_tmpa_seq ~


      ExplSyntaxOff

      NewDocumentCommandformmemph#1

      begindocument

      raggedright

      funNon eram nescius Brute cum quae summis ingeniis exquisitaque
      doctrina philosophi Graeco sermone tractavissent ea Latinis
      litteris mandaremus fore ut hic noster labor in varias
      reprehensiones incurreret Nam quibusdam et iis quidem non
      admodum indoctis totum hoc displicet philosophari Quidam
      autem non tam id reprehendunt si remissius agatur sed tantum
      studium tamque multam operam ponendam in eo non arbitrantur
      Erunt etiam et ii quidem eruditi Graecis litteris contemnentes
      Latinas qui se dicant in Graecis legendis operam malle consumere
      Postremo aliquos futuros suspicor qui me ad alias litteras
      vocent genus hoc scribendi etsi sit elegans personae tamen
      et dignitatis esse negent

      enddocument


      enter image description here






      share|improve this answer

























        2












        2








        2







        documentclassarticle
        usepackagexparse

        ExplSyntaxOn
        NewDocumentCommandfunm

        % split the input at the spaces
        seq_set_split:Nnn l_tmpa_seq ~ #1
        % use a counter for knowing where we are
        int_zero:N l_tmpa_int
        % map the sequence
        seq_map_inline:Nn l_tmpa_seq
        % one more step
        int_incr:N l_tmpa_int
        int_compare:nTF int_mod:nn l_tmpa_int - 3 5 = 0
        % if we're at the 3rd, 5th, 8th, 13th, ... item, apply form
        form ##1

        % otherwise just deliver the item
        ##1

        % if not at the last, add a space
        int_compare:nT l_tmpa_int < seq_count:N l_tmpa_seq ~


        ExplSyntaxOff

        NewDocumentCommandformmemph#1

        begindocument

        raggedright

        funNon eram nescius Brute cum quae summis ingeniis exquisitaque
        doctrina philosophi Graeco sermone tractavissent ea Latinis
        litteris mandaremus fore ut hic noster labor in varias
        reprehensiones incurreret Nam quibusdam et iis quidem non
        admodum indoctis totum hoc displicet philosophari Quidam
        autem non tam id reprehendunt si remissius agatur sed tantum
        studium tamque multam operam ponendam in eo non arbitrantur
        Erunt etiam et ii quidem eruditi Graecis litteris contemnentes
        Latinas qui se dicant in Graecis legendis operam malle consumere
        Postremo aliquos futuros suspicor qui me ad alias litteras
        vocent genus hoc scribendi etsi sit elegans personae tamen
        et dignitatis esse negent

        enddocument


        enter image description here






        share|improve this answer













        documentclassarticle
        usepackagexparse

        ExplSyntaxOn
        NewDocumentCommandfunm

        % split the input at the spaces
        seq_set_split:Nnn l_tmpa_seq ~ #1
        % use a counter for knowing where we are
        int_zero:N l_tmpa_int
        % map the sequence
        seq_map_inline:Nn l_tmpa_seq
        % one more step
        int_incr:N l_tmpa_int
        int_compare:nTF int_mod:nn l_tmpa_int - 3 5 = 0
        % if we're at the 3rd, 5th, 8th, 13th, ... item, apply form
        form ##1

        % otherwise just deliver the item
        ##1

        % if not at the last, add a space
        int_compare:nT l_tmpa_int < seq_count:N l_tmpa_seq ~


        ExplSyntaxOff

        NewDocumentCommandformmemph#1

        begindocument

        raggedright

        funNon eram nescius Brute cum quae summis ingeniis exquisitaque
        doctrina philosophi Graeco sermone tractavissent ea Latinis
        litteris mandaremus fore ut hic noster labor in varias
        reprehensiones incurreret Nam quibusdam et iis quidem non
        admodum indoctis totum hoc displicet philosophari Quidam
        autem non tam id reprehendunt si remissius agatur sed tantum
        studium tamque multam operam ponendam in eo non arbitrantur
        Erunt etiam et ii quidem eruditi Graecis litteris contemnentes
        Latinas qui se dicant in Graecis legendis operam malle consumere
        Postremo aliquos futuros suspicor qui me ad alias litteras
        vocent genus hoc scribendi etsi sit elegans personae tamen
        et dignitatis esse negent

        enddocument


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 39 mins ago









        egregegreg

        728k8819243235




        728k8819243235





















            2














            The listofitems package can grab these inputs very easily, preserving the original tokens without expansion.



            documentclassarticle
            usepackage[T1]fontenc
            usepackagelistofitems,tabto
            newcommandform[1]emph#1
            newcommandfun[1]%
            setsepchar %
            readlistfunlist#1%
            foreachitemxinfunlist[]%
            Argument xcnt istabto1.3in``detokenizeexpandafterx'':
            tabto2.5inxpar
            %

            begindocument
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
            efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
            EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
            EDF2 formxyz4 ...
            enddocument


            enter image description here



            If you need multi-layer parsing, say that efg jkl is the trigger to separate larger subgroups of arguments, then we have the following (note: efg jkl is not considered an argument, but an argument separator):



            documentclassarticle
            usepackage[T1]fontenc
            usepackagelistofitems,tabto
            newcommandform[1]emph#1
            newcommandfun[1]%
            setsepcharefg jkl/ %
            readlist*funlist#1%
            foreachitemxinfunlist[]%
            foreachitemyinfunlist[xcnt]%
            Group xcnt sub-argument ycnt istabto2in``detokenize
            expandafterexpandafterexpandafterfunlist[xcnt,ycnt]'':
            tabto3.2infunlist[xcnt,ycnt]par
            %

            begindocument
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
            efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
            EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
            EDF2 formxyz4 ...
            enddocument


            enter image description here






            share|improve this answer

























            • Can you say how to get a sentence in one line to occur, rather than a list? Of the rightmost list in the image? (Also for learning how to write such macros, how does listofitems pull this off, can you suggest? I assume it checks ifx style whether the argument separator occurs or not to decide to loop and relies on a def that that takes one argument and has two cases ... Or calls a package with check for ifempty?)

              – Guido Jorg
              1 hour ago












            • @GuidoJorg To learn about the package: ctan.org/pkg/listofitems

              – Steven B. Segletes
              1 hour ago











            • @GuidoJorg As to your request, to make a sentence of the right hand column is not really to parse the list at all, but just to typeset the argument. So could you clarify what you are asking?

              – Steven B. Segletes
              1 hour ago












            • The result looking for is what would be printed had abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... been entered manually. When in fact funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... was entered manually. Though the knowledge of how to parse the list completely is useful to know, as is the package, didn't know about it :)

              – Guido Jorg
              1 hour ago












            • @GuidoJorg If I understand what you are asking, the macro looks for anything starting with the letters xyz in order to decide whether or not to apply form to it??

              – Steven B. Segletes
              1 hour ago















            2














            The listofitems package can grab these inputs very easily, preserving the original tokens without expansion.



            documentclassarticle
            usepackage[T1]fontenc
            usepackagelistofitems,tabto
            newcommandform[1]emph#1
            newcommandfun[1]%
            setsepchar %
            readlistfunlist#1%
            foreachitemxinfunlist[]%
            Argument xcnt istabto1.3in``detokenizeexpandafterx'':
            tabto2.5inxpar
            %

            begindocument
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
            efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
            EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
            EDF2 formxyz4 ...
            enddocument


            enter image description here



            If you need multi-layer parsing, say that efg jkl is the trigger to separate larger subgroups of arguments, then we have the following (note: efg jkl is not considered an argument, but an argument separator):



            documentclassarticle
            usepackage[T1]fontenc
            usepackagelistofitems,tabto
            newcommandform[1]emph#1
            newcommandfun[1]%
            setsepcharefg jkl/ %
            readlist*funlist#1%
            foreachitemxinfunlist[]%
            foreachitemyinfunlist[xcnt]%
            Group xcnt sub-argument ycnt istabto2in``detokenize
            expandafterexpandafterexpandafterfunlist[xcnt,ycnt]'':
            tabto3.2infunlist[xcnt,ycnt]par
            %

            begindocument
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
            efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
            EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
            EDF2 formxyz4 ...
            enddocument


            enter image description here






            share|improve this answer

























            • Can you say how to get a sentence in one line to occur, rather than a list? Of the rightmost list in the image? (Also for learning how to write such macros, how does listofitems pull this off, can you suggest? I assume it checks ifx style whether the argument separator occurs or not to decide to loop and relies on a def that that takes one argument and has two cases ... Or calls a package with check for ifempty?)

              – Guido Jorg
              1 hour ago












            • @GuidoJorg To learn about the package: ctan.org/pkg/listofitems

              – Steven B. Segletes
              1 hour ago











            • @GuidoJorg As to your request, to make a sentence of the right hand column is not really to parse the list at all, but just to typeset the argument. So could you clarify what you are asking?

              – Steven B. Segletes
              1 hour ago












            • The result looking for is what would be printed had abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... been entered manually. When in fact funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... was entered manually. Though the knowledge of how to parse the list completely is useful to know, as is the package, didn't know about it :)

              – Guido Jorg
              1 hour ago












            • @GuidoJorg If I understand what you are asking, the macro looks for anything starting with the letters xyz in order to decide whether or not to apply form to it??

              – Steven B. Segletes
              1 hour ago













            2












            2








            2







            The listofitems package can grab these inputs very easily, preserving the original tokens without expansion.



            documentclassarticle
            usepackage[T1]fontenc
            usepackagelistofitems,tabto
            newcommandform[1]emph#1
            newcommandfun[1]%
            setsepchar %
            readlistfunlist#1%
            foreachitemxinfunlist[]%
            Argument xcnt istabto1.3in``detokenizeexpandafterx'':
            tabto2.5inxpar
            %

            begindocument
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
            efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
            EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
            EDF2 formxyz4 ...
            enddocument


            enter image description here



            If you need multi-layer parsing, say that efg jkl is the trigger to separate larger subgroups of arguments, then we have the following (note: efg jkl is not considered an argument, but an argument separator):



            documentclassarticle
            usepackage[T1]fontenc
            usepackagelistofitems,tabto
            newcommandform[1]emph#1
            newcommandfun[1]%
            setsepcharefg jkl/ %
            readlist*funlist#1%
            foreachitemxinfunlist[]%
            foreachitemyinfunlist[xcnt]%
            Group xcnt sub-argument ycnt istabto2in``detokenize
            expandafterexpandafterexpandafterfunlist[xcnt,ycnt]'':
            tabto3.2infunlist[xcnt,ycnt]par
            %

            begindocument
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
            efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
            EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
            EDF2 formxyz4 ...
            enddocument


            enter image description here






            share|improve this answer















            The listofitems package can grab these inputs very easily, preserving the original tokens without expansion.



            documentclassarticle
            usepackage[T1]fontenc
            usepackagelistofitems,tabto
            newcommandform[1]emph#1
            newcommandfun[1]%
            setsepchar %
            readlistfunlist#1%
            foreachitemxinfunlist[]%
            Argument xcnt istabto1.3in``detokenizeexpandafterx'':
            tabto2.5inxpar
            %

            begindocument
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
            efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
            EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
            EDF2 formxyz4 ...
            enddocument


            enter image description here



            If you need multi-layer parsing, say that efg jkl is the trigger to separate larger subgroups of arguments, then we have the following (note: efg jkl is not considered an argument, but an argument separator):



            documentclassarticle
            usepackage[T1]fontenc
            usepackagelistofitems,tabto
            newcommandform[1]emph#1
            newcommandfun[1]%
            setsepcharefg jkl/ %
            readlist*funlist#1%
            foreachitemxinfunlist[]%
            foreachitemyinfunlist[xcnt]%
            Group xcnt sub-argument ycnt istabto2in``detokenize
            expandafterexpandafterexpandafterfunlist[xcnt,ycnt]'':
            tabto3.2infunlist[xcnt,ycnt]par
            %

            begindocument
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3
            efg jkl abc4 EDF2 xyz4 ... abc1 EDF1 formxyz1 efg jkl abc2
            EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4
            EDF2 formxyz4 ...
            enddocument


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 1 hour ago

























            answered 1 hour ago









            Steven B. SegletesSteven B. Segletes

            159k9204412




            159k9204412












            • Can you say how to get a sentence in one line to occur, rather than a list? Of the rightmost list in the image? (Also for learning how to write such macros, how does listofitems pull this off, can you suggest? I assume it checks ifx style whether the argument separator occurs or not to decide to loop and relies on a def that that takes one argument and has two cases ... Or calls a package with check for ifempty?)

              – Guido Jorg
              1 hour ago












            • @GuidoJorg To learn about the package: ctan.org/pkg/listofitems

              – Steven B. Segletes
              1 hour ago











            • @GuidoJorg As to your request, to make a sentence of the right hand column is not really to parse the list at all, but just to typeset the argument. So could you clarify what you are asking?

              – Steven B. Segletes
              1 hour ago












            • The result looking for is what would be printed had abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... been entered manually. When in fact funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... was entered manually. Though the knowledge of how to parse the list completely is useful to know, as is the package, didn't know about it :)

              – Guido Jorg
              1 hour ago












            • @GuidoJorg If I understand what you are asking, the macro looks for anything starting with the letters xyz in order to decide whether or not to apply form to it??

              – Steven B. Segletes
              1 hour ago

















            • Can you say how to get a sentence in one line to occur, rather than a list? Of the rightmost list in the image? (Also for learning how to write such macros, how does listofitems pull this off, can you suggest? I assume it checks ifx style whether the argument separator occurs or not to decide to loop and relies on a def that that takes one argument and has two cases ... Or calls a package with check for ifempty?)

              – Guido Jorg
              1 hour ago












            • @GuidoJorg To learn about the package: ctan.org/pkg/listofitems

              – Steven B. Segletes
              1 hour ago











            • @GuidoJorg As to your request, to make a sentence of the right hand column is not really to parse the list at all, but just to typeset the argument. So could you clarify what you are asking?

              – Steven B. Segletes
              1 hour ago












            • The result looking for is what would be printed had abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... been entered manually. When in fact funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... was entered manually. Though the knowledge of how to parse the list completely is useful to know, as is the package, didn't know about it :)

              – Guido Jorg
              1 hour ago












            • @GuidoJorg If I understand what you are asking, the macro looks for anything starting with the letters xyz in order to decide whether or not to apply form to it??

              – Steven B. Segletes
              1 hour ago
















            Can you say how to get a sentence in one line to occur, rather than a list? Of the rightmost list in the image? (Also for learning how to write such macros, how does listofitems pull this off, can you suggest? I assume it checks ifx style whether the argument separator occurs or not to decide to loop and relies on a def that that takes one argument and has two cases ... Or calls a package with check for ifempty?)

            – Guido Jorg
            1 hour ago






            Can you say how to get a sentence in one line to occur, rather than a list? Of the rightmost list in the image? (Also for learning how to write such macros, how does listofitems pull this off, can you suggest? I assume it checks ifx style whether the argument separator occurs or not to decide to loop and relies on a def that that takes one argument and has two cases ... Or calls a package with check for ifempty?)

            – Guido Jorg
            1 hour ago














            @GuidoJorg To learn about the package: ctan.org/pkg/listofitems

            – Steven B. Segletes
            1 hour ago





            @GuidoJorg To learn about the package: ctan.org/pkg/listofitems

            – Steven B. Segletes
            1 hour ago













            @GuidoJorg As to your request, to make a sentence of the right hand column is not really to parse the list at all, but just to typeset the argument. So could you clarify what you are asking?

            – Steven B. Segletes
            1 hour ago






            @GuidoJorg As to your request, to make a sentence of the right hand column is not really to parse the list at all, but just to typeset the argument. So could you clarify what you are asking?

            – Steven B. Segletes
            1 hour ago














            The result looking for is what would be printed had abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... been entered manually. When in fact funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... was entered manually. Though the knowledge of how to parse the list completely is useful to know, as is the package, didn't know about it :)

            – Guido Jorg
            1 hour ago






            The result looking for is what would be printed had abc1 EDF1 formxyz1 efg jkl abc2 EDF2 formxyz2 efg jkl abc3 EDF3 formxyz3 efg jkl abc4 EDF2 formxyz4 ... been entered manually. When in fact funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl abc4 EDF2 xyz4 ... was entered manually. Though the knowledge of how to parse the list completely is useful to know, as is the package, didn't know about it :)

            – Guido Jorg
            1 hour ago














            @GuidoJorg If I understand what you are asking, the macro looks for anything starting with the letters xyz in order to decide whether or not to apply form to it??

            – Steven B. Segletes
            1 hour ago





            @GuidoJorg If I understand what you are asking, the macro looks for anything starting with the letters xyz in order to decide whether or not to apply form to it??

            – Steven B. Segletes
            1 hour ago











            2














            Here's a LuaLaTeX-based solution. It employs Lua's powerful string.gsub function to the argument of the fun macro, to encase the third word of each group of five words -- where "word" is any combination of characters and digits delimited by whitespace -- in the argument of fun in a form... "wrapper".



            Because luastringN (where N stands for "no expansion") is used in the argument of fun, the argument of fun is not expaneded prior to being passed to the Lua function that does all of the work.



            enter image description here



            % !TEX TS-program = lualatex
            documentclassarticle
            usepackageluacode % for 'luacode' env. and `luastringN` macro

            %% Lua-side code
            beginluacode


            function do_fun ( s )
            tex.sprint ( ( s:gsub (
            "(%w+%s*%w+%s*)(%w+)(%s*%w+%s*%w+%s-)" ,
            "%1\form%2%3" ) ) )
            end


            endluacode

            %% TeX-side code
            newcommandfun[1]directluado_fun(luastringN#1)
            newcommandform[1]emph#1

            begindocument

            noindent
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl
            abc4 EDF4 xyz4 efg jkl abc5 EDF5 xyz5 efg jkl abc6 EDF6 xyz6 efg jkl
            abc7 EDF7 xyz7 efg jkl abc8 EDF8 xyz8 efg jkl abc9 EDF9 xyz9 efg jkl
            abc10 EDF10 xyz10 efg jkl abc11 EDF11 xyz11 efg jkl abc12 EDF12 xyz12 efg jkl
            abc13 EDF13 xyz13 efg jkl abc14 EDF14 xyz14 efg jkl abc15 EDF15 xyz15 efg jkl
            abc16 EDF16 xyz16 efg jkl abc17 EDF17 xyz17 efg jkl
            enddocument





            share|improve this answer

























            • Probably cannot use for a journal but LuaLaTex solutions are very elegant. I will look at LuaTex some more for personal use, have not used it much before.

              – Guido Jorg
              1 hour ago











            • @GuidoJorg - Some, but certainly not all, journals by now allow LuaLaTeX in addition to pdfLaTeX.

              – Mico
              44 mins ago















            2














            Here's a LuaLaTeX-based solution. It employs Lua's powerful string.gsub function to the argument of the fun macro, to encase the third word of each group of five words -- where "word" is any combination of characters and digits delimited by whitespace -- in the argument of fun in a form... "wrapper".



            Because luastringN (where N stands for "no expansion") is used in the argument of fun, the argument of fun is not expaneded prior to being passed to the Lua function that does all of the work.



            enter image description here



            % !TEX TS-program = lualatex
            documentclassarticle
            usepackageluacode % for 'luacode' env. and `luastringN` macro

            %% Lua-side code
            beginluacode


            function do_fun ( s )
            tex.sprint ( ( s:gsub (
            "(%w+%s*%w+%s*)(%w+)(%s*%w+%s*%w+%s-)" ,
            "%1\form%2%3" ) ) )
            end


            endluacode

            %% TeX-side code
            newcommandfun[1]directluado_fun(luastringN#1)
            newcommandform[1]emph#1

            begindocument

            noindent
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl
            abc4 EDF4 xyz4 efg jkl abc5 EDF5 xyz5 efg jkl abc6 EDF6 xyz6 efg jkl
            abc7 EDF7 xyz7 efg jkl abc8 EDF8 xyz8 efg jkl abc9 EDF9 xyz9 efg jkl
            abc10 EDF10 xyz10 efg jkl abc11 EDF11 xyz11 efg jkl abc12 EDF12 xyz12 efg jkl
            abc13 EDF13 xyz13 efg jkl abc14 EDF14 xyz14 efg jkl abc15 EDF15 xyz15 efg jkl
            abc16 EDF16 xyz16 efg jkl abc17 EDF17 xyz17 efg jkl
            enddocument





            share|improve this answer

























            • Probably cannot use for a journal but LuaLaTex solutions are very elegant. I will look at LuaTex some more for personal use, have not used it much before.

              – Guido Jorg
              1 hour ago











            • @GuidoJorg - Some, but certainly not all, journals by now allow LuaLaTeX in addition to pdfLaTeX.

              – Mico
              44 mins ago













            2












            2








            2







            Here's a LuaLaTeX-based solution. It employs Lua's powerful string.gsub function to the argument of the fun macro, to encase the third word of each group of five words -- where "word" is any combination of characters and digits delimited by whitespace -- in the argument of fun in a form... "wrapper".



            Because luastringN (where N stands for "no expansion") is used in the argument of fun, the argument of fun is not expaneded prior to being passed to the Lua function that does all of the work.



            enter image description here



            % !TEX TS-program = lualatex
            documentclassarticle
            usepackageluacode % for 'luacode' env. and `luastringN` macro

            %% Lua-side code
            beginluacode


            function do_fun ( s )
            tex.sprint ( ( s:gsub (
            "(%w+%s*%w+%s*)(%w+)(%s*%w+%s*%w+%s-)" ,
            "%1\form%2%3" ) ) )
            end


            endluacode

            %% TeX-side code
            newcommandfun[1]directluado_fun(luastringN#1)
            newcommandform[1]emph#1

            begindocument

            noindent
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl
            abc4 EDF4 xyz4 efg jkl abc5 EDF5 xyz5 efg jkl abc6 EDF6 xyz6 efg jkl
            abc7 EDF7 xyz7 efg jkl abc8 EDF8 xyz8 efg jkl abc9 EDF9 xyz9 efg jkl
            abc10 EDF10 xyz10 efg jkl abc11 EDF11 xyz11 efg jkl abc12 EDF12 xyz12 efg jkl
            abc13 EDF13 xyz13 efg jkl abc14 EDF14 xyz14 efg jkl abc15 EDF15 xyz15 efg jkl
            abc16 EDF16 xyz16 efg jkl abc17 EDF17 xyz17 efg jkl
            enddocument





            share|improve this answer















            Here's a LuaLaTeX-based solution. It employs Lua's powerful string.gsub function to the argument of the fun macro, to encase the third word of each group of five words -- where "word" is any combination of characters and digits delimited by whitespace -- in the argument of fun in a form... "wrapper".



            Because luastringN (where N stands for "no expansion") is used in the argument of fun, the argument of fun is not expaneded prior to being passed to the Lua function that does all of the work.



            enter image description here



            % !TEX TS-program = lualatex
            documentclassarticle
            usepackageluacode % for 'luacode' env. and `luastringN` macro

            %% Lua-side code
            beginluacode


            function do_fun ( s )
            tex.sprint ( ( s:gsub (
            "(%w+%s*%w+%s*)(%w+)(%s*%w+%s*%w+%s-)" ,
            "%1\form%2%3" ) ) )
            end


            endluacode

            %% TeX-side code
            newcommandfun[1]directluado_fun(luastringN#1)
            newcommandform[1]emph#1

            begindocument

            noindent
            funabc1 EDF1 xyz1 efg jkl abc2 EDF2 xyz2 efg jkl abc3 EDF3 xyz3 efg jkl
            abc4 EDF4 xyz4 efg jkl abc5 EDF5 xyz5 efg jkl abc6 EDF6 xyz6 efg jkl
            abc7 EDF7 xyz7 efg jkl abc8 EDF8 xyz8 efg jkl abc9 EDF9 xyz9 efg jkl
            abc10 EDF10 xyz10 efg jkl abc11 EDF11 xyz11 efg jkl abc12 EDF12 xyz12 efg jkl
            abc13 EDF13 xyz13 efg jkl abc14 EDF14 xyz14 efg jkl abc15 EDF15 xyz15 efg jkl
            abc16 EDF16 xyz16 efg jkl abc17 EDF17 xyz17 efg jkl
            enddocument






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 54 mins ago

























            answered 1 hour ago









            MicoMico

            284k31388777




            284k31388777












            • Probably cannot use for a journal but LuaLaTex solutions are very elegant. I will look at LuaTex some more for personal use, have not used it much before.

              – Guido Jorg
              1 hour ago











            • @GuidoJorg - Some, but certainly not all, journals by now allow LuaLaTeX in addition to pdfLaTeX.

              – Mico
              44 mins ago

















            • Probably cannot use for a journal but LuaLaTex solutions are very elegant. I will look at LuaTex some more for personal use, have not used it much before.

              – Guido Jorg
              1 hour ago











            • @GuidoJorg - Some, but certainly not all, journals by now allow LuaLaTeX in addition to pdfLaTeX.

              – Mico
              44 mins ago
















            Probably cannot use for a journal but LuaLaTex solutions are very elegant. I will look at LuaTex some more for personal use, have not used it much before.

            – Guido Jorg
            1 hour ago





            Probably cannot use for a journal but LuaLaTex solutions are very elegant. I will look at LuaTex some more for personal use, have not used it much before.

            – Guido Jorg
            1 hour ago













            @GuidoJorg - Some, but certainly not all, journals by now allow LuaLaTeX in addition to pdfLaTeX.

            – Mico
            44 mins ago





            @GuidoJorg - Some, but certainly not all, journals by now allow LuaLaTeX in addition to pdfLaTeX.

            – Mico
            44 mins ago

















            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%2f480991%2fextract-more-than-nine-arguments-that-occur-periodically-in-a-sentence-to-use-in%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

            Disable / Remove link to Product Items in Cart Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How can I limit products that can be bought / added to cart?Remove item from cartHide “Add to Cart” button if specific products are already in cart“Prettifying” the custom options in cart pageCreate link in cart sidebar to view all added items After limit reachedLink products together in checkout/cartHow to Get product from cart and add it againHide action-edit on cart page if simple productRemoving Cart items - ObserverRemove wishlist items when added to cart

            Helsingin valtaus Sisällysluettelo Taustaa | Yleistä sotatoimista | Osapuolet | Taistelut Helsingin ympäristössä | Punaisten antautumissuunnitelma | Taistelujen kulku Helsingissä | Valtauksen jälkeen | Tappiot | Muistaminen | Kirjallisuutta | Lähteet | Aiheesta muualla | NavigointivalikkoTeoksen verkkoversioTeoksen verkkoversioGoogle BooksSisällissota Helsingissä päättyi tasan 95 vuotta sittenSaksalaisten ylivoima jyräsi punaisen HelsinginSuomalaiset kuvaavat sotien jälkiä kaupungeissa – katso kuvat ja tarinat tutuilta kulmiltaHelsingin valtaus 90 vuotta sittenSaksalaiset valtasivat HelsinginHyökkäys HelsinkiinHelsingin valtaus 12.–13.4. 1918Saksalaiset käyttivät ihmiskilpiä Helsingin valtauksessa 1918Teoksen verkkoversioTeoksen verkkoversioSaksalaiset hyökkäävät Etelä-SuomeenTaistelut LeppävaarassaSotilaat ja taistelutLeppävaara 1918 huhtikuussa. KapinatarinaHelsingin taistelut 1918Saksalaisten voitonparaati HelsingissäHelsingin valtausta juhlittiinSaksalaisten Helsinki vuonna 1918Helsingin taistelussa kaatuneet valkokaartilaisetHelsinkiin haudatut taisteluissa kaatuneet punaiset12.4.1918 Helsingin valtauksessa saksalaiset apujoukot vapauttavat kaupunginVapaussodan muistomerkkejä Helsingissä ja pääkaupunkiseudullaCrescendo / Vuoden 1918 Kansalaissodan uhrien muistomerkkim

            Adjektiivitarina Tarinan tekeminen | Esimerkki: ennen | Esimerkki: jälkeen | Navigointivalikko