2

Is there a way to underbrace a quantikz circuit without the inputs?

What I have:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{quantikz2}

\begin{document}
$\underbrace{
\begin{quantikz}
    \lstick{\ket{\psi_1}} & \ctrl{1} & \\
    \lstick{\ket{\psi_2}} & \targ{} &
\end{quantikz}
}_{}$

\end{document}

What I want:

1 Answer 1

3

I can offer a modified \underbrace command that takes optional arguments to specify the amount of space to cut from the left and from the right, using the widest entry (with some space added).

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{quantikz2}

\newlength{\Ubraceignoreleft}
\newlength{\Ubraceignoreright}

\NewDocumentCommand{\Ubrace}{ommo}{%
  % #1 = optional part to ignore (on the left)
  % #2 = object to be underbraced
  % #3 = subscript
  % #4 = optional part to ignore (on the right)
  {% start a group to fix the spacing
   % and to limit the setting to the lengths
   \IfValueT{#1}{\settowidth{\Ubraceignoreleft}{$#1$}}%
   \IfValueT{#4}{\settowidth{\Ubraceignoreright}{$#4$}}%
   \hspace*{\Ubraceignoreleft}
   \underbrace{%
     \hspace*{-\Ubraceignoreleft}%
     #2%
     \hspace*{-\Ubraceignoreright}%
   }_{#3}%
   \hspace*{\Ubraceignoreright}%
  }%
}

\begin{document}
\[
\Ubrace[\ket{\psi_1}\enspace]{
  \begin{quantikz}
    \lstick{\ket{\psi_1}} & \ctrl{1} & \\
    \lstick{\ket{\psi_2}} & \targ{} &
  \end{quantikz}
}{\text{text}}
\]

\end{document}

The \enspace was computed “by eye”.

enter image description here

Basically, the space is added in front of the \underbrace command, and removed inside it. Similarly if you want to cut from the right. I don't know whether you need to remove from the right, but, you know, mathematicians love symmetry.

You must log in to answer this question.

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