A better way to do this would be to define the LaTeX printer for the object (which should be a separate printer from the pretty printer), and enable LaTeX printing with init_printing().
Aaron Meurer On Thu, Jul 2, 2015 at 10:30 AM, brombo <[email protected]> wrote: > I have implemented a custom matrix printer with "_print_MatrixBase(self, > expr)." I am running "jupyter notebook" with the output of > "_print_MatrixBase(self, expr)" being given by - > > def _print_MatrixBase(self, expr): > rows = expr.rows > cols = expr.cols > > out_str = ' \\left [ \\begin{array}{' + (cols * 'c') + '} ' > for row in range(rows): > for col in range(cols): > out_str += latex(expr[row,col]) + ' & ' > out_str = out_str[:-2] + ' \\\\ ' > out_str = out_str[:-4] + ' \\end{array}\\right ] ' > > if isinteractive(): > return display(Math(out_str)) > else: > return out_str > > for "jupyter notebook" the output is "return display(Math(out_str))" where > the out_str ins the tex output for the matrix. The notebook output is - > > See attached file > > Where sp3.g is a sympy Matrix. Why is "None" output along with the > correct matrix output? > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/2d60f6fc-a7bc-41e7-a82a-86cad4b7d096%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6L4V40%3DFL1oUSkPKSkDgcqkZJ4ZTXJ41BexTYwwLPVQCQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
