Search code examples
jupyter-notebooksympymathjax

how to control display output size in ipython


I have an ipython notebook and I want to write a function to display matrixes:

from IPython.display import display
import sympy
sympy.init_printing()
def print_matrix(a):
    display(sympy.Matrix(a))

import numpy as np
print_matrix(np.random.random((20, 20)))

This is producing a mathml output which is very large on my screen. How to control the size? I don't want to truncate numbers, I want to decrease the size of the fonts / size of the output image.

I have accomplished it with

sympy.init_printing(use_latex='png', fontsize='5pt')

but I don't like the png output, I would like the default mathjax


Solution

  • I won't save with the notebook (you'll probably need to execute some Javascript in a cell to do that), but if you right click on an equation there is an option to scale it up or down (this is a MathJax feature, which has nothing to do with the IPython notebook).