Automattic / Automattic/jetpack

Support Multi-Line LaTeX Formatting

Open
#19,684 0 comments 0 reactions 0 assignees View on GitHub
[Feature] Beautiful Math [Pri] Low Customer Report [LEGACY] Enhancement
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

#### Is your feature request related to a problem? Please describe.

The markdown block does not include support for multi-line LaTeX.

#### Describe the solution you'd like

Instead of using $latex prefix and and $ suffix for full equations with no line-breaks in all cases, can we add support for multi-line LaTeX. Example on how it could be used below.

Original equation:

```
$latex Q(\lambda,\hat{\lambda}) = -\frac{1}{2} P{(O \mid \lambda )} \sum_s \sum_m \sum_t \gamma_m^{(s)} (t)\left( n \log(2 \pi ) + \log \left| C_m^{(s)} \right| + \left( \mathbf{o}_t - \hat{\mu}_m^{(s)} \right) ^T C_m^{(s)-1} \left(\mathbf{o}_t - \hat{\mu}_m^{(s)}\right) \right)$
```

Which outputs:

![LaTeX01Long](https://user-images.githubusercontent.com/29556134/116463685-3833a900-a828-11eb-9633-a57986a1443f.JPG)

We could instead use this:

```
\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{equation}
X=
\begin{cases}
0, & \text{if}\ a=1 \\
1, & \text{otherwise}
\end{cases}
\end{equation}
\end{document}
```
Which outputs:
![LaTeX02Broken](https://user-images.githubusercontent.com/29556134/116463699-3d90f380-a828-11eb-8feb-f50b647711c2.JPG)

#### Describe alternatives you've considered

[Stack exchange discussion](https://tex.stackexchange.com/questions/3782/how-can-i-split-an-equation-over-two-or-more-lines), it can be done with an additional plugin, but if we could build the support directly and add on the LaTeX that already works, while making long equations easier to understand on the web, that seems ideal.

#### Additional context

Filled in this repo, due to [this request to show a preview of LaTeX within the block](https://github.com/Automattic/jetpack/issues/13163).

Contributor guide

Open the contributing guide

Research direction

Start by locating the markdown block and its existing LaTeX handling, then compare the requested multi-line examples with the current behavior. Define the supported syntax and rendering expectations first; the work is done when multi-line equations render correctly without breaking existing LaTeX formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex
Domain
content
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.