I have written a macro to denote either the Fourier transformation (curly F by itself) or the Fourier transform of a function (curly F followed by a function and enclosed in \left( and \right) ). It does so by testing if the argument is equal to void or not:
\newcommand*{\fourier}[1]{\ensuremath{\mathscr{F}\ifthenelse{\equal{#1}{}}{}{\!\left({#1}\right)}}}%
Therefore
\fourier{}
or
\fourier{f(\omega t)}
give the expected results.
I wanted to apply \fourier twice to a function and therefore wrote
\fourier{\fourier{f}}(x)
However, I'm getting a ! Missing \endcsname inserted. error. How should I modify my macro so that it allows nesting? I'm guessing it's because of the \ifthenelse construct?


\!before\leftand\rightthough. Why not use the classic solution by Philipp Stephani:\mathopen{}\mathclose{\left( #1 \right)}. For the\fourier[\big]{...}variants, I was wondering if there is a possible direct use of\bigland\bigr. ;-) – Ruixi Zhang Sep 05 '18 at 15:56\left\rightbit from the OP. I'll see if I can find something that works for\big->\bigl/\bigr, though I'm not sure if that is necessary when we already use\mathopenand\mathclose. – moewe Sep 05 '18 at 16:06\biglis just\def\bigl{\mathopen\big}I don't think the conversion from\bigto\biglis really necessary here. If anyone is interested I came up with\newcommand{\frde@size@getlr}[3]{\csname\expandafter\@gobble\string#1#2\endcsname#3}which you can use as\frde@size@getlr{\big}{l}{(}to get\bigl(. – moewe Sep 05 '18 at 19:26mathtoolswhich does\@nameuse {\MH_cs_to_str:N ##1 l} #2and\@nameuse {\MH_cs_to_str:N ##1 r} #3, going this extra mile to get\bigl(just seems convoluted. – Ruixi Zhang Sep 05 '18 at 19:47\mathopenand\mathclosecould solve my spacing problem, I will definitely be using that.I did not have much use for the
– Frédéric Delacroix Sep 06 '18 at 07:56\bigversion although I understand it may be useful. On the other hand I modified the macro (and renamed it as\integraltransform) so it would accept a second argument to use as the symbol, as may be useful for example for Laplace transformation :\newcommand{\laplace}[1]{\integraltransform{\mathscr{L}}{#1}}%and conjugate Fourier transform (with\overline{\mathscr{F}}as the symbol).\left/\rightbecause the automatic commands may pick out sizes that are unnecessarily large or too small in certain situations (there is even a quote from the TeXbook that acknowledges that and it is reproduced in an answer here, but I can't find that right now). – moewe Sep 06 '18 at 08:13