Answer by tim for newcommand with comma separated argument, and optional...
Another solution using LuaLatex:\documentclass{article}\usepackage{fontspec}\usepackage{luacode}\newcommand{\mycmd}[2][]{%\luadirect{ oargs = \luastring{#1} if oargs \string~= "" then...
View ArticleAnswer by egreg for newcommand with comma separated argument, and optional...
A variant of jon's answer, where the original setup is used. It's mainly for showing how expl3 makes things easy.I'll assume you want to separate the prefix the optional arguments by “Optional:”, then...
View ArticleAnswer by Ruben for newcommand with comma separated argument, and optional...
This solution works with two light-weight comma parsers defined in the solution itself (\p@rse@csl@opt and \p@rse@csl@mnd). What is executed on the parsed arguments is layed out to \domycmdopt and...
View ArticleAnswer by tim for newcommand with comma separated argument, and optional...
If the number of arguments is not known, one can use pgfkeys for something like this:\documentclass{article}\usepackage{pgfkeys,pgffor}\newcounter{mainargs}\pgfkeys{mainargs/.is family, mainargs,step...
View ArticleAnswer by wipet for newcommand with comma separated argument, and optional...
If you know exact number of arguments, then simple \def with comma separated arguments is sufficient and you can denote the parameters by #1, #2, etc. in macro body. If the exact number of argument...
View ArticleAnswer by jon for newcommand with comma separated argument, and optional...
Perhaps something like this? I used 'bold' formatting as an arbitrary choice to help show which parts are from the command and which parts from the input to \mycmd. \documentclass{article}\parindent...
View ArticleAnswer by Heiko Oberdiek for newcommand with comma separated argument, and...
The following example uses \comma@parse of package kvsetkeys to parse the comma separated argument lists.\documentclass{report}\usepackage{kvsetkeys}% provides \comma@parse\usepackage{etexcmds}%...
View Articlenewcommand with comma separated argument, and optional arguments
I want to define a command (not with \def) the simplest possible way that ittakes arguments separated by a comma,supports an optional argument (the first one).maybe another solution with extra optional...
View Article