Pass optional empty arguments in a newcommand down to another command with optional empty arguments in LaTeX

macrosoptional arguments

I would like to define a newcommand with two optional arguments, which in turn, calls on another command with two optional arguments.

Something like the following (\B calls \A). How do I do it?

\newcommand{A}[3][][]{{#1 + #2 + #3}}
\newcommand{B}[3][][]{#1 + \A[#2][#3]{#1}}

\B{9}
\B[1][]{9}
\B[][3]{9}
\B[1][3]{9}

EDIT

I tried to give a similar MWE, but I am afraid that the above example actually may not properly convey exactly what I need.

The reason I had this question is to create a command that takes in a certain bib-item and highlights it. I would like to pass two optional arguments to \parencite[pre][post]{#1} (where pre and post could be empty) via a newcommand \hlcite[pre][post]{#1}. The command \hlcite would then highlight the references.

\usepackage{graphicx, color}
\usepackage[dvipsnames]{xcolor}
\usepackage{bookmark}
\usepackage[
    backend=biber,          % backend: biber
    style=authoryear,       % style: numeric-comp, authoryear
    sorting=ynt,            % sorting: none, ynt
]{biblatex}
\usepackage{soul} 
\newcommand{\hlc}[2][yellow]{\sethlcolor{#1} \hl{#2}}
%% This works
\newcommand{\hlcite}[1]{\colorbox[green]{\mbox{\parencite{#1}}}}
%% But this throws error
\newcommand{\hlcite}[3]{\hlc[green]{\mbox{\parencite[#2][#3]{#1}}}}

References

Adding optional arguments

Non-stackoverflow/stackexchange links:

Using if conditional in latex:

References to use \mbox with \cite or \parencite inside \newcommand for highlighting.

Highlighting text in Latex:

Best Answer

You can use \NewDocumentCommand.

\NewDocumentCommand{\hlc}{O{yellow}m}{\sethlcolor{#1}\hl{#2}}

\NewDocumentCommand{\hlcite}{oom}{%
  \hlc[green]{%
    \IfNoValueTF{#1}{% no optional argument
      \parencite{#3}%
    }{%
      \IfNoValueTF{#2}{% just one optional argument
        \parencite[#1]{#3}%
      }{% both optional arguments
        \parencite[#1][#2]{#3}%
      }%
    }%
  }% end of \hlc
}

Note that you don't want a space between \sethlcolor{#1} ad \hl{#2}.

Related Question