⚠️ Inline LaTeX $...$ dentro [grid] vaza BBCode quando usado com [details]

Renderização de BBCode e LaTeX em [grid] e [details]: Comportamento Inesperado Explicado

Tenho experimentado como o Discourse lida com LaTeX dentro de [grid] e [details] e queria documentar o comportamento e a solução alternativa aqui para outros que usam formatação com muitas fórmulas matemáticas.

:warning: Problema

Ao usar [grid] para organizar várias expressões LaTeX lado a lado, inserir até mesmo um único espaço em branco entre dois blocos de matemática em linha $...$ dentro da grade interrompe a renderização:

  • [grid] mostra conteúdo lado a lado com \\text{espaço em branco} = 1 :white_check_mark:
  • Mas as tags BBCode como [grid] e [/grid] se tornam visíveis :cross_mark:

Veja esta captura de tela, onde o layout parece correto, mas [grid] aparece como texto:

:backhand_index_pointing_right: Captura de tela 1: [grid] visível apesar de renderizar corretamente


:magnifying_glass_tilted_left: Diagnóstico

O analisador de markdown do Discourse interpreta:

  • $...$ sem espaço em branco entre os blocos como matemática em linha
  • Isso causa confusão no layout dentro de [grid]
  • [grid] espera conteúdo de nível de bloco, não em linha

:white_check_mark: Solução

Use $$...$$ (LaTeX de bloco) em vez de $...$ em linha dentro de [grid] para garantir a renderização correta. Exemplo:

[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]

Então, pensei em atualizar tudo no painel de administração e comecei a fazer alguns testes


[details="Derivando a fórmula para o rotacional cartesiano"]
[grid]
$$\n\\nabla \\times \\mathbf{A} = \\left| \\begin{matrix}\n\\hat{i} \u0026 \\hat{j} \u0026 \\hat{k} \\\\\n\\partial_x \u0026 \\partial_y \u0026 \\partial_z \\\\\nA_x \u0026 A_y \u0026 A_z\n\\end{matrix} \\right|$$
$$\n\\nabla \\times \\mathbf{A} = \\left| \\begin{matrix}\n\\hat{i} \u0026 \\hat{j} \u0026 \\hat{k} \\\\\n\\partial_x \u0026 \\partial_y \u0026 \\partial_z \\\\\nA_x \u0026 A_y \u0026 A_z\n\\end{matrix} \\right|$$
[/grid]

[grid]
$$\n\\begin{align*}\n\\nabla \\times \\mathbf{A} =\\ \n\u0026\\hat{i} \\left| \\begin{matrix}\n\\partial_y \u0026 \\partial_z \\\\\nA_y \u0026 A_z\n\\end{matrix} \\right|\n- \\hat{j} \\left| \\begin{matrix}\n\\partial_x \u0026 \\partial_z \\\\\nA_x \u0026 A_z\n\\end{matrix} \\right| \\\\\n\u0026+ \\hat{k} \\left| \\begin{matrix}\n\\partial_x \u0026 \\partial_y \\\\\nA_x \u0026 A_y\n\\end{matrix} \\right|\n\\end{align*}$$

$$\n\\begin{align*}\n\\nabla \\times \\mathbf{A} =\\ \n\u0026\\hat{i} \\left| \\begin{matrix}\n\\partial_y \u0026 \\partial_z \\\\\nA_y \u0026 A_z\n\\end{matrix} \\right|\n+ \\hat{j} \\left| \\begin{matrix}\nA_z \u0026 A_x \\\\\n\\partial_z \u0026 \\partial_x\n\\end{matrix} \\right| \\\\\n\u0026+ \\hat{k} \\left| \\begin{matrix}\n\\partial_x \u0026 \\partial_y \\\\\nA_x \u0026 A_y\n\\end{matrix} \\right|\n\\end{align*}$$
[/grid]
[/details]

passou :white_check_mark:


IA sendo tola ao colocar espaço excessivo entre dois $...$ em grid
[details="Derivando a fórmula para o rotacional cartesiano"]
[grid]
$\\nabla \\times \\mathbf{A} = \\left| \\begin{matrix}\n\\hat{i} \u0026 \\hat{j} \u0026 \\hat{k} \\\\\n\\partial_x \u0026 \\partial_y \u0026 \\partial_z \\\\\nA_x \u0026 A_y \u0026 A_z\n\\end{matrix} \\right|$

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

[grid]
$\\begin{aligned}\n\\nabla \\times \\mathbf{A} =\\ \n\u0026\\hat{i} \\left| \\begin{matrix}\n\\partial_y \u0026 \\partial_z \\\\\nA_y \u0026 A_z\n\\end{matrix} \\right|\n- \\hat{j} \\left| \\begin{matrix}\n\\partial_x \u0026 \\partial_z \\\\\nA_x \u0026 A_z\n\\end{matrix} \\right| \\\\\n\u0026+ \\hat{k} \\left| \\begin{matrix}\n\\partial_x \u0026 \\partial_y \\\\\nA_x \u0026 A_y\n\\end{matrix} \\right|\n\\end{aligned}$

$\\begin{aligned}\n\\nabla \\times \\mathbf{A} =\\ \n\u0026\\hat{i} \\left| \\begin{matrix}\n\\partial_y \u0026 \\partial_z \\\\\nA_y \u0026 A_z\n\\end{matrix} \\right|\n+ \\hat{j} \\left| \\begin{matrix}\nA_z \u0026 A_x \\\\\n\\partial_z \u0026 \\partial_x\n\\end{matrix} \\right| \\\\\n\u0026+ \\hat{k} \\left| \\begin{matrix}\n\\partial_x \u0026 \\partial_y \\\\\nA_x \u0026 A_y\n\\end{matrix} \\right|\n\\end{aligned}$
[/grid]
[/details]

falhou :cross_mark:


[details="Derivando a fórmula para o rotacional esférico"]

[grid]
$$\n\\nabla \\times \\mathbf{A} =\n\\frac{1}{r^2 \\sin\\theta}\n\\left| \\begin{matrix}\n\\hat{r} \u0026 r\\hat{\\theta} \u0026 r\\sin\\theta\\,\\hat{\\phi} \\\\\n\\partial_r \u0026 \\partial_\\theta \u0026 \\partial_\\phi \\\\\nA_r \u0026 r A_\\theta \u0026 r\\sin\\theta\\, A_\\phi\n\\end{matrix} \\right|$$

$$\n= \\frac{1}{r^2 \\sin\\theta}\n\\left| \\begin{matrix}\n\\hat{r} \u0026 \\hat{\\theta} \u0026 \\hat{\\phi} \\\\\n\\partial_\\theta \u0026 \\partial_\\phi \u0026 \\partial_r \\\\\nr A_\\theta \u0026 r \\sin\\theta A_\\phi \u0026 A_r\n\\end{matrix} \\right|$$
[/grid]

[grid]
$$\n\\begin{align*}\n= \\frac{1}{r^2 \\sin\\theta} \\Big(\n\u0026\\hat{r} \\left| \\begin{matrix} \\partial_\\theta \u0026 \\partial_\\phi \\\\ r A_\\theta \u0026 r \\sin\\theta A_\\phi \\end{matrix} \\right|\n\\ \\\\\u0026- \\hat{\\theta} \\left| \\begin{matrix} \\partial_r \u0026 \\partial_\\phi \\\\ A_r \u0026 r \\sin\\theta A_\\phi \\end{matrix} \\right| \\\\\n\u0026+ \\hat{\\phi} \\left| \\begin{matrix} \\partial_r \u0026 \\partial_\\theta \\\\ A_r \u0026 r A_\\theta \\end{matrix} \\right|\n\\Big)\n\\end{align*}$$

$$\n\\begin{align*}\n= \\frac{1}{r^2 \\sin\\theta} \\Big(\n\u0026\\hat{r} \\left| \\begin{matrix} \\partial_\\phi \u0026 \\partial_r \\\\ r \\sin\\theta A_\\phi \u0026 A_r \\end{matrix} \\right|\n\\ \\\\\u0026+ \\hat{\\theta} \\left| \\begin{matrix} A_r \u0026 r \\sin\\theta A_\\phi \\\\ \\partial_r \u0026 \\partial_\\phi \\end{matrix} \\right| \\\\\n\u0026+ \\hat{\\phi} \\left| \\begin{matrix} \\partial_\\theta \u0026 \\partial_r \\\\ r A_\\theta \u0026 A_r \\end{matrix} \\right|\n\\Big)\n\\end{align*}$$
[/grid]

[/details]

passou :white_check_mark:


[details="Derivando a fórmula para o rotacional esférico"]

[grid]
$$\n\\nabla \\times \\mathbf{A} =\n\\frac{1}{r^2 \\sin\\theta}\n\\left| \\begin{matrix}\n\\hat{r} \u0026 r\\hat{\\theta} \u0026 r\\sin\\theta\\,\\hat{\\phi} \\\\\n\\partial_r \u0026 \\partial_\\theta \u0026 \\partial_\\phi \\\\\nA_r \u0026 r A_\\theta \u0026 r\\sin\\theta\\, A_\\phi\n\\end{matrix} \\right|$$

$$\n= \\frac{1}{r^2 \\sin\\theta}\n\\left| \\begin{matrix}\n\\hat{r} \u0026 \\hat{\\theta} \u0026 \\hat{\\phi} \\\\\n\\partial_\\theta \u0026 \\partial_\\phi \u0026 \\partial_r \\\\\nr A_\\theta \u0026 r \\sin\\theta A_\\phi \u0026 A_r\n\\end{matrix} \\right|$$
[/grid]

[grid]
$\\begin{align}\n= \\frac{1}{r^2 \\sin\\theta} \\Big(\n\u0026\\hat{r} \\left| \\begin{matrix} \\partial_\\theta \u0026 \\partial_\\phi \\\\ r A_\\theta \u0026 r \\sin\\theta A_\\phi \\end{matrix} \\right|\n\\ \\\\\u0026- \\hat{\\theta} \\left| \\begin{matrix} \\partial_r \u0026 \\partial_\\phi \\\\ A_r \u0026 r \\sin\\theta A_\\phi \\end{matrix} \\right| \\\\\n\u0026+ \\hat{\\phi} \\left| \\begin{matrix} \\partial_r \u0026 \\partial_\\theta \\\\ A_r \u0026 r A_\\theta \\end{matrix} \\right|\n\\Big)\n\\end{align}$ $\\begin{align}\n= \\frac{1}{r^2 \\sin\\theta} \\Big(\n\u0026\\hat{r} \\left| \\begin{matrix} \\partial_\\phi \u0026 \\partial_r \\\\ r \\sin\\theta A_\\phi \u0026 A_r \\end{matrix} \\right|\n\\ \\\\\u0026+ \\hat{\\theta} \\left| \\begin{matrix} A_r \u0026 r \\sin\\theta A_\\phi \\\\ \\partial_r \u0026 \\partial_\\phi \\end{matrix} \\right| \\\\\n\u0026+ \\hat{\\phi} \\left| \\begin{matrix} \\partial_\\theta \u0026 \\partial_r \\\\ r A_\\theta \u0026 A_r \\end{matrix} \\right|\n\\Big)\n\\end{align}$
[/grid]

[/details]

passou :white_check_mark:


[details="Derivando a fórmula para o rotacional esférico"]

[grid]
$$\n\\nabla \\times \\mathbf{A} =\n\\frac{1}{r^2 \\sin\\theta}\n\\left| \\begin{matrix}\n\\hat{r} \u0026 r\\hat{\\theta} \u0026 r\\sin\\theta\\,\\hat{\\phi} \\\\\n\\partial_r \u0026 \\partial_\\theta \u0026 \\partial_\\phi \\\\\nA_r \u0026 r A_\\theta \u0026 r\\sin\\theta\\, A_\\phi\n\\end{matrix} \\right|$$

$$\n= \\frac{1}{r^2 \\sin\\theta}\n\\left| \\begin{matrix}\n\\hat{r} \u0026 \\hat{\\theta} \u0026 \\hat{\\phi} \\\\\n\\partial_\\theta \u0026 \\partial_\\phi \u0026 \\partial_r \\\\\nr A_\\theta \u0026 r \\sin\\theta A_\\phi \u0026 A_r\n\\end{matrix} \\right|$$
[/grid]

[grid]
$\\begin{align}\n= \\frac{1}{r^2 \\sin\\theta} \\Big(\n\u0026\\hat{r} \\left| \\begin{matrix} \\partial_\\theta \u0026 \\partial_\\phi \\\\ r A_\\theta \u0026 r \\sin\\theta A_\\phi \\end{matrix} \\right|\n\\ \\\\\u0026- \\hat{\\theta} \\left| \\begin{matrix} \\partial_r \u0026 \\partial_\\phi \\\\ A_r \u0026 r \\sin\\theta A_\\phi \\end{matrix} \\right| \\\\\n\u0026+ \\hat{\\phi} \\left| \\begin{matrix} \\partial_r \u0026 \\partial_\\theta \\\\ A_r \u0026 r A_\\theta \\end{matrix} \\right|\n\\Big)\n\\end{align}$ $\\begin{align}\n= \\frac{1}{r^2 \\sin\\theta} \\Big(\n\u0026\\hat{r} \\left| \\begin{matrix} \\partial_\\phi \u0026 \\partial_r \\\\ r \\sin\\theta A_\\phi \u0026 A_r \\end{matrix} \\right|\n\\ \\\\\u0026+ \\hat{\\theta} \\left| \\begin{matrix} A_r \u0026 r \\sin\\theta A_\\phi \\\\ \\partial_r \u0026 \\partial_\\phi \\end{matrix} \\right| \\\\\n\u0026+ \\hat{\\phi} \\left| \\begin{matrix} \\partial_\\theta \u0026 \\partial_r \\\\ r A_\\theta \u0026 A_r \\end{matrix} \\right|\n\\Big)\n\\end{align}$
[/grid]

[/details]

é aí que falha

:warning: o problema é que estou colocando muito pouco espaço entre [grid] -\u003e object e/ou object -\u003e [/grid]

1 curtida

Eu pensei que deveria pelo menos concluir com informações matematicamente precisas, não com enrolação do ChatGPT :grinning_face:


\frac{1}{r^2 \sin\theta} \left| \begin{matrix} \textcolor{orange}{\hat{r}} & r\hat{\theta} & r\sin\theta\, \hat{\phi} \\ \partial_r & \boxed{\partial_\theta} & \boxed{\partial_\phi} \\ A_r & \boxed{r A_\theta} & \boxed{r\sin\theta\, A_\phi} \end{matrix} \right|
\frac{1}{r^2 \sin\theta} \left| \begin{matrix} \textcolor{orange}{\hat{r}} & r\hat{\theta} & r\sin\theta\, \hat{\phi} \\ \partial_r & \boxed{\partial_\theta} & \boxed{\partial_\phi} \\ A_r & \boxed{r A_\theta} & \boxed{r\sin\theta\, A_\phi} \end{matrix} \right|
o 1º termo do Rotacional

[center]
\Huge \frac{1}{r^2 \sin\theta} \cdot \textcolor{orange}{\hat{r}}\begin{vmatrix} \partial_\theta & \partial_\phi \\ r A_\theta & r\sin\theta\, A_\phi \end{vmatrix}
[/center]


\textcolor{red}{ \frac{1}{r^2 \sin\theta} \left| \begin{matrix} \hat{r} & \textcolor{purple}{r\hat{\theta}} & r\sin\theta\, \hat{\phi} \\ \left.\overrightarrow{\partial_r}\right| & \partial_\theta & \left|\overrightarrow{\;\;\;\;\partial_\phi\;}\right. \\ \left.\underrightarrow{A_r}\right| & r A_\theta & \underrightarrow{\biggl| \, r\sin\theta\, A_\phi \,} \end{matrix} \right| }
\textcolor{green}{ \frac{1}{r^2 \sin\theta} \left| \begin{matrix} \hat{r} & \textcolor{purple}{r\hat{\theta}} & r\sin\theta\, \hat{\phi} \\ \left|\overrightarrow{\partial_r}\right. & \partial_\theta & \left.\overrightarrow{\;\;\;\;\partial_\phi\;}\right| \\ \left|\underrightarrow{A_r}\right. & r A_\theta & \underrightarrow{ \, r\sin\theta\, A_\phi \, \biggl|} \end{matrix} \right| }
o 2º termo do Rotacional

[center]
\Huge \textcolor{red}{- \frac{1}{r^2 \sin\theta} \cdot \textcolor{purple}{r\hat{\theta}}\begin{vmatrix} \partial_\phi & \partial_r \\ r\sin\theta\, A_\phi & A_r \end{vmatrix} }

\Huge \textcolor{green}{+ \frac{1}{r^2 \sin\theta} \cdot \textcolor{purple}{r\hat{\theta}}\begin{vmatrix} \partial_r & \partial_\phi \\ A_r & r\sin\theta\, A_\phi \end{vmatrix} }
[/center]


\frac{1}{r^2 \sin\theta} \left| \begin{matrix} \hat{r} & r\hat{\theta} & \textcolor{blue}{r\sin\theta\, \hat{\phi}} \\ \boxed{\partial_r} & \boxed{\partial_\theta} & \partial_\phi \\ \boxed{A_r} & \boxed{r A_\theta} & r\sin\theta\, A_\phi \end{matrix} \right|
\frac{1}{r^2 \sin\theta} \left| \begin{matrix} \hat{r} & r\hat{\theta} & \textcolor{blue}{r\sin\theta\, \hat{\phi}} \\ \boxed{\partial_r} & \boxed{\partial_\theta} & \partial_\phi \\ \boxed{A_r} & \boxed{r A_\theta} & r\sin\theta\, A_\phi \end{matrix} \right|
o 3º termo do Rotacional

[center]
\Huge \frac{1}{r^2 \sin\theta} \cdot \textcolor{blue}{r\sin\theta\, \hat{\phi}}\begin{vmatrix} \partial_r & \partial_\theta \\ A_r & r A_\theta \end{vmatrix}
[/center]


criei outro Tópico sobre colorir o texto nos títulos dos painéis de detalhes, que poderia corresponder às 3 cores em elementos específicos

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