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

Mathematical fonts are being ignored #622

Open
PaulRegular opened this issue Apr 10, 2024 · 2 comments
Open

Mathematical fonts are being ignored #622

PaulRegular opened this issue Apr 10, 2024 · 2 comments

Comments

@PaulRegular
Copy link

I'm not sure whether this is an equatags or flextable issue; however, mathematical fonts aside from mathnormal, mathrm and mathbf are not rendering:

eqs <- c(
  "3x^2 \\in R \\subset Q",
  "\\mathnormal{3x^2 \\in R \\subset Q}",
  "\\mathrm{3x^2 \\in R \\subset Q}",
  "\\mathbf{3x^2 \\in R \\subset Q}",
  "\\mathsf{3x^2 \\in R \\subset Q}",
  "\\mathtt{3x^2 \\in R \\subset Q}",
  "\\mathfrak{3x^2 \\in R \\subset Q}"
)
df <- data.frame(formula = eqs)
df


ft <- flextable(df)
ft <- compose(
  x = ft, j = "formula",
  value = as_paragraph(as_equation(formula, width = 2, height = .5))
)
ft <- align(ft, align = "center", part = "all")
ft <- width(ft, width = 2)
ft

image

I'm using flextable 0.9.4 and equatags 0.2.0.

@davidgohel
Copy link
Owner

Don't worry, the two packages are closely interrelated.

Basically, you want to be able to change colors, fonts, etc in equations created with as_equation()? What do you mean by "Mathematical fonts".

We can try to reduce the limitations, but I'm not sure that some of them (especially those related to HTML) can be overcome.

@PaulRegular
Copy link
Author

I am by no means well versed with latex equations (or math), but there are options to apply different styles: https://www.overleaf.com/learn/latex/Mathematical_fonts. These styles are sometimes applied to follow specific notation conventions. I also know little about how all of this is translated in the background, especially in an HTML context, but it looks like Rmarkdown applies the fonts via (I presume) pandoc and MathJax.

---
output: html_document
---

**Formula**

$3x^2 \in R \subset Q$  
$\mathrm{3x^2 \in R \subset Q}$  
$\mathbf{3x^2 \in R \subset Q}$  
$\mathsf{3x^2 \in R \subset Q}$  
$\mathtt{3x^2 \in R \subset Q}$  
$\mathfrak{3x^2 \in R \subset Q}$  
$\mathbb{3x^2 \in R \subset Q}$

image

(...though, it doesn't like \mathnormal{})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants