I wrote some commands, recently adding some convenience command \FS to add figure sources:
\newcommand{\FS}[1]{%
\protect\\{\protect\scriptsize{}Bildquelle: #1}}
I don't know whether this is correct (all those \protect), but it seems to work inside \caption.
Unfortunately I tried to improve the command, adding an optional parameter:
\newcommand{\FS}[2][Bildquelle]{%
\protect\ifthenelse{\equal{#1}{}}%
\protect\\{\protect\scriptsize{}#2}
\protect\\{\protect\scriptsize{}#1: #2}}
When using the variant with no optional parameter specified, the effect is that expanded #2 is output, followed by expanded Bildquelle: #2 (Actually even when specifying the optional parameter the output is duplicated as described).
For example:
I'm not deep enough into TeX to to able to fix the problem myself, even after reading those answers on \protect.
How should the command be written?


\newcommand{\FS}[2][Bildquelle]{% \protect\ifthenelse{\equal{#1}{}}{% \protect\\{\protect\scriptsize{}#2}}{% \protect\\{\protect\scriptsize{}#1: #2}}}. – Nov 29 '19 at 23:33\DeclareRobustCommandavailable in all environments, or do I need spacial packages for it? My LaTeX knowledge is a bit outdated... – U. Windl Nov 30 '19 at 01:31\newcommandare already made robust in case of having an optional argument. Thus all the\DeclareRobustCommand-thingies shown in my (now deleted) answer aren't needed at all. Sorry for the noise. – Ulrich Diez Nov 30 '19 at 09:06