# Creating wysiwyg preview for a custom math functions on lyx

Let's say I want to create a "macro" called \limx that will be defined as:

\newcommand{\limx}{\displaystyle{\lim_{x\to\x_{0}}}}


How can I make LyX recognize it and make an auto-prieview of it?

Another example, I'm using the cancel package. When I'm using \cancel in a math equation it doesn't preview it while editing. I can still see "\cancel" on the equation editor. Only when I render the document the \cancel is being really rendered. How can I add that functionality to the LyX's WYSIWYG environment as well?

-
Which version of LyX do you use? I have version 1.6.7 and when using the cancel package, \cancel previews just fine. So do macros that I define in the preamble. – Jan Hlavacek Dec 5 '10 at 4:42
@Dave: Why the mathmode tag? – Jan Hlavacek Dec 14 '10 at 17:59
@Jan: My mistake. – Dave Jarvis Dec 14 '10 at 18:03
@Jan I'm using Lyx 1.6.7, but when i use "\cancel" it doesn't work for me. I still just see "\cancel" in the mathmode... – DiGMi Dec 16 '10 at 13:29
In the equation editor, when actually editing the formula, it will use \cancel. As far as I know, there is no way to teach LyX a graphical representation of new macros that it doesn't already know. When you are done with editing, and leave the particular "equation" (I think it is "math inset" in LyXspeak), LyX should preview the formula just the way it will look in the compiled document. At that moment, \cancel should render the way it is supposed to. When you click on the equation again, you will enter edit mode, and and you will see cancel again. – Jan Hlavacek Dec 16 '10 at 17:08

As I understand things, it's not necessary to do anything special for macros that get used inside equations; LyX just runs them through LaTeX and (with the aid of preview.sty) extracts the preview images.