katexquarto

Latex equation does not properly split in quarto


Goal

To render a long latex equation in two lines in quarto

YAML

---
title: "ABC"
description: "XYZ"
format: 
  html:
    page-layout: full
    toc-location: left
    html-math-method: katex
---

Attempts

The attempts and renders are as follows:

Attempt 1

$$
v_n(t+\tau) = {min} \left\{v_n(t) + 2.5 a_n\tau (1-v_n(t)/V_n){(0.025+v_n(t)/V_n)}^{1/2}, \\ b_n\tau+\sqrt{b_n^2\tau^2 -b_n [ 2[x_{n-1}(t)-s_{n-1}-x_n(t)] - v_n(t)\tau- v_{n-1}(t)^2\hat{b}]}\right\}
$$

enter image description here

Attempt 2

$$
\begin{split}
v_n(t+\tau) = {min} \left \{v_n(t) + 2.5 a_n\tau(1-v_n(t)/V_n){(0.025+v_n(t)/V_n)}^{1/2}, \\ b_n \tau + \sqrt{b_n^2 \tau^2 - b_n [2 [x_{n-1}(t) - s_{n-1} - x_n(t)]] - v_n(t) \tau - v_{n-1}(t)^2 \hat{b}]} \right \}
\end{split} 
$$

enter image description here

Attempt 3: Remove \left and \right

enter image description here

But I want large braces. How can I fix this?


Solution

  • Line break will not work inside the \left..\right group. Instead, try \biggl..\biggr.


    ---
    title: "ABC"
    description: "XYZ"
    format: 
      html:
        page-layout: full
        toc-location: left
        html-math-method: katex
    ---
    
    ## Quarto
    
    ### Long Math equation
    
    
    $$
    v_n(t+\tau) = {min} \biggl\{v_n(t) + 2.5 a_n\tau (1-v_n(t)/V_n){(0.025+v_n(t)/V_n)}^{1/2}, \\ b_n\tau+\sqrt{b_n^2\tau^2 -b_n [ 2[x_{n-1}(t)-s_{n-1}-x_n(t)] - v_n(t)\tau- v_{n-1}(t)^2\hat{b}]}\biggr\}
    $$
    
    

    The rendered document looks like this,

    long_math_equation


    Also note that, you cannot use eqnarray here, because this environment is not supported in katex. see here what environments are supported in katex