projekter / yquant

Typesetting quantum circuits in a human-readable language
LaTeX Project Public License v1.3c
56 stars 5 forks source link

bmatrix in yquantgroup not supported #26

Closed amirebrahimi closed 1 year ago

amirebrahimi commented 1 year ago

Describe the bug The \\ line break gets interpreted by yquantgroup instead of bmatrix

To Reproduce

\begin{figure}[H]
    \centering
    \begin{tikzpicture}[scale=1]
        \begin{yquantgroup}[
        register/minimum height=5mm,
        ]
            \registers{
                qubit {} q[2];
            }
            \circuit{
                box {U} q[1] | q[0];
            }
            \equals
            \circuit{
                box {C} q[1];
                cnot q[1] | q[0];
                box {B} q[1];
                cnot q[0] | q[1];    
                box {$\begin{bmatrix} 1 & 0 \\ 0 & e^{ia}\end{bmatrix}$} q[0];
                box {A} q[1];
            }
       \end{yquantgroup}
    \end{tikzpicture}
    \caption{Singly-controlled-U gate decomposition}
\end{figure}

Expected output I'd expect that I can create the same boxes with matrices that I can in yquant.

Screenshots This is an example of it being in yquant, but ultimately I'd like to set this as being equal to another circuit on the left side. image

Environment Overleaf

projekter commented 1 year ago

You are right, we should reset all the special commands as soon as a grouped circuit is entered, as they don't make any sense in there. This commit should fix it.

amirebrahimi commented 1 year ago

Thank you!

amirebrahimi commented 1 year ago

Hmm...I'm still getting an error: Use of \yquantgroup@linebreak@i doesn't match its definition.

I downloaded the latest and copied it to Overleaf directly and used the local one.

projekter commented 1 year ago

Can you give your full code? The following works without any error for me:

\documentclass{article}

\usepackage[compat=newest]{yquant}
\usepackage{amsmath}
\useyquantlanguage{groups}

\begin{document}
\begin{tikzpicture}[scale=1]
        \begin{yquantgroup}[
        register/minimum height=5mm,
        ]
            \registers{
                qubit {} q[2];
            }
            \circuit{
                box {U} q[1] | q[0];
            }
            \equals
            \circuit{
                box {C} q[1];
                cnot q[1] | q[0];
                box {B} q[1];
                cnot q[0] | q[1];    
                box {$\begin{bmatrix} 1 & 0 \\ 0 & e^{ia}\end{bmatrix}$} q[0];
                box {A} q[1];
            }
       \end{yquantgroup}
    \end{tikzpicture}
\end{document}
amirebrahimi commented 1 year ago

I created a new project to test: https://www.overleaf.com/read/nppvykmhpqdm

amirebrahimi commented 1 year ago

Looking at the log files it looks like it is picking up the individual .tex files from the 2022 texlive distribution for each \input command in the local file yquant.sty. I'm trying now to override it to use the local files, but I'm not that well versed in LaTeX.

amirebrahimi commented 1 year ago

Figured it out thanks to this: https://tex.stackexchange.com/questions/505271/override-package-with-local-package-overleaf