-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
latex-source (and latex) circuit drawer support for standalone (and c…
…leaner output) (#6483) * fixed issue 6447 to use standalone and fewer cleaner lines * blacking and removing comments * fixed cropping of latex image labels when initial_state is True * fixed scaling issue using scalebox. Improved label strings * blacked code * fixed deprecated gates in test_circuit_latex Co-authored-by: Luciano Bello <[email protected]> Co-authored-by: Abby Mitchell <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ab97ee8
commit d9c3d55
Showing
36 changed files
with
434 additions
and
854 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
38 changes: 13 additions & 25 deletions
38
test/python/visualization/references/test_latex_big_gates.tex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
32 changes: 10 additions & 22 deletions
32
test/python/visualization/references/test_latex_conditional.tex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
34 changes: 11 additions & 23 deletions
34
test/python/visualization/references/test_latex_creg_initial_false.tex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
32 changes: 10 additions & 22 deletions
32
test/python/visualization/references/test_latex_creg_initial_true.tex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
36 changes: 12 additions & 24 deletions
36
test/python/visualization/references/test_latex_cswap_rzz.tex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
Oops, something went wrong.