如何用 quantikz 绘制这种看起来复杂的电路?
编辑:这是我的尝试:
\documentclass[english]{revtex4}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{quantikz}
\usepackage{braket}
\begin{document}
\begin{quantikz}[thin lines]
\lstick{$\ket{\psi_0}$}& \gate{U} & \ctrl{1} & \qw & \ctrl{1} & \gate{V_1} & \gate{V_2} & \qw \\
\lstick{$\ket{0}$} & \qw & \gate{R_y(\theta_1)} & \qw & \gate{R_y(\theta_2)} & & & \qw
\end{quantikz}
\end{document}
答案1
我无法让它与您选择的文档类别兼容,但在独立模式下它可以工作。这里有两个版本,一个没有虚线轮廓,一个有虚线轮廓。
\documentclass[border=3.14mm,tikz]{standalone}
\usepackage{graphicx}
\usepackage{amsmath}
\usetikzlibrary{quantikz}
\usepackage{braket}
\begin{document}
\begin{quantikz}[thin lines]
\lstick{$\ket{\psi_0}$}& \gate{U} & \octrl{1} & \qw & \ctrl{1} & \gate{V_1} & \gate{V_2} & \qw \\
\lstick{$\ket{0}$} & \qw & \gate{R_y(\theta_1)} & \qw & \gate{R_y(\theta_2)} & \octrl{-1} & \ctrl{-1} & \qw
\end{quantikz}
\begin{quantikz}[thin lines]
\lstick{$\ket{\psi_0}$}& \qw & \gate{U} \gategroup[wires=2,steps=6,style={dotted,cap=round,inner sep=10pt}]{} & \octrl{1} & \qw & \ctrl{1} & \gate{V_1} & \gate{V_2} & \qw & \qw \\
\lstick{$\ket{0}$} & \qw &\qw & \gate{R_y(\theta_1)} & \qw & \gate{R_y(\theta_2)} & \octrl{-1} & \ctrl{-1} & \qw & \qw
\end{quantikz}
\end{document}
编辑:适用于 revtex4-2 文档类
\documentclass[english]{revtex4-2}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{quantikz}
\usepackage{braket}
\begin{document}
\begin{quantikz}[thin lines]
\lstick{$\ket{\psi_0}$}& \gate{U} & \octrl{1} & \qw & \ctrl{1} & \gate{V_1} & \gate{V_2} & \qw \\
\lstick{$\ket{0}$} & \qw & \gate{R_y(\theta_1)} & \qw & \gate{R_y(\theta_2)} & \octrl{-1} & \ctrl{-1} & \qw
\end{quantikz}
\begin{quantikz}[thin lines,node distance=2pt]
\lstick{$\ket{\psi_0}$}& \qw & \gate{U} \gategroup[wires=2,steps=6,style={dotted,cap=round,inner sep=10pt}]{} & \octrl{1} & \qw & \ctrl{1} & \gate{V_1} & \gate{V_2} & \qw & \qw \\
\lstick{$\ket{0}$} & \qw &\qw & \gate{R_y(\theta_1)} & \qw & \gate{R_y(\theta_2)} & \octrl{-1} & \ctrl{-1} & \qw & \qw
\end{quantikz}
\end{document}
答案2
您的代码非常接近解决方案。
(1)需要使用revtex4-2
。
(2)对于两列,可以使用\resizebox
。
(我使用了 SebGlav 答案中的代码)
\documentclass[aps,reprint]{revtex4-2}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{quantikz}
\usepackage{braket}
\usepackage{kantlipsum} % added
\begin{document}
1. \kant[11]
\noindent \resizebox{\columnwidth}{!}{% code from SebGlav answer
\begin{quantikz}[thin lines]
\lstick{$\ket{\psi_0}$}& \qw & \gate{U} \gategroup[wires=2,steps=6,style={dotted,cap=round,inner sep=10pt}]{} & \octrl{1} & \qw & \ctrl{1} & \gate{V_1} & \gate{V_2} & \qw & \qw \\
\lstick{$\ket{0}$} & \qw &\qw & \gate{R_y(\theta_1)} & \qw & \gate{R_y(\theta_2)} & \octrl{-1} & \ctrl{-1} & \qw & \qw
\end{quantikz}
}
\medskip
2. \kant[2]
\tikzset{operator/.append style={fill=red!20}}
\noindent \resizebox{\columnwidth}{!}{% code from SebGlav answer
\begin{quantikz}[thin lines]
\lstick{$\ket{\psi_0}$}& \qw & \gate{U} \gategroup[2,steps=6,style={dashed,rounded corners,fill=blue!20,inner sep=10pt},background]{} & \octrl{1} & \qw & \ctrl{1} & \gate{V_1} & \gate{V_2} & \qw & \qw \\
\lstick{$\ket{0}$} & \qw &\qw & \gate{R_y(\theta_1)} & \qw & \gate{R_y(\theta_2)} & \octrl{-1} & \ctrl{-1} & \qw & \qw
\end{quantikz}
}
\medskip
3. \kant[3]
\end{document}