4
$\begingroup$

I found an unusual behavior of pmatrix environment when editing a post.

Basically, when editing this question $A=\begin{pmatrix} 0&9 \cr -1&0 \end{pmatrix}$ renders correctly, but $A=\begin{pmatrix} 0&9 \\ -1&0 \end{pmatrix}$ does not. The only difference is that in one case I use \cr to make new line, in the other case I use \\.

As you can see, both versions render correctly here:
$A=\begin{pmatrix} 0&9 \cr -1&0 \end{pmatrix}$ and $A=\begin{pmatrix} 0&9 \\ -1&0 \end{pmatrix}$.

However, here is screenshot showing what the matrix/question looked like when I used version with \\ instead of \cr:

screenshot of the matrix

screenshot of the post

I don't think it's a big deal, but it I'm curious why the same code behaves differently in that question. And also it might be useful to know, in case something similar might manifest elsewhere.

EDIT: Now I am confused even more. At the moment the question renders ok with \ (at least I see it rendered correctly). But when I click on edit, the preview show the strange version with the exclamation mark.

$\endgroup$
0

1 Answer 1

6
$\begingroup$

The answer to that question contains the definition $\def\\#1{\frac1{#1!}}$ which spills over to the preview, but not to the question. (Owing to the order of script execution, I assume).

$\endgroup$
3
  • 1
    $\begingroup$ D'oh!. I searched whether there is \newcommand somewhere in the source. And \def simply did not occur to me. Based on this older post I would expect the same behavior in the question: The scope of \newcommand is the entire page $\endgroup$ Nov 28, 2014 at 7:04
  • 3
    $\begingroup$ Quite a horrible incident. Almost as bad as someone redefining other core commands. Like integrals and sine stuff. Try it out... $\newcommand{\sin}{\text{Troll'd!}}\newcommand{\int}{\text{Ha ha }}\newcommand{\cos}{\text{ Fo' shizzle!}}$ $\endgroup$
    – Asaf Karagila Mod
    Nov 28, 2014 at 15:55
  • $\begingroup$ @AsafKaragila As we all know, $\int \sin(x)\;dx = -\cos(x)$. :) $\endgroup$
    – apnorton
    Dec 1, 2014 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .