Inconsistent rendering of display math between RStudio and Quarto Render

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}$$

If this is about the $$ showing in the result then this issue could be related

Thanks - It is similar but in my case, the formatting is off and some symbols are not displayed at all (from the first line).
The answer on the other appears in correct as I show both cases the same exact code with $$ on the same line, not a separate line, works and then when copied and pasted below does not work and then works again on the next paste.

I was able to get it all to work when I got rid of every line break inside a display math (leading to some long, unreadable lines). As I fixed one, the next display math would stop working until I got rid of all line breaks in every display math in the document.
Something funning is going on that the preview works fine but the render does not.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.