# How to define a \newenvironment more than 9 parameters?

I want to define the following new environment with 10 parameters, as you see, the 10-th param is not availble! How to?

\newenvironment{newenv}[10]{
\begin{center}
\begin{tabular}{|m{2cm}<{\centering}|m{2cm}<{\centering}|m{2cm}<{\centering}|m{2cm}<{\centering}|m{2cm}<{\centering}|m{2cm}<{\centering}|}
\hline
Name       &{#1}              &{#3}              &{#5}          &{#7}          &{#9}   \\
\hline
EN-Name   &{#2}              &{#4}              &{#6}         &{#8}          &{#10}   \\
\hline
File-Name     &{#2}.in           &{#4}.in           &{#6}.in       &{#8}.in       &{#10}  \\
\hline
Out-Name     &{#2}.out          &{#4}.out          &{#6}.out      &{#8}.out      &{#10}  \\
\hline
}{
\end{tabular}
\end{center}
}

• Have a look at tex.stackexchange.com/q/2132/35864, texfaq.org/FAQ-moren9. The usual sentiment is that 10 arguments is probably too much and that a key-value approach could be a better fit. – moewe Jul 6 '18 at 7:36
• are you sure you want m{2cm}<{\centering\arraybackslash} not >{\centering\arraybackslash}m{2cm} putting \centering at the end sort of works in some cases but makes the behaviour of blank lines rather odd, any text before a blank line won't be centred. (even though in this case you are constructing the whole table so there are no blank lines, unless you add them in the arguments) – David Carlisle Jul 6 '18 at 7:41

Your environment looks merely like a command as there is no meaningful use for the content of the environment.

Nevertheless if you have a more practical use of this, I suggest to provide arguments as a single list, using list processing of package listofitems (those from etoolbox are an alternative option but more difficult to handle).

Here is a MWE (with 13 "arguments"):

\documentclass{article}
\usepackage{listofitems}

\newenvironment{newenv}[1]{
\setsepchar{, }
\begin{center}
\begin{tabular}{|*{6}{c|}}
\hline
Name        & \args[1]    & \args[3]    & \args[5]    & \args[7]    & \args[9]     \\
\hline
EN-Name     & \args[2]    & \args[4]    & \args[6]    & \args[8]    & \args[10]    \\
\hline
File-Name   & \args[2].in & \args[4].in & \args[6].in & \args[8].in & \args[10].in \\
\hline
Out-Name    &\args[2].out &\args[4].out &\args[6].out &\args[8].out &\args[10].out \\
\hline
}{
\end{tabular}
\end{center}
}

\begin{document}

\begin{newenv}{zero, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve}
Digit &1 & 2 & 3 & 4 & 5 \\
\hline
\end{newenv}

\end{document}


that produces:

Here's a fairly general method for defining commands with as many arguments you like, provided these arguments are given as a comma separated list:

\documentclass{article}
\usepackage{array}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\newlistcommand}{mm}
{
\NewDocumentCommand{#1}{m}
{
\clist_set:Nn \l_xaero_args_clist { ##1 }
#2
}
}
\NewExpandableDocumentCommand{\argx}{m}
{
\clist_item:Nn \l_xaero_args_clist { #1 }
}
\ExplSyntaxOff

\newlistcommand{\mytabular}{%
\begin{center}
\begin{tabular}{|*{6}{>{\centering\arraybackslash}p{2cm}|}}
\hline
Name      &\argx{1}     &\argx{3}     &\argx{5}     &\argx{7}     &\argx{9}  \\
\hline
EN-Name   &\argx{2}     &\argx{4}     &\argx{6}     &\argx{8}     &\argx{10} \\
\hline
File-Name &\argx{2}.in  &\argx{4}.in  &\argx{6}.in  &\argx{8}.in  &\argx{10} \\
\hline
Out-Name  &\argx{2}.out &\argx{4}.out &\argx{6}.out &\argx{8}.out &\argx{10} \\
\hline
\end{tabular}
\end{center}
}

\begin{document}

\mytabular{one,two,three,four,five,six,seven,eight,nine,ten}

\end{document}


You see that \argx{n} is used instead of #n in the definition of \mylistcommand.

This could be generalized if you plan to nest commands defined with \newlistcommand, which is not possible with this definition.