Question: Some very nice people here helped me write the code snippet below. And the code works great
it prints out the correct subtext, and have a optional argument by typing `*` 

```
\documentclass[10pt,a4paper]{article}
\newcounter{problem}
\setcounter{problem}{0}
\newcounter{alternative}
\setcounter{alternative}{0}
\newif\iffirstalt
\usepackage{xparse}

\NewDocumentCommand{\Oppgave}{s m}{%
  \IfBooleanTF{#1}%
     {\stepcounter{alternative}\iffirstalt\else\stepcounter{problem}\firstalttrue\fi}%
     {\setcounter{alternative}{0}\stepcounter{problem}\firstaltfalse}%
  \section*{Oppgave \arabic{problem}%
             {\normalfont\IfBooleanTF{#1}{~Alternative \Roman{alternative}\ }{}
                \normalsize (#2 poeng)}%
   \addcontentsline{toc}{section}{Oppgave \arabic{problem} }} 
}
\begin{document}

\tableofcontents

\oppgaveS{3}

\oppgaveS{4}

\oppgaveS*{2}

\oppgaveS*{2}

\oppgaveS{3}

\oppgaveS*{2}

\end{document}    

```

Is there any possibility to add zero optional inputs? I mean so that i can write 

```
\Oppgave and \Oppgave*

```

To be displayed as

**Oppgave 1** and **Oppgave 1 Alternativ 1**

I just want to have no small text, if I just plainly write the command =)

Answer: 
Here is an example with default TeX syntax and without the xparse package which is already more for package developers than for users with local macros:

```
\documentclass[10pt,a4paper]{article}
\newcounter{problem}
\newcounter{alternative}
\newif\iffirstalt

\makeatletter
\def\Oppgave{\@ifnextchar*{\Oppgave@i}{\Oppgave@ii}}
\def\Oppgave@i*{\@ifnextchar\bgroup{\Oppgave@iii}{\Oppgave*{1}}}
\def\Oppgave@ii{\@ifnextchar\bgroup{\Oppgave@iv}{\Oppgave{1}}}
\def\Oppgave@iii#1{%
  \setcounter{alternative}{0}\stepcounter{problem}\firstaltfalse
  \section*{Oppgave \arabic{problem}%
             \normalfont~Alternative \Roman{alternative}\ \normalsize (#1 poeng)}%
   \addcontentsline{toc}{section}{Oppgave \arabic{problem} }} 
\def\Oppgave@iv#1{\stepcounter{alternative}\iffirstalt\else\stepcounter{problem}\firstalttrue\fi
  \section*{Oppgave \arabic{problem} \normalsize (#1 poeng)}%
   \addcontentsline{toc}{section}{Oppgave \arabic{problem} }} 
\makeatletter
\begin{document}
\tableofcontents

\Oppgave{3}    
\Oppgave{4}
\Oppgave*{2}
\Oppgave*{2}
\Oppgave{3}
\Oppgave*{2}
\Oppgave
\Oppgave*
\end{document}  

```

![enter image description here](https://i.stack.imgur.com/ryknd.png)
You can declare the argument as optional by changing the first line of the definition into

```
\NewDocumentCommand{\Oppgave}{s g}{%

```

You have to change also `\normalsize (#2 poeng)` into

```
\IfNoValueTF{#2}{}{\ \normalsize (#2 poeng)}

```

deleting `\` (control space) in the line before.

On the other hand it would be clearer if you adopted the syntax

```
\Oppgave*[n]

```

(simply change the "g" in the argument to `\NewDocumentCommand` to an "o").

```
\NewDocumentCommand{\oppgaveS}{s g}{% Put o instead of g for clearer syntax
  \IfBooleanTF{#1}%
   {\stepcounter{alternative}\iffirstalt\else\stepcounter{problem}\firstalttrue\fi}%
   {\setcounter{alternative}{0}\stepcounter{problem}\firstaltfalse}%
  \section*{Oppgave~\arabic{problem}%
    {\normalfont\IfBooleanTF{#1}{\ Alternative \Roman{alternative}}{}}%
                \IfNoValueTF{#2}{}{\ \normalfont\normalsize (#2 poeng)}}%
   \addcontentsline{toc}{section}{Oppgave~\arabic{problem}} 
}  

```