# ⚠️ Inline KaTeX/MathJax $...$ inside \[grid\] can leak BBCode when used with \[details\]

**URL:** <https://meta.discourse.org/t/inline-katex-mathjax-inside-grid-can-leak-bbcode-when-used-with-details/372802>\
**Category:** Product Support\
**Tags:** math\
**Created:** [July 3, 2025, 4:22pm UTC](https://meta.discourse.org/t/inline-katex-mathjax-inside-grid-can-leak-bbcode-when-used-with-details/372802 "2025-07-03T16:22:25Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)\
**Post date:** [July 3, 2025, 4:22pm UTC](https://meta.discourse.org/t/inline-katex-mathjax-inside-grid-can-leak-bbcode-when-used-with-details/372802/1 "2025-07-03T16:22:25Z")

</div>

## BBCode and LaTeX Rendering in [grid] and [details]: Unexpected Behavior Explained

I’ve been experimenting with how Discourse handles LaTeX inside `[grid]` and `[details]` and wanted to document the behavior and workaround here for others using math-heavy formatting.

### ⚠ Problem

When using `[grid]` to lay out multiple LaTeX expressions side-by-side, inserting **even one whitespace** between two `$...$` inline math blocks inside the grid **breaks the rendering** :

- `[grid]` shows side-by-side content with \text{whitespace} = 1 ✅
- **But BBCode tags like `[grid]` and `[/grid]` become visible** ❌

See this screenshot, where the layout looks correct but `[grid]` appears as text:

👉 **Screenshot 1: `[grid]` showing visibly despite rendering correctly**

 ![screenshot showing visible [grid] BBCode](https://global.discourse-cdn.com/meta/original/4X/b/0/e/b0ea810f54c14fd495383dbe4f533725ae4f5519.png)

* * *

### 🔍 Diagnosis

Discourse’s markdown parser interprets:

- `$...$` with **no whitespace between blocks** as _inline math_
- This causes **layout confusion** inside `[grid]`
- `[grid]` expects **block-level content** , not inline

* * *

### ✅ Solution

Use `$$...$$` (block LaTeX) **instead of inline `$...$`** inside `[grid]` to ensure correct rendering. Example:

```bbcode
[grid]
$$
\nabla \times \mathbf{A} = \left| \begin{matrix}
\hat{i} & \hat{j} & \hat{k} \\
\partial_x & \partial_y & \partial_z \\
A_x & A_y & A_z
\end{matrix} \right|
$$
$$
\nabla \times \mathbf{A} = \left| \begin{matrix}
\hat{i} & \hat{j} & \hat{k} \\
\partial_x & \partial_y & \partial_z \\
A_x & A_y & A_z
\end{matrix} \right|
$$
[/grid]

```

 ![A fluffy, ginger cat is curled up asleep on a grey cushion, looking very comfortable and peaceful. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/1/9/0/1907c0575c38679a7c6335a5876b6edeae535129.png)

---

_[View the full topic](https://meta.discourse.org/t/inline-katex-mathjax-inside-grid-can-leak-bbcode-when-used-with-details/372802)._
