I have this bit of LaTeX code.
f(n)=\begin{cases}n/2&\mbox{if }n\equiv0\\(3n+1)/2&\mbox{if}n\equiv1.\end{cases}\pmod{2}
I want to see it rendered in my LyX document. If I copy and paste it into the "Insert Math" box given by Ctrl+M, it works and I see the this in my document
I would like to be able to manually type that code (and code in general) into LyX and get the same result. That is, I would like to be able to manually enter code into LyX and have it have the same effect as pasting that code into LyX. I can't find a way to do this. My current workaround is to keep a separate text editor open from which I paste into LyX, which is not ideal.
If I try to type the same code by hand into a math box, I get a mess whose beginning looks like this:
The same happens if try to type it into a "Insert -> TeX code" box nested inside the math box.
If I type or paste it into a code box not nested inside a math box, I get this:
What am I doing wrong? Based on googling, the "instant preview" setting seems to be connected. I've turned it on and off and see no difference. I'm using LyX 2.12 with all default settings (except for the instant preview).