Working through the Qiskit text and came across this bit of coding on the density matrix page:
psi_AB.draw('latex', prefix='|\\psi_{AB}\\rangle = ')
which is supposed to produce... $$|\psi_{AB}\rangle = 1/\sqrt{2}(|00\rangle +|11\rangle)$$ However, it seems that the prefix as a part of the .draw() no longer works to create this output so I am attempting to write the the $|\psi_{AB}\rangle = $ portion just as I have done here. The problem is that this is not working in Jupyter notebook and I am not sure what I could be doing wrong.
I've tried single and double $'s.I've tried single and double quotations. I've attempted to use display() and print(). No matter what I try I end up with syntax errors that indicate the dollar signs as the issue or it prints |\psi_{AB}\rangle = without converting to latex. Any help with this coding issue would be appreciated!
Edit: I have run an update on my qiskit and everything now works exactly how it does on the Density matrix page in the qiskit text. They have errors with the prefix in the Statevector and so do I. The page is just to emphasize where the code came from. The real problem is that writing 'DollarSign x=5 DollarSign' in my Jupyter notebook does not change it to the latex $x=5$ as it does here. Instead I get a syntax error indicating the first dollar sign. Perhaps there is something I need to import to make this feature work?
Edit 2.0 Pylatexenc has been properly installed and is up to date. I've figured out how to get the markdown to work when I wish to simply type text. I now feel that the error is in the source coding for qiskit.quantum_info.Statevector.draw. I believe this function is not correctly creating the prefix because the coding, as seen below, does not allow for prefix as an arguement.
operator_shape = state._op_shape
# we only use the ket convetion for qubit statevectors
# this means the operator shape should hve no input dimensions and all output dimensions equal to 2
is_qubit_statevector = len(operator_shape.dims_r()) == 0 and set(operator_shape.dims_l()) == {2}
if convention == "ket" and is_qubit_statevector:
latex_str = _state_to_latex_ket(state._data)
else:
latex_str = array_to_latex(state._data, source=True, **args)
return prefix + latex_str + suffix
As seen in the excerpt above the _state_to_latex_ket() does not allow for any arguments other than the state data which would be why it continues to give me errors no matter how I type the prefix in!
If I am correct, then this renders my question moot! Thank you for your help!