# Coding a *short* newcommand with a variable number of arguments for a very specific use-case

Is it possible to create a simple, robust command with a variable number of arguments for the following specific use-case ?

Consider

\newcommand{\bigmap}[7]{%
#1\!\begin{pmatrix}#2\\
#3\\
#4
\end{pmatrix}=\begin{pmatrix}#5\\
#6\\
#7
\end{pmatrix}\!
}%


What \bigmap{F}{a_{1}}{a_{2}}{a_{3}}{b_{1}}{b_{2}}{b_{3}} does is, it creates a map

But I would like this command dto be flexibel, so that I may add more or less a_i and/or b_i, like

(Nota bene: For that, of course, it one more argument would be necessary that specifies in the sequence of arguments #1, #2, ... #N, which one belong to the left parenthesis of the function and which ones to the right.
The existing answers to allow commands with variable arguments are much too complex for me to understang as they refer to much more complicated use cases. If possible, I would like less lines of code than those answers to achieve this goal.
The answer from LaTeX newcommand with a variable number of arguments is very close to what I want, but unfortunately it falls short of a way to tell the command, like I mentioned in the first paragraph here, which of the arguments of the list should go where in the function.
Also note that solution like LuaTex would only be employed, if nothing else works.)

)

• Erh, that macro only needs 3 args if done slightly different. {F} {a\\b\\c} {d\\e}  I'll leave the details to you – daleif Sep 25 '16 at 18:49

Does the following solution meet your expectations for simplicity and flexibility? :-)

Instead of thinking of each row of each of the two column vectors being a separate argument, you may want to think of each entire vector as being one of the arguments of the macro \bigmap. That way, the macro \bigmap may be defined as having exactly 3 arguments.

\documentclass{article}
\usepackage{amsmath} % for 'pmatrix' environment
\newcommand{\bigmap}[3]{#1\!
\begin{pmatrix}#2\end{pmatrix}=\begin{pmatrix}#3\end{pmatrix}}
\begin{document}

$\bigmap{F}{a_1\\a_2\\a_3}{b_1\\b_2\\b_3}$

$\bigmap{G}{c_1\\c_2\\c_3\\c_4}{d_1\\d_2\\d_3\\d_4\\d_5}$
\end{document}

• It was simpler to delete my answer than to produce also a screenshot. And you are in need of reputation points anyway ;-) I just moved my introductory sentence to your post; feel free to delete it. – gernot Sep 25 '16 at 18:58