The following rmarkdown
works fine when compiling to PDF (via LaTeX), but not when compiling to HTML (via Markdown).
PDF (via LaTeX)
---
title: "test"
author: "Maximilian Held"
output: pdf_document
documentclass: memoir
---
(@matrix-test2) $$
\bordermatrix{
~ & Petra & Ingrid \cr
Petra & 1 & 0 \cr
Ingrid & 0 & 1 \cr
}
$$
HTML (via Markdown)
---
title: "test"
author: "Maximilian Held"
output: html_document
documentclass: memoir
---
(@matrix-test2) $$
\bordermatrix{
~ & Petra & Ingrid \cr
Petra & 1 & 0 \cr
Ingrid & 0 & 1 \cr
}
$$
yields
What's up with that and on whose end is this (Pandoc? Markdown? MathML?)
knitr, the tool normally used to convert RMarkdown to HTML/PDF (from LaTeX)/DOCX, uses Pandoc. Pandoc is a nice tool to convert Markdown to HTML and LaTeX and allows you to use LaTeX math environments inside Markdown, e.g.
$a x^2 + b x + c = 0$
or
$$a x^2 + b x + c = 0$$
or
\begin{equation}
a x^2 + b x + c = 0
\end{equation}
are properly converted by Pandoc. Pandoc also supports the amsmath
, a very popular LaTeX package for math. Unfortunately, Pandoc doesn't support all (La)TeX commands/environment as you discovered.
What I always do when working with Pandoc is try to keep things simple. In the case you present, I would use normal tables instead of a matrix.