4

Using QCircuit, the following code

\documentclass{article}
\usepackage{amsmath}
\usepackage{qcircuit}
\usepackage{braket}
\begin{document}

\Qcircuit @C=0.5cm @R=.2cm {
\lstick{\ket{0}_n} & \gate{H_n} & \qw & \hdots && \gate{\mathsf{M}} & \rstick{\ket{y}_n} \qw \\
& & & \underbrace{}_{\text{some text}}
}

\end{document}

gives the output

which is exactly what I want. However, I get the following error when compiling my source files:

Illegal parameter number in definition of \lastprentry@@ }

Why is this error showing up and what can I do to fix it?

0
1

When you find mysterious error messages, a good strategy is trying with \protect:

\Qcircuit @C=0.5cm @R=.2cm {
\lstick{\ket{0}_n} & \gate{H_n} & \qw & \hdots && \gate{\mathsf{M}} & \rstick{\ket{y}_n} \qw \\
& & & \protect\underbrace{}_{\text{some text}}
}

However, this is a common problem with Xy-pic if an entry starts with “risky” tokens and \relax works: it stops expanding the first token in the cell, which is the problem in this case.

\documentclass{article}
\usepackage{amsmath}
\usepackage{qcircuit}
\usepackage{braket}
\begin{document}

\Qcircuit @C=0.5cm @R=.2cm {
\lstick{\ket{0}_n} & \gate{H_n} & \qw & \hdots && \gate{\mathsf{M}} & \rstick{\ket{y}_n} \qw \\
& & & \relax\underbrace{}_{\text{some text}}
}

\end{document}

Also bracing the item will do:

\Qcircuit @C=0.5cm @R=.2cm {
\lstick{\ket{0}_n} & \gate{H_n} & \qw & \hdots && \gate{\mathsf{M}} & \rstick{\ket{y}_n} \qw \\
& & & {\underbrace{}_{\text{some text}}}
}

enter image description here

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.