1

I'm working in a huge file in Tex Studio in which I create lots of circuits using quantikz. The issue is that whenever I draw a circuit in the third chapter or later, the diagram that appears in the compiled pdf has blank spaces. enter image description here enter image description here

I've tried copying the code of circuits that in previous chapters had behaved as expected, but when the circuits are generated in this chapters they fail, so it's not the circuits code fault. However, this is the method I uso to import them.

\begin{figure}[h]
  \centering
  \subimport{texto/circuitos/clausura/}{fasedoblecontrol.tex}
  \caption{Circuito del Algoritmo de Grover aplicado a búsqueda.}
  \label{Fase doblemente controlada}
\end{figure}

I don't get any relevant error, as the only warning I get is from a picture from a previous chapter.enter image description here. I've also tried including the code of the diagram directly in the main code, but it doesn't seem to improve anything.

It seems that the problem comes from a previous circuit,so here I add a simplify version of the code with only these two circuits:

\documentclass[11pt,oneside]{book}
\usepackage[spanish]{babel}
%\usepackage[latin1]{inputenc}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsfonts,amssymb,amsmath}
\usepackage{color,tikz}
\usepackage{graphicx}
\usepackage{dsfont}
\usepackage{amsthm}%para las fuentes matematicas
\usepackage{lmodern}
\usepackage{biblatex} %Imports biblatex package
\addbibresource{Biblio.bib}%Import the bibliography file
%%%%%%%%%%%%%%%Quantum Circuits%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz}
\usetikzlibrary{quantikz2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagestyle{plain}
\begin{figure}[h]
   \centering
   \begin{quantikz}
       & \gate[4][2.4cm]{O}\gateinput[3]{$x$}\gateoutput[3]{$x$}   & \gate[3][1.7cm]{H^{\otimes n}}     & & \gate[4][3.7cm]{S_0}\gateinput[3]{$x$}\gateoutput[3]{$x$}     & \gate[3][1.7cm]{H^{\otimes n}}     &  \\
    \vdots\\
       &  &   & &   & & \\
       & \gateinput{$-$}\gateoutput{$-\oplus f(x)$}   & & &\gateinput{$-$}\gateoutput{$-\oplus (x_1\vee \ldots \vee x_n)$}&&
   \end{quantikz}
   \caption{Operador de Grover G.}
   \label{Grover operador}
\end{figure}
\begin{figure}[h]
    \begin{center}
        \begin{quantikz}
           \lstick{\ket{0}}&\gate{R_y(\theta)}& \ctrl{1}&\\
           \lstick{\ket{\Psi_0}}&&\gate{U}&\\
           \lstick{\ket{\Psi_0'}}&&&
        \end{quantikz}
    \end{center}
    \caption{QADS de fase doblemente controlada}
    \label{fasedoblecontrol}
\end{figure}
\end{document}

Could anyone tell me what should I do? Or what is causing the trouble?

Thanks in advance.

3
  • 1
    Welcome to TeX.SE! Do you get error messages? Please show the first one. And please show an short compilable TeX code resulting in your issue ...
    – Mensch
    Commented Mar 26 at 18:45
  • 1
    What's in the log file/on the terminal? Relevant warnings? What happens if you include the code for the picture directly at that point in the document? That's one level of complexity extra, so see what happens. If you still see the problem, simplify until you get something minimal to reproduce the issue.
    – cfr
    Commented Mar 26 at 19:35
  • We need something we can reproduce the problem with. So you need to simplify your code to create a minimal example you can post here for people to work with. Also, try zooming in just to rule out a viewer artefact.
    – cfr
    Commented Mar 27 at 16:26

1 Answer 1

0

Your issue amounts to

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{quantikz2}

\begin{document}
 \begin{quantikz}
   & \gate[3]{O} \\
  \\
   & \\
 \end{quantikz}

 \begin{quantikz}
   & \gate{Z} & \\
   & & \\
 \end{quantikz}
\end{document}

Loosely speaking, the first circuit logs that the cell in the second row and second column is spanned by a gate in a global variable. As this cell is never drawn, this instruction outlives the first quantikz environment and remains present when that cell is drawn in the second circuit.

This can be manually reset, in this case for the [2,2] cell, by doing

\makeatletter
\csundef{cell@width@2-2}
\makeatother

between the two quantikz environments.

However, I imagine better practice would be to draw the cell the first time round, which would mean making your first quantikz environment something like

\begin{quantikz}
 & \gate[4][2.4cm]{O} \gateinput[3]{$x$} \gateoutput[3]{$x$} & \gate[3][1.7cm]{H^{\otimes n}} & & \gate[4][3.7cm]{S_0} \gateinput[3]{$x$} \gateoutput[3]{$x$} & \gate[3][1.7cm]{H^{\otimes n}} & \\
 \rstick{\vdots} & \wireoverride{n} & & & & \\
 & & & & & & \\
 & \gateinput{$-$} \gateoutput{$-\oplus f(x)$} & & & \gateinput{$-$} \gateoutput{$-\oplus (x_1\vee \ldots \vee x_n)$} & &
\end{quantikz}

enter image description here

The \vdots are not perfectly placed vertically, but I think all you can do is something manual like \rstick{\raisebox{1.5ex}{\vdots}}.

1
  • Thank you very much, I wouldn't have found this error on my own. I had this error in previous diagrams, but everything works fine now.
    – ryoutatsu
    Commented Mar 28 at 17:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .