[Tex/LaTex] Insert a TeX code into a math mode at LyX

lyx

If i'm at math mode at LyX and I want to add a TeX code, how can I do it?

This is possible?

i.e something like: \Ding{152} (or code that is more then a symbol) in math mode.

Best Answer

In math mode just type the TeX code. Of course, you need to include used packages in the LaTeX Preamble. For example, in math mode

  • \rightarrow + space will produce rightarrow;

  • if you put \usepackage{stmaryrd} into the LaTeX Preamble then you can type a\leftrightarrowtriangle b. This results in lrarrowtriangle or if "Tools > Preferences > Look&Feel > Instant Preview" is turned on then you will see lrarrowtriangle preview after leaving math mode;

  • furthermore, you can type \def\a{\rightarrow} and use \a later on. (Be aware that copying and pasting the \def-code will transform it into a \global\long\def. This is the same as using "Insert > Math > Macro".)

Overall, you can type probably every TeX code that can be used in math mode. You might find "View > View Source" helpful to check whether LyX understood correctly what you typed. (If you interrupt typing of \ding{123} it might come out as \ding\{123\}.)