Extract more than nine arguments that occur periodically in a sentence to use in macros in order to typset The Next CEO of Stack OverflowHow much negative space needed? To recognizably remove a space by letting something be added? For macros whose argument is another macro?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

If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?

Why am I allowed to create multiple unique pointers from a single object?

What can we do to stop prior company from asking us questions?

How did the Bene Gesserit know how to make a Kwisatz Haderach?

Where do students learn to solve polynomial equations these days?

Plot of histogram similar to output from @risk

Why the difference in type-inference over the as-pattern in two similar function definitions?

Is 'diverse range' a pleonastic phrase?

Is it ever safe to open a suspicious html file (e.g. email attachment)?

Why, when going from special to general relativity, do we just replace partial derivatives with covariant derivatives?

Which one is the true statement?

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?

Is micro rebar a better way to reinforce concrete than rebar?

Is there a way to save my career from absolute disaster?

Is it possible to search for a directory/file combination?

How do I go from 300 unfinished/half written blog posts, to published posts?

Why do airplanes bank sharply to the right after air-to-air refueling?

Is it professional to write unrelated content in an almost-empty email?

Is wanting to ask what to write an indication that you need to change your story?

What's the best way to handle refactoring a big file?

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Can you replace a racial trait cantrip when leveling up?

Ubuntu shell scripting

Grabbing quick drinks



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



The Next CEO of Stack OverflowHow much negative space needed? To recognizably remove a space by letting something be added? For macros whose argument is another macro?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










4















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
    Mar 22 at 22:13












  • 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
    Mar 22 at 22:19











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

    – egreg
    Mar 22 at 22:22











  • @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
    Mar 22 at 22:41












  • @egreg to the 3rd, 8th, 13th, 18th ... word in the sentence. Separator can be assumed to repeat. form affects only these parts. And sentence can be arbitrarily long and will end without the separator.

    – Guido Jorg
    Mar 22 at 22:46
















4















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
    Mar 22 at 22:13












  • 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
    Mar 22 at 22:19











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

    – egreg
    Mar 22 at 22:22











  • @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
    Mar 22 at 22:41












  • @egreg to the 3rd, 8th, 13th, 18th ... word in the sentence. Separator can be assumed to repeat. form affects only these parts. And sentence can be arbitrarily long and will end without the separator.

    – Guido Jorg
    Mar 22 at 22:46














4












4








4


0






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 Mar 22 at 22:59







Guido Jorg

















asked Mar 22 at 22:12









Guido JorgGuido Jorg

1,15631344




1,15631344












  • 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
    Mar 22 at 22:13












  • 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
    Mar 22 at 22:19











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

    – egreg
    Mar 22 at 22:22











  • @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
    Mar 22 at 22:41












  • @egreg to the 3rd, 8th, 13th, 18th ... word in the sentence. Separator can be assumed to repeat. form affects only these parts. And sentence can be arbitrarily long and will end without the separator.

    – Guido Jorg
    Mar 22 at 22:46


















  • 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
    Mar 22 at 22:13












  • 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
    Mar 22 at 22:19











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

    – egreg
    Mar 22 at 22:22











  • @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
    Mar 22 at 22:41












  • @egreg to the 3rd, 8th, 13th, 18th ... word in the sentence. Separator can be assumed to repeat. form affects only these parts. And sentence can be arbitrarily long and will end without the separator.

    – Guido Jorg
    Mar 22 at 22:46

















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
Mar 22 at 22:13






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
Mar 22 at 22:13














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
Mar 22 at 22:19





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
Mar 22 at 22:19













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

– egreg
Mar 22 at 22:22





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

– egreg
Mar 22 at 22:22













@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
Mar 22 at 22:41






@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
Mar 22 at 22:41














@egreg to the 3rd, 8th, 13th, 18th ... word in the sentence. Separator can be assumed to repeat. form affects only these parts. And sentence can be arbitrarily long and will end without the separator.

– Guido Jorg
Mar 22 at 22:46






@egreg to the 3rd, 8th, 13th, 18th ... word in the sentence. Separator can be assumed to repeat. form affects only these parts. And sentence can be arbitrarily long and will end without the separator.

– Guido Jorg
Mar 22 at 22:46











3 Answers
3






active

oldest

votes


















5














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























  • @GuidoJorg That's very vague.

    – egreg
    Mar 23 at 11:10











  • @GuidoJorg That makes things even more obscure.

    – egreg
    Mar 23 at 13:52











  • Simplest example: funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco' displays Non eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco` not the result of funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco. Due to extra . What should be done so funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco displays when funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco is entered?

    – Guido Jorg
    Mar 23 at 14:05












  • @GuidoJorg Why should fun... give the same result as fun...? I see no reason to.

    – egreg
    Mar 23 at 14:06












  • By itself: A displays as A. In the use case, composition is desirable. If the text into fun is generated by some macro, not directly entered, fun won't process it. Because it seems the result is treated as A rather than A. Even though it is A. Single object. fun sees no separators when Ab Cd Ef = macrotest and funmacrotest.

    – Guido Jorg
    Mar 23 at 14:13



















5














(updated this answer signficantly to allow for multiple (expandable) macros in the argument of fun.)



Here's a LuaLaTeX-based solution. It can handle multiple, expandable macros in the argument of fun. The Lua code first splits the (expanded) input string into separate words, taking note of punctuation characters, if present. It then proceeds to print them, encasing the 3rd, 8th, 13th, 18th words in the form macro. (Mathematically speaking, the selection criterion is that the word's position in the table, modulo 4, equals 3.) Non-ASCII UTF8-encoded characters are fine (because the unicode.utf8.gmatch function rather than the "basic" string.gmatch function is employed.)



enter image description here



% !TEX TS-program = lualatex
documentclassarticle
usepackageluacode % for 'luacode' environment and 'luastring' macro

%% Lua-side code
beginluacode


function do_fun ( s )
words = -- initialize a Lua table
-- split 's' into constituent words
for word in unicode.utf8.gmatch ( s , "%w+%p?" ) do
table.insert ( words , word )
end
-- apply "form" macro at 3rd, 8th, 13th, etc words
for i = 1 , #words do
if i%5 == 3 then
tex.sprint ( "\form"..words[i].." " )
else
tex.sprint ( words[i].." " )
end
end
end


endluacode

%% TeX-side code
newcommandfun[1]directluado_fun(luastring#1)
newcommandform[1]emph#1
newcommandblurbALorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
newcommandblurbBNam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant.
newcommandblurbCabc1 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

begindocument
raggedright
funblurbAblurbBblurbC
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
    Mar 22 at 23:02






  • 1





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

    – Mico
    Mar 22 at 23:24


















3














documentclassarticle
usepackage[T1]fontenc
usepackagelistofitems,tabto
newcounterformtrigger
newcommandform[1]emph#1
newcommandfun[1]%
setsepchar %
readlist*funlist#1%
setcounterformtrigger2%
foreachitemxinfunlist[]%
stepcounterformtrigger%
ifnumtheformtrigger=5relax
formxsetcounterformtrigger0%
else%
x%
fi%
%


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


enter image description here



ORIGINAL 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

























  • 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
    Mar 22 at 22:36












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

    – Steven B. Segletes
    Mar 22 at 22:39











  • @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
    Mar 22 at 22:40












  • 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
    Mar 22 at 22:42







  • 1





    @GuidoJorg Please see my revision.

    – Steven B. Segletes
    Mar 23 at 1:14











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









5














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























  • @GuidoJorg That's very vague.

    – egreg
    Mar 23 at 11:10











  • @GuidoJorg That makes things even more obscure.

    – egreg
    Mar 23 at 13:52











  • Simplest example: funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco' displays Non eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco` not the result of funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco. Due to extra . What should be done so funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco displays when funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco is entered?

    – Guido Jorg
    Mar 23 at 14:05












  • @GuidoJorg Why should fun... give the same result as fun...? I see no reason to.

    – egreg
    Mar 23 at 14:06












  • By itself: A displays as A. In the use case, composition is desirable. If the text into fun is generated by some macro, not directly entered, fun won't process it. Because it seems the result is treated as A rather than A. Even though it is A. Single object. fun sees no separators when Ab Cd Ef = macrotest and funmacrotest.

    – Guido Jorg
    Mar 23 at 14:13
















5














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























  • @GuidoJorg That's very vague.

    – egreg
    Mar 23 at 11:10











  • @GuidoJorg That makes things even more obscure.

    – egreg
    Mar 23 at 13:52











  • Simplest example: funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco' displays Non eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco` not the result of funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco. Due to extra . What should be done so funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco displays when funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco is entered?

    – Guido Jorg
    Mar 23 at 14:05












  • @GuidoJorg Why should fun... give the same result as fun...? I see no reason to.

    – egreg
    Mar 23 at 14:06












  • By itself: A displays as A. In the use case, composition is desirable. If the text into fun is generated by some macro, not directly entered, fun won't process it. Because it seems the result is treated as A rather than A. Even though it is A. Single object. fun sees no separators when Ab Cd Ef = macrotest and funmacrotest.

    – Guido Jorg
    Mar 23 at 14:13














5












5








5







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 Mar 22 at 23:28









egregegreg

730k8819283242




730k8819283242












  • @GuidoJorg That's very vague.

    – egreg
    Mar 23 at 11:10











  • @GuidoJorg That makes things even more obscure.

    – egreg
    Mar 23 at 13:52











  • Simplest example: funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco' displays Non eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco` not the result of funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco. Due to extra . What should be done so funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco displays when funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco is entered?

    – Guido Jorg
    Mar 23 at 14:05












  • @GuidoJorg Why should fun... give the same result as fun...? I see no reason to.

    – egreg
    Mar 23 at 14:06












  • By itself: A displays as A. In the use case, composition is desirable. If the text into fun is generated by some macro, not directly entered, fun won't process it. Because it seems the result is treated as A rather than A. Even though it is A. Single object. fun sees no separators when Ab Cd Ef = macrotest and funmacrotest.

    – Guido Jorg
    Mar 23 at 14:13


















  • @GuidoJorg That's very vague.

    – egreg
    Mar 23 at 11:10











  • @GuidoJorg That makes things even more obscure.

    – egreg
    Mar 23 at 13:52











  • Simplest example: funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco' displays Non eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco` not the result of funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco. Due to extra . What should be done so funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco displays when funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco is entered?

    – Guido Jorg
    Mar 23 at 14:05












  • @GuidoJorg Why should fun... give the same result as fun...? I see no reason to.

    – egreg
    Mar 23 at 14:06












  • By itself: A displays as A. In the use case, composition is desirable. If the text into fun is generated by some macro, not directly entered, fun won't process it. Because it seems the result is treated as A rather than A. Even though it is A. Single object. fun sees no separators when Ab Cd Ef = macrotest and funmacrotest.

    – Guido Jorg
    Mar 23 at 14:13

















@GuidoJorg That's very vague.

– egreg
Mar 23 at 11:10





@GuidoJorg That's very vague.

– egreg
Mar 23 at 11:10













@GuidoJorg That makes things even more obscure.

– egreg
Mar 23 at 13:52





@GuidoJorg That makes things even more obscure.

– egreg
Mar 23 at 13:52













Simplest example: funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco' displays Non eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco` not the result of funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco. Due to extra . What should be done so funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco displays when funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco is entered?

– Guido Jorg
Mar 23 at 14:05






Simplest example: funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco' displays Non eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco` not the result of funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco. Due to extra . What should be done so funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco displays when funNon eram nescius Brute cum quae summis ingeniis exquisitaque doctrina philosophi Graeco is entered?

– Guido Jorg
Mar 23 at 14:05














@GuidoJorg Why should fun... give the same result as fun...? I see no reason to.

– egreg
Mar 23 at 14:06






@GuidoJorg Why should fun... give the same result as fun...? I see no reason to.

– egreg
Mar 23 at 14:06














By itself: A displays as A. In the use case, composition is desirable. If the text into fun is generated by some macro, not directly entered, fun won't process it. Because it seems the result is treated as A rather than A. Even though it is A. Single object. fun sees no separators when Ab Cd Ef = macrotest and funmacrotest.

– Guido Jorg
Mar 23 at 14:13






By itself: A displays as A. In the use case, composition is desirable. If the text into fun is generated by some macro, not directly entered, fun won't process it. Because it seems the result is treated as A rather than A. Even though it is A. Single object. fun sees no separators when Ab Cd Ef = macrotest and funmacrotest.

– Guido Jorg
Mar 23 at 14:13












5














(updated this answer signficantly to allow for multiple (expandable) macros in the argument of fun.)



Here's a LuaLaTeX-based solution. It can handle multiple, expandable macros in the argument of fun. The Lua code first splits the (expanded) input string into separate words, taking note of punctuation characters, if present. It then proceeds to print them, encasing the 3rd, 8th, 13th, 18th words in the form macro. (Mathematically speaking, the selection criterion is that the word's position in the table, modulo 4, equals 3.) Non-ASCII UTF8-encoded characters are fine (because the unicode.utf8.gmatch function rather than the "basic" string.gmatch function is employed.)



enter image description here



% !TEX TS-program = lualatex
documentclassarticle
usepackageluacode % for 'luacode' environment and 'luastring' macro

%% Lua-side code
beginluacode


function do_fun ( s )
words = -- initialize a Lua table
-- split 's' into constituent words
for word in unicode.utf8.gmatch ( s , "%w+%p?" ) do
table.insert ( words , word )
end
-- apply "form" macro at 3rd, 8th, 13th, etc words
for i = 1 , #words do
if i%5 == 3 then
tex.sprint ( "\form"..words[i].." " )
else
tex.sprint ( words[i].." " )
end
end
end


endluacode

%% TeX-side code
newcommandfun[1]directluado_fun(luastring#1)
newcommandform[1]emph#1
newcommandblurbALorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
newcommandblurbBNam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant.
newcommandblurbCabc1 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

begindocument
raggedright
funblurbAblurbBblurbC
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
    Mar 22 at 23:02






  • 1





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

    – Mico
    Mar 22 at 23:24















5














(updated this answer signficantly to allow for multiple (expandable) macros in the argument of fun.)



Here's a LuaLaTeX-based solution. It can handle multiple, expandable macros in the argument of fun. The Lua code first splits the (expanded) input string into separate words, taking note of punctuation characters, if present. It then proceeds to print them, encasing the 3rd, 8th, 13th, 18th words in the form macro. (Mathematically speaking, the selection criterion is that the word's position in the table, modulo 4, equals 3.) Non-ASCII UTF8-encoded characters are fine (because the unicode.utf8.gmatch function rather than the "basic" string.gmatch function is employed.)



enter image description here



% !TEX TS-program = lualatex
documentclassarticle
usepackageluacode % for 'luacode' environment and 'luastring' macro

%% Lua-side code
beginluacode


function do_fun ( s )
words = -- initialize a Lua table
-- split 's' into constituent words
for word in unicode.utf8.gmatch ( s , "%w+%p?" ) do
table.insert ( words , word )
end
-- apply "form" macro at 3rd, 8th, 13th, etc words
for i = 1 , #words do
if i%5 == 3 then
tex.sprint ( "\form"..words[i].." " )
else
tex.sprint ( words[i].." " )
end
end
end


endluacode

%% TeX-side code
newcommandfun[1]directluado_fun(luastring#1)
newcommandform[1]emph#1
newcommandblurbALorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
newcommandblurbBNam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant.
newcommandblurbCabc1 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

begindocument
raggedright
funblurbAblurbBblurbC
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
    Mar 22 at 23:02






  • 1





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

    – Mico
    Mar 22 at 23:24













5












5








5







(updated this answer signficantly to allow for multiple (expandable) macros in the argument of fun.)



Here's a LuaLaTeX-based solution. It can handle multiple, expandable macros in the argument of fun. The Lua code first splits the (expanded) input string into separate words, taking note of punctuation characters, if present. It then proceeds to print them, encasing the 3rd, 8th, 13th, 18th words in the form macro. (Mathematically speaking, the selection criterion is that the word's position in the table, modulo 4, equals 3.) Non-ASCII UTF8-encoded characters are fine (because the unicode.utf8.gmatch function rather than the "basic" string.gmatch function is employed.)



enter image description here



% !TEX TS-program = lualatex
documentclassarticle
usepackageluacode % for 'luacode' environment and 'luastring' macro

%% Lua-side code
beginluacode


function do_fun ( s )
words = -- initialize a Lua table
-- split 's' into constituent words
for word in unicode.utf8.gmatch ( s , "%w+%p?" ) do
table.insert ( words , word )
end
-- apply "form" macro at 3rd, 8th, 13th, etc words
for i = 1 , #words do
if i%5 == 3 then
tex.sprint ( "\form"..words[i].." " )
else
tex.sprint ( words[i].." " )
end
end
end


endluacode

%% TeX-side code
newcommandfun[1]directluado_fun(luastring#1)
newcommandform[1]emph#1
newcommandblurbALorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
newcommandblurbBNam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant.
newcommandblurbCabc1 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

begindocument
raggedright
funblurbAblurbBblurbC
enddocument





share|improve this answer















(updated this answer signficantly to allow for multiple (expandable) macros in the argument of fun.)



Here's a LuaLaTeX-based solution. It can handle multiple, expandable macros in the argument of fun. The Lua code first splits the (expanded) input string into separate words, taking note of punctuation characters, if present. It then proceeds to print them, encasing the 3rd, 8th, 13th, 18th words in the form macro. (Mathematically speaking, the selection criterion is that the word's position in the table, modulo 4, equals 3.) Non-ASCII UTF8-encoded characters are fine (because the unicode.utf8.gmatch function rather than the "basic" string.gmatch function is employed.)



enter image description here



% !TEX TS-program = lualatex
documentclassarticle
usepackageluacode % for 'luacode' environment and 'luastring' macro

%% Lua-side code
beginluacode


function do_fun ( s )
words = -- initialize a Lua table
-- split 's' into constituent words
for word in unicode.utf8.gmatch ( s , "%w+%p?" ) do
table.insert ( words , word )
end
-- apply "form" macro at 3rd, 8th, 13th, etc words
for i = 1 , #words do
if i%5 == 3 then
tex.sprint ( "\form"..words[i].." " )
else
tex.sprint ( words[i].." " )
end
end
end


endluacode

%% TeX-side code
newcommandfun[1]directluado_fun(luastring#1)
newcommandform[1]emph#1
newcommandblurbALorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
newcommandblurbBNam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant.
newcommandblurbCabc1 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

begindocument
raggedright
funblurbAblurbBblurbC
enddocument






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 23 at 10:14

























answered Mar 22 at 22:57









MicoMico

284k31388778




284k31388778












  • 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
    Mar 22 at 23:02






  • 1





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

    – Mico
    Mar 22 at 23:24

















  • 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
    Mar 22 at 23:02






  • 1





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

    – Mico
    Mar 22 at 23:24
















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
Mar 22 at 23:02





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
Mar 22 at 23:02




1




1





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

– Mico
Mar 22 at 23:24





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

– Mico
Mar 22 at 23:24











3














documentclassarticle
usepackage[T1]fontenc
usepackagelistofitems,tabto
newcounterformtrigger
newcommandform[1]emph#1
newcommandfun[1]%
setsepchar %
readlist*funlist#1%
setcounterformtrigger2%
foreachitemxinfunlist[]%
stepcounterformtrigger%
ifnumtheformtrigger=5relax
formxsetcounterformtrigger0%
else%
x%
fi%
%


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


enter image description here



ORIGINAL 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

























  • 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
    Mar 22 at 22:36












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

    – Steven B. Segletes
    Mar 22 at 22:39











  • @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
    Mar 22 at 22:40












  • 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
    Mar 22 at 22:42







  • 1





    @GuidoJorg Please see my revision.

    – Steven B. Segletes
    Mar 23 at 1:14















3














documentclassarticle
usepackage[T1]fontenc
usepackagelistofitems,tabto
newcounterformtrigger
newcommandform[1]emph#1
newcommandfun[1]%
setsepchar %
readlist*funlist#1%
setcounterformtrigger2%
foreachitemxinfunlist[]%
stepcounterformtrigger%
ifnumtheformtrigger=5relax
formxsetcounterformtrigger0%
else%
x%
fi%
%


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


enter image description here



ORIGINAL 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

























  • 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
    Mar 22 at 22:36












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

    – Steven B. Segletes
    Mar 22 at 22:39











  • @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
    Mar 22 at 22:40












  • 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
    Mar 22 at 22:42







  • 1





    @GuidoJorg Please see my revision.

    – Steven B. Segletes
    Mar 23 at 1:14













3












3








3







documentclassarticle
usepackage[T1]fontenc
usepackagelistofitems,tabto
newcounterformtrigger
newcommandform[1]emph#1
newcommandfun[1]%
setsepchar %
readlist*funlist#1%
setcounterformtrigger2%
foreachitemxinfunlist[]%
stepcounterformtrigger%
ifnumtheformtrigger=5relax
formxsetcounterformtrigger0%
else%
x%
fi%
%


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


enter image description here



ORIGINAL 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















documentclassarticle
usepackage[T1]fontenc
usepackagelistofitems,tabto
newcounterformtrigger
newcommandform[1]emph#1
newcommandfun[1]%
setsepchar %
readlist*funlist#1%
setcounterformtrigger2%
foreachitemxinfunlist[]%
stepcounterformtrigger%
ifnumtheformtrigger=5relax
formxsetcounterformtrigger0%
else%
x%
fi%
%


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


enter image description here



ORIGINAL 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 Mar 23 at 1:13

























answered Mar 22 at 22:20









Steven B. SegletesSteven B. Segletes

160k9204413




160k9204413












  • 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
    Mar 22 at 22:36












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

    – Steven B. Segletes
    Mar 22 at 22:39











  • @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
    Mar 22 at 22:40












  • 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
    Mar 22 at 22:42







  • 1





    @GuidoJorg Please see my revision.

    – Steven B. Segletes
    Mar 23 at 1:14

















  • 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
    Mar 22 at 22:36












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

    – Steven B. Segletes
    Mar 22 at 22:39











  • @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
    Mar 22 at 22:40












  • 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
    Mar 22 at 22:42







  • 1





    @GuidoJorg Please see my revision.

    – Steven B. Segletes
    Mar 23 at 1:14
















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
Mar 22 at 22:36






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
Mar 22 at 22:36














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

– Steven B. Segletes
Mar 22 at 22:39





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

– Steven B. Segletes
Mar 22 at 22:39













@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
Mar 22 at 22:40






@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
Mar 22 at 22:40














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
Mar 22 at 22:42






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
Mar 22 at 22:42





1




1





@GuidoJorg Please see my revision.

– Steven B. Segletes
Mar 23 at 1:14





@GuidoJorg Please see my revision.

– Steven B. Segletes
Mar 23 at 1:14

















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

Is flight data recorder erased after every flight?When are black boxes used?What protects the location beacon (pinger) of a flight data recorder?Is there anywhere I can pick up raw flight data recorder information?Who legally owns the Flight Data Recorder?Constructing flight recorder dataWhy are FDRs and CVRs still two separate physical devices?What are the data elements shown on the GE235 flight data recorder (FDR) plot?Are CVR and FDR reset after every flight?What is the format of data stored by a Flight Data Recorder?How much data is stored in the flight data recorder per hour in a typical flight of an A380?Is a smart flight data recorder possible?

Which is better: GPT or RelGAN for text generation?2019 Community Moderator ElectionWhat is the difference between TextGAN and LM for text generation?GANs (generative adversarial networks) possible for text as well?Generator loss not decreasing- text to image synthesisChoosing a right algorithm for template-based text generationHow should I format input and output for text generation with LSTMsGumbel Softmax vs Vanilla Softmax for GAN trainingWhich neural network to choose for classification from text/speech?NLP text autoencoder that generates text in poetic meterWhat is the interpretation of the expectation notation in the GAN formulation?What is the difference between TextGAN and LM for text generation?How to prepare the data for text generation task

Is there a general name for the setup in which payoffs are not known exactly but players try to influence each other's perception of the payoffs?Osborne, Nash equilibria and the correctness of beliefsIs there a name for this family of games (Binomial games?)?Perfect Bayesian EquilibriumCalculating mixed strategy equilibrium in battle of sexesPure Strategy SPNEIs there a commitment mechanism which allows players to achieve pareto optimal solutions?Extensive Form GamesAn $n$-player prisoner's dilemma where a coalition of 2 players is better off defectingTit-For-Stat Strategy Best RepliesPotential solutions of the $n$-player Prisoner's Dilemma