[Tex/LaTex] How to make a list with variable parameter size inside of a custom environment

argumentsenvironmentsitemizeoptional argumentstemplates

I have a custom environment that I am using as part of a template. Right now this is the code for the template file.

%-----------------------------------------------------------
%    customtemplate.cls
%-----------------------------------------------------------

\setlength{\tabcolsep}{0pt}

% New environment for the long list
\newenvironment{twenty}{%
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ll}}{%
    \end{tabular*}
}

\newcommand{\twentyitem}[3]{%
    \parbox[t]{\textwidth}{%
        \textbf{#2}%
        \hfill%
        #1\\%
        #3\vspace{\parsep}%
   }\\
}

In a .tex file the command is called like so:

%-----------------------------------------------------------
%    somefile.tex
%-----------------------------------------------------------

\begin{twenty}
    \twentyitem{2013}{This is an example}{lorem ipsum etc\ldots}
\end{twenty}

gives this output:

enter image description here

The behavior I would like is this, where I can have as many or as little arguments as I want, with the condition that the first 3 are required. "meaning there needs to be at least one item in the list"

%-----------------------------------------------------------
%    somefile.tex
%-----------------------------------------------------------

\begin{twenty}
    \twentyitem{2013}{This is an example}{lorem ipsum etc\ldots}{as}{many}{as}{possible}
\end{twenty}

enter image description here

I made an attempt at putting an itemize in the template code but was unable to figure out how to make a variable number of arguments with the precondition that there must be at least 3. None of what I tried would actually compile.

Any help would be appreciated.

Best Answer

I'm guessing at what the OP really wants, but am convinced, regardless, that nested environments are preferable to long-argument macros, for what he wants.

\documentclass{article}
\usepackage{enumitem,lipsum}
\newenvironment{twenty}{
  \noindent\hrulefill The Twenty Environment\hrulefill
  \begin{itemize}[itemindent=1em,label={}]}{
  \end{itemize}
  \hrulefill End of The Twenty Environment\hrulefill
}
\newenvironment{twentyitem}[2]{
  \item #2\hfill#1\begin{itemize}}{\end{itemize}}
\begin{document}
\lipsum[1]
\begin{twenty}
\begin{twentyitem}{2013}{This is an example}
\item Blah
\item blah blah
\item lah blah blah
\end{twentyitem}
\begin{twentyitem}{2014}{This is a second example}
\item Blah
\item blah blah
\item lah blah blah
\end{twentyitem}
\end{twenty}
\end{document}

enter image description here

Related Question