A command with a variable number of arguments: comma versus andCommands that may take a variable number of argumentsrelative hspace in newcommandIterating through comma-separated argumentsCommand with variable number of arguments to format menu sequencesProcessing “List” of “List”Aliasing a variable argument command into tabular environmentDynamic length variable with argument? (like “setlengthfoo[1]0.5+#1*0.5”)Variable number of arguments in a commandOptional arguments in “families”… When and how?Command to format any number of equationsAn ellipsis with N dots
Anatomically Correct Strange Women In Ponds Distributing Swords
Is there a good way to store credentials outside of a password manager?
How do I find the solutions of the following equation?
What is the intuitive meaning of having a linear relationship between the logs of two variables?
India just shot down a satellite from the ground. At what altitude range is the resulting debris field?
Do the temporary hit points from the Battlerager barbarian's Reckless Abandon stack if I make multiple attacks on my turn?
Is exact Kanji stroke length important?
Two monoidal structures and copowering
Why are there no referendums in the US?
Roman Numeral Treatment of Suspensions
How to Reset Passwords on Multiple Websites Easily?
What can we do to stop prior company from asking us questions?
How to run a prison with the smallest amount of guards?
How to pronounce the slash sign
Is there a korbon needed for conversion?
What is paid subscription needed for in Mortal Kombat 11?
Sort a list by elements of another list
System.debug(JSON.Serialize(o)) Not longer shows full string
Unreliable Magic - Is it worth it?
How do I extract a value from a time formatted value in excel?
Large drywall patch supports
How can I get through very long and very dry, but also very useful technical documents when learning a new tool?
How do scammers retract money, while you can’t?
Failed to fetch jessie backports repository
A command with a variable number of arguments: comma versus and
Commands that may take a variable number of argumentsrelative hspace in newcommandIterating through comma-separated argumentsCommand with variable number of arguments to format menu sequencesProcessing “List” of “List”Aliasing a variable argument command into tabular environmentDynamic length variable with argument? (like “setlengthfoo[1]0.5+#1*0.5”)Variable number of arguments in a commandOptional arguments in “families”… When and how?Command to format any number of equationsAn ellipsis with N dots
I have the following command: newcommandtriangles[2]triangles $triangle #1$ and $triangle #2
, such that trianglesABCDEF
produces triangles $triangle ABC$ and $triangle DEF$
. I would like to expand that command such that it can take any number of arguments and such that trianglesABCDEFGHIJKL
produces triangles $triangle ABC$, $triangle DEF$, $triangle GHI$ and $triangle DEF$
. I have seen a solution somewhere for a shoppinglist that makes use of makeatletter
and some TeX command, but this is more difficult, I think, because before you add the current argument, you need to know whether it is the last argument (if not: put a comma, if yes: put "and").
macros
New contributor
add a comment |
I have the following command: newcommandtriangles[2]triangles $triangle #1$ and $triangle #2
, such that trianglesABCDEF
produces triangles $triangle ABC$ and $triangle DEF$
. I would like to expand that command such that it can take any number of arguments and such that trianglesABCDEFGHIJKL
produces triangles $triangle ABC$, $triangle DEF$, $triangle GHI$ and $triangle DEF$
. I have seen a solution somewhere for a shoppinglist that makes use of makeatletter
and some TeX command, but this is more difficult, I think, because before you add the current argument, you need to know whether it is the last argument (if not: put a comma, if yes: put "and").
macros
New contributor
For the sake of unambiguity regarding the question which brace groups belong totriangles
and which do not, I strongly recommend a syntax liketrianglesABCDEFGHI
. Or a syntax without brace-groups at all, as suggested by egreg,trianglesABC,DEF,GHI
.
– Ulrich Diez
9 hours ago
add a comment |
I have the following command: newcommandtriangles[2]triangles $triangle #1$ and $triangle #2
, such that trianglesABCDEF
produces triangles $triangle ABC$ and $triangle DEF$
. I would like to expand that command such that it can take any number of arguments and such that trianglesABCDEFGHIJKL
produces triangles $triangle ABC$, $triangle DEF$, $triangle GHI$ and $triangle DEF$
. I have seen a solution somewhere for a shoppinglist that makes use of makeatletter
and some TeX command, but this is more difficult, I think, because before you add the current argument, you need to know whether it is the last argument (if not: put a comma, if yes: put "and").
macros
New contributor
I have the following command: newcommandtriangles[2]triangles $triangle #1$ and $triangle #2
, such that trianglesABCDEF
produces triangles $triangle ABC$ and $triangle DEF$
. I would like to expand that command such that it can take any number of arguments and such that trianglesABCDEFGHIJKL
produces triangles $triangle ABC$, $triangle DEF$, $triangle GHI$ and $triangle DEF$
. I have seen a solution somewhere for a shoppinglist that makes use of makeatletter
and some TeX command, but this is more difficult, I think, because before you add the current argument, you need to know whether it is the last argument (if not: put a comma, if yes: put "and").
macros
macros
New contributor
New contributor
edited 14 hours ago
egreg
729k8819273240
729k8819273240
New contributor
asked 14 hours ago
BartBart
111
111
New contributor
New contributor
For the sake of unambiguity regarding the question which brace groups belong totriangles
and which do not, I strongly recommend a syntax liketrianglesABCDEFGHI
. Or a syntax without brace-groups at all, as suggested by egreg,trianglesABC,DEF,GHI
.
– Ulrich Diez
9 hours ago
add a comment |
For the sake of unambiguity regarding the question which brace groups belong totriangles
and which do not, I strongly recommend a syntax liketrianglesABCDEFGHI
. Or a syntax without brace-groups at all, as suggested by egreg,trianglesABC,DEF,GHI
.
– Ulrich Diez
9 hours ago
For the sake of unambiguity regarding the question which brace groups belong to
triangles
and which do not, I strongly recommend a syntax like trianglesABCDEFGHI
. Or a syntax without brace-groups at all, as suggested by egreg, trianglesABC,DEF,GHI
.– Ulrich Diez
9 hours ago
For the sake of unambiguity regarding the question which brace groups belong to
triangles
and which do not, I strongly recommend a syntax like trianglesABCDEFGHI
. Or a syntax without brace-groups at all, as suggested by egreg, trianglesABC,DEF,GHI
.– Ulrich Diez
9 hours ago
add a comment |
4 Answers
4
active
oldest
votes
The shoppinglist you're talking about is at Writing a LaTeX macro that takes a variable number of arguments.
You can adapt it quickly to work with any number of triangles. The case with one triangle is also handled in order to only display "Triangle" instead of "Triangles".
documentclass[11pt]article
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
@ifnextcharbgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
@ifnextcharbgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
enddocument
This is the result obtained:
EDIT
Following the comment by Ulrich Diez, an improved version of this command would be:
documentclass[11pt]article
usepackageltxcmds
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
ltx@ifnextchar@nospacebgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
ltx@ifnextchar@nospacebgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
trianglesABCDEFGHIJKL Large This shall not be part of the command
enddocument
where ltx@ifnextchar@nospace
does not skip space and prevent the text after the command to be interpreted as an "argument" of the command triangles
.
However, as stated in egreg's answer, this way of doing things should be avoided.
New contributor
1
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
– Ulrich Diez
9 hours ago
add a comment |
Macros with a variable number of arguments are not the best thing to do with LaTeX; in your case it's simpler to use a comma separated list of triangles.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandtrianglesm
bart_triangles:n #1
seq_new:N l__bart_triangles_seq
tl_new:N l__bart_triangles_item_tl
cs_new_protected:Nn bart_triangles:n
seq_clear:N l__bart_triangles_seq
clist_map_variable:nNn #1 l__bart_triangles_item_tl
__bart_triangles_add:V l__bart_triangles_item_tl
triangle
int_compare:nF seq_count:N l__bart_triangles_seq < 2 s
nobreakspace
seq_use:Nnnn l__bart_triangles_seq ~and~ ,~ ~and~
cs_new_protected:Nn __bart_triangles_add:n
seq_put_right:Nn l__bart_triangles_seq $triangle #1$
cs_generate_variant:Nn __bart_triangles_add:n V
ExplSyntaxOff
begindocument
trianglesABC
trianglesABC,DEF
trianglesABC,DEF,GHI
enddocument
The comma separated list is mapped and each item is added to a sequence in the form $triangle<vertices>$
. Then the sequence is used, with the specified separators (between two, between more than two, between last two).
The “s” is added only if the list contains at least two items.
add a comment |
A listofitems
approach. Note: I was taught that for a list of more than 2 items, a comma precedes the "and".
documentclassarticle
usepackagelistofitems
newcommandtriangles[1]%
setsepchar,%
readlisttrilist#1%
foreachitemxintrilist[]%
$trianglex$%
ifnumnumexprxcnt+1<listlentrilist[]relax%
, %
else%
ifnumnumexprxcnt+1=listlentrilist[]relax%
ifnumlistlentrilist[]>2relax,fi
and %
fi
fi%
%
begindocument
Given trianglesABC.par
Given trianglesABC, DEF.par
Given trianglesABC, DEF,GHI.par
Given trianglesABC, DEF,GHI, JKL.par
enddocument
add a comment |
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
For the sake of unambiguity regarding the question which brace groups belong to triangles
and which do not, I strongly recommend a syntax like trianglesABCDEFGHI
.
Or a syntax without brace-groups at all, as suggested by egreg, trianglesABC,DEF,GHI
The following example exhibits a romannumeral
-expansion-based way of implementing the trianglesABCDEFGHI
-syntax:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[2]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@PassFirstToSecondexpandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEF GHIpar
trianglesABC DEFpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
In case you wish a comma before the "and" when the list has more than two items:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[3]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@exchangeexpandafter%
romannumeral0UD@exchange expandafterexpandafterexpandafter
expandafterexpandafterexpandafterexpandafter%
expandafterUD@exchangeexpandafter%
romannumeral0%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1 %
UD@CheckWhetherBlank#2 ,%
%
expandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2#3 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEFpar
trianglesABC DEF GHIpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
add a comment |
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
);
);
Bart is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481707%2fa-command-with-a-variable-number-of-arguments-comma-versus-and%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
The shoppinglist you're talking about is at Writing a LaTeX macro that takes a variable number of arguments.
You can adapt it quickly to work with any number of triangles. The case with one triangle is also handled in order to only display "Triangle" instead of "Triangles".
documentclass[11pt]article
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
@ifnextcharbgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
@ifnextcharbgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
enddocument
This is the result obtained:
EDIT
Following the comment by Ulrich Diez, an improved version of this command would be:
documentclass[11pt]article
usepackageltxcmds
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
ltx@ifnextchar@nospacebgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
ltx@ifnextchar@nospacebgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
trianglesABCDEFGHIJKL Large This shall not be part of the command
enddocument
where ltx@ifnextchar@nospace
does not skip space and prevent the text after the command to be interpreted as an "argument" of the command triangles
.
However, as stated in egreg's answer, this way of doing things should be avoided.
New contributor
1
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
– Ulrich Diez
9 hours ago
add a comment |
The shoppinglist you're talking about is at Writing a LaTeX macro that takes a variable number of arguments.
You can adapt it quickly to work with any number of triangles. The case with one triangle is also handled in order to only display "Triangle" instead of "Triangles".
documentclass[11pt]article
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
@ifnextcharbgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
@ifnextcharbgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
enddocument
This is the result obtained:
EDIT
Following the comment by Ulrich Diez, an improved version of this command would be:
documentclass[11pt]article
usepackageltxcmds
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
ltx@ifnextchar@nospacebgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
ltx@ifnextchar@nospacebgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
trianglesABCDEFGHIJKL Large This shall not be part of the command
enddocument
where ltx@ifnextchar@nospace
does not skip space and prevent the text after the command to be interpreted as an "argument" of the command triangles
.
However, as stated in egreg's answer, this way of doing things should be avoided.
New contributor
1
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
– Ulrich Diez
9 hours ago
add a comment |
The shoppinglist you're talking about is at Writing a LaTeX macro that takes a variable number of arguments.
You can adapt it quickly to work with any number of triangles. The case with one triangle is also handled in order to only display "Triangle" instead of "Triangles".
documentclass[11pt]article
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
@ifnextcharbgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
@ifnextcharbgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
enddocument
This is the result obtained:
EDIT
Following the comment by Ulrich Diez, an improved version of this command would be:
documentclass[11pt]article
usepackageltxcmds
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
ltx@ifnextchar@nospacebgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
ltx@ifnextchar@nospacebgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
trianglesABCDEFGHIJKL Large This shall not be part of the command
enddocument
where ltx@ifnextchar@nospace
does not skip space and prevent the text after the command to be interpreted as an "argument" of the command triangles
.
However, as stated in egreg's answer, this way of doing things should be avoided.
New contributor
The shoppinglist you're talking about is at Writing a LaTeX macro that takes a variable number of arguments.
You can adapt it quickly to work with any number of triangles. The case with one triangle is also handled in order to only display "Triangle" instead of "Triangles".
documentclass[11pt]article
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
@ifnextcharbgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
@ifnextcharbgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
enddocument
This is the result obtained:
EDIT
Following the comment by Ulrich Diez, an improved version of this command would be:
documentclass[11pt]article
usepackageltxcmds
makeatletter
newcommandtriangles[1]%
checknextarg#1
newcommandchecknextarg[1]%
ltx@ifnextchar@nospacebgroupTriangles $triangle #1$gobblenextargTriangle $triangle #1$
newcommandgobblenextarg[1]%
ltx@ifnextchar@nospacebgroup, $triangle #1$gobblenextarg and $triangle #1$
makeatother
begindocument
trianglesABC
trianglesABCDEF
trianglesABCDEFGHI
trianglesABCDEFGHIJKL
trianglesABCDEFGHIJKL Large This shall not be part of the command
enddocument
where ltx@ifnextchar@nospace
does not skip space and prevent the text after the command to be interpreted as an "argument" of the command triangles
.
However, as stated in egreg's answer, this way of doing things should be avoided.
New contributor
edited 8 hours ago
New contributor
answered 14 hours ago
KersouManKersouMan
1215
1215
New contributor
New contributor
1
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
– Ulrich Diez
9 hours ago
add a comment |
1
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
– Ulrich Diez
9 hours ago
1
1
What about
trianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?– Ulrich Diez
9 hours ago
What about
trianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?– Ulrich Diez
9 hours ago
add a comment |
Macros with a variable number of arguments are not the best thing to do with LaTeX; in your case it's simpler to use a comma separated list of triangles.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandtrianglesm
bart_triangles:n #1
seq_new:N l__bart_triangles_seq
tl_new:N l__bart_triangles_item_tl
cs_new_protected:Nn bart_triangles:n
seq_clear:N l__bart_triangles_seq
clist_map_variable:nNn #1 l__bart_triangles_item_tl
__bart_triangles_add:V l__bart_triangles_item_tl
triangle
int_compare:nF seq_count:N l__bart_triangles_seq < 2 s
nobreakspace
seq_use:Nnnn l__bart_triangles_seq ~and~ ,~ ~and~
cs_new_protected:Nn __bart_triangles_add:n
seq_put_right:Nn l__bart_triangles_seq $triangle #1$
cs_generate_variant:Nn __bart_triangles_add:n V
ExplSyntaxOff
begindocument
trianglesABC
trianglesABC,DEF
trianglesABC,DEF,GHI
enddocument
The comma separated list is mapped and each item is added to a sequence in the form $triangle<vertices>$
. Then the sequence is used, with the specified separators (between two, between more than two, between last two).
The “s” is added only if the list contains at least two items.
add a comment |
Macros with a variable number of arguments are not the best thing to do with LaTeX; in your case it's simpler to use a comma separated list of triangles.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandtrianglesm
bart_triangles:n #1
seq_new:N l__bart_triangles_seq
tl_new:N l__bart_triangles_item_tl
cs_new_protected:Nn bart_triangles:n
seq_clear:N l__bart_triangles_seq
clist_map_variable:nNn #1 l__bart_triangles_item_tl
__bart_triangles_add:V l__bart_triangles_item_tl
triangle
int_compare:nF seq_count:N l__bart_triangles_seq < 2 s
nobreakspace
seq_use:Nnnn l__bart_triangles_seq ~and~ ,~ ~and~
cs_new_protected:Nn __bart_triangles_add:n
seq_put_right:Nn l__bart_triangles_seq $triangle #1$
cs_generate_variant:Nn __bart_triangles_add:n V
ExplSyntaxOff
begindocument
trianglesABC
trianglesABC,DEF
trianglesABC,DEF,GHI
enddocument
The comma separated list is mapped and each item is added to a sequence in the form $triangle<vertices>$
. Then the sequence is used, with the specified separators (between two, between more than two, between last two).
The “s” is added only if the list contains at least two items.
add a comment |
Macros with a variable number of arguments are not the best thing to do with LaTeX; in your case it's simpler to use a comma separated list of triangles.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandtrianglesm
bart_triangles:n #1
seq_new:N l__bart_triangles_seq
tl_new:N l__bart_triangles_item_tl
cs_new_protected:Nn bart_triangles:n
seq_clear:N l__bart_triangles_seq
clist_map_variable:nNn #1 l__bart_triangles_item_tl
__bart_triangles_add:V l__bart_triangles_item_tl
triangle
int_compare:nF seq_count:N l__bart_triangles_seq < 2 s
nobreakspace
seq_use:Nnnn l__bart_triangles_seq ~and~ ,~ ~and~
cs_new_protected:Nn __bart_triangles_add:n
seq_put_right:Nn l__bart_triangles_seq $triangle #1$
cs_generate_variant:Nn __bart_triangles_add:n V
ExplSyntaxOff
begindocument
trianglesABC
trianglesABC,DEF
trianglesABC,DEF,GHI
enddocument
The comma separated list is mapped and each item is added to a sequence in the form $triangle<vertices>$
. Then the sequence is used, with the specified separators (between two, between more than two, between last two).
The “s” is added only if the list contains at least two items.
Macros with a variable number of arguments are not the best thing to do with LaTeX; in your case it's simpler to use a comma separated list of triangles.
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandtrianglesm
bart_triangles:n #1
seq_new:N l__bart_triangles_seq
tl_new:N l__bart_triangles_item_tl
cs_new_protected:Nn bart_triangles:n
seq_clear:N l__bart_triangles_seq
clist_map_variable:nNn #1 l__bart_triangles_item_tl
__bart_triangles_add:V l__bart_triangles_item_tl
triangle
int_compare:nF seq_count:N l__bart_triangles_seq < 2 s
nobreakspace
seq_use:Nnnn l__bart_triangles_seq ~and~ ,~ ~and~
cs_new_protected:Nn __bart_triangles_add:n
seq_put_right:Nn l__bart_triangles_seq $triangle #1$
cs_generate_variant:Nn __bart_triangles_add:n V
ExplSyntaxOff
begindocument
trianglesABC
trianglesABC,DEF
trianglesABC,DEF,GHI
enddocument
The comma separated list is mapped and each item is added to a sequence in the form $triangle<vertices>$
. Then the sequence is used, with the specified separators (between two, between more than two, between last two).
The “s” is added only if the list contains at least two items.
answered 14 hours ago
egregegreg
729k8819273240
729k8819273240
add a comment |
add a comment |
A listofitems
approach. Note: I was taught that for a list of more than 2 items, a comma precedes the "and".
documentclassarticle
usepackagelistofitems
newcommandtriangles[1]%
setsepchar,%
readlisttrilist#1%
foreachitemxintrilist[]%
$trianglex$%
ifnumnumexprxcnt+1<listlentrilist[]relax%
, %
else%
ifnumnumexprxcnt+1=listlentrilist[]relax%
ifnumlistlentrilist[]>2relax,fi
and %
fi
fi%
%
begindocument
Given trianglesABC.par
Given trianglesABC, DEF.par
Given trianglesABC, DEF,GHI.par
Given trianglesABC, DEF,GHI, JKL.par
enddocument
add a comment |
A listofitems
approach. Note: I was taught that for a list of more than 2 items, a comma precedes the "and".
documentclassarticle
usepackagelistofitems
newcommandtriangles[1]%
setsepchar,%
readlisttrilist#1%
foreachitemxintrilist[]%
$trianglex$%
ifnumnumexprxcnt+1<listlentrilist[]relax%
, %
else%
ifnumnumexprxcnt+1=listlentrilist[]relax%
ifnumlistlentrilist[]>2relax,fi
and %
fi
fi%
%
begindocument
Given trianglesABC.par
Given trianglesABC, DEF.par
Given trianglesABC, DEF,GHI.par
Given trianglesABC, DEF,GHI, JKL.par
enddocument
add a comment |
A listofitems
approach. Note: I was taught that for a list of more than 2 items, a comma precedes the "and".
documentclassarticle
usepackagelistofitems
newcommandtriangles[1]%
setsepchar,%
readlisttrilist#1%
foreachitemxintrilist[]%
$trianglex$%
ifnumnumexprxcnt+1<listlentrilist[]relax%
, %
else%
ifnumnumexprxcnt+1=listlentrilist[]relax%
ifnumlistlentrilist[]>2relax,fi
and %
fi
fi%
%
begindocument
Given trianglesABC.par
Given trianglesABC, DEF.par
Given trianglesABC, DEF,GHI.par
Given trianglesABC, DEF,GHI, JKL.par
enddocument
A listofitems
approach. Note: I was taught that for a list of more than 2 items, a comma precedes the "and".
documentclassarticle
usepackagelistofitems
newcommandtriangles[1]%
setsepchar,%
readlisttrilist#1%
foreachitemxintrilist[]%
$trianglex$%
ifnumnumexprxcnt+1<listlentrilist[]relax%
, %
else%
ifnumnumexprxcnt+1=listlentrilist[]relax%
ifnumlistlentrilist[]>2relax,fi
and %
fi
fi%
%
begindocument
Given trianglesABC.par
Given trianglesABC, DEF.par
Given trianglesABC, DEF,GHI.par
Given trianglesABC, DEF,GHI, JKL.par
enddocument
answered 2 hours ago
Steven B. SegletesSteven B. Segletes
159k9204413
159k9204413
add a comment |
add a comment |
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
For the sake of unambiguity regarding the question which brace groups belong to triangles
and which do not, I strongly recommend a syntax like trianglesABCDEFGHI
.
Or a syntax without brace-groups at all, as suggested by egreg, trianglesABC,DEF,GHI
The following example exhibits a romannumeral
-expansion-based way of implementing the trianglesABCDEFGHI
-syntax:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[2]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@PassFirstToSecondexpandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEF GHIpar
trianglesABC DEFpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
In case you wish a comma before the "and" when the list has more than two items:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[3]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@exchangeexpandafter%
romannumeral0UD@exchange expandafterexpandafterexpandafter
expandafterexpandafterexpandafterexpandafter%
expandafterUD@exchangeexpandafter%
romannumeral0%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1 %
UD@CheckWhetherBlank#2 ,%
%
expandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2#3 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEFpar
trianglesABC DEF GHIpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
add a comment |
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
For the sake of unambiguity regarding the question which brace groups belong to triangles
and which do not, I strongly recommend a syntax like trianglesABCDEFGHI
.
Or a syntax without brace-groups at all, as suggested by egreg, trianglesABC,DEF,GHI
The following example exhibits a romannumeral
-expansion-based way of implementing the trianglesABCDEFGHI
-syntax:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[2]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@PassFirstToSecondexpandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEF GHIpar
trianglesABC DEFpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
In case you wish a comma before the "and" when the list has more than two items:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[3]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@exchangeexpandafter%
romannumeral0UD@exchange expandafterexpandafterexpandafter
expandafterexpandafterexpandafterexpandafter%
expandafterUD@exchangeexpandafter%
romannumeral0%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1 %
UD@CheckWhetherBlank#2 ,%
%
expandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2#3 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEFpar
trianglesABC DEF GHIpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
add a comment |
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
For the sake of unambiguity regarding the question which brace groups belong to triangles
and which do not, I strongly recommend a syntax like trianglesABCDEFGHI
.
Or a syntax without brace-groups at all, as suggested by egreg, trianglesABC,DEF,GHI
The following example exhibits a romannumeral
-expansion-based way of implementing the trianglesABCDEFGHI
-syntax:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[2]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@PassFirstToSecondexpandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEF GHIpar
trianglesABC DEFpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
In case you wish a comma before the "and" when the list has more than two items:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[3]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@exchangeexpandafter%
romannumeral0UD@exchange expandafterexpandafterexpandafter
expandafterexpandafterexpandafterexpandafter%
expandafterUD@exchangeexpandafter%
romannumeral0%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1 %
UD@CheckWhetherBlank#2 ,%
%
expandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2#3 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEFpar
trianglesABC DEF GHIpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
What abouttrianglesABCDEFGHIJKL large This shall not be part of the triangle-command
?
For the sake of unambiguity regarding the question which brace groups belong to triangles
and which do not, I strongly recommend a syntax like trianglesABCDEFGHI
.
Or a syntax without brace-groups at all, as suggested by egreg, trianglesABC,DEF,GHI
The following example exhibits a romannumeral
-expansion-based way of implementing the trianglesABCDEFGHI
-syntax:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[2]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@PassFirstToSecondexpandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEF GHIpar
trianglesABC DEFpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
In case you wish a comma before the "and" when the list has more than two items:
documentclassarticle
makeatletter
%%----------------------------------------------------------------------
newcommandUD@gobble[1]%
newcommandUD@firstoftwo[2]#1%
newcommandUD@secondoftwo[2]#2%
newcommandUD@exchange[2]#2#1%
newcommandUD@PassFirstToSecond[2]#2#1%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%.............................................................................
%% UD@ExtractFirstArgABCDE yields A
%%
%% UD@ExtractFirstArgABCDE yields AB
%%
%% !!! The argument of UD@ExtractFirstArg must not be empty. !!!
%% You can check for emptiness via UD@CheckWhetherNull before applying
%% UD@ExtractFirstArg.
%% The argument of UD@ExtractFirstArg may contain the token UD@SelDOm.
%%
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm#1%
newcommandUD@ExtractFirstArg[1]%
romannumeral0%
UD@ExtractFirstArgLoop#1UD@SelDOm%
%
newcommandUD@ExtractFirstArgLoop[1]%
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1%
UD@exchange#1 %
expandafterUD@ExtractFirstArgLoopexpandafterUD@RemoveTillUD@SelDOm#1%
%
%%----------------------------------------------------------------------
%% Check whether argument is empty:
%%......................................................................
%% UD@CheckWhetherNull<Argument which is to be checked>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is empty>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not empty>%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]%
romannumeral0expandafterUD@secondoftwostringexpandafter
UD@secondoftwoexpandafterexpandafterstring#1expandafter
UD@secondoftwostringexpandafterUD@firstoftwoexpandafterexpandafter
UD@secondoftwostringexpandafterexpandafterUD@firstoftwo %
UD@secondoftwoexpandafterexpandafterUD@firstoftwo UD@firstoftwo%
%
%%------------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%..............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank<Argument which is to be checked>%
%% <Tokens to be delivered in case that
%% argument which is to be checked is blank>%
%% <Tokens to be delivered in case that argument
%% which is to be checked is not blank%
newcommandUD@CheckWhetherBlank[1]%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafterUD@firstoftwo#1.%
%
%%------------------------------------------------------------------------------
%% The triangles-list:
%%..............................................................................
newcommandtriangles[1]%
romannumeral0UD@CheckWhetherBlank#1 no triangletriangleloop#1%
%
newcommandtriangleloop[3]%
UD@CheckWhetherBlank#1 #2%
expandafterUD@exchangeexpandafter%
romannumeral0UD@exchange expandafterexpandafterexpandafter
expandafterexpandafterexpandafterexpandafter%
expandafterUD@exchangeexpandafter%
romannumeral0%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1 %
UD@CheckWhetherBlank#2 ,%
%
expandafter%
romannumeral0expandafterUD@exchangeexpandafter
%
romannumeral0expandafterexpandafterexpandafterUD@exchange
expandafterexpandafterexpandafterUD@ExtractFirstArg#1$ $triangle%
%
expandafterUD@CheckWhetherBlankexpandafterUD@gobble#1%
UD@CheckWhetherBlank#2 triangle triangles #2#3 and %
%
UD@CheckWhetherBlank#2 #2, %
%
%
%
%
expandaftertriangleloopexpandafterUD@gobble#1%
%
%
%
makeatother
begindocument
trianglespar
trianglesABCpar
trianglesABC DEFpar
trianglesABC DEF GHIpar
trianglesABC DEF GHI JKLpar
expandafterexpandafterexpandafterdef
expandafterexpandafterexpandafterThisTrianglelist
expandafterexpandafterexpandafter%
trianglesABC DEF GHI JKL%
%
textttstringThisTrianglelist=meaningThisTrianglelist
enddocument
edited 48 mins ago
answered 2 hours ago
Ulrich DiezUlrich Diez
5,520620
5,520620
add a comment |
add a comment |
Bart is a new contributor. Be nice, and check out our Code of Conduct.
Bart is a new contributor. Be nice, and check out our Code of Conduct.
Bart is a new contributor. Be nice, and check out our Code of Conduct.
Bart is a new contributor. Be nice, and check out our Code of Conduct.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481707%2fa-command-with-a-variable-number-of-arguments-comma-versus-and%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
For the sake of unambiguity regarding the question which brace groups belong to
triangles
and which do not, I strongly recommend a syntax liketrianglesABCDEFGHI
. Or a syntax without brace-groups at all, as suggested by egreg,trianglesABC,DEF,GHI
.– Ulrich Diez
9 hours ago