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

Math rendering in Quarto + LaTeX errors #1798

Open
olivroy opened this issue Jul 16, 2024 · 0 comments
Open

Math rendering in Quarto + LaTeX errors #1798

olivroy opened this issue Jul 16, 2024 · 0 comments

Comments

@olivroy
Copy link
Collaborator

olivroy commented Jul 16, 2024

While trying to setup visual tests, I encountered a LaTeX error in Quarto.
Works with html output.

here is the Quarto document + error message (with current main and the same with gt 0.11). The recent addition of Floating tables #1588 isn't the culprit here as I tested with both latex.use_longtable = TRUE and FALSE.

Missing $ inserted.
<inserted text> 
                $
l.335 1 & \(1\) & $$\frac{1}{s}
                               $$ \\ 

You may need to $ $ around an expression in this file.
---
title: "x"
format: pdf
editor: visual
---

# Home


```{r}
# devtools::load_all()
library(gt)
data.frame(
  idx = 1:37,
  l_time_domain = 
    c(
      "$1$",
      "${{\\bf{e}}^{a\\,t}}$",
      "${t^n},\\,\\,\\,\\,\\,n = 1,2,3, \\ldots$",
      "${t^p}, p > -1$",
      "$\\sqrt t$",
      "${t^{n - \\frac{1}{2}}},\\,\\,\\,\\,\\,n = 1,2,3, \\ldots$",
      "$\\sin \\left( {at} \\right)$",
      "$\\cos \\left( {at} \\right)$",
      "$t\\sin \\left( {at} \\right)$",
      "$t\\cos \\left( {at} \\right)$",
      "$\\sin \\left( {at} \\right) - at\\cos \\left( {at} \\right)$",
      "$\\sin \\left( {at} \\right) + at\\cos \\left( {at} \\right)$",
      "$\\cos \\left( {at} \\right) - at\\sin \\left( {at} \\right)$",
      "$\\cos \\left( {at} \\right) + at\\sin \\left( {at} \\right)$",
      "$\\sin \\left( {at + b} \\right)$",
      "$\\cos \\left( {at + b} \\right)$",
      "$\\sinh \\left( {at} \\right)$",
      "$\\cosh \\left( {at} \\right)$",
      "${{\\bf{e}}^{at}}\\sin \\left( {bt} \\right)$",
      "${{\\bf{e}}^{at}}\\cos \\left( {bt} \\right)$",
      "${{\\bf{e}}^{at}}\\sinh \\left( {bt} \\right)$",
      "${{\\bf{e}}^{at}}\\cosh \\left( {bt} \\right)$",
      "${t^n}{{\\bf{e}}^{at}},\\,\\,\\,\\,\\,n = 1,2,3, \\ldots$",
      "$f\\left( {ct} \\right)$",
      "${u_c}\\left( t \\right) = u\\left( {t - c} \\right)$",
      "$\\delta \\left( {t - c} \\right)$",
      "${u_c}\\left( t \\right)f\\left( {t - c} \\right)$",
      "${u_c}\\left( t \\right)g\\left( t \\right)$",
      "${{\\bf{e}}^{ct}}f\\left( t \\right)$",
      "${t^n}f\\left( t \\right),\\,\\,\\,\\,\\,n = 1,2,3, \\ldots$",
      "$\\displaystyle \\frac{1}{t}f\\left( t \\right)$",
      "$\\displaystyle \\int_{{\\,0}}^{{\\,t}}{{\\,f\\left( v \\right)\\,dv}}$",
      "$\\displaystyle \\int_{{\\,0}}^{{\\,t}}{{f\\left( {t - \\tau } \\right)g\\left( \\tau  \\right)\\,d\\tau }}$",
      "$f\\left( {t + T} \\right) = f\\left( t \\right)$",
      "$f'\\left( t \\right)$",
      "$f''\\left( t \\right)$",
      "${f^{\\left( n \\right)}}\\left( t \\right)$"
    ),
  l_laplace_s_domain =
    c(
      "$$\\frac{1}{s}$$",
      "$$\\frac{1}{{s - a}}$$",
      "$$\\frac{{n!}}{{{s^{n + 1}}}}$$",
      "$$\\frac{{\\Gamma \\left( {p + 1} \\right)}}{{{s^{p + 1}}}}$$",
      "$$\\frac{{\\sqrt \\pi }}{{2{s^{\\frac{3}{2}}}}}$$",
      "$$\\frac{{1 \\cdot 3 \\cdot 5 \\cdots \\left( {2n - 1} \\right)\\sqrt \\pi }}{{{2^n}{s^{n + \\frac{1}{2}}}}}$$",
      "$$\\frac{a}{{{s^2} + {a^2}}}$$",
      "$$\\frac{s}{{{s^2} + {a^2}}}$$",
      "$$\\frac{{2as}}{{{{\\left( {{s^2} + {a^2}} \\right)}^2}}}$$",
      "$$\\frac{{{s^2} - {a^2}}}{{{{\\left( {{s^2} + {a^2}} \\right)}^2}}}$$",
      "$$\\frac{{2{a^3}}}{{{{\\left( {{s^2} + {a^2}} \\right)}^2}}}$$",
      "$$\\frac{{2a{s^2}}}{{{{\\left( {{s^2} + {a^2}} \\right)}^2}}}$$",
      "$$\\frac{{s\\left( {{s^2} - {a^2}} \\right)}}{{{{\\left( {{s^2} + {a^2}} \\right)}^2}}}$$",
      "$$\\frac{{s\\left( {{s^2} + 3{a^2}} \\right)}}{{{{\\left( {{s^2} + {a^2}} \\right)}^2}}}$$",
      "$$\\frac{{s\\sin \\left( b \\right) + a\\cos \\left( b \\right)}}{{{s^2} + {a^2}}}$$",
      "$$\\frac{{s\\cos \\left( b \\right) - a\\sin \\left( b \\right)}}{{{s^2} + {a^2}}}$$",
      "$$\\frac{a}{{{s^2} - {a^2}}}$$",
      "$$\\frac{s}{{{s^2} - {a^2}}}$$",
      "$$\\frac{b}{{{{\\left( {s - a} \\right)}^2} + {b^2}}}$$",
      "$$\\frac{{s - a}}{{{{\\left( {s - a} \\right)}^2} + {b^2}}}$$",
      "$$\\frac{b}{{{{\\left( {s - a} \\right)}^2} - {b^2}}}$$",
      "$$\\frac{{s - a}}{{{{\\left( {s - a} \\right)}^2} - {b^2}}}$$",
      "$$\\frac{{n!}}{{{{\\left( {s - a} \\right)}^{n + 1}}}}$$",
      "$$\\frac{1}{c}F\\left( {\\frac{s}{c}} \\right)$$",
      "$$\\frac{{{{\\bf{e}}^{ - cs}}}}{s}$$",
      "${{\\bf{e}}^{ - cs}}$",
      "${{\\bf{e}}^{ - cs}}F\\left( s \\right)$",
      "${{\\bf{e}}^{ - cs}}{\\mathcal{L}}\\left\\{ {g\\left( {t + c} \\right)} \\right\\}$",
      "$F\\left( {s - c} \\right)$",
      "${\\left( { - 1} \\right)^n}{F^{\\left( n \\right)}}\\left( s \\right)$",
      "$\\int_{{\\,s}}^{{\\,\\infty }}{{F\\left( u \\right)\\,du}}$",
      "$\\displaystyle \\frac{{F\\left( s \\right)}}{s}$",
      "$F\\left( s \\right)G\\left( s \\right)$",
      "$\\displaystyle \\frac{{\\displaystyle \\int_{{\\,0}}^{{\\,T}}{{{{\\bf{e}}^{ - st}}f\\left( t \\right)\\,dt}}}}{{1 - {{\\bf{e}}^{ - sT}}}}$",
      "$sF\\left( s \\right) - f\\left( 0 \\right)$",
      "${s^2}F\\left( s \\right) - sf\\left( 0 \\right) - f'\\left( 0 \\right)$",
      "${s^n}F\\left( s \\right) - {s^{n - 1}}f\\left( 0 \\right) - {s^{n - 2}}f'\\left( 0 \\right) \\cdots - s{f^{\\left( {n - 2} \\right)}}\\left( 0 \\right) - {f^{\\left( {n - 1} \\right)}}\\left( 0 \\right)$"
    )
) |>
  gt() |>
  fmt_markdown() |>
  cols_label(
    idx = "",
    l_time_domain = md("$f\\left( t \\right) = {\\mathcal{L}^{\\,\\, - 1}}\\left\\{ {F\\left( s \\right)} \\right\\}$"),
    l_laplace_s_domain = md("$F\\left( s \\right) = \\mathcal{L}\\left\\{ {f\\left( t \\right)} \\right\\}$")
  ) |>
  tab_header(title = "Math Rendering") |>
  tab_source_note(
    source_note = md("The hyperbolic functions: $\\cosh \\left( t \\right) = \\frac{{{{\\bf{e}}^t} + {{\\bf{e}}^{ - t}}}}{2}$ , $\\sinh \\left( t \\right) = \\frac{{{{\\bf{e}}^t} - {{\\bf{e}}^{ - t}}}}{2}$")
  ) |>
  cols_align(align = "center") 
```

Also dates, don't render properly without fmt_date() in LaTeX. Will probably get fixed as part of #1687

@olivroy olivroy changed the title While trying to setup visual tests, I encountered a LaTeX error in Quarto Math rendering in Quarto + LaTeX errors Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants