How to change the alignment of the displayed equations in IPython Notebook?

I would like my MathJax to display equations in the IPython Notebook for left justification, not centering. This is controlled by the kernel configuration parameter. Run in MathJax as described here .

I tried to set this parameter in IPython Notebook by adding it to the config.js file

MathJax.Hub.Config({ displayAlign: "left" }); 

but it has no effect.

How to configure MathJax kernel configuration parameters in IPython laptop?

[Update] I found one way that works: add the specified configuration lines not in config.js, but in mathjaxutils.js. In my case (Windows 8) this file is here: C:\Anaconda\Lib\site-packages\IPython\html\static\notebook\js\mathjaxutils‌​.js . This is not a big solution because it involves modifying the file, which is supposed to be overwritten the next time IPython is updated.

[Refresh] The method suggested by @Ian in the comments works, but only one notepad at a time. To summarize, I created the file my_css.css, the contents of which

 <script> MathJax.Hub.Config({ displayAlign: 'left' }); </script> 

In the notebook, if I run this cell

 from IPython.core.display import HTML css_file = 'my_css.css' HTML(open(css_file, "r").read()) 

the displayed equations are left-aligned as desired.

However, I would like it to be the default for all my laptops. I tried adding this to my custom.js

 MathJax.Hub.Config({ displayAlign: 'left' }); 

and for good measure added this to my custom.css

 <script> MathJax.Hub.Config({ displayAlign: 'left' }); </script> 

But not one of them has any effect. If there is a way to make this the default setting for all laptops without changing the main IPython files, this will be ideal.

+6
source share
2 answers

You can try to include the css file. For example, this set of laptops draws this css file (see the last cell in the notebook), which explicitly sets the displayAlign tag, but sets it to center .

+1
source

Use \begin{align} and \end{align} . This does not exactly answer the question, but has the desired effect. For example, try:

 $ \begin{align} \frac{1}{2} \times \frac{3}{2} = \frac{3}{4} \end{align} $ 

The above value does the same as

 $$ \frac{1}{2} \times \frac{3}{2} = \frac{3}{4} $$ 

except that it is valid.

This approach has the added benefit that other alignments can be added, for example:

 $ \begin{align} \dot{x} & = \sigma(yx) \\ \dot{y} & = \rho x - y - xz \\ \dot{z} & = -\beta z + xy \end{align} $ 

This last block of code is from Motivational Examples in Jupyter Notebook docs.

Other examples of aligning equations can be found here. Aligning Multiple Equations

0
source

Source: https://habr.com/ru/post/982067/


All Articles