# Why does LyX flag the following maths macro definition as an error?

The following macro is the LaTeX equivalent of a macro that I defined using the LyX maths macro facility.

\global\long\def\fdd#1#2#3{\mathscr{F}^{\left(#1\right)}\left[#2_{#3}\right]}


LyX comes up with the following error when I compile my document:

! Undefined control sequence.
\fdd #1#2#3->\mathscr {F}^{\left (#1\right )}\left [#2_{#3}\right ]


However, the following macro, in which \mathscr is replaced with \textrm, compiles successfully.

\global\long\def\fdd#1#2#3{\textrm{F}^{\left(#1\right)}\left[#2_{#3}\right]}


What could be wrong with the first macro?

• \mathscr isn't defined in "basic" latex, so you probably have to load a package that defines it. euscript and mathrsfs are two packages that do define this command. i'm not a lyx user, so i can't say how to access them "natively". – barbara beeton Sep 3 '13 at 17:57
• Why \global\long\def\fdd#1#2#3 and not \newcommand{\fdd}[3]? – egreg Sep 3 '13 at 18:03
• Note that LyX is not flagging it as an error. That is a LaTeX error. LyX is just passing it on to you. – scottkosty Sep 4 '13 at 2:26
• Thanks for all the responses. It works when I use the package mathrsfs. What is interesting is that the problem only occurs when the formal script font is used in a macro definition. When I use the formal script font in the body of a LyX document the error does not occur, even if I don't use the package mathrsfs explicitly. I therefore thought that the same condition would naturally be extended to the context of the use of the LyX maths macro definition facility. I was dead wrong! Thanks. – user24098 Sep 4 '13 at 7:31

Add the package mathrsfs to your preamble (Document > Settings... > LaTeX preamble) - it provides the functionality to use \mathscr.