7

I would like to fill in values in a report that I'm generating using a Jupyter notebook. While I am using the nbextension Python Markdown, this appears to only allow variables that can isolated, i.e. I can't fill in values that would be in a fraction.

This works, since it is only symbolic:

Markdown cell:

\begin{equation*}
\xi_b = \frac{\epsilon_c}{\epsilon_c + \epsilon_y}
\end{equation*}

But this code snippet wouldn't:

Code cell:

epsilon_c = 0.003
epsilon_y = 0.005

Markdown cell:

\begin{equation*}
\xi_b = \frac{{{epsilon_c}}}{{{epsilon_c}} + {{epsilon_y}}}
\end{equation*}

Is there some way to inject the python variable values directly into my LaTeX expression?

1

1 Answer 1

5

You can generate the Latex output from Python cell like this:

from IPython.display import Latex

epsilon_c = 0.003
epsilon_y = 0.005
Latex(f"""\\begin{{equation*}}
\\xi_b = \\frac{{{epsilon_c}}}{{{epsilon_c}}} + {{{epsilon_y}}}
\\end{{equation*}}
""")

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.