1
$\begingroup$

The circuit draw command doesn't work when there is a custom gate as follows:

qc = QuantumCircuit(2)
phi = pi/2
qc.cz(0,1)
qc.rx(5*phi,0)
qc.rx(9*phi,1)
qc.cx(0,1)
qc.rx(3*phi,0)
qc.cx(0,1)
qc.cz(0,1)
Urot = qc.to_gate()
Urot.name = "$U_\mathrm{rot}$"
ctrl_Urot = Urot.control()
ctrl_Urot.label = "C-Urot"
circ = QuantumCircuit(2)
circ.append(Urot,[0,1])
circ.draw('latex')  

In the Jupyter notebook in VSCode, it states

Unable to compile LaTeX. Perhaps you are missing the `qcircuit` package. The output from the `pdflatex` command is in `latex_error.log`.

This is the relevant part of the error log.

(...\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-pdf
tex.def)
No file circuit.aux.

It works when circ.draw('mpl') is called, however. The package qcircuit is installed.

Circuit with 'mpl' label

$\endgroup$
1
  • $\begingroup$ I have just run into the identical problem! Fortunately, as you mentioned, mpl gives good enough results. $\endgroup$ Nov 16, 2022 at 19:32

2 Answers 2

1
$\begingroup$

It seems to me that the problem is related with the Qiskit's Latex math mode in the gate name "$U_\mathrm{rot}$". Replacing that line for Urot.name = "U_{\mathrm{rot}}" shows this result in my environment:

Custom Urot gate

What you tried should be valid, I think, given you set \mathrm between curly brackets (that is $U_{\mathrm{rot}}$). So I reported the problem here https://github.com/Qiskit/qiskit-terra/issues/9208

$\endgroup$
0
$\begingroup$

If qcircuit and pdflatex are already Installed, ....

Retry after installing texlive, if not downloaded in prior on your system.

Download and unzip the zip-file

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.