[Tex/LaTex] How to create two commands with the same name but different number of parameters


I want to define a command with the same name, but a different number of parameters.

I'm considering something like this:



\newcommand{\quelle}[1]{\textit{(Quelle: \url{#1})})}
\newcommand{\quelle}[2]{\textit{(Quelle: \url{#1} Absatz: #2)})}


    Test: \quelle{www.wikipedia.de}
    Test: \quelle{www.wikipedia.de, sometext}


If I try to compile this, I get the following result:

Command \quelle already defined. ...2]{\textit{(Quelle: \url{#1} Absatz: #2)})}

Thank you for your help!

Best Answer

The only change from the requested syntax is to use a ! as the separator between the http reference and "sometext", as I figured a comma , was much more likely to appear as part of "sometext:.

  (\textit{Quelle: \url{\qarg[1]}}%
  \ifnum\listlen\qarg[]>1\relax\textit{ Absatz: \qarg[2]}\fi%
    Test: \quelle{www.wikipedia.de}
    Test: \quelle{www.wikipedia.de! sometext}

enter image description here