Matrices in LaTeX not displaying

  • Unknown's avatar

    I am writing a math post which includes some matrices; the LaTeX code should look something like

    $latex left(begin{array}{cc}1&2\ 3&4end{array}right)$

    which is legitimate LaTeX. But after saving, all the ampersands are turned into & which is not what I want at all, and the formula fails to be typeset.

    I am using the Digg 3 Column theme.

    Does anybody know how I can produce matrices for display in wordpress.com?

    Thanks,
    Alasdair

  • Unknown's avatar

    Alasdair,

    I just tried your LaTeX code in a draft post, and it works correctly (while I’m using a different theme, that shouldn’t make any difference since the LaTeX rendering process produces images…)

    Are you seeing the & character entity in the visual or HTML view when you’re editing your post?

  • Unknown's avatar

    I am using the plain HTML editor – which is where the ampersands are changed to & after saving. Interestingly enough, the example matrix in my original post typesets fine, but the larger 4 by 4 matrices which I really want don’t typeset at all.

    So in my post, when I preview it, instead of a nice matrix equation, I get the LaTeX code instead.

    Thanks,
    Alasdair

  • Unknown's avatar

    I don’t think the & representation in the HTML view is a problem; all of my $latex LaTeX$ has that as well in HTML view. The rendering process doesn’t usually have a problem with it. That almost sounds like you accidentally wrote something like
    $left(...right)$
    instead of
    $latex left(...right)$

    Can you post the code for one of the 4-by-4 matrices that isn’t rendering?

  • Unknown's avatar

    Awww… no LaTeX rendering in the forums. :-(

  • Unknown's avatar

    Thanks for your help. Here is one matrix equation which is not typesetting:

    $latex left(begin{array}{c}x'\ y'\ z'\ w'end{array}right)=
    left(begin{array}{cccc}1&0&0&0\ 0&1&0&0\ 0&0&costheta&-sintheta\
    0&0&sintheta&costhetaend{array}right)
    left(begin{array}{c}x\ y\ z\ wend{array}right)$

    For the purpose of this forum post I’ve changed all the & back to plain &.

    Thanks again!
    Alasdair

  • Unknown's avatar

    It looks like you have line breaks in your LaTeX, and the WordPress rendering process doesn’t like it. I suspect that they check each line of the input for a pattern like $latex …$, and hand the … to their LaTeX rendering process to produce the images.

  • Unknown's avatar

    You also seem to be missing a line break (\) between the third and fourth rows of the second array, which led to a “Formula does not parse” message.

    :-)

  • Unknown's avatar

    Hmmm… if I try to put everything on one line, then the editor puts a line break between $latex and the first character of my LaTeX code. I can’t force the editor to keep one (very long!) line. I suppose I could try to switch to the enhanced editor, although I much prefer the HTML editor.

    This is quite tricky…!

    Thanks again for your help. I’ll keep fiddling during the day – it’s now early morning here.

    -Alasdair

  • Unknown's avatar

    It may just be wrapping the line (part of how it displays the text, but no bytes in the data saying “put a line break here”), which is different than actually having a line break (which actually has one or two bytes of data saying “put a line break here”).

    Good luck!

  • Unknown's avatar

    I ended up getting round the problem by creating the equation in my own LaTeX, and uploading the result as an image. It’s a painful way to do it, because editing and changing the equation takes far longer, but at least the final result looks good:

    http://amca01.wordpress.com/2008/05/15/a-really-beautiful-animation/

  • Unknown's avatar

    Put a space after the \ and before the first 0 on the last row of the second matrix. For some reason wordpress.com replaces by &.
    $latex left(begin{array}{c}x'\ y'\ z'\ w'end{array}right)=left(begin{array}{cccc}1&0&0&0\ 0&1&0&0\ 0&0&costheta&-sintheta\ 0&0&sintheta&costhetaend{array}right)left(begin{array}{c}x\ y\ z\ wend{array}right)$
    works.

    BUT better still use the pmatrix environment which is easier to use, though you still need to put the space in on the fourth row.

    $latex begin{pmatrix}x'\ y'\ z'\ w'end{pmatrix}=begin{pmatrix}1&0&0&0\ 0&1&0&0\ 0&0&costheta&-sintheta\ 0&0&sintheta&costhetaend{pmatrix}begin{pmatrix}x\ y\ z\ wend{pmatrix}$

  • The topic ‘Matrices in LaTeX not displaying’ is closed to new replies.