Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hi, I'm new to Cadabra. If I try to run the following code

test := e_{\mu}{}^{a}; for n in test: print(str(n))

I get the following error message:


Generic typesetting error; LaTeX failed. Please report a bug.

Package hyperref Warning: Rerun to get /PageLabels entry.

! Package inputenc Error: Unicode character μ (U+03BC) (inputenc) not set up for use with LaTeX.

See the inputenc package documentation for explanation. Type H for immediate help. ...

l.191 \end{verbatim}

No pages of output. Transcript written on file1HlZM6.log. . See file1HlZM6.tex to debug this.

TEXINPUTS = /usr/local/share/cadabra2/latex/: TMPDIR = /tmp/


I'm using Cadabra 2.3.9 on Ubuntu 20.04 (Tex Live 2019).

Thanks in advance,

Jan

in Bug reports by

1 Answer

+1 vote
 
Best answer

There are a few things going on here. Let me start with the right way to do this:

test := e_{\mu}{}^{a};
for n in test:
    display(n.ex())

In order to display Cadabra expressions, it's almost always best to use display, as print lacks the logic to make the notebook display LaTeX expressions. The display function ensures that many things (mathematical expressions, plots, ...) show up in the best way in the notebook.

You also need n.ex(), not just n, because display does not (yet) understand the ExNode object (which n is). For everything it does not understand, it calls str on it, and then you are effectively back to what you wrote. By calling n.ex() you convert the ExNode object n to an Ex object, which display knows how to handle.

Finally: I agree it would have been useful if str(n) produced something printable in the notebook (so that your original code would display the three expressions in non-typeset LaTeX form). Unfortunately, by default str turns \mu into the Unicode symbol for that character, and LaTeX doesn't understand that. This is a bug, we should turn off Unicode printing in the notebook.

by (80.3k points)
...