# Creating a newcommand with indefinite arguments


\documentclass{article}

\usepackage{lmodern}
\usepackage[T1]{fontenc}

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage[norsk]{babel}

\titleformat{\section}{\LARGE\filcenter}{}{1em}{}
\setlength{\jot}{14pt}

\author{Sami Rashiti}

\newcommand{\degree}[2]{#1\,^{\circ}\ \mathrm{#2}}

\begin{document}

\maketitle
\newpage

\section*{Innlevering 1}
\input{innleveringer/innlevering1.tex}
~\newline

\begin{align}
e_n &= \sqrt{4KTBR}                                                                     \\
e_n^2 &= 4KTBR                                                                          \\
R &= \frac{e_n^2}{4KTB}                                                                 \\
&= \frac{(\frac{V_o}{A})^2}{4KTB} \qquad ,der \quad e_n = \frac{V_o}{A} = 3,2\mu V    \\
&= \frac{(3.2\mu V)^2}{4\cdot1.38\cdot 10^{-23}\cdot 310\cdot   100\cdot 10^3}        \\
&= 6\ k\Omega
\end{align}

\end{document}


You can use a list; here's an example using etoolbox and borrowing the idea for the first item in the list used by Werner in his answer to Iterating through comma-separated arguments:

\documentclass{article}
\usepackage{etoolbox}

\newcommand\Multiply[2][\cdot]{%
\def\nextitem{\def\nextitem{#1}}% Separator
\renewcommand*\do[1]{\nextitem##1}% How to process each item
\docsvlist{#2}% Process list
}
\begin{document}

$\Multiply[\times]{4,1.38\cdot 10^{-23},310,100,10^3}\qquad \Multiply{a,b,c,d,e,f,g,h,i,j,k,l,m,n}$

\end{document}


It's a breeze with xparse and expl3. Separate the items by a comma and that's all.

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand\Multiply{O{\cdot}m}
{
\seq_set_split:Nnn \l_tmpa_seq { , } { #2 } % split the input at commas
\seq_use:Nn \l_tmpa_seq { #1 }              % put #1 between items
}
\ExplSyntaxOff

\begin{document}

$\Multiply[\times]{4,1.38\cdot 10^{-23},310,100,10^3}$

$\Multiply{a,b,c,d,e,f,g,h,i,j,k,l,m,n}$

\end{document}


• Note that, differently from the other answers, this method removes spaces around the items. So with this method, inputting \Multiply{ a , b} is equivalent to inputting \Multiply{a,b}. It's not relevant in this case, because the macro works in math mode, but it can be very important in case of a macro used in normal text. – egreg Mar 9 '15 at 8:55

The common method how to deal more arguments at TeX primitive level is:

\def\Multiply#1{\MultiplyA#1,,}
\def\MultiplyA#1,{#1\MultiplyB}
\def\MultiplyB#1,{\ifx,#1,\else\cdot#1\expandafter\MultiplyB\fi}

$$\Multiply{a,b,c,d,e,f,g,h,i,j,k,l,m,n}$$

\end