# Help with \newenvironment

I am trying to make a new environment that looks like this:

\documentclass{article}
\usepackage{fontspec}
\usepackage{multicol}

\setlength{\columnseprule}{1pt}
\def\columnseprulecolor{\color{black}}

\newenvironment{program}{
\newcommand{\innslag}[3]{ \item{\textbf{##1} / \emph{##2} // ##3\} }
\begin{multicols}[2]{
\begin{description}
}
{
\end{description}
}
\end{multicols}
}

\begin{document}

\begin{program}
\innslag{test1}{test}{test}
...etc
\end{program}

\end{document}


to re-produce this:

\documentclass{article}
\usepackage{fontspec}
\usepackage{multicol}

\setlength{\columnseprule}{1pt}
\def\columnseprulecolor{\color{black}}

\begin{document}

\begin{multicols}{2}
\begin{description}
\end{description}
\end{multicols}

\end{document}


which should look like this:

But my LaTeX-Fu isn't there quite yet so i cant get my enviroment to work. What am i doing wrong?

It's difficult to list all errors you make. ;-)

\documentclass{article}
\usepackage{multicol}

\setlength{\columnseprule}{1pt}

\newenvironment{program}
{% begin part
\newcommand{\innslag}[3]{\item \textbf{##1} (\emph{##2})\\##3}%
\begin{multicols}{2}
\begin{description}
}
{% end part
\end{description}
\end{multicols}
}

\begin{document}

\begin{program}
\innslag{test1}{test}{test}
\innslag{test1}{test}{test}
\innslag{test1}{test}{test}
\innslag{test1}{test}{test}
\innslag{test1}{test}{test}
\innslag{test1}{test}{test}
\innslag{test1}{test}{test}
\innslag{test1}{test}{test}
\end{program}

\end{document}


Actually, I'm not sure why defining \innslag only inside the environment, but it's a possible stylistic choice.

Where did you go wrong?

1. \item doesn't take an argument.

2. \item{\textbf{##1} / \emph{##2} // ##3\} has an unwanted slash and an unwanted double slash; moreover \} doesn't balance the opening brace.

3. \begin{multicols}[2] is wrong: the number of columns is a mandatory argument

4. Opening a brace after \begin{multicols}{2} (after fixing the previous error) is wrong: multicols is an environment, so it doesn't take the text to be typeset in multiple columns as an argument.

• Many thanks. Constructive and educational. It makes sense when seeing the correct way to do it. What did you mean about defining '\innslag' only inside the environment? – Buschmann Nov 29 '16 at 16:06
• @Buschmann Don't you have \newcommand inside the “begin part”? The \innslag command will be undefined outside the program environment. – egreg Nov 29 '16 at 16:07
• This is true. Would it be better to define it outside as well? – Buschmann Nov 29 '16 at 16:09
• @Buschmann I see no problem in having it only available inside the environment, although I'd probably use a different strategy. Not a big deal, though. – egreg Nov 29 '16 at 16:15
• When my chops advance perhaps I'll learn to do things more efficient. For now this will do the job. Thanks! – Buschmann Nov 29 '16 at 16:16