# How to define an environment that takes a number of arguments and produces a table

What is the best way to create an environment that takes a number of arguments, like this:

\finding{%
Text argument #1,
Text argument #2,
Text argument #3,
Text argument #4}


and produces something like this:

\documentclass[11pt,letterpaper]{article}

\begin{document}
\begin{table}
\begin{tabular}{|l|l|}
\multicolumn{1}{l}{\textbf{Finding \foo}} \\
\hline
\textbf{Synopsis:}  & \textbf{Text argument \#1} \\
\hline
Recommendation:     & Text argument \#2 \\
\hline
Comments:           & Text argument \#3 \\
\hline
Risk value          & Text argument \#4 \\
\hline
\end{tabular}
\end{table}
\end{document}


Where \foo is a custom stepcounter defined by

\newcounter{bar}
\newcommand{\foo}{%
\stepcounter{bar}%
\thebar}

-
Are you sure you want that syntax for \finding? What if a "text argument" contains a comma? \finding{Text argument #1}{Text argument #2}{Text argument #3}{Text argument #4} would be easier to set up and less ambiguous. And how would you specify a caption? –  Jubobs Aug 6 '14 at 23:20
Good point. Your suggestion is better. For this table, I do not want a caption. –  Martin Clouthier Aug 6 '14 at 23:25
Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. –  Jubobs Aug 6 '14 at 23:32

Specifying the four arguments as a comma-separated list is probably not a good idea: what if an argument contains a comma? Using the regular TeX syntax for passing arguments is preferable.

Note that \tn is defined nowhere in your code snippet; I substituted \\ for every occurence of it.

\documentclass[12pt]{article}

\newcommand\finding[4]{%
\begin{table}
\begin{tabular}{|l|l|}
\multicolumn{1}{l}{\textbf{Finding AUTOMATIC\_COUNTER}} \\
\hline
\textbf{Synopsis:}  & \textbf{#1} \\
\hline
Recommendation:     & #2 \\
\hline
\hline
Risk value          & #4 \\
\hline
\end{tabular}
\end{table}
}

\begin{document}
\finding
{one}
{two}
{three}
{four}
\end{document}

-