[Tex/LaTex] Conditional formatting in \newcommand

conditionals

I'm using the following from a dictionary template:

\newcommand{\entry}[4]{\framebox(7,7){}\hspace{.75em}\markboth{#1}{#1}\textbf{#1}\ {(#2)}\ \textit{#3}\ $\bullet$\ {#4}}

\entry{Purfling}{pur-fling}{Guitar Part}{Definition}

\entry{Neck}{}{}{Definition}

Produces

Purfling (pur-fling) Guitar Part * Definition

Neck () * Definition

I'd like the second element (the parenthesis) to appear only if there is text inside it:

Purfling (pur-fling) Guitar Part * Definition

Neck * Definition

Best Answer

If arguments 2 and/or 3 are blank, they are omitted, along with the space that follows.

\documentclass{article}
\newcommand{\entry}[4]{\framebox(7,7){}\hspace{.75em}\markboth{#1}{#1}\textbf{#1}\ %
  \ifx\relax#2\relax\else{(#2)}\ \fi%
  \ifx\relax#3\relax\else\textit{#3}\ \fi%
  $\bullet$\ {#4}}
\begin{document}
\entry{Purfling}{pur-fling}{Guitar Part}{Definition}

\entry{Neck}{}{}{Definition}
\end{document}

enter image description here

Related Question