skip to Main Content

I am trying to represent a basic vector, the following code works in Visual Studio Code.

I am using the following line $begin{bmatrix}X\Yend{bmatrix}$

All whitespace removed. It should look like this,

https://i.stack.imgur.com/kDxdg.png

However, when pushed to Github it does not render correctly and instead just renders to entire text letter for letter like it is unsupported. Does anybody know how to get get the following vector to display correctly?

3

Answers


  1. The GitHub implementation of MathJax has a number of problems, and it does not seem to want to process some commands in in-line mode. In particular arrays and matrices don’t seem to be processed in in-line math on GitHub. I could not find a work-around that would process your expression, however, an alternative for this matrix would be to use $left[Xatop Yright]$ instead. A bit more awkward, but perhaps that will be sufficient for your needs. I do wish GitHub would improve their processing of math.

    Login or Signup to reply.
  2. One solution is to use the code block highlighting like so,

    ```math
    begin{bmatrix}X\Yend{bmatrix}
    ```
    

    You can see how this looks in a gist I created below.

    Resources

    1. Reddit post where I originally found this solution — https://www.reddit.com/r/github/comments/yen375/comment/itzwbrn/?utm_source=share&utm_medium=web2x&context=3
    2. Gist showing how it works — https://gist.github.com/jesshart/8dd0fd56feb6afda264a0f7c3683abbf
    Login or Signup to reply.
  3. The GitHub/MathJax implementation seems to be lacking. I couldn’t get column vectors or matrices to render correctly unless I added whitespace and split rows over multiple lines.

    I think using the \ as an instruction to move onto the next row followed by end to finish the matrix confuses MathJax when it attempts to render the matrix, with the whitespace it seems to render correctly on GitHub.

    Row Vector Example:

    $$begin{bmatrix} a & b & c end{bmatrix}$$
    

    This seems to work without whitespace.

    Column Vector Example:

    $$  begin{bmatrix}
        a \
        b \
        c \
        end{bmatrix} $$ 
    

    If all whitespace is removed, this doesn’t render…

    Matrix Example:

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

    If all whitespace is removed, this doesn’t render…

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search