Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matrix by matrix in R markdown

Tags:

markdown

r

matrix

I want to have multiple matrices side by side to present spectral decomposition in R markdown, but it doesn't seem to work. Please help

$$
\left(\begin{array}
0.8944272 & 0.4472136\\
-0.4472136 & -0.8944272
\end{array}\right\)

\left(\begin{array}
10 & 0\\
0 & 5
\end{array}\right)
$$ 
like image 355
xTernal Avatar asked Sep 14 '15 13:09

xTernal


3 Answers

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

like image 113
RHertel Avatar answered Jan 10 '23 22:01

RHertel


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.

like image 29
Raniere Silva Avatar answered Jan 10 '23 20:01

Raniere Silva


You can also do this to get brackets instead of parentheses

$\left[\begin{array}{ccc}
10 & 0\\
0 & 5
\end{array}\right]$
like image 41
t.hall Avatar answered Jan 10 '23 20:01

t.hall