Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX equation line break operator stopped working for book project #8121

Closed
ercbk opened this issue Jan 4, 2024 · 8 comments
Closed

LaTeX equation line break operator stopped working for book project #8121

ercbk opened this issue Jan 4, 2024 · 8 comments
Labels
support a request for support third-party Issues involving interaction with a third-party library
Milestone

Comments

@ercbk
Copy link

ercbk commented Jan 4, 2024

Bug description

After updating to Quarto 1.3.340, the latex equation line break operator, \\, stopped working in "display math" blocks for my book project. Inside the RStudio visual editor, the line break operator still works as intended, but after rendering the document, the equations are inline instead of multiline.

Steps to reproduce

$$
B y_t = y_{t-1} \\
B^2 y_t = y_{t-2}
$$

Expected behavior

$$ \begin{aligned} B y_t = y_{t-1} \\ B^2 y_t = y_{t-2} \end{aligned} $$

Actual behavior

$$ B y_t = y_{t-1} \\ B^2 y_t = y_{t-2} $$

Your environment

  • IDE: RStudio 2023.12.0 Build 369
  • OS: Windows 10 Pro, Version 22H2

Quarto check output

[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.3.340
      Path: C:\Users\tbats\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.10.11
      Path: C:/Users/tbats/AppData/Local/Programs/Python/Python310/python.exe
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with py -m pip install jupyter

[>] Checking R installation...........OK
      Version: 4.3.2
      Path: C:/PROGRA~1/R/R-43~1.2
      LibPaths:
        - C:/Users/tbats/AppData/Local/R/win-library/4.3
        - C:/Program Files/R/R-4.3.2/library
      knitr: 1.45
      rmarkdown: 2.25

[>] Checking Knitr engine render......OK
@ercbk ercbk added the bug Something isn't working label Jan 4, 2024
@cscheid
Copy link
Collaborator

cscheid commented Jan 4, 2024

Can you try updating to the 1.4 prereleases? https://github.com/quarto-dev/quarto-cli/releases

@mcanouil
Copy link
Collaborator

mcanouil commented Jan 4, 2024

In case you reproduce using 1.4, please share a small self-contained "working" (reproducible) example to work with, i.e., a complete Quarto document or a Git repository? Thanks.
For instance, books can be from LaTeX or HTML, you did not specify in which your issue occurred.
Because, and if I am not mistaken, the equation mechanism is independent of book project, a simple/single document should display the same issue.

You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````).

````qmd
---
title: "Reproducible Quarto Document"
format: html
engine: knitr
---

This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.

```{r}
plot(cars)
```

![A placeholder image](https://placehold.co/600x400.png)

The end.
````

@ercbk
Copy link
Author

ercbk commented Jan 4, 2024

Yes, the behavior is still present in 1.4, and I'm rendering a HTML document. The book is in a repo, and the example that I used is here. You can see it rendered in this section. I haven't pushed the 1.4 version yet though. If you would like me to do that, let me know.

---
title: "Reproducible Quarto Document"
format: html
engine: knitr
---

$$
B y_t = y_{t-1} \\
B^2 y_t = y_{t-2}
$$ 

@cscheid
Copy link
Collaborator

cscheid commented Jan 4, 2024

By inspecting the source of your own "expected behavior" vs "observed behavior", you had to add \begin{aligned} in order for the line breaks to appear in the HTML rendering (and they don't without them, on GitHub as well). I believe this comes from a MathJax update, so it's "working as intended", as in "we're using MathJax". Is there a reason you can't use \begin{aligned}?

@cscheid cscheid added third-party Issues involving interaction with a third-party library and removed bug Something isn't working labels Jan 4, 2024
@ercbk
Copy link
Author

ercbk commented Jan 4, 2024

Yeah, I can use that, but it's kind of a hack. I think the {aligned} purpose is to align multiple equations. It also means that the places I haven't used {aligned} in the book will be affected if I ever edit and re-render them. In other words, I'll have to redo the sections where I haven't used {aligned}.

@cderv
Copy link
Collaborator

cderv commented Jan 4, 2024

It seems you are targeting HTML output right ?

The linebreak issue with Mathajx is a known MathJax 3 limitation

It was discussed previously in this repo

and also on the web

I am surprised this was working for you with a previous quarto version unless you where somehow using Mathjax 2.

Regarding the use of // in equation environment, I don't even think this works in LaTeX itself. You would have to use amsmath package for example, and special environment like split or align. Or aligned also as adviced. Example: https://www.overleaf.com/learn/latex/Aligning_equations_with_amsmath

Probably this will be fixed in HTML with Mathjax v4

In the meantime, you could also switch to KaTeX for math rendering in HTML as I think it supports // (but you may lack other things maybe 🤔 )

So considering all this, I am curious how this worked on your side with Mathjax.

Do you still have a page in your book rendered with previous Quarto version ?
Or know when your website did have a working version so that we could look at the produced HTLM at the time in your gh-pages branch ?

@ercbk
Copy link
Author

ercbk commented Jan 4, 2024

Geez. I'm feeling a little gaslit 😅. I can't find me using it like I'm describing anywhere! Every place where I have multiline equation blocks, I'm always aligning them anyways. I know I've wanted to do it without aligning at least twice in the last week or so, and I just ended up splitting them into separate blocks. I guess maybe I'm remembering doing it that way back when I was creating equation image files with quicklatex or something. Evidently it's not that big of a deal (for me at least). Sorry for the fuss 😬.

@cderv
Copy link
Collaborator

cderv commented Jan 4, 2024

No worries ! Thanks for reaching out !

I'll close this if you don't mind - this is really a Mathjax 3 limitation for now and the behavior will depend on its evolution, and then Quarto / Pandoc support.

@cderv cderv closed this as completed Jan 4, 2024
@cderv cderv added this to the v1.4 milestone Jan 4, 2024
@cderv cderv added the support a request for support label Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support a request for support third-party Issues involving interaction with a third-party library
Projects
None yet
Development

No branches or pull requests

4 participants