

\newcommand{\defTerm}[3]{%
\expandafter\newcommand\csname #1\endcsname[1][]{%
\ifthenelse{\equal{#***}{}}%
{\textbf{\tooltip{#2}{\begin{varwidth}{10cm}#3\end{varwidth}}}}%
{\textbf{\tooltip{#***}{\begin{varwidth}{10cm}#3\end{varwidth}}}}%
}%
}


An example usage of this is:

\defTerm{ETNZ}{Emirates Team New Zealand}{The winner of the 35th America's Cup}


then in the text:

\ETNZ was the winner in Bermuda. \ETNZ[They] beat BMW Oracle Racing.


## UPDATE

Corrected \ETNZ{They} to \ETNZ[They] in my example.

• Welcome. Did you try to use ##1? – TeXnician Feb 23 '18 at 5:27

The # is doubled in each level of nested definitions:

\newcommand{\defTerm}[3]{%
\expandafter\newcommand\csname #1\endcsname[1][]{%
\ifthenelse{\equal{##1}{}}%
{\textbf{\tooltip{#2}{\begin{varwidth}{10cm}#3\end{varwidth}}}}%
{\textbf{\tooltip{##1}{\begin{varwidth}{10cm}#3\end{varwidth}}}}%
}%
}


Another example:

\documentclass{article}
\begin{document}

\newcommand*{\foo}[3]{%
foo=(#1, #2, #3)\par
\def\foobar##1##2{%
foo=(#1, #2, #3) foobar=(##1, ##2)\par
\newcommand{\foobarbaz}[1]{%
foo=(#1, #2, #3) foobar=(##1, ##2) foobarbaz=####1\par
}%
\foobarbaz{##2}%
}%
\foobar{#2}{#3}%
}

\foo{A}{B}{C}

\end{document}


• Thanks - solved... after I corrected my own example above. – pancake Feb 26 '18 at 2:53