Repository: Qiskit/qiskit

Issue:
Feature request: Get "cleaner" tex code from QuantumCircuit.draw('latex_source')
The output of `QuantumCircuit.draw('latex_source')` not `standalone`, creating a full page. This creates an effect of a lot of spacing around it (like in here https://quantumcomputing.stackexchange.com/questions/17573/saving-vectorized-circuits-in-qiskit ). Additionally, many of the output code is not necessary and might look intimidating:

Currently, this is the output:
```python
from qiskit import *

circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
print(circuit.draw('latex_source'))
```
```latex
% \documentclass[preview]{standalone}
% If the image is too large to fit on this documentclass use
\documentclass[draft]{beamer}
% img_width = 2, img_depth = 4
\usepackage[size=custom,height=10,width=12,scale=0.7]{beamerposter}
% instead and customize the height and width (in cm) to fit.
% Large images may run out of memory quickly.
% To fix this use the LuaLaTeX compiler, which dynamically
% allocates memory.
\usepackage[braket, qm]{qcircuit}
\usepackage{amsmath}
\pdfmapfile{+sansmathaccent.map}
% \usepackage[landscape]{geometry}
% Comment out the above line if using the beamer documentclass.
\begin{document}

\begin{equation*}
    \Qcircuit @C=1.0em @R=0.2em @!R {
	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \ctrl{1} & \qw & \qw\\
	 	\lstick{ {q}_{1} :  } & \qw & \targ & \qw & \qw\\
	 }
\end{equation*}

\end{document}
``` 

It would be great if could look more like this:
```latex
\documentclass{standalone}
\usepackage[braket, qm]{qcircuit}

\begin{document}
    \Qcircuit @C=1.0em @R=0.2em @!R {
                \lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \ctrl{1} & \qw & \qw\\
                \lstick{ {q}_{1} :  } & \qw & \targ & \qw & \qw\\
         }
\end{document}
```

I'm aware that `qcircuit` and `standalone` [do not play well together](https://github.com/CQuIC/qcircuit/issues/41). However, I still thing would it be possible to hack the way around while waiting for a solution in that front. For example (I did not test this solution extensibly), this code produces this image (which is correctly cropped):
```latex
\documentclass[border=2px]{standalone}

\usepackage[braket, qm]{qcircuit}

\begin{document}
\Qcircuit @C=1.0em @R=0.2em @!R {
    \nghost{} & \lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \ctrl{1} & \qw & \qw\\
    \nghost{} & \lstick{ {q}_{1} :  } & \qw & \targ & \qw & \qw\\
}

\end{document}
```
<img width="591" alt="Screenshot 2021-05-20 at 14 44 20" src="https://user-images.githubusercontent.com/766693/118980561-e0491780-b979-11eb-9ab3-c4d3d774c519.png">




Discussion:
Hi! Can I work on this one?
Hi @1ucian0! Don't you think that #2015 should be fixed/discussed beforehand? Adding to the arguments discussed there, I never had any problem using `standalone` with `quantikz`.
@JoshDumo assigning you!

@tnemoz  #2015 seems stalled to me and, even if the outcome of that discussion is to change to quantikz in the future, I don't see that happening any time soon. So, in that context and for the sake of avoiding blockers, I think moving forward here is easier. 
@1ucian0 In that case, would you mind if I were to work in this direction (that is, switching from `qcircuit` to `quantikz`)? Or do you prefer to wait for this issue to be closed?
A discussion for #2015 🙃

Resolving patch:
diff --git a/qiskit/visualization/latex.py b/qiskit/visualization/latex.py
--- a/qiskit/visualization/latex.py
+++ b/qiskit/visualization/latex.py
@@ -75,7 +75,7 @@ def __init__(
         self.ops = ops
 
         # image scaling
-        self.scale = 0.7 if scale is None else scale
+        self.scale = 1.0 if scale is None else scale
 
         # Map of qregs to sizes
         self.qregs = {}
@@ -157,31 +157,24 @@ def latex(self):
 
         self._initialize_latex_array()
         self._build_latex_array()
-        header_1 = r"""% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-"""
-        beamer_line = "\\usepackage[size=custom,height=%d,width=%d,scale=%.1f]{beamerposter}\n"
-        header_2 = r"""% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+        header_1 = r"""\documentclass[border=2px]{standalone}
+        """
+
+        header_2 = r"""
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
+\usepackage{graphicx}
+
+\begin{document} 
 """
+        header_scale = "\\scalebox{{{}}}".format(self.scale) + "{"
+
         qcircuit_line = r"""
-\begin{equation*}
-    \Qcircuit @C=%.1fem @R=%.1fem @!R {
+\Qcircuit @C=%.1fem @R=%.1fem @!R { \\
 """
         output = io.StringIO()
         output.write(header_1)
-        output.write("%% img_width = %d, img_depth = %d\n" % (self.img_width, self.img_depth))
-        output.write(beamer_line % self._get_beamer_page())
         output.write(header_2)
+        output.write(header_scale)
         if self.global_phase:
             output.write(
                 r"""{$\mathrm{%s} \mathrm{%s}$}"""
@@ -195,9 +188,8 @@ def latex(self):
                 if j != self.img_depth:
                     output.write(" & ")
                 else:
-                    output.write(r"\\" + "\n")
-        output.write("\t }\n")
-        output.write("\\end{equation*}\n\n")
+                    output.write(r"\\ " + "\n")
+        output.write(r"\\ " + "}}\n")
         output.write("\\end{document}")
         contents = output.getvalue()
         output.close()
@@ -228,24 +220,20 @@ def _initialize_latex_array(self):
             if isinstance(self.ordered_bits[i], Clbit):
                 if self.cregbundle:
                     reg = self.bit_locations[self.ordered_bits[i + offset]]["register"]
-                    self._latex[i][0] = "\\lstick{" + reg.name + ":"
+                    label = reg.name + ":"
                     clbitsize = self.cregs[reg]
                     self._latex[i][1] = "\\lstick{/_{_{" + str(clbitsize) + "}}} \\cw"
                     offset += clbitsize - 1
                 else:
-                    self._latex[i][0] = (
-                        "\\lstick{"
-                        + self.bit_locations[self.ordered_bits[i]]["register"].name
-                        + "_{"
-                        + str(self.bit_locations[self.ordered_bits[i]]["index"])
-                        + "}:"
-                    )
+                    label = self.bit_locations[self.ordered_bits[i]]["register"].name + "_{"
+                    label += str(self.bit_locations[self.ordered_bits[i]]["index"]) + "}:"
                 if self.initial_state:
-                    self._latex[i][0] += "0"
-                self._latex[i][0] += "}"
+                    label += "0"
+                label += "}"
+                self._latex[i][0] = "\\nghost{" + label + " & " + "\\lstick{" + label
             else:
                 if self.layout is None:
-                    label = "\\lstick{{ {{{}}}_{{{}}} : ".format(
+                    label = " {{{}}}_{{{}}} : ".format(
                         self.bit_locations[self.ordered_bits[i]]["register"].name,
                         self.bit_locations[self.ordered_bits[i]]["index"],
                     )
@@ -257,17 +245,17 @@ def _initialize_latex_array(self):
                             virt_reg = next(
                                 reg for reg in self.layout.get_registers() if virt_bit in reg
                             )
-                            label = "\\lstick{{ {{{}}}_{{{}}}\\mapsto{{{}}} : ".format(
+                            label = " {{{}}}_{{{}}}\\mapsto{{{}}} : ".format(
                                 virt_reg.name, virt_reg[:].index(virt_bit), bit_location["index"]
                             )
                         except StopIteration:
-                            label = "\\lstick{{ {{{}}} : ".format(bit_location["index"])
+                            label = "  {{{}}} : ".format(bit_location["index"])
                     else:
-                        label = "\\lstick{{ {{{}}} : ".format(bit_location["index"])
+                        label = " {{{}}} : ".format(bit_location["index"])
                 if self.initial_state:
                     label += "\\ket{{0}}"
                 label += " }"
-                self._latex[i][0] = label
+                self._latex[i][0] = "\\nghost{" + label + " & " + "\\lstick{" + label
 
     def _get_image_depth(self):
         """Get depth information for the circuit."""


Test patch:
diff --git a/test/python/visualization/references/test_latex_4597.tex b/test/python/visualization/references/test_latex_4597.tex
--- a/test/python/visualization/references/test_latex_4597.tex
+++ b/test/python/visualization/references/test_latex_4597.tex
@@ -1,26 +1,14 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 4, img_depth = 4
-\usepackage[size=custom,height=10,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \qw & \gate{\mathrm{X}} & \qw & \qw\\
-	 	\lstick{c:} & \lstick{/_{_{3}}} \cw & \dstick{_{_{=2}}} \cw \cwx[-1] & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \qw & \gate{\mathrm{X}} & \qw & \qw\\ 
+	 	\nghost{c:} & \lstick{c:} & \lstick{/_{_{3}}} \cw & \dstick{_{_{=2}}} \cw \cwx[-1] & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_big_gates.tex b/test/python/visualization/references/test_latex_big_gates.tex
--- a/test/python/visualization/references/test_latex_big_gates.tex
+++ b/test/python/visualization/references/test_latex_big_gates.tex
@@ -1,28 +1,16 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 6, img_depth = 4
-\usepackage[size=custom,height=10,width=40,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=1.0em @!R {
-	 	\lstick{ {q}_{0} :  } & \multigate{2}{\mathrm{iqp:[[6\,5\,3];\,[5\,4\,5];\,[3\,5\,1]]}}_<<<{0} & \gate{\mathrm{Unitary}} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \ghost{\mathrm{iqp:[[6\,5\,3];\,[5\,4\,5];\,[3\,5\,1]]}}_<<<{1} & \multigate{1}{\mathrm{Hamiltonian}}_<<<{0} & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \ghost{\mathrm{iqp:[[6\,5\,3];\,[5\,4\,5];\,[3\,5\,1]]}}_<<<{2} & \ghost{\mathrm{Hamiltonian}}_<<<{1} & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \multigate{2}{|\psi\rangle\,\mathrm{(}\mathrm{0.25\jmath},\mathrm{0.3536},\mathrm{0.25+0.25\jmath},\mathrm{0},...\mathrm{)}}_<<<{0} & \multigate{1}{\mathrm{Isometry}}_<<<{0} & \qw & \qw\\
-	 	\lstick{ {q}_{4} :  } & \ghost{|\psi\rangle\,\mathrm{(}\mathrm{0.25\jmath},\mathrm{0.3536},\mathrm{0.25+0.25\jmath},\mathrm{0},...\mathrm{)}}_<<<{1} & \ghost{\mathrm{Isometry}}_<<<{1} & \qw & \qw\\
-	 	\lstick{ {q}_{5} :  } & \ghost{|\psi\rangle\,\mathrm{(}\mathrm{0.25\jmath},\mathrm{0.3536},\mathrm{0.25+0.25\jmath},\mathrm{0},...\mathrm{)}}_<<<{2} & \qw & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \ghost{\mathrm{iqp:[[6\,5\,3];\,[5\,4\,5];\,[3\,5\,1]]}}_<<<{1} & \multigate{1}{\mathrm{Hamiltonian}}_<<<{0} & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \ghost{\mathrm{iqp:[[6\,5\,3];\,[5\,4\,5];\,[3\,5\,1]]}}_<<<{2} & \ghost{\mathrm{Hamiltonian}}_<<<{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \multigate{2}{|\psi\rangle\,\mathrm{(}\mathrm{0.25\jmath},\mathrm{0.3536},\mathrm{0.25+0.25\jmath},\mathrm{0},...\mathrm{)}}_<<<{0} & \multigate{1}{\mathrm{Isometry}}_<<<{0} & \qw & \qw\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \ghost{|\psi\rangle\,\mathrm{(}\mathrm{0.25\jmath},\mathrm{0.3536},\mathrm{0.25+0.25\jmath},\mathrm{0},...\mathrm{)}}_<<<{1} & \ghost{\mathrm{Isometry}}_<<<{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{5} :  } & \lstick{ {q}_{5} :  } & \ghost{|\psi\rangle\,\mathrm{(}\mathrm{0.25\jmath},\mathrm{0.3536},\mathrm{0.25+0.25\jmath},\mathrm{0},...\mathrm{)}}_<<<{2} & \qw & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_cnot.tex b/test/python/visualization/references/test_latex_cnot.tex
--- a/test/python/visualization/references/test_latex_cnot.tex
+++ b/test/python/visualization/references/test_latex_cnot.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 7
-\usepackage[size=custom,height=10,width=16,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{X}} & \ctrl{1} & \ctrl{1} & \ctrlo{1} & \ctrl{1} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \qw & \targ & \ctrl{1} & \targ & \ctrlo{1} & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \qw & \qw & \targ & \ctrlo{-1} & \ctrl{2} & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \qw & \qw & \qw & \ctrl{-1} & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{4} :  } & \qw & \qw & \qw & \qw & \targ & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \qw & \targ & \ctrl{1} & \targ & \ctrlo{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \qw & \qw & \targ & \ctrlo{-1} & \ctrl{2} & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \qw & \qw & \qw & \ctrl{-1} & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \qw & \qw & \qw & \qw & \targ & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_conditional.tex b/test/python/visualization/references/test_latex_conditional.tex
--- a/test/python/visualization/references/test_latex_conditional.tex
+++ b/test/python/visualization/references/test_latex_conditional.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 6
-\usepackage[size=custom,height=10,width=15,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \meter & \qw & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \meter & \qw & \qw & \qw\\
-	 	\lstick{c:} & \lstick{/_{_{2}}} \cw & \dstick{_{_{0}}} \cw \cwx[-2] & \dstick{_{_{1}}} \cw \cwx[-1] & \dstick{_{_{=2}}} \cw \cwx[-2] & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \meter & \qw & \qw & \qw\\ 
+	 	\nghost{c:} & \lstick{c:} & \lstick{/_{_{2}}} \cw & \dstick{_{_{0}}} \cw \cwx[-2] & \dstick{_{_{1}}} \cw \cwx[-1] & \dstick{_{_{=2}}} \cw \cwx[-2] & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_creg_initial_false.tex b/test/python/visualization/references/test_latex_creg_initial_false.tex
--- a/test/python/visualization/references/test_latex_creg_initial_false.tex
+++ b/test/python/visualization/references/test_latex_creg_initial_false.tex
@@ -1,26 +1,14 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 4, img_depth = 4
-\usepackage[size=custom,height=10,width=12,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{X}} & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{X}} & \qw & \qw & \qw\\
-	 	\lstick{c_{0}:} & \cw & \cw & \cw & \cw\\
-	 	\lstick{c_{1}:} & \cw & \cw & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{X}} & \qw & \qw & \qw\\ 
+	 	\nghost{c_{0}:} & \lstick{c_{0}:} & \cw & \cw & \cw & \cw\\ 
+	 	\nghost{c_{1}:} & \lstick{c_{1}:} & \cw & \cw & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_creg_initial_true.tex b/test/python/visualization/references/test_latex_creg_initial_true.tex
--- a/test/python/visualization/references/test_latex_creg_initial_true.tex
+++ b/test/python/visualization/references/test_latex_creg_initial_true.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 4
-\usepackage[size=custom,height=10,width=12,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} : \ket{{0}} } & \gate{\mathrm{X}} & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{1} : \ket{{0}} } & \gate{\mathrm{X}} & \qw & \qw & \qw\\
-	 	\lstick{c:0} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} : \ket{{0}} } & \lstick{ {q}_{1} : \ket{{0}} } & \gate{\mathrm{X}} & \qw & \qw & \qw\\ 
+	 	\nghost{c:0} & \lstick{c:0} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_cswap_rzz.tex b/test/python/visualization/references/test_latex_cswap_rzz.tex
--- a/test/python/visualization/references/test_latex_cswap_rzz.tex
+++ b/test/python/visualization/references/test_latex_cswap_rzz.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 8
-\usepackage[size=custom,height=10,width=16,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{X}} & \ctrl{1} & \control \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{X}} & \qswap & \ctrl{-1} & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \qw & \qswap \qwx[-1] & \ctrlo{-1} & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \qw & \qw & \ctrl{-3} & \dstick{\hspace{2.0em}\mathrm{ZZ}\,\mathrm{(}\mathrm{\frac{3\pi}{4}}\mathrm{)}} \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{4} :  } & \qw & \qw & \ctrlo{-1} & \qw & \qw & \qw & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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{(}\mathrm{\frac{3\pi}{4}}\mathrm{)}} \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \qw & \qw & \ctrlo{-1} & \qw & \qw & \qw & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_deep.tex b/test/python/visualization/references/test_latex_deep.tex
--- a/test/python/visualization/references/test_latex_deep.tex
+++ b/test/python/visualization/references/test_latex_deep.tex
@@ -1,23 +1,11 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 1, img_depth = 102
-\usepackage[size=custom,height=10,width=159,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\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\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_empty.tex b/test/python/visualization/references/test_latex_empty.tex
--- a/test/python/visualization/references/test_latex_empty.tex
+++ b/test/python/visualization/references/test_latex_empty.tex
@@ -1,23 +1,11 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 1, img_depth = 2
-\usepackage[size=custom,height=10,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=1.0em @!R {
-	 	\lstick{ {q}_{0} :  } & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=1.0em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_ghz_to_gate.tex b/test/python/visualization/references/test_latex_ghz_to_gate.tex
--- a/test/python/visualization/references/test_latex_ghz_to_gate.tex
+++ b/test/python/visualization/references/test_latex_ghz_to_gate.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 3
-\usepackage[size=custom,height=10,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \ctrl{1} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \multigate{2}{\mathrm{Ctrl\mbox{-}GHZ\,Circuit}}_<<<{0} & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \ghost{\mathrm{Ctrl\mbox{-}GHZ\,Circuit}}_<<<{2} & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \ghost{\mathrm{Ctrl\mbox{-}GHZ\,Circuit}}_<<<{1} & \qw & \qw\\
-	 	\lstick{ {q}_{4} :  } & \ctrlo{-1} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \ctrl{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \multigate{2}{\mathrm{Ctrl\mbox{-}GHZ\,Circuit}}_<<<{0} & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \ghost{\mathrm{Ctrl\mbox{-}GHZ\,Circuit}}_<<<{2} & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \ghost{\mathrm{Ctrl\mbox{-}GHZ\,Circuit}}_<<<{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \ctrlo{-1} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_global_phase.tex b/test/python/visualization/references/test_latex_global_phase.tex
--- a/test/python/visualization/references/test_latex_global_phase.tex
+++ b/test/python/visualization/references/test_latex_global_phase.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 3
-\usepackage[size=custom,height=10,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-{$\mathrm{global\,phase:\,} \mathrm{\frac{\pi}{2}}$}
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_huge.tex b/test/python/visualization/references/test_latex_huge.tex
--- a/test/python/visualization/references/test_latex_huge.tex
+++ b/test/python/visualization/references/test_latex_huge.tex
@@ -1,62 +1,50 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 40, img_depth = 42
-\usepackage[size=custom,height=60,width=69,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\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\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \ctrl{38} & \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\\
-	 	\lstick{ {q}_{2} :  } & \gate{\mathrm{H}} & \qw & \qw & \ctrl{37} & \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\\
-	 	\lstick{ {q}_{3} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \ctrl{36} & \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\\
-	 	\lstick{ {q}_{4} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \ctrl{35} & \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\\
-	 	\lstick{ {q}_{5} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \ctrl{34} & \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\\
-	 	\lstick{ {q}_{6} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{33} & \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\\
-	 	\lstick{ {q}_{7} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{32} & \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\\
-	 	\lstick{ {q}_{8} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{31} & \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\\
-	 	\lstick{ {q}_{9} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{30} & \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\\
-	 	\lstick{ {q}_{10} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{29} & \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\\
-	 	\lstick{ {q}_{11} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{28} & \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\\
-	 	\lstick{ {q}_{12} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{27} & \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\\
-	 	\lstick{ {q}_{13} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{26} & \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\\
-	 	\lstick{ {q}_{14} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{25} & \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\\
-	 	\lstick{ {q}_{15} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{24} & \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\\
-	 	\lstick{ {q}_{16} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{23} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{17} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{22} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{18} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{21} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{19} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{20} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{20} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{19} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{21} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{18} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{22} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{17} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{23} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{16} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{24} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{15} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{25} :  } & \gate{\mathrm{H}} & \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 & \ctrl{14} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{26} :  } & \gate{\mathrm{H}} & \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 & \ctrl{13} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{27} :  } & \gate{\mathrm{H}} & \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 & \ctrl{12} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{28} :  } & \gate{\mathrm{H}} & \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 & \ctrl{11} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{29} :  } & \gate{\mathrm{H}} & \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 & \ctrl{10} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{30} :  } & \gate{\mathrm{H}} & \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 & \ctrl{9} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{31} :  } & \gate{\mathrm{H}} & \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 & \ctrl{8} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{32} :  } & \gate{\mathrm{H}} & \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 & \ctrl{7} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{33} :  } & \gate{\mathrm{H}} & \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 & \ctrl{6} & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{34} :  } & \gate{\mathrm{H}} & \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 & \ctrl{5} & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{35} :  } & \gate{\mathrm{H}} & \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 & \ctrl{4} & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{36} :  } & \gate{\mathrm{H}} & \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 & \ctrl{3} & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{37} :  } & \gate{\mathrm{H}} & \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 & \ctrl{2} & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{38} :  } & \gate{\mathrm{H}} & \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 & \ctrl{1} & \qw & \qw\\
-	 	\lstick{ {q}_{39} :  } & \qw & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \ctrl{38} & \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\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \gate{\mathrm{H}} & \qw & \qw & \ctrl{37} & \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\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \ctrl{36} & \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\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \ctrl{35} & \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\\ 
+	 	\nghost{ {q}_{5} :  } & \lstick{ {q}_{5} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \ctrl{34} & \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\\ 
+	 	\nghost{ {q}_{6} :  } & \lstick{ {q}_{6} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{33} & \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\\ 
+	 	\nghost{ {q}_{7} :  } & \lstick{ {q}_{7} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{32} & \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\\ 
+	 	\nghost{ {q}_{8} :  } & \lstick{ {q}_{8} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{31} & \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\\ 
+	 	\nghost{ {q}_{9} :  } & \lstick{ {q}_{9} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{30} & \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\\ 
+	 	\nghost{ {q}_{10} :  } & \lstick{ {q}_{10} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{29} & \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\\ 
+	 	\nghost{ {q}_{11} :  } & \lstick{ {q}_{11} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{28} & \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\\ 
+	 	\nghost{ {q}_{12} :  } & \lstick{ {q}_{12} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{27} & \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\\ 
+	 	\nghost{ {q}_{13} :  } & \lstick{ {q}_{13} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{26} & \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\\ 
+	 	\nghost{ {q}_{14} :  } & \lstick{ {q}_{14} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{25} & \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\\ 
+	 	\nghost{ {q}_{15} :  } & \lstick{ {q}_{15} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{24} & \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\\ 
+	 	\nghost{ {q}_{16} :  } & \lstick{ {q}_{16} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{23} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{17} :  } & \lstick{ {q}_{17} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{22} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{18} :  } & \lstick{ {q}_{18} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{21} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{19} :  } & \lstick{ {q}_{19} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{20} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{20} :  } & \lstick{ {q}_{20} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{19} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{21} :  } & \lstick{ {q}_{21} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{18} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{22} :  } & \lstick{ {q}_{22} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{17} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{23} :  } & \lstick{ {q}_{23} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{16} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{24} :  } & \lstick{ {q}_{24} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \ctrl{15} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{25} :  } & \lstick{ {q}_{25} :  } & \gate{\mathrm{H}} & \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 & \ctrl{14} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{26} :  } & \lstick{ {q}_{26} :  } & \gate{\mathrm{H}} & \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 & \ctrl{13} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{27} :  } & \lstick{ {q}_{27} :  } & \gate{\mathrm{H}} & \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 & \ctrl{12} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{28} :  } & \lstick{ {q}_{28} :  } & \gate{\mathrm{H}} & \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 & \ctrl{11} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{29} :  } & \lstick{ {q}_{29} :  } & \gate{\mathrm{H}} & \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 & \ctrl{10} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{30} :  } & \lstick{ {q}_{30} :  } & \gate{\mathrm{H}} & \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 & \ctrl{9} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{31} :  } & \lstick{ {q}_{31} :  } & \gate{\mathrm{H}} & \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 & \ctrl{8} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{32} :  } & \lstick{ {q}_{32} :  } & \gate{\mathrm{H}} & \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 & \ctrl{7} & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{33} :  } & \lstick{ {q}_{33} :  } & \gate{\mathrm{H}} & \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 & \ctrl{6} & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{34} :  } & \lstick{ {q}_{34} :  } & \gate{\mathrm{H}} & \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 & \ctrl{5} & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{35} :  } & \lstick{ {q}_{35} :  } & \gate{\mathrm{H}} & \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 & \ctrl{4} & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{36} :  } & \lstick{ {q}_{36} :  } & \gate{\mathrm{H}} & \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 & \ctrl{3} & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{37} :  } & \lstick{ {q}_{37} :  } & \gate{\mathrm{H}} & \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 & \ctrl{2} & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{38} :  } & \lstick{ {q}_{38} :  } & \gate{\mathrm{H}} & \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 & \ctrl{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{39} :  } & \lstick{ {q}_{39} :  } & \qw & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \targ & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_init_reset.tex b/test/python/visualization/references/test_latex_init_reset.tex
--- a/test/python/visualization/references/test_latex_init_reset.tex
+++ b/test/python/visualization/references/test_latex_init_reset.tex
@@ -1,24 +1,12 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 2, img_depth = 4
-\usepackage[size=custom,height=10,width=22,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=1.0em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{|\psi\rangle\,\mathrm{(}\mathrm{0},\mathrm{1}\mathrm{)}} & \multigate{1}{|\psi\rangle\,\mathrm{(}\mathrm{0},\mathrm{1},\mathrm{0},\mathrm{0}\mathrm{)}}_<<<{0} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\left|0\right\rangle} & \ghost{|\psi\rangle\,\mathrm{(}\mathrm{0},\mathrm{1},\mathrm{0},\mathrm{0}\mathrm{)}}_<<<{1} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=1.0em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \gate{|\psi\rangle\,\mathrm{(}\mathrm{0},\mathrm{1}\mathrm{)}} & \multigate{1}{|\psi\rangle\,\mathrm{(}\mathrm{0},\mathrm{1},\mathrm{0},\mathrm{0}\mathrm{)}}_<<<{0} & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\left|0\right\rangle} & \ghost{|\psi\rangle\,\mathrm{(}\mathrm{0},\mathrm{1},\mathrm{0},\mathrm{0}\mathrm{)}}_<<<{1} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_inst_with_cbits.tex b/test/python/visualization/references/test_latex_inst_with_cbits.tex
--- a/test/python/visualization/references/test_latex_inst_with_cbits.tex
+++ b/test/python/visualization/references/test_latex_inst_with_cbits.tex
@@ -1,30 +1,18 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 8, img_depth = 3
-\usepackage[size=custom,height=12,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=1.0em @!R {
-	 	\lstick{ {qr}_{0} :  } & \qw & \qw & \qw\\
-	 	\lstick{ {qr}_{1} :  } & \multigate{5}{\mathrm{instruction}}_<<<{0} & \qw & \qw\\
-	 	\lstick{ {qr}_{2} :  } & \ghost{\mathrm{instruction}}_<<<{1} & \qw & \qw\\
-	 	\lstick{ {qr}_{3} :  } & \ghost{\mathrm{instruction}} & \qw & \qw\\
-	 	\lstick{cr_{0}:} & \cghost{\mathrm{instruction}} & \cw & \cw\\
-	 	\lstick{cr_{1}:} & \cghost{\mathrm{instruction}}_<<<{1} & \cw & \cw\\
-	 	\lstick{cr_{2}:} & \cghost{\mathrm{instruction}}_<<<{0} & \cw & \cw\\
-	 	\lstick{cr_{3}:} & \cw & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=1.0em @!R { \\
+	 	\nghost{ {qr}_{0} :  } & \lstick{ {qr}_{0} :  } & \qw & \qw & \qw\\ 
+	 	\nghost{ {qr}_{1} :  } & \lstick{ {qr}_{1} :  } & \multigate{5}{\mathrm{instruction}}_<<<{0} & \qw & \qw\\ 
+	 	\nghost{ {qr}_{2} :  } & \lstick{ {qr}_{2} :  } & \ghost{\mathrm{instruction}}_<<<{1} & \qw & \qw\\ 
+	 	\nghost{ {qr}_{3} :  } & \lstick{ {qr}_{3} :  } & \ghost{\mathrm{instruction}} & \qw & \qw\\ 
+	 	\nghost{cr_{0}:} & \lstick{cr_{0}:} & \cghost{\mathrm{instruction}} & \cw & \cw\\ 
+	 	\nghost{cr_{1}:} & \lstick{cr_{1}:} & \cghost{\mathrm{instruction}}_<<<{1} & \cw & \cw\\ 
+	 	\nghost{cr_{2}:} & \lstick{cr_{2}:} & \cghost{\mathrm{instruction}}_<<<{0} & \cw & \cw\\ 
+	 	\nghost{cr_{3}:} & \lstick{cr_{3}:} & \cw & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_iqx.tex b/test/python/visualization/references/test_latex_iqx.tex
--- a/test/python/visualization/references/test_latex_iqx.tex
+++ b/test/python/visualization/references/test_latex_iqx.tex
@@ -1,29 +1,17 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 7, img_depth = 15
-\usepackage[size=custom,height=10,width=39,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\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\\
-	 	\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\\
-	 	\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\\
-	 	\lstick{ {q}_{3} :  } & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qw & \qswap \qwx[-1] & \qw & \qw & \ghost{\mathrm{Dcx}}_<<<{1} & \qw & \qw\\
-	 	\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{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} & \gate{\mathrm{U}_1\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{5} :  } & \ctrl{1} & \ctrl{1} & \dstick{\hspace{2.0em}\mathrm{U}_1\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} \qw & \qw & \qw & \gate{\mathrm{Y}} & \gate{\mathrm{R}_\mathrm{X}\,\mathrm{(}\mathrm{\frac{\pi}{3}}\mathrm{)}} & \multigate{1}{\mathrm{R}_{\mathrm{ZX}}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}}_<<<{0} & \gate{\mathrm{U}_2\,\mathrm{(}\mathrm{\frac{\pi}{2}},\mathrm{\frac{\pi}{2}}\mathrm{)}} \barrier[0em]{1} & \qw & \gate{\left|0\right\rangle} & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{6} :  } & \control\qw & \control \qw & \qw & \qw & \qw & \qw & \qw & \ghost{\mathrm{R}_{\mathrm{ZX}}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}}_<<<{1} & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} & \gate{\mathrm{P}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{5} :  } & \lstick{ {q}_{5} :  } & \ctrl{1} & \ctrl{1} & \dstick{\hspace{2.0em}\mathrm{P}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} \qw & \qw & \qw & \gate{\mathrm{Y}} & \gate{\mathrm{R}_\mathrm{X}\,\mathrm{(}\mathrm{\frac{\pi}{3}}\mathrm{)}} & \multigate{1}{\mathrm{R}_{\mathrm{ZX}}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}}_<<<{0} & \gate{\mathrm{U}\,\mathrm{(}\mathrm{\frac{\pi}{2}},\mathrm{\frac{\pi}{2}},\mathrm{\frac{\pi}{2}}\mathrm{)}} \barrier[0em]{1} & \qw & \gate{\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}_{\mathrm{ZX}}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}}_<<<{1} & \qw & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_long_name.tex b/test/python/visualization/references/test_latex_long_name.tex
--- a/test/python/visualization/references/test_latex_long_name.tex
+++ b/test/python/visualization/references/test_latex_long_name.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 5
-\usepackage[size=custom,height=10,width=25,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {veryLongQuantumRegisterName}_{0} :  } & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {veryLongQuantumRegisterName}_{1} :  } & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {veryLongQuantumRegisterName}_{2} :  } & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {veryLongQuantumRegisterName}_{3} :  } & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q0}_{0} :  } & \qw & \qw & \qw & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {veryLongQuantumRegisterName}_{1} :  } & \lstick{ {veryLongQuantumRegisterName}_{1} :  } & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{ {veryLongQuantumRegisterName}_{2} :  } & \lstick{ {veryLongQuantumRegisterName}_{2} :  } & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{ {veryLongQuantumRegisterName}_{3} :  } & \lstick{ {veryLongQuantumRegisterName}_{3} :  } & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{ {q0}_{0} :  } & \lstick{ {q0}_{0} :  } & \qw & \qw & \qw & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_meas_condition.tex b/test/python/visualization/references/test_latex_meas_condition.tex
--- a/test/python/visualization/references/test_latex_meas_condition.tex
+++ b/test/python/visualization/references/test_latex_meas_condition.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 5
-\usepackage[size=custom,height=10,width=13,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {qr}_{0} :  } & \gate{\mathrm{H}} & \meter & \qw & \qw & \qw\\
-	 	\lstick{ {qr}_{1} :  } & \qw & \qw & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{cr:} & \lstick{/_{_{2}}} \cw & \dstick{_{_{0}}} \cw \cwx[-2] & \dstick{_{_{=1}}} \cw \cwx[-1] & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {qr}_{0} :  } & \lstick{ {qr}_{0} :  } & \gate{\mathrm{H}} & \meter & \qw & \qw & \qw\\ 
+	 	\nghost{ {qr}_{1} :  } & \lstick{ {qr}_{1} :  } & \qw & \qw & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{cr:} & \lstick{cr:} & \lstick{/_{_{2}}} \cw & \dstick{_{_{0}}} \cw \cwx[-2] & \dstick{_{_{=1}}} \cw \cwx[-1] & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_no_barriers_false.tex b/test/python/visualization/references/test_latex_no_barriers_false.tex
--- a/test/python/visualization/references/test_latex_no_barriers_false.tex
+++ b/test/python/visualization/references/test_latex_no_barriers_false.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 3
-\usepackage[size=custom,height=10,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{c:} & \lstick{/_{_{2}}} \cw & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{c:} & \lstick{c:} & \lstick{/_{_{2}}} \cw & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_no_ops.tex b/test/python/visualization/references/test_latex_no_ops.tex
--- a/test/python/visualization/references/test_latex_no_ops.tex
+++ b/test/python/visualization/references/test_latex_no_ops.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 2
-\usepackage[size=custom,height=10,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=1.0em @!R {
-	 	\lstick{ {q}_{0} :  } & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \qw & \qw\\
-	 	\lstick{c:} & \lstick{/_{_{3}}} \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=1.0em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \qw & \qw\\ 
+	 	\nghost{c:} & \lstick{c:} & \lstick{/_{_{3}}} \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_normal.tex b/test/python/visualization/references/test_latex_normal.tex
--- a/test/python/visualization/references/test_latex_normal.tex
+++ b/test/python/visualization/references/test_latex_normal.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 3
-\usepackage[size=custom,height=10,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{4} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_partial_layout.tex b/test/python/visualization/references/test_latex_partial_layout.tex
--- a/test/python/visualization/references/test_latex_partial_layout.tex
+++ b/test/python/visualization/references/test_latex_partial_layout.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 3
-\usepackage[size=custom,height=10,width=13,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{2}\mapsto{0} :  } & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{0}\mapsto{1} :  } & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{1}\mapsto{2} :  } & \gate{\mathrm{U}_2\,\mathrm{(}\mathrm{0},\mathrm{\pi}\mathrm{)}} & \qw & \qw\\
-	 	\lstick{ {ancilla}_{0}\mapsto{3} :  } & \qw & \qw & \qw\\
-	 	\lstick{ {ancilla}_{1}\mapsto{4} :  } & \qw & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{2}\mapsto{0} :  } & \lstick{ {q}_{2}\mapsto{0} :  } & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{0}\mapsto{1} :  } & \lstick{ {q}_{0}\mapsto{1} :  } & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{1}\mapsto{2} :  } & \lstick{ {q}_{1}\mapsto{2} :  } & \gate{\mathrm{U}_2\,\mathrm{(}\mathrm{0},\mathrm{\pi}\mathrm{)}} & \qw & \qw\\ 
+	 	\nghost{ {ancilla}_{0}\mapsto{3} :  } & \lstick{ {ancilla}_{0}\mapsto{3} :  } & \qw & \qw & \qw\\ 
+	 	\nghost{ {ancilla}_{1}\mapsto{4} :  } & \lstick{ {ancilla}_{1}\mapsto{4} :  } & \qw & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_pauli_clifford.tex b/test/python/visualization/references/test_latex_pauli_clifford.tex
--- a/test/python/visualization/references/test_latex_pauli_clifford.tex
+++ b/test/python/visualization/references/test_latex_pauli_clifford.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 7
-\usepackage[size=custom,height=10,width=16,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{X}} & \gate{\mathrm{Y}} & \gate{\mathrm{Z}} & \gate{\mathrm{I}} & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \ctrl{1} & \ctrl{1} & \ctrl{1} & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \qw & \targ & \gate{\mathrm{Y}} & \control\qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \qswap & \gate{\mathrm{S}} & \gate{\mathrm{S}^\dagger} & \multigate{1}{\mathrm{Iswap}}_<<<{0} & \multigate{1}{\mathrm{Dcx}}_<<<{0} & \qw & \qw\\
-	 	\lstick{ {q}_{4} :  } & \qswap \qwx[-1] & \qw & \qw & \ghost{\mathrm{Iswap}}_<<<{1} & \ghost{\mathrm{Dcx}}_<<<{1} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \ctrl{1} & \ctrl{1} & \ctrl{1} & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \qw & \targ & \gate{\mathrm{Y}} & \control\qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \qswap & \gate{\mathrm{S}} & \gate{\mathrm{S}^\dagger} & \multigate{1}{\mathrm{Iswap}}_<<<{0} & \multigate{1}{\mathrm{Dcx}}_<<<{0} & \qw & \qw\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \qswap \qwx[-1] & \qw & \qw & \ghost{\mathrm{Iswap}}_<<<{1} & \ghost{\mathrm{Dcx}}_<<<{1} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_pi_param_expr.tex b/test/python/visualization/references/test_latex_pi_param_expr.tex
--- a/test/python/visualization/references/test_latex_pi_param_expr.tex
+++ b/test/python/visualization/references/test_latex_pi_param_expr.tex
@@ -1,23 +1,11 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 1, img_depth = 3
-\usepackage[size=custom,height=10,width=22,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{R}_\mathrm{X}\,\mathrm{(}\mathrm{(\pi\,-\,x)*(\pi\,-\,y)}\mathrm{)}} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \gate{\mathrm{R}_\mathrm{X}\,\mathrm{(}\mathrm{(\pi\,-\,x)*(\pi\,-\,y)}\mathrm{)}} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_plot_barriers_false.tex b/test/python/visualization/references/test_latex_plot_barriers_false.tex
--- a/test/python/visualization/references/test_latex_plot_barriers_false.tex
+++ b/test/python/visualization/references/test_latex_plot_barriers_false.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 6
-\usepackage[size=custom,height=10,width=15,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \qw & \qw & \gate{\mathrm{H}} & \qw & \qw & \qw\\
-	 	\lstick{c:} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \qw & \qw & \gate{\mathrm{H}} & \qw & \qw & \qw\\ 
+	 	\nghost{c:} & \lstick{c:} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_plot_barriers_true.tex b/test/python/visualization/references/test_latex_plot_barriers_true.tex
--- a/test/python/visualization/references/test_latex_plot_barriers_true.tex
+++ b/test/python/visualization/references/test_latex_plot_barriers_true.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 6
-\usepackage[size=custom,height=10,width=15,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} \barrier[0em]{1} & \qw & \qw \barrier[0em]{1} & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \qw & \qw & \gate{\mathrm{H}} & \qw & \qw & \qw\\
-	 	\lstick{c:} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \qw & \qw & \gate{\mathrm{H}} & \qw & \qw & \qw\\ 
+	 	\nghost{c:} & \lstick{c:} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_plot_partial_barriers.tex b/test/python/visualization/references/test_latex_plot_partial_barriers.tex
--- a/test/python/visualization/references/test_latex_plot_partial_barriers.tex
+++ b/test/python/visualization/references/test_latex_plot_partial_barriers.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 5
-\usepackage[size=custom,height=10,width=13,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} \barrier[0em]{0} & \qw & \gate{\mathrm{H}} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{c:} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\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\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{c:} & \lstick{c:} & \lstick{/_{_{2}}} \cw & \cw & \cw & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_r_gates.tex b/test/python/visualization/references/test_latex_r_gates.tex
--- a/test/python/visualization/references/test_latex_r_gates.tex
+++ b/test/python/visualization/references/test_latex_r_gates.tex
@@ -1,26 +1,14 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 4, img_depth = 8
-\usepackage[size=custom,height=10,width=24,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{R}\,\mathrm{(}\mathrm{\frac{3\pi}{4}},\mathrm{\frac{3\pi}{8}}\mathrm{)}} & \multigate{1}{\mathrm{R}_{\mathrm{XX}}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}}_<<<{0} & \multigate{1}{\mathrm{R}_{\mathrm{ZX}}\,\mathrm{(}\mathrm{\frac{-\pi}{2}}\mathrm{)}}_<<<{0} & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{R}_\mathrm{X}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} & \ghost{\mathrm{R}_{\mathrm{XX}}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}}_<<<{1} & \ghost{\mathrm{R}_{\mathrm{ZX}}\,\mathrm{(}\mathrm{\frac{-\pi}{2}}\mathrm{)}}_<<<{1} & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \gate{\mathrm{R}_\mathrm{Y}\,\mathrm{(}\mathrm{\frac{-\pi}{2}}\mathrm{)}} & \multigate{1}{\mathrm{R}_{\mathrm{YY}}\,\mathrm{(}\mathrm{\frac{3\pi}{4}}\mathrm{)}}_<<<{0} & \ctrl{1} & \dstick{\hspace{2.0em}\mathrm{ZZ}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \gate{\mathrm{R}_\mathrm{Z}\,\mathrm{(}\mathrm{\frac{3\pi}{4}}\mathrm{)}} & \ghost{\mathrm{R}_{\mathrm{YY}}\,\mathrm{(}\mathrm{\frac{3\pi}{4}}\mathrm{)}}_<<<{1} & \control \qw & \qw & \qw & \qw & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \gate{\mathrm{R}\,\mathrm{(}\mathrm{\frac{3\pi}{4}},\mathrm{\frac{3\pi}{8}}\mathrm{)}} & \multigate{1}{\mathrm{R}_{\mathrm{XX}}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}}_<<<{0} & \multigate{1}{\mathrm{R}_{\mathrm{ZX}}\,\mathrm{(}\mathrm{\frac{-\pi}{2}}\mathrm{)}}_<<<{0} & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{R}_\mathrm{X}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} & \ghost{\mathrm{R}_{\mathrm{XX}}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}}_<<<{1} & \ghost{\mathrm{R}_{\mathrm{ZX}}\,\mathrm{(}\mathrm{\frac{-\pi}{2}}\mathrm{)}}_<<<{1} & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \gate{\mathrm{R}_\mathrm{Y}\,\mathrm{(}\mathrm{\frac{-\pi}{2}}\mathrm{)}} & \multigate{1}{\mathrm{R}_{\mathrm{YY}}\,\mathrm{(}\mathrm{\frac{3\pi}{4}}\mathrm{)}}_<<<{0} & \ctrl{1} & \dstick{\hspace{2.0em}\mathrm{ZZ}\,\mathrm{(}\mathrm{\frac{\pi}{2}}\mathrm{)}} \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \gate{\mathrm{R}_\mathrm{Z}\,\mathrm{(}\mathrm{\frac{3\pi}{4}}\mathrm{)}} & \ghost{\mathrm{R}_{\mathrm{YY}}\,\mathrm{(}\mathrm{\frac{3\pi}{4}}\mathrm{)}}_<<<{1} & \control \qw & \qw & \qw & \qw & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_reverse_bits.tex b/test/python/visualization/references/test_latex_reverse_bits.tex
--- a/test/python/visualization/references/test_latex_reverse_bits.tex
+++ b/test/python/visualization/references/test_latex_reverse_bits.tex
@@ -1,25 +1,13 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 3, img_depth = 5
-\usepackage[size=custom,height=10,width=13,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{2} :  } & \qw & \qw & \ctrl{1} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \qw & \targ & \ctrl{1} & \qw & \qw\\
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \ctrl{-1} & \targ & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \qw & \qw & \ctrl{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \qw & \targ & \ctrl{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \ctrl{-1} & \targ & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_scale_default.tex b/test/python/visualization/references/test_latex_scale_default.tex
--- a/test/python/visualization/references/test_latex_scale_default.tex
+++ b/test/python/visualization/references/test_latex_scale_default.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 3
-\usepackage[size=custom,height=10,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=1.0em @!R {
-	 	\lstick{ {q}_{0} :  } & \multigate{4}{\mathrm{Unitary}}_<<<{0} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \ghost{\mathrm{Unitary}}_<<<{1} & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \ghost{\mathrm{Unitary}}_<<<{2} & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \ghost{\mathrm{Unitary}}_<<<{3} & \qw & \qw\\
-	 	\lstick{ {q}_{4} :  } & \ghost{\mathrm{Unitary}}_<<<{4} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=1.0em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \multigate{4}{\mathrm{Unitary}}_<<<{0} & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \ghost{\mathrm{Unitary}}_<<<{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \ghost{\mathrm{Unitary}}_<<<{2} & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \ghost{\mathrm{Unitary}}_<<<{3} & \qw & \qw\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \ghost{\mathrm{Unitary}}_<<<{4} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_scale_double.tex b/test/python/visualization/references/test_latex_scale_double.tex
--- a/test/python/visualization/references/test_latex_scale_double.tex
+++ b/test/python/visualization/references/test_latex_scale_double.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 3
-\usepackage[size=custom,height=10,width=10,scale=2.0]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=1.0em @!R {
-	 	\lstick{ {q}_{0} :  } & \multigate{4}{\mathrm{Unitary}}_<<<{0} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \ghost{\mathrm{Unitary}}_<<<{1} & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \ghost{\mathrm{Unitary}}_<<<{2} & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \ghost{\mathrm{Unitary}}_<<<{3} & \qw & \qw\\
-	 	\lstick{ {q}_{4} :  } & \ghost{\mathrm{Unitary}}_<<<{4} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{2.0}{
+\Qcircuit @C=1.0em @R=1.0em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \multigate{4}{\mathrm{Unitary}}_<<<{0} & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \ghost{\mathrm{Unitary}}_<<<{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \ghost{\mathrm{Unitary}}_<<<{2} & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \ghost{\mathrm{Unitary}}_<<<{3} & \qw & \qw\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \ghost{\mathrm{Unitary}}_<<<{4} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_scale_half.tex b/test/python/visualization/references/test_latex_scale_half.tex
--- a/test/python/visualization/references/test_latex_scale_half.tex
+++ b/test/python/visualization/references/test_latex_scale_half.tex
@@ -1,27 +1,15 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 5, img_depth = 3
-\usepackage[size=custom,height=10,width=10,scale=0.5]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=1.0em @!R {
-	 	\lstick{ {q}_{0} :  } & \multigate{4}{\mathrm{Unitary}}_<<<{0} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \ghost{\mathrm{Unitary}}_<<<{1} & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \ghost{\mathrm{Unitary}}_<<<{2} & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \ghost{\mathrm{Unitary}}_<<<{3} & \qw & \qw\\
-	 	\lstick{ {q}_{4} :  } & \ghost{\mathrm{Unitary}}_<<<{4} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{0.5}{
+\Qcircuit @C=1.0em @R=1.0em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \multigate{4}{\mathrm{Unitary}}_<<<{0} & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \ghost{\mathrm{Unitary}}_<<<{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \ghost{\mathrm{Unitary}}_<<<{2} & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \ghost{\mathrm{Unitary}}_<<<{3} & \qw & \qw\\ 
+	 	\nghost{ {q}_{4} :  } & \lstick{ {q}_{4} :  } & \ghost{\mathrm{Unitary}}_<<<{4} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_teleport.tex b/test/python/visualization/references/test_latex_teleport.tex
--- a/test/python/visualization/references/test_latex_teleport.tex
+++ b/test/python/visualization/references/test_latex_teleport.tex
@@ -1,26 +1,14 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 4, img_depth = 11
-\usepackage[size=custom,height=10,width=27,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{U}_3\,\mathrm{(}\mathrm{0.3},\mathrm{0.2},\mathrm{0.1}\mathrm{)}} & \qw \barrier[0em]{2} & \qw & \ctrl{1} & \gate{\mathrm{H}} & \meter & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \ctrl{1} & \qw & \targ & \meter & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \qw & \targ & \qw & \qw & \qw & \qw & \gate{\mathrm{Z}} & \gate{\mathrm{X}} & \meter & \qw & \qw\\
-	 	\lstick{c:} & \lstick{/_{_{3}}} \cw & \cw & \cw & \cw & \dstick{_{_{1}}} \cw \cwx[-2] & \dstick{_{_{0}}} \cw \cwx[-3] & \dstick{_{_{=1}}} \cw \cwx[-1] & \dstick{_{_{=2}}} \cw \cwx[-1] & \dstick{_{_{2}}} \cw \cwx[-1] & \cw & \cw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \gate{\mathrm{U}\,\mathrm{(}\mathrm{0.3},\mathrm{0.2},\mathrm{0.1}\mathrm{)}} & \qw \barrier[0em]{2} & \qw & \ctrl{1} & \gate{\mathrm{H}} & \meter & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{H}} & \ctrl{1} & \qw & \targ & \meter & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \qw & \targ & \qw & \qw & \qw & \qw & \gate{\mathrm{Z}} & \gate{\mathrm{X}} & \meter & \qw & \qw\\ 
+	 	\nghost{c:} & \lstick{c:} & \lstick{/_{_{3}}} \cw & \cw & \cw & \cw & \dstick{_{_{1}}} \cw \cwx[-2] & \dstick{_{_{0}}} \cw \cwx[-3] & \dstick{_{_{=1}}} \cw \cwx[-1] & \dstick{_{_{=2}}} \cw \cwx[-1] & \dstick{_{_{2}}} \cw \cwx[-1] & \cw & \cw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_tiny.tex b/test/python/visualization/references/test_latex_tiny.tex
--- a/test/python/visualization/references/test_latex_tiny.tex
+++ b/test/python/visualization/references/test_latex_tiny.tex
@@ -1,23 +1,11 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 1, img_depth = 3
-\usepackage[size=custom,height=10,width=10,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \gate{\mathrm{H}} & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/references/test_latex_u_gates.tex b/test/python/visualization/references/test_latex_u_gates.tex
--- a/test/python/visualization/references/test_latex_u_gates.tex
+++ b/test/python/visualization/references/test_latex_u_gates.tex
@@ -1,26 +1,14 @@
-% \documentclass[preview]{standalone}
-% If the image is too large to fit on this documentclass use
-\documentclass[draft]{beamer}
-% img_width = 4, img_depth = 8
-\usepackage[size=custom,height=10,width=34,scale=0.7]{beamerposter}
-% instead and customize the height and width (in cm) to fit.
-% Large images may run out of memory quickly.
-% To fix this use the LuaLaTeX compiler, which dynamically
-% allocates memory.
+\documentclass[border=2px]{standalone}
+        
 \usepackage[braket, qm]{qcircuit}
-\usepackage{amsmath}
-\pdfmapfile{+sansmathaccent.map}
-% \usepackage[landscape]{geometry}
-% Comment out the above line if using the beamer documentclass.
-\begin{document}
-
-\begin{equation*}
-    \Qcircuit @C=1.0em @R=0.2em @!R {
-	 	\lstick{ {q}_{0} :  } & \gate{\mathrm{U}_1\,\mathrm{(}\mathrm{\frac{3\pi}{2}}\mathrm{)}} & \ctrl{1} & \dstick{\hspace{2.0em}\mathrm{U}_1\,\mathrm{(}\mathrm{\frac{\pi}{4}}\mathrm{)}} \qw & \qw & \qw & \ctrl{1} & \qw & \qw\\
-	 	\lstick{ {q}_{1} :  } & \gate{\mathrm{U}_2\,\mathrm{(}\mathrm{\frac{3\pi}{2}},\mathrm{\frac{2\pi}{3}}\mathrm{)}} & \control \qw & \qw & \qw & \qw & \gate{\mathrm{U}_3\,\mathrm{(}\mathrm{\frac{3\pi}{2}},\mathrm{\frac{-3\pi}{4}},\mathrm{\frac{-\pi}{2}}\mathrm{)}} & \qw & \qw\\
-	 	\lstick{ {q}_{2} :  } & \gate{\mathrm{U}_3\,\mathrm{(}\mathrm{\frac{3\pi}{2}},\mathrm{4.5},\mathrm{\frac{\pi}{4}}\mathrm{)}} & \ctrl{1} & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 	\lstick{ {q}_{3} :  } & \qw & \gate{\mathrm{U}_2\,\mathrm{(}\mathrm{\frac{\pi}{2}},\mathrm{\frac{3\pi}{2}}\mathrm{)}} & \qw & \qw & \qw & \qw & \qw & \qw\\
-	 }
-\end{equation*}
+\usepackage{graphicx}
 
+\begin{document} 
+\scalebox{1.0}{
+\Qcircuit @C=1.0em @R=0.2em @!R { \\
+	 	\nghost{ {q}_{0} :  } & \lstick{ {q}_{0} :  } & \gate{\mathrm{U}_1\,\mathrm{(}\mathrm{\frac{3\pi}{2}}\mathrm{)}} & \ctrl{1} & \dstick{\hspace{2.0em}\mathrm{U}_1\,\mathrm{(}\mathrm{\frac{\pi}{4}}\mathrm{)}} \qw & \qw & \qw & \ctrl{1} & \qw & \qw\\ 
+	 	\nghost{ {q}_{1} :  } & \lstick{ {q}_{1} :  } & \gate{\mathrm{U}_2\,\mathrm{(}\mathrm{\frac{3\pi}{2}},\mathrm{\frac{2\pi}{3}}\mathrm{)}} & \control \qw & \qw & \qw & \qw & \gate{\mathrm{U}_3\,\mathrm{(}\mathrm{\frac{3\pi}{2}},\mathrm{\frac{-3\pi}{4}},\mathrm{\frac{-\pi}{2}}\mathrm{)}} & \qw & \qw\\ 
+	 	\nghost{ {q}_{2} :  } & \lstick{ {q}_{2} :  } & \gate{\mathrm{U}_3\,\mathrm{(}\mathrm{\frac{3\pi}{2}},\mathrm{4.5},\mathrm{\frac{\pi}{4}}\mathrm{)}} & \ctrl{1} & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+	 	\nghost{ {q}_{3} :  } & \lstick{ {q}_{3} :  } & \qw & \gate{\mathrm{U}_2\,\mathrm{(}\mathrm{\frac{\pi}{2}},\mathrm{\frac{3\pi}{2}}\mathrm{)}} & \qw & \qw & \qw & \qw & \qw & \qw\\ 
+\\ }}
 \end{document}
\ No newline at end of file
diff --git a/test/python/visualization/test_circuit_latex.py b/test/python/visualization/test_circuit_latex.py
--- a/test/python/visualization/test_circuit_latex.py
+++ b/test/python/visualization/test_circuit_latex.py
@@ -112,7 +112,7 @@ def test_teleport(self):
         cr = ClassicalRegister(3, "c")
         circuit = QuantumCircuit(qr, cr)
         # Prepare an initial state
-        circuit.u3(0.3, 0.2, 0.1, [qr[0]])
+        circuit.u(0.3, 0.2, 0.1, [qr[0]])
         # Prepare a Bell pair
         circuit.h(qr[1])
         circuit.cx(qr[1], qr[2])
@@ -492,13 +492,13 @@ def test_iqx_colors(self):
         circuit.t(4)
         circuit.tdg(4)
         circuit.p(pi / 2, 4)
-        circuit.u1(pi / 2, 4)
+        circuit.p(pi / 2, 4)
         circuit.cz(5, 6)
-        circuit.cu1(pi / 2, 5, 6)
+        circuit.cp(pi / 2, 5, 6)
         circuit.y(5)
         circuit.rx(pi / 3, 5)
         circuit.rzx(pi / 2, 5, 6)
-        circuit.u2(pi / 2, pi / 2, 5)
+        circuit.u(pi / 2, pi / 2, pi / 2, 5)
         circuit.barrier(5, 6)
         circuit.reset(5)