Not sure if the answer here Jupyter notebook not printing underscores? is related:
The problem is not with Jupyter notebook but with the way the underscore is rendered in the example. The browser decided not to show the underscore for that particular resolution
... but here it goes: I try to enter the equation $$ \mathtt{A\_b} = \frac{A}{b} $$ in a Markdown cell in Jupyter notebook; and the rendering I get is this:
Don't know about you, but that looks like a dash/minus sign to me, not like an underscore.
So, how can I get a proper underline rendered in an equation in Jupyter notebook Markdown (where the equation is written as Latex, but rendered as MathML)?
Found a workaround - but I'd still love to hear a proper answer by someone who knows better ...
In the meantime - simply don't include the underscore inside \mathtt; that is, use:
$$ \mathtt{A}\_\mathtt{b} = \frac{A}{b} $$
... which results with:
Related
When I am writing math equations in a markdown cell of a jupyter notebook, I casually put all of that in $ ... $. Today, I converted an .ipynb file to .tex, and realized most of these equations are converted into messy stuff in the output pdf. For instance, I realized it is converting all '$'s into '$'s.
This is an example of what has happened:
Jupyter Notebook markdown:
$ \nabla ^{2} f(x) = \frac{-1}{(x+1)^{2}} $
Tex Output:
\$ \nabla \^{}\{2\} f(x) = \frac{-1}{(x+1)^{2}} \$
Does anyone have any ideas why this is happening? Is there a better way to write down in-line math equations so that it is more compatible with LaTeX?
If you are eventually going to LaTeX version, the traditional advice is spelled out in minrk's comment from November 8 of 2012:
"The best solution for that right now would be to use 'raw' cells instead of markdown, and just type LaTeX as you would. Then use nbconvert to turn the ipynb to TeX (code, figures and all), and run latex to render that to PDF, etc. You don't get live-rendered TeX in the browser like you do with MathJax / Markdown, but you do still have TeX / code in one document."
The step where you are converting now is probably using nbconvert under the hood even if you aren't directly. (You may be using it directly since you tagged with 'nbconvert`.)
Alternatively, if you are going to LaTeX ultimately, you may want to use a code cell and use the LaTeX magic cell line at the start of that cell. See here and here about %%latex cell magic. (You'll note it is also mentioned among the StackOverflow thread I referenced earlier.) In regards to the %%latex cell magic, I suggest actually consulting the link that leads use in an example notebook in this post because it seems it has to be full-blown LaTeX code and not just simple equations that work easily elsewhere with just dollar signs bracketing them, i.e., MathJax.
I tried that option with your equation and when I output the notebook as LaTeX, I didn't see additional backslashes added. (I didn't however actually try rendering the LaTeX, and so I cannot address if all the cruft/boilerplate that Jupyter is adding causes any issues for downstream useability.)
My question is similar to this question, but I don't know how to apply the solution to a Jupyter Notebook. When I use the \square or \Box symbol in a Markdown cell, it comes out in italics:
How can I correct this in a consistent manner? It would be great if I could do it in a global manner rather than opting for a per-notebook fix.
I want to number the LaTeX equation, I searched internet that I shall use
%%javascript
MathJax.Hub.Config({
TeX:{equationNumbers:{autoNumber:'all'}}
});
I tested with an equation also with \eqref{}:
In equation $\eqref{eq:sample}$, we find the value of an interesting integral:
\begin{equation}
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\label{eq:sample}{\tag{99}}
\end{equation}
The output in JupyterLab is
So far everything looks alright, however I start any another cell, use \eqref{eq:sample} or \ref{eq:sample} again.
In equation $\eqref{eq:sample}$, we find the value of an interesting integral:
it turns out to be a bunch of question marks.
So I tested in Jupyter Notebook as well, as long as I call the reference from another cell, MathJax failed to link the reference.
How can I solve the problem? Any suggestions?
First, at the top of your notebook, put the following:
%%javascript
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "AMS" } }
});
Then make equations in your Jupyter cells with things like:
\begin{equation}
\ddot{x} + a\dot{x} + bx = 0
\end{equation}
You will end up with numbered equations in your cells, but starting with 1 in each cell. To final step is you need to press the following reset equation numbering toolbar button that is in your Jupyter toolbar:
The equations all magically sort in order, across cells!
Note if you aren't seeing the reset numbering toolbar button, it means you haven't installed the equation number notebook extension. For instructions on how to install it, see this answer:
https://stackoverflow.com/a/42940005/1886357
I have been using WxMaxima for my symbolic calculations for a while now. The good thing about WxMaxima is that you can get formatted outputs right in the program and then export them to LaTeX format with a click of the mouse.
Now I want to try the Jupyter/Ipython plus sympy for multiple reasons. I know how to use display(Math(r' some LaTeX math here ')) but what I want is to have the result/output of a cell in a nice mathematical form; something like the TraditionalForm[] command in Mathematica.
I would appreciate if you could help me know if/how I can get that right in a Jupyter notebook?
I think I found the proper solution and it is a sympy feature rather than Jupyter/IPython one. As explained here:
If all you want is the best pretty printing, use the init_printing() function. This will automatically enable the best printer available in your environment.
and
In the [Jupyter/]IPython notebook, it will use MathJax to render LATEX.
Then one can right click on the output and select Show Math As > Tex commands:
to get the LaTeX output.
P.S. A more proper formatting can be achieved via galgebra library. I will look into that and add it here later.
I am using R Markdown 1.0.9016 in RStudio 1.0.35 Windows.
I used to be able to render equations like
$\epsilon$
But now it just shows \epsilon instead of rendering the epsilon symbol.
What went wrong and how can I fix it?
Try this, it should work:
\(\epsilon\)
You seem to need to wrap it in double $ like $$\epsilon$$