3
$\begingroup$

See e.g. here. I tried both \begin{pmatrix}... and \begin{array}{cc}....

edit Reading the answers, the problem turns out to be the special treatment of backslashes by markdown, which should be turned off (or auto-escaped) inside TeX environments.

$\endgroup$
2
  • $\begingroup$ @Administrators: The bug is not resolved (see my answer and proposed solution). $\endgroup$
    – 97832123
    Commented Aug 10, 2010 at 15:04
  • 1
    $\begingroup$ I'm marking this as [status-bydesign]. If you can accept the MO behavior, check [ Allow TeXification in <code> tags. ](meta.math.stackexchange.com/questions/551/…). Otherwise, please ask a new question. $\endgroup$
    – kennytm Mod
    Commented Aug 12, 2010 at 15:41

3 Answers 3

6
$\begingroup$

$\begin{matrix}a&b&c\\ d&e&f\\ g&h&i\end{matrix}$

\begin{matrix}a&b&c\\\ d&e&f\\\ g&h&i\end{matrix}

Note that I am forced to escape the backslashes. This is a bug.

To do a pmatrix, we would do:

$\begin{pmatrix}a&b&c\\ d&e&f\\ g&h&i\end{pmatrix}$

\begin{pmatrix}a&b&c\\\ d&e&f\\\ g&h&i\end{pmatrix}

On MO, we can surround all tex by backticks to automatically escape all reserved characters like so:

'$\begin{matrix}a&b&c\\ d&e&f\\ g&h&i\end{matrix}$' (replace the apostrophes with backticks)

The array solution proposed by Tom is deprecated in mathematical documents (see the amsmath documentation).

Solution


A good solution would be as follows: The administrators should automatically escape all text within dollar signs before it is served to MathJax.

$\endgroup$
5
  • 1
    $\begingroup$ Escaping stuff between $ requires changing the server side code specially for math.SE (and stat.SE). I don't see a high chance it will be accepted. $\endgroup$
    – kennytm
    Commented Aug 10, 2010 at 15:34
  • 3
    $\begingroup$ @KennyTM: Then the administrators should give us a new way to escape TeX from markdown. On MO, we solved the issue by having jsMath render text inside of code boxes (delimited by backticks) and changing the background of code boxes to white. Another solution would be if the administrators changed the "escape the next character key" for this site (and also changed the underscore to something else). However, the current solution of forced escaping on reserved characters within TeX is not acceptable, since these are some of the most-used characters for TeX markup.. $\endgroup$
    – 97832123
    Commented Aug 10, 2010 at 16:10
  • 1
    $\begingroup$ I agree. In MO TeXification is only disabled inside <pre>, but in math.SE it is disabled inside <code> as well. The latter prevents TeXification between backquotes. We could allow TeXification in a <code>. $\endgroup$
    – kennytm
    Commented Aug 10, 2010 at 16:22
  • $\begingroup$ @KennyTM: We would also need to change the background color of <code> to white. The solution to escape characters inside of dollar signs is optimal, while the MO solution is not. If we could get the SO team to do it, it would be very useful indeed. I hope the administrators will consider it. $\endgroup$
    – 97832123
    Commented Aug 10, 2010 at 16:49
  • $\begingroup$ See meta.math.stackexchange.com/questions/551/…. $\endgroup$
    – kennytm
    Commented Aug 10, 2010 at 18:30
3
$\begingroup$

EDIT: This approach has been deprecated. However, according to the amsmath documentation, page 10: "If you need left or right alignment in a column or other special formats you must resort to [the] array [environment]." The accepted solution has been provided above.


So, it looks like this works using the array environment. I am pretty sure this site is supporting specific latex packages (ex. amsmath, etc.) but I don't know which ones. At the end of the day, I am confident that we have a robust system at our fingertips - we just have to figure it out!!

So, the code for matrices appears to be something like this:

$A = \left[ \begin{array}{rrr} 1 & -1 & 1 \\ -1 & 1 & -1 \\ 0 & 1 & 2 \end{array} \right]$

$A = \left[ \begin{array}{rrr} 
1  & -1 & 1 \\\
-1 &  1 & -1 \\\
0  &  1 &  2 
\end{array} \right]$

Notice the {rrr} after beginning the array environment. This specifies that we will have three columns, each one right-justified (other options should be well known, l=left-justified, c=centered). Also, there is an extra backslash because this rendering software interprets the first one as an escape character.

Thanks to all of those who have worked very hard to get this site up and running with pretty darn good latex support.

$\endgroup$
2
  • $\begingroup$ Nope! Please see my answer. This is incorrect. $\endgroup$
    – 97832123
    Commented Aug 10, 2010 at 15:00
  • $\begingroup$ @97832123: it is not incorrect, although I also prefer pmatrix to array $\endgroup$ Commented Aug 11, 2010 at 8:11
2
$\begingroup$

$\\\$ <- Three slashes between dollar signs

This will be escaped* in new (or edited) posts. This is not yet reflected in the preview pane. This is also a per-site setting, this behavior does not exist on sites without client-side LaTeX rendering enabled.

*Technically, it just bypasses markdown conversion entirely.

$\endgroup$

You must log in to answer this question.

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