我正在尝试使用 重写 Grover 搜索算法quantikz
。我尝试使用 突出显示内部操作组(基本上是除第一列和最后一列之外的整个电路)\gategroup
,但出现错误no shape named tikzf@1@-col3 is known
,并且分组框无法正确呈现。有什么建议吗?
这是我写的 latex 代码
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz} % for quantum circuits
\usetikzlibrary{quantikz} % for quantum circuits
\begin{document}
\begin{quantikz}
\lstick{$\ket{0}$} & \gate{H} & \gate[wires=4]{U_\omega} \gategroup[wires=4,steps=4,style={dotted,cap=round,inner sep=7pt}, label style={label position=below, yshift = -0.5cm}]{repeat $r(N)$ times} & \gate{H} & \gate[wires=4]{2\ket{0}\bra{0}-I} & \gate{H} & \meter{}\\
\lstick{$\ket{0}$} & \gate{H} & {} & \gate{H} & {} & \gate{H} & \meter{}\\
\lstick{$\vdots$} & \push{...} & {} & \push{...} & {} & \push{...} & \meter{}\\
\lstick{$\ket{0}$} & \gate{H} & {} & \gate{H} & {} &\gate{H} &\meter{} \\
\end{quantikz}
\end{document}
答案1
欢迎使用 TeX.SX!这可能有点违反直觉,但你不应该\\
在最后一行添加:
\documentclass[border=1mm]{standalone}
\usepackage{quantikz}
\begin{document}
\begin{quantikz}
\lstick{$\ket{0}$} & \gate{H} & \gate[wires=4]{U_\omega} \gategroup[wires=4, steps=4, style={dotted, cap=round, inner sep=7pt}, label style={label position=below, yshift=-0.5cm}]{repeat $r(N)$ times} & \gate{H} & \gate[wires=4]{2\ket{0}\bra{0}-I} & \gate{H} & \meter{} \\
\lstick{$\ket{0}$} & \gate{H} & {} & \gate{H} & {} & \gate{H} & \meter{}\\
\lstick{$\vdots$} & \push{...} & {} & \push{...} & {} & \push{...} & \meter{}\\
\lstick{$\ket{0}$} & \gate{H} & {} & \gate{H} & {} &\gate{H} &\meter{}
\end{quantikz}
\end{document}