3

I am a long-time consumer of the discussions in this great forum. This is my first question, so please correct me if I do not follow some protocols.

In my attempt to use both the packages zx-calculus and quantikz I run into two (maybe related) problems. Please note that compilation works just fine when I compile with TeXShop (which I commonly use) but the problems occur when compiling with pdflatex or latex from console (originally discovered while trying to upload an article to arxiv with their AutoTeX). Also note that I need quantikz in the same document but did not include it in the MWEs because quantikz' functions are not affected.

  1. When loading zx-calculus first and quantikz second, the ZX-diagrams have overlying horizontal lines along all rows of the diagram. This is clearly some redefinition of a command in tikzcd by quantikz. However, I cannot pin it down and fix it.

MWE 1:

\documentclass{standalone}

\usepackage{quantikz} \usepackage{zx-calculus}

\begin{document}

\begin{ZX} \leftManyDots{} \zxZ{} \end{ZX}

\end{document}

Results in:

ZX-diagram with bar overlay

  1. When loading quantikz first and zx-calculus second, zx-calculus/tikzcd/pgf fails on the command \leftManyDots{} and gives the error
! Package pgf Error: Sorry, the requested layer 'edgelayer' is not part of the 
layer list. Please verify that you provided \pgfsetlayers and that 'edgelayer' 
is part of this list.

See the pgf package documentation for explanation. Type H <return> for immediate help ... l.10 I think the culprit is a tikzcd arrow in cell 1-1. \errmessage ...currentrow -\tikzcd@currentcolumn }

l.11 \end{ZX}

I pinned the error down to the command \leftManyDots{} which automatically creates a new cell and separator & within tikzcd. I have played around with the code in the package but have not found any solution.

MWE 2:

\documentclass{standalone}

\usepackage{zx-calculus} \usepackage{quantikz}

\begin{document}

\begin{ZX} \leftManyDots{} \zxZ{} \end{ZX}

\end{document}

The following shows how the MWE should look like.

Expected:

ZX-diagram with \leftManyDots

I would be happy if you could point me to a direction or even find a solution.

  • Do you actually need dvi? arXiv can be set to use pdftex – Dai Bowen Jun 22 '23 at 08:26
  • I see no difference between pdflatex + latex+dvips+ps2pdf. The one order errors the other gives the middle line. – Ulrike Fischer Jun 22 '23 at 10:17
  • @DaiBowen no I do not need dvi. But pdftex (\pdfoutput=1 in the first five lines of the preamble) does not solve the problem for me whilst trying to submit to arxiv. – Max Schwetz Jun 23 '23 at 06:28
  • @UlrikeFischer you are right. I just tested it from console. I was working with TeXShop (where everything worked fine with MWE 2) before and assumed it uses PDFLaTeX. I will correct that in the original post. I will try to figure out what TeXShop does differently to make it work. – Max Schwetz Jun 23 '23 at 06:37
  • So I finally found that I was still using texlive 2022 with TeXShop. The 2022 version of quantikz does solve the problem. This works for me now to upload to arxiv. Thanks for your hints to both of you! I will however still try to figure it out with the 2023 version. For my future work as well as for others. I will post any solution here. – Max Schwetz Jun 23 '23 at 08:06

1 Answers1

3

If you load quantikz first, you get an error as quantikz patches two commands from the tikz-cd library (\tikzcd@ and \endtikzcd) in a way that it clashes with other uses of tikz-cd. That is not good, but happily you can avoid the error in your example by loading zx-calculus first, as it stores copies of the original commands and uses these.

The line in the middle then appears as quantikz sets tikz-cd options. It even acknowledges in the code that this isn't a great idea:

annoyingly, this first one will affect all tikzcd instances, not just quantum circuits. I should have only provided the quantikz environment as a modified version of tikzcd, and not allowed direct use of tikzcd. Probably too late now.

You can reset the style. To avoid that it affects quantikz do it only for the environment:

\documentclass{standalone}
\usepackage{zx-calculus}
\usepackage{quantikz}

\AddToHook{env/ZX/begin}{\tikzcdset{every cell/.style={}}}

\begin{document}

\begin{ZX} \leftManyDots{} \zxZ{} \end{ZX}

\end{document}

enter image description here

Ulrike Fischer
  • 327,261