2

I am writing an article in which I need a quantum circuit figure, and want to use the quantikz package for the purpose. However, I got a series of errors upon loading quantikz. I have pinpointed the problem to be of not two but three different elements, but cannot figure out how to resolve it.

There must be some type of conflict between the quantikz and cleveref packackages. Interestingly this conflict only throws errors when also using a gather-environment.

The minimal example below produces the following errors once each for every gather-environment present in the document:

  1. Only one # is allowed per tab.
  2. Misplaced alignment tab character &.
  3. Extra alignment tab has been changed to \cr.
\documentclass{article}
\usepackage{quantikz}
\usepackage{cleveref}

\begin{document} \begin{gather} some~maths \end{gather} \end{document}

1 Answers1

2

Description

From the quantikz manual (section "Troubleshooting"):

Package load order: I’ve had reports that if you load certain packages in the wrong order it can create weird errors. For example, if you load the package cleveref after quantikz, and then use a split environment, it can lead to the error “Only one # is allowed per tab.”. Change the load order and it goes away. I have no idea why this happens.

So change the load order.

\usepackage{cleveref}
\usepackage{quantikz}

As cleveref must be load after amsmath that is used for gather, but also implicitly used by quantikz, you have to load amsmath before:

\usepackage{amsmath}
\usepackage{cleveref}
\usepackage{quantikz}

Note: If you want to use hyperef, it must come before cleveref:

\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{quantikz}

Code

\documentclass{article}
\usepackage{amsmath}
%\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{quantikz}

\begin{document} \begin{gather} some~maths \end{gather} \end{document}

dexteritas
  • 9,161