2

How can one draw this complicated-looking circuit with quantikz?

enter image description here

Edit: Here is my attempt:

 \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}
8
  • 1
    Have you tried something looking the manual?
    – Sebastiano
    Jul 25 at 12:17
  • Yep...still trying: \begin{quantikz}[thin lines] \lstick{$\ket{\psi_0}$}& \gate{U} & \ctrl{1} & \qw & \ctrl{1} & \qw & \gate{V_1} & \gate{V_2} & \qw \\ \lstick{$\ket{0}$} & \qw & \gate{R_y(\theta_1)} & \qw & \gate{R_y(\theta_2)} & \qw & & & \qw \end{quantikz}
    – Zubin
    Jul 25 at 12:30
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – DG'
    Jul 25 at 12:31
  • @Zubin Please, read the comment of DG': edit your question.....Thus we can help you better.
    – Sebastiano
    Jul 25 at 12:33
  • 1
    Thanks @Sebastiano. I have just updated my questioin.
    – Zubin
    Jul 25 at 12:59
3

I couldn't make ot work with your chosen document class, but in standalone it's working. Here are two versions, one without the dotted outline and one with it.

V1

V2

\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}

EDIT: works on revtex4-2 document class

\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}

on revtex4-2

3
  • Thanks, @SebGlav. Is it possible to reduce the size such that this fits in one column in a two-column format?
    – Zubin
    Jul 25 at 13:32
  • Or any other better way of drawing the same circuit?
    – Zubin
    Jul 25 at 13:34
  • I don't know about resizing with quantikz. I tried several obvious solutions that failed. You can try and design with older packages, like circuitikz, or qcircuit, but I don' master them to say if a resizing is possible. You could ask this as a new question, and I'm sure you'll get answers.
    – SebGlav
    Jul 25 at 13:42
5

Your code is very close to the solution.

(1) Need to use revtex4-2.

(2) For two columns, you can use \resizebox.

(I used the code from SebGlav answer)

c

\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}
2
  • Thanks, @Simon. Is there a better way of drawing the same circuit, by compacting its size (to fit in a single column of a two column format) and maybe beautify it a little bit?
    – Zubin
    Jul 25 at 14:05
  • @Zubin I updated my answer. Beauty is in the eye of the beholder Jul 25 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.