# How to create a new command with a variable number of arguments?

I've been trying to play around with LaTeX to create a class for my CV template and I would like to use itemize as an input argument but I haven't been able to make it work. So far this is what I've got in the cvdoc.cls:

\newcommand{\cvitem}[1]{\begin{itemize}
\end{itemize}}


And in the cv.tex file I've written this:

\cvitem{\item thing 1
\item thing 2
\item thing 3}


In the final command there will be more input as in date, information, location, this would be for the description .

Also keep in mind i am very new in latex

• Welcome! Try \newcommand{\cvitem}[1]{\begin{itemize} #1 \end{itemize}}. But this is really not a good idea. It will just make your code much more opaque and harder to maintain for essentially no benefit at all. – cfr Oct 8 '16 at 1:23
• I agree with cfr here (especially about the advice not to do it), and am only commenting because of the 'i am very new' caveat. The type of 'command' you are seeking is only taking one argument. A classical and basic LaTeX command with two arguments would be in the form of \command{<arg 1>}{<arg 2>}. – jon Oct 8 '16 at 1:58
• What would you guys recommend then? Cause I would really like to add bullet points for the description. – RenéB Oct 8 '16 at 2:19
• Also there is a maximun number of arguments allowed (8 or 9 IIRC). – John Kormylo Oct 8 '16 at 3:18
• if you want an itemized list use \begin{itemize} making it into a command does not change the formatting in any way, it just obfuscates the source file. – David Carlisle Oct 8 '16 at 9:42

So i found how to fix my problem this is my new command, the part with the tabular is right before #4

    \newcommand{\cvitem}[4]{\vspace{1mm}%
#1&\parbox[t]{0.83\textwidth}{%
\textbf{#2}%
\hfill%
{\footnotesize#3}\\%
\vspace{-5mm}{\begin{itemize}[noitemsep,topsep=0pt,leftmargin=*] #4 %\vspace
\end{itemize}}%
}\\
}


the way to use it is like so:

    \cvitem{1863-1865}{M.Sc. magna cum laude}{Wonderland}{\item Majoring in Computer Science \item Minor in aerospace}


works really well

• There are far too many CV templates out there, and most are terrible. Your definition looks mighty close to a bunch of badly designed CV templates. I cannot upvote this answer. – Johannes_B Oct 10 '16 at 6:51
• well i am new in latex and pretty much only learn off templates so this is the best I can do. If you have a recommendation I would love to see it in order to expand my knowledge of good LaTeX. – RenéB Jan 30 '17 at 23:09
• Have a look for LaTeX for complete novices a free ebook. Learning from templates is pretty much the worst you can do. – Johannes_B Jan 31 '17 at 5:51