How to output latex embedded in dataframe into jupyterbook

16 Views Asked by At

I am writing a jupyterbook and want to output formatted tables which used dataframes. In the dataframes there are sometimes references or math formulas in the cells, stored as text. Is it possible to render these as part of the table? I am using the markdown/jupyterbook code below to generate but as is visible the formula and reference are not rendering. Moreover the formula does not get a numbering but only ().

Please note the comments in the code - in order to run remove the two spaces that were needed to embed the code itself (markdown makes use of the same "hypertext" syntax)

Help is much appreciated. The goal is by the way to be able to publish to HTML but also PDF, keeping the table formatting, HTML only is a good start.

Thanks

Output from jupyterbook markdown file (code below)

---
jupytext:
  formats: md:myst
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.13
    jupytext_version: 1.11.5
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

# TITLE
Hello some text

```{math}
:label: myformula
X_{m}=\frac{1}{\beta e^{-S_{m-1}+1}}
# note remove space in next line
` ``

```{code-cell} ipython3
:tags: ["remove-input"]

import pandas as pd
import numpy as np
from IPython.display import display, HTML
data = {
'col':
['$\alpha$'],
'col1':
['$$h$$ello and reference: {eq}`myformula`']
}
df = pd.DataFrame(data)
s = df.style.set_table_styles([
                               {'selector': 'th','props': [('background-color', '#4f81bd')]},
                               {'selector': 'th','props': 'color: white; font-weight:normal;'},                               
                               ])                             
s
# note remove space in next line
` ``
0

There are 0 best solutions below