Replies: 4 comments 1 reply
-
That will not work. Instead, write a Python cell that emits Math code:
That will work for simple cases. For more complicated cases (if you need to use Quarto's crossref system, etc), you will need to use |
Beta Was this translation helpful? Give feedback.
-
@rputikar Could you properly format your post using code blocks for code and terminal outputs? Thanks. |
Beta Was this translation helpful? Give feedback.
-
---
title: "Inline python inside latex equation"
format: html
engine: jupyter
---
```{python}
a = 1.02
b = 3.05
```
$a = `{python} f'{a:.2f}'`$
$a =$ `{python} f'{a:.2f}'`
$$
\frac{a^2}{b} = \frac{({`{python} f'{a:.2f}'`})^2}{(`{python} f'{b:.2f}'`)}
$$ |
Beta Was this translation helpful? Give feedback.
-
I think this could work if you correctly output Markdown content to avoid the escaping. Currently it is not working because the When trying your example above I get Inline code output is considered a text to write in Markdown, so anything related to markdown syntax is escaped (like ---
title: "Inline python inside latex equation"
format: html
engine: jupyter
keep-md: true
---
```{python}
from IPython.display import Markdown
```
```{python}
a = 1.02
b = 3.05
```
$a = `{python} Markdown(f'{a:.2f}')`$
$$
\frac{a^2}{b} = \frac{({`{python} Markdown(f'{a:.2f}')`})^2}{(`{python} Markdown(f'{b:.2f}')`)}
$$ |
Beta Was this translation helpful? Give feedback.
-
Description
Is it possible to write inline python inside latex equation?
I have (ignore the \)
when I write
I get 102 instead of 1.02
writing
prints 1.02 correctly
yields
Beta Was this translation helpful? Give feedback.
All reactions