The in-line preview of display-mode math looks fine in all of the examples below but when the document is rendered to HTML, the math is not rendered properly in several cases, or even consistently for a copied set of code . The attached image shows an extract from a much longer document where this issue occurs multiple times and I cannot figure out a pattern. I am using the latest versions of RStudio, Quarto, and knitr. It is using the quarto default for mathjax.
Appreciate any suggestions.
Richard
title: "Untitled"
output: html
Example 1
$$A^\intercal = \begin{bmatrix}
a_{11}&a_{21}&\cdots &a_{n1} \
a_{12}&a_{22}&\cdots &a_{2n}\
\vdots & \vdots & \ddots & \vdots\
a_{1m}&a_{2m}&\cdots &a_{mn}\end{bmatrix}$$
$$A^\intercal = \begin{bmatrix}
a_{11}&a_{21}&\cdots &a_{n1} \
a_{12}&a_{22}&\cdots &a_{2n}\
\vdots & \vdots & \ddots & \vdots\
a_{1m}&a_{2m}&\cdots &a_{mn}\end{bmatrix}$$
$$A^\intercal = \begin{bmatrix}
a_{11}&a_{21}&\cdots &a_{n1} \
a_{12}&a_{22}&\cdots &a_{2n}\
\vdots & \vdots & \ddots & \vdots\
a_{1m}&a_{2m}&\cdots &a_{mn}\end{bmatrix}$$
Example 2
Matrix A has 3 rows and 2 columns so has size (3 \times 2).
$$A = \begin{bmatrix}1 &2 \
3 & 0 \
-1 & 4
\end{bmatrix}$$
Matrix B has 2 rows and 4 columns so has size (2 \times 4).
$$B = \begin{bmatrix}a&b&c&d \
e&f&g&h
\end{bmatrix}$$
$$A = \begin{bmatrix}1 &2 \
3 & 0 \
-1 & 4
\end{bmatrix}$$
$$B = \begin{bmatrix}a&b&c&d \
e&f&g&h
\end{bmatrix}$$