matrix by matrix in R markdown

You can also do this to get brackets instead of parentheses

$\left[\begin{array}{ccc}
10 & 0\\
0 & 5
\end{array}\right]$

You can also use the *matrix environments of amsmath

$$
\begin{pmatrix}
0.8944272 & 0.4472136\\
-0.4472136 & -0.8944272
\end{pmatrix}
\begin{pmatrix}
10 & 0\\ 
0 & 5
\end{pmatrix}
$$

amsmath is supported by Pandoc and MathJax, the tools that are commonly used when converting RMarkdown to HTML or PDF.


Three minor corrections should be sufficient to make this work for both, HTML and PDF output:

  1. remove the backslash before the closing bracket in \right\)
  2. delete the empty line in the middle
  3. specify the column alignment in each array environment, e.g., with \begin{array}{cc}

-

$$
\left(\begin{array}{cc} 
0.8944272 & 0.4472136\\
-0.4472136 & -0.8944272
\end{array}\right)
\left(\begin{array}{cc} 
10 & 0\\ 
0 & 5
\end{array}\right)
$$ 

enter image description here

Tags:

Matrix

Markdown

R