Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix latex drawer symmetrical gates display #6877

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions qiskit/visualization/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def latex(self):
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
"""
header_scale = "\\scalebox{{{}}}".format(self.scale) + "{"

Expand Down Expand Up @@ -328,7 +330,7 @@ def _get_image_depth(self):
# which take 4 columns
base_type = None if not hasattr(op, "base_gate") else op.base_gate
if isinstance(op, RZZGate) or isinstance(base_type, (U1Gate, PhaseGate, RZZGate)):
column_width = 4
column_width = 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just trying out some gates. I feel in the below circuit the gap between the first and the second layer of gates is large. I think this trouble arises whenever there is a large gate in the same layer as that of the symmetric gate.

from math import pi

qc = QuantumCircuit(4)
qc.u3(0.23123414,0.1223412343,0.3412342345,0)
qc.cu1(0.123456,1,2)
qc.rzz(pi,3,1)
qc.cp(pi/3,0,1)
qc.swap(0,1)

qc.draw('latex)

image

Do you think we can we do something about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could go back to 4 columns, but then the ZZ gate may overlap with the next layer of gates in case there aren't wider gates giving some extra space. (I'm not entirely sure, but I think ZZ is the only gate with such issue).

image

As @enavarro51 said in #6061, changing the number of columns based on the gate text may add unnecessary complexness. My take had been trying to use a smaller font for the labels, but I was unable to figure it out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, if only RZZ allows for the overlap to happen, then maybe we could just split the column counts (5 for RZZ, 4 otherwise). The issue would still remain for RZZ gates in the same layer as other (large enough) gates, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit of a messy problem. I agree with @TharrmashasthaPV that the spacing is too wide. The problem is that qcircuit takes care of spacing for gates, but doesn't know what to do with this arbitrary side text, so it deals with it as if it is just the 2 bullets and a vertical line in terms of horizontal space.

image

image

There's a simple (kind of) solution which is just to restrict the floats to 1 decimal and lower case ZZ (which is what it used to be), then set cols to increment by 3 instead of 5. Not perfect, but maybe acceptable?

image

But then you run into this.

image

Ultimately this should work the same as gates, where the sidetext is a special gate that expands the space to the next column based on the width of the text. Maybe need a \newcommand?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe \phantom could help to normalize the space?

Forcing the amount of decimals sounds like a too drastic solution to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been thinking about this issue a fair bit, tried using \phantom but that didn't seem to resolve much. I think we need a way to dynamically change the number of columns depending on the length of the gate_text. When the actual gate is drawn, is it always placed in the centre of the columns? If yes then as we increase the number of columns we will also inadvertently be increasing the space on the left of the gate. Maybe another solution would be to have gates with side text not placed in the centre of the columns but on the left hand side.

max_column_widths.append(current_max)
columns += column_width

Expand Down Expand Up @@ -527,8 +529,12 @@ def _build_symmetric_gate(self, op, gate_text, wire_list, col):
)
self._latex[wire_last][col] = "\\control \\qw"
# Put side text to the right between bottom wire in wire_list and the one above it
self._latex[wire_max - 1][col + 1] = "\\dstick{\\hspace{2.0em}%s} \\qw" % gate_text
return 4 # num_cols for side text gates
# \settowidth allows redefining \glen to the width of the gate. This avoids overlapping.
self._latex[wire_max][col] += (
" \\cds{-1}{\\settowidth{\\glen}{\\ensuremath{%s}}"
" \\hspace{0.5em}\\hspace{\\glen}\\ensuremath{%s}}" % (gate_text, gate_text)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I could check, I think \hphantom latex command also creates empty space as required. So I think on replacing lines 533-536 by

self._latex[wire_max][col] += (
    " \\cds{-1}{\hspace{0.5em}\hphantom{\\ensuremath{%s}}"
    "\\ensuremath{%s}}" % (gate_text, gate_text)
)

we should still get the required spacing correctly.

return 5 # num_cols for side text gates

def _build_measure(self, node, col):
"""Build a meter and the lines to the creg"""
Expand Down
2 changes: 2 additions & 0 deletions test/python/visualization/references/test_latex_4597.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \qw & \qw & \qw & \qw\\
Expand Down
2 changes: 2 additions & 0 deletions test/python/visualization/references/test_latex_big_gates.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=1.0em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \multigate{2}{\mathrm{iqp:[[6\,5\,3];\,[5\,4\,5];\,[3\,5\,1]]}}_<<<{0} & \gate{\mathrm{Unitary}} & \qw & \qw\\
Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions test/python/visualization/references/test_latex_cnot.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{X}} & \ctrl{1} & \ctrl{1} & \ctrlo{1} & \ctrl{1} & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} & \meter & \qw & \gate{\mathrm{H}} & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{X}} & \gate{\mathrm{H}} & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : \ket{{0}} } & \lstick{ {q}_{0} : \ket{{0}} } & \gate{\mathrm{X}} & \gate{\mathrm{H}} & \qw & \qw\\
Expand Down
12 changes: 7 additions & 5 deletions test/python/visualization/references/test_latex_cswap_rzz.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{X}} & \ctrl{1} & \control \qw & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{1} : } & \lstick{ {q}_{1} : } & \gate{\mathrm{X}} & \qswap & \ctrl{-1} & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{2} : } & \lstick{ {q}_{2} : } & \qw & \qswap \qwx[-1] & \ctrlo{-1} & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{3} : } & \lstick{ {q}_{3} : } & \qw & \qw & \ctrl{-3} & \dstick{\hspace{2.0em}\mathrm{ZZ}\,(\mathrm{\frac{3\pi}{4}})} \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{4} : } & \lstick{ {q}_{4} : } & \qw & \qw & \ctrlo{-1} & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{X}} & \ctrl{1} & \control \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{1} : } & \lstick{ {q}_{1} : } & \gate{\mathrm{X}} & \qswap & \ctrl{-1} & \qw & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{2} : } & \lstick{ {q}_{2} : } & \qw & \qswap \qwx[-1] & \ctrlo{-1} & \qw & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{3} : } & \lstick{ {q}_{3} : } & \qw & \qw & \ctrl{-3} & \qw & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{4} : } & \lstick{ {q}_{4} : } & \qw & \qw & \ctrlo{-1} \cds{-1}{\settowidth{\glen}{\ensuremath{\mathrm{ZZ}\,(\mathrm{\frac{3\pi}{4}})}} \hspace{0.5em}\hspace{\glen}\ensuremath{\mathrm{ZZ}\,(\mathrm{\frac{3\pi}{4}})}} & \qw & \qw & \qw & \qw & \qw & \qw\\
\\ }}
\end{document}
2 changes: 2 additions & 0 deletions test/python/visualization/references/test_latex_deep.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \qw & \qw\\
Expand Down
2 changes: 2 additions & 0 deletions test/python/visualization/references/test_latex_empty.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=1.0em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \ctrl{1} & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{{$\mathrm{global\,phase:\,} \mathrm{\frac{\pi}{2}}$}
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} & \qw & \qw\\
Expand Down
2 changes: 2 additions & 0 deletions test/python/visualization/references/test_latex_huge.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} & \ctrl{39} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=1.0em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{|\psi\rangle\,(\mathrm{0,1})} & \multigate{1}{|\psi\rangle\,(\mathrm{0,1,0,0})}_<<<{0} & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=1.0em @!R { \\
\nghost{ {qr}_{0} : } & \lstick{ {qr}_{0} : } & \qw & \qw & \qw\\
Expand Down
16 changes: 9 additions & 7 deletions test/python/visualization/references/test_latex_iqx.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} & \gate{\mathrm{X}} & \qw & \qw & \qw & \ctrl{1} & \ctrl{1} & \qswap & \ctrl{1} & \ctrl{1} & \multigate{1}{\mathrm{Dcx}}_<<<{0} & \ctrl{1} & \ctrl{1} & \qw & \qw\\
\nghost{ {q}_{1} : } & \lstick{ {q}_{1} : } & \qw & \qw & \qw & \qw & \qw & \targ & \ctrl{1} & \qswap \qwx[-1] & \qswap & \ctrl{1} & \ghost{\mathrm{Dcx}}_<<<{1} & \multigate{1}{\mathrm{Dcx}}_<<<{0} & \ctrl{1} & \qw & \qw\\
\nghost{ {q}_{2} : } & \lstick{ {q}_{2} : } & \qw & \qw & \qw & \qw & \qw & \qw & \targ & \qw & \qswap \qwx[-1] & \qswap & \qw & \ghost{\mathrm{Dcx}}_<<<{1} & \multigate{1}{\mathrm{Dcx}}_<<<{0} & \qw & \qw\\
\nghost{ {q}_{3} : } & \lstick{ {q}_{3} : } & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qswap \qwx[-1] & \qw & \qw & \ghost{\mathrm{Dcx}}_<<<{1} & \qw & \qw\\
\nghost{ {q}_{4} : } & \lstick{ {q}_{4} : } & \gate{\mathrm{Z}} & \gate{\mathrm{S}} & \qw & \qw & \qw & \gate{\mathrm{S^\dagger}} & \gate{\mathrm{T}} & \gate{\mathrm{T^\dagger}} & \gate{\mathrm{P}\,(\mathrm{\frac{\pi}{2}})} & \gate{\mathrm{P}\,(\mathrm{\frac{\pi}{2}})} & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{5} : } & \lstick{ {q}_{5} : } & \ctrl{1} & \ctrl{1} & \dstick{\hspace{2.0em}\mathrm{P}\,(\mathrm{\frac{\pi}{2}})} \qw & \qw & \qw & \gate{\mathrm{Y}} & \gate{\mathrm{R_X}\,(\mathrm{\frac{\pi}{3}})} & \multigate{1}{\mathrm{R_{ZX}}\,(\mathrm{\frac{\pi}{2}})}_<<<{0} & \gate{\mathrm{U}\,(\mathrm{\frac{\pi}{2},\frac{\pi}{2},\frac{\pi}{2}})} \barrier[0em]{1} & \qw & \gate{\mathrm{\left|0\right\rangle}} & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{6} : } & \lstick{ {q}_{6} : } & \control\qw & \control \qw & \qw & \qw & \qw & \qw & \qw & \ghost{\mathrm{R_{ZX}}\,(\mathrm{\frac{\pi}{2}})}_<<<{1} & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} & \gate{\mathrm{X}} & \qw & \qw & \qw & \qw & \ctrl{1} & \ctrl{1} & \qswap & \ctrl{1} & \ctrl{1} & \multigate{1}{\mathrm{Dcx}}_<<<{0} & \ctrl{1} & \ctrl{1} & \qw & \qw\\
\nghost{ {q}_{1} : } & \lstick{ {q}_{1} : } & \qw & \qw & \qw & \qw & \qw & \qw & \targ & \ctrl{1} & \qswap \qwx[-1] & \qswap & \ctrl{1} & \ghost{\mathrm{Dcx}}_<<<{1} & \multigate{1}{\mathrm{Dcx}}_<<<{0} & \ctrl{1} & \qw & \qw\\
\nghost{ {q}_{2} : } & \lstick{ {q}_{2} : } & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \targ & \qw & \qswap \qwx[-1] & \qswap & \qw & \ghost{\mathrm{Dcx}}_<<<{1} & \multigate{1}{\mathrm{Dcx}}_<<<{0} & \qw & \qw\\
\nghost{ {q}_{3} : } & \lstick{ {q}_{3} : } & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qswap \qwx[-1] & \qw & \qw & \ghost{\mathrm{Dcx}}_<<<{1} & \qw & \qw\\
\nghost{ {q}_{4} : } & \lstick{ {q}_{4} : } & \gate{\mathrm{Z}} & \gate{\mathrm{S}} & \qw & \qw & \qw & \qw & \gate{\mathrm{S^\dagger}} & \gate{\mathrm{T}} & \gate{\mathrm{T^\dagger}} & \gate{\mathrm{P}\,(\mathrm{\frac{\pi}{2}})} & \gate{\mathrm{P}\,(\mathrm{\frac{\pi}{2}})} & \qw & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{5} : } & \lstick{ {q}_{5} : } & \ctrl{1} & \ctrl{1} & \qw & \qw & \qw & \qw & \gate{\mathrm{Y}} & \gate{\mathrm{R_X}\,(\mathrm{\frac{\pi}{3}})} & \multigate{1}{\mathrm{R_{ZX}}\,(\mathrm{\frac{\pi}{2}})}_<<<{0} & \gate{\mathrm{U}\,(\mathrm{\frac{\pi}{2},\frac{\pi}{2},\frac{\pi}{2}})} \barrier[0em]{1} & \qw & \gate{\mathrm{\left|0\right\rangle}} & \qw & \qw & \qw & \qw\\
\nghost{ {q}_{6} : } & \lstick{ {q}_{6} : } & \control\qw & \control \qw \cds{-1}{\settowidth{\glen}{\ensuremath{\mathrm{P}\,(\mathrm{\frac{\pi}{2}})}} \hspace{0.5em}\hspace{\glen}\ensuremath{\mathrm{P}\,(\mathrm{\frac{\pi}{2}})}} & \qw & \qw & \qw & \qw & \qw & \qw & \ghost{\mathrm{R_{ZX}}\,(\mathrm{\frac{\pi}{2}})}_<<<{1} & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
\\ }}
\end{document}
2 changes: 2 additions & 0 deletions test/python/visualization/references/test_latex_long_name.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {veryLongQuantumRegisterName}_{0} : } & \lstick{ {veryLongQuantumRegisterName}_{0} : } & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {qr}_{0} : } & \lstick{ {qr}_{0} : } & \gate{\mathrm{H}} & \meter & \qw & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} & \qw & \qw\\
Expand Down
2 changes: 2 additions & 0 deletions test/python/visualization/references/test_latex_no_ops.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=1.0em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \qw & \qw\\
Expand Down
2 changes: 2 additions & 0 deletions test/python/visualization/references/test_latex_normal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{2}\mapsto{0} : } & \lstick{ {q}_{2}\mapsto{0} : } & \qw & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{X}} & \gate{\mathrm{Y}} & \gate{\mathrm{Z}} & \gate{\mathrm{I}} & \qw & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{R_X}\,(\mathrm{(\pi\,-\,x)*(\pi\,-\,y)})} & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} \barrier[0em]{1} & \qw & \qw \barrier[0em]{1} & \qw & \qw & \qw\\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
\usepackage{graphicx}

\begin{document}
% Delete the command below if there are no CP, CU1, RZZ in the circuit.
\newlength{\glen}
\scalebox{1.0}{
\Qcircuit @C=1.0em @R=0.2em @!R { \\
\nghost{ {q}_{0} : } & \lstick{ {q}_{0} : } & \gate{\mathrm{H}} \barrier[0em]{0} & \qw & \gate{\mathrm{H}} & \qw & \qw\\
Expand Down
Loading