# Inserting evil red code in LyX in mathmode

How can I put code inside a math environment in LyX. For example, I want to insert a matrix, that is created via the \tikzpicture command, like in the first answer from here. But if I just copy the code from there and paste it into math mode, it turns to text - I don't seems to be able to insert evil red code in math mode. I can only type (which is tiring) some of the code hand, but can't insert text like \\ this automatically is converted from evil red code to a text backslash.

Is there any solution for this ? I would really like to have LyX display to me the matrices on the left and right, from the post of the link above, and have only the middle in evil red code.

(Of course I could just put everything in evil red code, including the math stuff, but then the left and right matrices would also be in code, which would be a pity).

-
write the complete code with ERT –  Herbert Jun 20 '12 at 10:50
I really hate that LyX refers to code as "Evil". It may be jokey, but it's alienating LyX users from the power of TeX. –  Seamus Jun 20 '12 at 12:04
@Herbert Yes, as I said, in the last paragraph, that would be an option...but an ugly one. –  user10324 Jul 14 '12 at 14:10
To everybody else who reads this (so far unanswered) question: A negative answer is also a solution (at least then I could stop looking for one!) –  user10324 Jul 14 '12 at 14:11

[Something of an extended comment]

Lyx can handle a variety of math mode items, but where it cannot handle them you have to insert raw LaTeX code ('ERT'). Other than extending the Lyx binary, there is not much that can be done here. (Even then, there will still be limits to what Lyx can handle.)

-