\documentclass{article}
\usepackage[a4paper, textwidth=150mm]{geometry}

\usepackage{qworld}

\usepackage{bookmark}
\usepackage{fontspec}
\usepackage{pdfpages}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{mathtools}

\usepackage{ascmac}
\usepackage{fancybox}
\usepackage{float}

\usepackage{bbm}
\usepackage{mathrsfs}
%\numberwithin{equation}{subsection}

\usepackage{framed}
\newenvironment{longshadowbox}{%
  \def\FrameCommand{\fboxsep=\FrameSep \shadowbox}%
  \MakeFramed {\FrameRestore}}%
{\endMakeFramed}

\usepackage{url}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue}

\usepackage{iitem}

\usepackage{xspace}
\newcommand{\qworldname}{\texttt{QWorld}\xspace}
\newcommand{\tikzname}{Ti\emph{k}Z\xspace}
\newcommand{\texlivename}{\TeX{} \textsf{Live}\xspace}

\setcounter{tocdepth}{3}

\usepackage[most]{tcolorbox}
\newtcblisting{mybox}[2][]{
  colback=red!5!white,
  colframe=red!75!black,
  fonttitle=\bfseries,
  title=#2,
  #1
}

\tcbset
{
  codeinfo/.style=
  { 
    colframe=cyan!90,
    coltitle=cyan!60,
    colbacktitle=black,
    fonttitle=\small\sffamily\bfseries, 
    fontupper=\small, 
    fontlower=\small
  },
  exampletitleinfo/.style 2 args=
  {
    codeinfo,
    title={Example \thetcbcounter : #1},
    label={#2}
  },
  failurecodeinfo/.style=
  {
    colframe=red!90,
    coltitle=red!60, 
    colbacktitle=black,
    fonttitle=\small\sffamily\bfseries, 
    fontupper=\small, 
    fontlower=\small
  },
  failureexampletitleinfo/.style 2 args=
  {
    failurecodeinfo,
    title={Failure Example \thetcbcounter : #1},
    label={#2}
  }
}
\newtcblisting{texexp}[1]
{
  codeinfo,
  #1
}
\newtcblisting[auto counter,number within=section]{codebox}[3][center lower,listing side text,righthand width=3.5cm,bicolor,colbacklower=white]
{
  exampletitleinfo={#2}{#3},
  breakable,
  #1
}

\newtcblisting[use counter from=codebox,number within=section]{CODEBOX}[3][center lower,bicolor,colbacklower=white]
{
  exampletitleinfo={#2}{#3},
  breakable,
  #1
}
\newtcolorbox[use counter from=codebox]{codeboxspec}[3][]
{
  exampletitleinfo={#2}{#3},
  breakable,
  #1
}

\newtcblisting{texfexp}[1]
{
  failurecodeinfo,
  #1
}
\newtcblisting[auto counter,number within=section]{fcodebox}[3][center lower,listing side text,righthand width=3.5cm,bicolor,colbacklower=white]
{
  failureexampletitleinfo={#2}{#3},
  breakable,
  #1
}

\newtcblisting[use counter from=fcodebox,number within=section]{FCODEBOX}[3][center lower,bicolor,colbacklower=white]
{
  failureexampletitleinfo={#2}{#3},
  breakable,
  #1
}
\newtcolorbox[use counter from=fcodebox]{fcodeboxspec}[3][]
{
  failureexampletitleinfo={#2}{#3},
  breakable,
  #1
}

\begin{document}

\title{
    \Huge\textbf{The QWorld Package}\\[4pt]
    \scriptsize\texttt{Version 1.1.0} \\[4pt]
}
\author{
    \textbf{Niina Ryota} \\[4pt]
}
\date{\today}
\maketitle

\begin{abstract}
  \qworldname is a \LaTeX\ package designed for efficiently rendering complex graphical calculus in monoidal categories.
  In particular, it supports the typesetting of diagrammatic languages in category theory, quantum theory, and related fields, where diagrammatic reasoning plays a crucial role.
\end{abstract}

\tableofcontents
\section{Introduction}
This document aims to provide a step-by-step guide to installing and using the \qworldname package, from basic commands to advanced applications. 
\qworldname is a \LaTeX\ package specifically designed for the typesetting of diagrammatic languages, offering an intuitive command set for describing diagrams related to monoidal categories, Frobenius structures, braiding, Hopf algebras, symmetries, dualities, pivotal structures, and dagger categories using \tikzname\cite{tikz-manual}.
\section{Basic Usage}
\subsection{Fundamental Elements}
The following are the most fundamental commands in the \qworldname package, forming the basis for drawing diagrams:
\begin{itemize}
  \item \texttt{\textbackslash q}: A canvas for placing diagram elements.
  \item \texttt{\textbackslash qbox}: Draws a box\(\q[scale=0.5]{\qbox}\).
  \item \texttt{\textbackslash qwire}: Draws a wire\(\q[scale=0.5]{\qwire}\).
  \item \texttt{\textbackslash qcirc}: Compositon.
\end{itemize}
These commands are used within the canvas environment, denoted by \verb|\q{...}|. 
For example, writing \verb|\q{\qbox}| results in the rendering of a box\(\q[scale=0.5]{\qbox}\).\par
  To compose \(\q[scale=0.5]{\qbox}\)and\(\q[scale=0.5]{\qbox}\), use \verb|\qcirc|. 
  This is analogous to function composition in mathematics, such as \(g\circ f\) (\verb|\(g\circ f\)|). 
  \begin{codebox}{}{Ex:20250317}
    \q{ \qbox \qcirc \qbox }
  \end{codebox}
  Additionally, placing multiple \verb|\qbox| commands in sequence results in boxes\(\q[scale=0.5]{\qbox}\)being arranged horizontally:
  \begin{codebox}{}{boxs2}
    \q{ \qbox \qbox \qbox }
  \end{codebox}
  It is also possible to compose multiple boxes using\verb|\qcirc|:
  \begin{codebox}{}{boxsbr}
      \q
      {
        \qbox \qbox \qbox
          \qcirc
        \qbox \qbox \qbox
      }
  \end{codebox}
  Note that \verb|\n| is synonymous with\verb|\qcirc|
  \begin{codebox}{}{boxsn}
    \q
    {
      \qbox \qbox \qbox \n
      \qbox \qbox \qbox
    }
\end{codebox}
\subsubsection{Identification Number}
All commands placed within \verb|\q{...}| are automatically assigned unique identification numbers based on their execution order. 
For example, in the previous example \ref{boxsn}, each \verb|\qbox| is numbered as follows:
\[\q{\qloop[2]{\qloop[3]{\qbox[show id={true}]}\n}}\]
For more details, see Section \ref{subsub:show id} on page \pageref{subsub:show id}.
\subsubsection{Bounding Box}
\[\q{
  \qcaprev \qcap           \n
  \qwire   \qbraid  \qwire \n
  \qwire   \qbraid \qwire \n
  \qcup    \qcuprev
  \qbb[red][1,2]
    \bbsymbol{Measure}
    \bbsymbol[W]{Output}[left]
    \bbsymbol[NW]{Computation}[above left]
    \bbsymbol[NE]{Physics}[above right]
  \qbb[yellow][3,5,6,8]
    \bbsymbol{Braid}
    \bbsymbol[W]{Compute}[left]
  \qbb[cyan][9,10]
    \bbsymbol{Create}
    \bbsymbol[W]{Initialize}[left]
}\]
See the following example \ref{ex:hopflink}:
\begin{codebox}{}{ex:hopflink}
  \q{
    \qcaprev \qcap          \n
    \qwire   \qbraid \qwire \n
    \qwire   \qbraid \qwire \n
    \qcup    \qcuprev
  }
\end{codebox}
\begin{itemize}
  \item \verb|\qcaprev| draws \(\q[scale=0.6]{\qcaprev}\).
  \item \verb|\qcap| draws \(\q[scale=0.6]{\qcap}\).
  \item \verb|\qwire| draws \(\q[scale=0.5]{\qwire}\).
  \item \verb|\qbraid| draws \(\q[scale=0.5]{\qbraid}\).
  \item \verb|\qcup| draws\(\q[scale=0.6]{\qcup}\).
  \item \verb|\qcuprev| draws \(\q[scale=0.6]{\qcuprev}\).
\end{itemize}
As a whole, the elements are arranged in the diagram according to the order in which the commands are written.\par
Each element has an associated bounding box. The following are examples:
  \begin{itemize}
    \item The bounding box of\q{\qcaprev}is visualized as\q{\qcaprev\qbball}.
    \item The bounding box of\q{\qbraid}is visualized as\q{\qbraid\qbball}.
    \item The bounding box of\q{\qwire}is visualized as\q{\qwire\qbball}.
    \item The bounding box of\q{\qcuprev}is visualized as\q{\qcuprev\qbball}.
  \end{itemize}
  The following commands are available for visualizing bounding boxes and placing text near them:
  \begin{itemize}
    \item Visualization
      \iitem \texttt{\textbackslash qbb}: Displays the bounding box of a specific element.
      \iitem \texttt{\textbackslash qbball}: Displays the bounding boxes of all elements at once.
      \iitem \texttt{\textbackslash qBBall}: Displays the bounding box surrounding the entire canvas.
    \item Placing text
      \iitem \texttt{\textbackslash bbsymbol}: Places text within a bounding box.
  \end{itemize}
  
  \begin{verbatim}
    \qbb[<color>][<ID list>]
  \end{verbatim}
  \begin{itemize}
    \item First argument (optional): Specifies the color. If omitted, no color is applied.
    \item Second argument: Specifies a list of element IDs to display their bounding boxes.
  \end{itemize}
  \begin{codebox}{}{Ex:20250320}
    \q{\qbox\qbb[1]}
  \end{codebox}
  \begin{codebox}{}{ex:202503270454}
    \q{
      \qcaprev \qcap          \n
      \qwire   \qbraid \qwire \n
      \qwire   \qbraid \qwire \n
      \qcup    \qcuprev
      \qbb[4,7]
    }
  \end{codebox}
  \begin{CODEBOX}{}{Ex:20250321}
    \q{\qbox\qbox\qbox\qbox\qbox\qbox\qbb[yellow][2,...,5]}
  \end{CODEBOX}
  \begin{codebox}{}{Ex:20250222}
    \q
    {
      \qbox\qbox\qbox\n
      \qbox\qbox\qbox
      \qbb[green][2,5]
    }
  \end{codebox}
  \begin{codebox}{}{Ex:20250318}
    \q{
      \qcaprev \qcap          \n
      \qwire   \qbraid \qwire \n
      \qwire   \qbraid \qwire \n
      \qcup    \qcuprev
      \qbb[blue][4,7]
    }
  \end{codebox}
  \begin{verbatim}
    \qbball[<color>]
  \end{verbatim}
  \begin{itemize}
    \item Displays multiple bounding boxes at once (even for a single element).
    \item Ensures that the bounding boxes of different elements are properly aligned without overlap.
    \item The \qworldname package \textbf{minimizes the need for tedious manual coordinate adjustments} in diagram drawing.
  \end{itemize}
  \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{Ex:202503270511}
    \q{
      \qcaprev \qcap          \n
      \qwire   \qbraid \qwire \n
      \qwire   \qbraid \qwire \n
      \qcup    \qcuprev
      \qbball
    }
  \end{codebox}

  \begin{verbatim}
    \qBBall[<color>]
  \end{verbatim}
  \begin{itemize}
    \item Displays the bounding box surrounding all elements within the canvas.
  \end{itemize}
  \begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{Ex:20250316}
    \q{
      \qcaprev \qcap          \n
      \qwire   \qbraid \qwire \n
      \qwire   \qbraid \qwire \n
      \qcup    \qcuprev
      \qBBall
    }
  \end{codebox}
  \begin{verbatim}
    \bbsymbol[<direction>]{<text>}[<options>]
  \end{verbatim}
  \begin{itemize}
    \item First argument (optional): Specifies placement direction. Options:
      \iitem N (North), S (South), E (East), W (West),
      \iitem NW (Northwest), NE (Northeast), SE (Southeast), SW (Southwest),
      \iitem C (Center).
      \iitem Default: E (East).
    \item Second argument: Specifies the text to be placed.
    \item Third argument (optional): Adjusts position (e.g., above, below, left, right).
      \iitem Default: right.
  \end{itemize}
  \begin{CODEBOX}{}{Ex:bbsymbol}
    \q[scale=5]{
      \qbox
      \qbb[1]
      \bbsymbol{East (Default)}
      \bbsymbol[W]{West}[left]
      \bbsymbol[N]{North}[above]
      \bbsymbol[S]{South}[below]
      \bbsymbol[NE]{NorthEast}[above right]
      \bbsymbol[NW]{NorthWest}[above left]
      \bbsymbol[SE]{SouthWest}[below right]
      \bbsymbol[SW]{SouthEast}[below left]
      \bbsymbol[C]{Center}[]
    }
  \end{CODEBOX}
  \begin{CODEBOX}{}{Ex:20250315}
    \q
    {
      \qcaprev \qcap          \n
      \qwire   \qbraid \qwire \n
      \qwire   \qbraid \qwire \n
      \qcup    \qcuprev
      \qbb[red][1,2]
        \bbsymbol{Measure}
        \bbsymbol[W]{Output}[left]
        \bbsymbol[NW]{Computation}[above left]
        \bbsymbol[NE]{Physics}[above right]
      \qbb[yellow][3,5,6,8]
        \bbsymbol{Braid}
        \bbsymbol[W]{Compute}[left]
      \qbb[cyan][9,10]
        \bbsymbol{Create}
        \bbsymbol[W]{Initialize}[left]
    }
  \end{CODEBOX}

  \subsection{Mathematical Mode}
  When writing equations that include diagrammatic language, use the mathematical mode.
  \begin{CODEBOX}{}{IntroEx}
    \[
      \operatorname{Tr}\left(\q{\qbraid\qcirc\qbraid}\right)
      =\q{
        \qcap    \qcap             \n
        \qwire   \qbraidinv \qwire \n
        \qwire   \qbraidinv \qwire \n
        \qcuprev \qcuprev
      }
    \]
  \end{CODEBOX}

  \subsection{Installation}
  The style file for the \qworldname package, \texttt{qworld.sty}, is available for download from CTAN.
  To use it, place the file in your \TeX\ package directory and include the following line in the preamble:
  \begin{verbatim}
    \usepackage{qworld}
  \end{verbatim}
  \paragraph{Dependencies} 
  The package depends on the following:
  \begin{itemize}
      \item \tikzname, with the following libraries:
        \iitem \texttt{cd}
        \iitem \texttt{positioning}
        \iitem \texttt{arrows}
        \iitem \texttt{arrows.meta}
        \iitem \texttt{calc}
        \iitem \texttt{intersections}
        \iitem \texttt{shapes.symbols}
        \iitem \texttt{shapes.geometric}
        \iitem \texttt{shapes.misc}
        \iitem \texttt{decorations.pathreplacing}
        \iitem \texttt{decorations.markings}
        \iitem \texttt{decorations.pathmorphing}
      \item \texttt{pgffor}
      \item \texttt{ifthen}
      \item \texttt{xparse}
      \item \texttt{xfp}
      \item \texttt{xstring}
  \end{itemize}
  These dependencies are included by default in the \texlivename distribution, so no additional setup is required.
\subsection{Basic Customization}
This section explains how to customize commands in the \qworldname package.
  \subsubsection{Box Customization}
  \label{subsubsec:boxcustomization}
  Keys can be used to adjust the number and arrangement of the box’s boundary lines.
For example, the following boxes can be drawn:
\begin{itemize}
  \item \(\q[scale=0.5]{\qbox[p=20,hlen=3]}\)
  \item \(\q[scale=0.5]{\qbox[p=10,N={1,2,3,8,9,10},S={4,5,6,7},hlen=3]}\)
\end{itemize}
These keys are applicable to many elements other than wires.
The main keys are as follows: 
\begin{itemize}
  \item \texttt{n}
    \iitem The number of points on the north edge of the box\(\q[scale=0.5]{\qbox[p=2, P={}]}\)where wires\(\q[scale=0.31]{\qwire}\)can be generated (these points will be referred to as \texttt{n} terminals).
    \iitem For example, if \texttt{n=3}, three points can be placed at equal intervals on the north edge of the box.
    \iitem The default value is \texttt{n=1}.
    \iitem The point obtained by vertically moving an \texttt{n} terminal to the northernmost position is called an \texttt{N} terminal.
    \iitem Both \texttt{n} terminals and \texttt{N} terminals are indexed as \(1,2,...\) from the west (left).   
    \iitem Generating a wire from the \(i\)-th \texttt{n} terminal means connecting the \(i\)-th \texttt{n} terminal and the \(i\)-th \texttt{N} terminal with a line segment.
  \item \texttt{N}
    \iitem The set of indices of the \texttt{n} terminals from which wires are actually generated.
    \iitem For example, if \texttt{n=3} and \texttt{N=\{2\}}, a wire can be generated from the \(2\)nd of the three \texttt{n} terminals.
    \iitem If \texttt{n} is unspecified and \texttt{N} is specified, \texttt{n} is automatically set to \(\texttt{n}\coloneq\max\texttt{N}\).
    \iitem If \texttt{N} is unspecified and \texttt{n} is specified, \texttt{N} is automatically set to \(\texttt{N}\coloneq\{1,...,\texttt{n}\}\).
    \iitem The northernmost end of a wire actually generated from an \texttt{n} terminal is called the output point, or \texttt{O} terminal.
  \item \texttt{s}
      \iitem The number of points on the south edge of the box where wires can be generated (these points will be referred to as \texttt{s} terminals).
      \iitem For example, if \texttt{s=4}, four points can be placed at equal intervals on the south edge of the box. 
      \iitem The default value is \texttt{s=1}.
      \iitem The point obtained by vertically moving an \texttt{s} terminal to the southernmost position is called an \texttt{S} terminal.
      \iitem Both \texttt{s} terminals and \texttt{S} terminals are indexed as \(1,2,...\) from the west (left).     
      \iitem Generating a wire from the \(i\)-th \texttt{s} terminal means connecting the \(i\)-th \texttt{s} terminal and the \(i\)-th \texttt{S} terminal with a line segment.
  \item \texttt{S}
      \iitem The set of indices of the \texttt{s} terminals from which wires are actually generated.
      \iitem For example, if \texttt{s=4} and \texttt{S=\{1,4\}}, wires can be generated from the 1st and 4th of the four \texttt{s} terminals.
      \iitem If \texttt{s} is unspecified and \texttt{S} is specified, \texttt{s} is automatically set to \(\texttt{s}\coloneq\max\texttt{S}\).
      \iitem If \texttt{S} is unspecified and \texttt{s} is specified, \texttt{S} is automatically set to \(\texttt{S}\coloneq\{1,...,\texttt{s}\}\).
      \iitem The southernmost end of a wire actually generated from an \texttt{s} terminal is called the input point, or \texttt{I} terminal.
  \item \texttt{hlen}
      \iitem The horizontal length of the bounding box.
      \iitem For example, if \texttt{hlen=2}, the horizontal length of the bounding box becomes \texttt{2}.
      \iitem With one exception, the distance between the westernmost wire and the bounding box's boundary, and the distance between the easternmost wire and the bounding box's boundary, are both \(\fpeval{0.5*\qwireinterval}\).
      \iitem When \texttt{hlen} is unspecified, the \texttt{n} terminals and \texttt{s} terminals are arranged with an interval of \(1\).
      \iitem When \texttt{hlen} is specified, the \texttt{n} terminals and \texttt{s} terminals are arranged at equal intervals in a section of length \(\texttt{hlen}-\fpeval{\qwireinterval}\). The spacing depends on \texttt{hlen} and the number of terminals.
          \iiitem If there is only one terminal, it is placed at the center of the section. In this case, if \(\texttt{hlen}>1\), the distance between the westernmost wire and the bounding box's boundary, and the distance between the easternmost wire and the bounding box's boundary, are both \(\frac{\texttt{hlen}}{2}>\fpeval{0.5*\qwireinterval}\).
  \item \texttt{vlen}
      \iitem The vertical length (height) of the bounding box.
      \iitem The default value is \texttt{vlen=1}.
  \item \texttt{id}
      \iitem The identifier of the box.
      \iitem For example, if \texttt{id=ID}, the following names are automatically assigned to the various points:
          \iiitem The \(i\)-th \texttt{n} terminal (counting from the west): (n-\(i\)-ID).
          \iiitem The \(i\)-th \texttt{s} terminal: (s-\(i\)-ID).
          \iiitem The point obtained by vertically moving the \(i\)-th \texttt{n} terminal to the north edge of the box: (N-\(i\)-ID).
          \iiitem The point obtained by vertically moving the \(i\)-th \texttt{s} terminal to the south edge of the box: (S-\(i\)-ID).
          \iiitem The northwest corner of the bounding box: (NW-ID)
          \iiitem The northeast corner of the bounding box: (NE-ID)
          \iiitem The southwest corner of the bounding box: (SW-ID)
          \iiitem The southeast corner of the bounding box: (SE-ID)
          \iiitem The northernmost point of the bounding box: (N-ID)
          \iiitem The southernmost point of the bounding box: (S-ID)
          \iiitem The westernmost point of the bounding box: (W-ID)
          \iiitem The easternmost point of the bounding box: (E-ID)
          \iiitem The center of the bounding box: (C-ID)
          \iiitem The northwest corner of the box: (nw-ID)
          \iiitem The northeast corner of the box: (ne-ID)
          \iiitem The southwest corner of the box: (sw-ID)
          \iiitem The southeast corner of the box: (se-ID)
          \iiitem The northernmost point of the box: (n-ID)          
          \iiitem The southernmost point of the box: (s-ID)
          \iiitem The westernmost point of the box: (w-ID)
          \iiitem The easternmost point of the box: (e-ID)          
          \iiitem The \(i\)-th output point: (O-\(i\)-ID)
          \iiitem The \(i\)-th input point: (I-\(i\)-ID)          
      \iitem Regardless of whether it is specified, each command placed inside \texttt{\textbackslash q\{...\}} is assigned an identification number. Replacing the ID part with that number refers to the same point. See section \ref{subsub:show id} for details.
    \item \texttt{p}, \texttt{P}
        \iitem For a positive integer \texttt{k}, \texttt{p=k} means \texttt{n=k} and \texttt{s=k}.
        \iitem For a finite set of positive integers \texttt{K}, \texttt{P=K} means \texttt{N=K} and \texttt{S=K}.
    \item \texttt{name}
        \iitem With \texttt{name=<text>}, \text{<text>} is placed at the center of the box.
\end{itemize}
\begin{CODEBOX}{}{ex:boxpoints}
  \def\pradius{0.4pt}
  \q[scale=4]
  {
    \qbox
    [
      n=3,N={2},
      s=4,S={1,4},
      hlen=2,
      vlen=2,
      id={ID},
      name={Center (C-ID)}
    ]\n
    \qbb[ID]
    \node [above] at (NE-ID) {NE-ID};
    \node [above] at (NW-ID) {NW-ID};
    \node [below] at (SE-ID) {SE-ID};
    \node [below] at (SW-ID) {SW-ID};
    \fill (NE-ID) circle (\pradius);
    \fill (NW-ID) circle (\pradius);
    \fill (SE-ID) circle (\pradius);
    \fill (SW-ID) circle (\pradius);
    \node [above] at (ne-ID) {ne-ID};
    \node [above] at (nw-ID) {nw-ID};
    \node [below] at (se-ID) {se-ID};
    \node [below] at (sw-ID) {sw-ID};
    \fill (ne-ID) circle (\pradius);
    \fill (nw-ID) circle (\pradius);
    \fill (se-ID) circle (\pradius);
    \fill (sw-ID) circle (\pradius);
    \foreach\i in {1,...,3}
    {
      \symboln[\i]{n-\i-ID}[below]
      \fill (n-\i-ID) circle (\pradius);
      \symbolN[\i]{N-\i-ID}
      \fill (N-\i-ID) circle (\pradius);
    }
    \foreach\i in {1,...,4}
    {
      \symbols[\i]{s-\i-ID}[above]
      \fill (s-\i-ID) circle (\pradius);
      \symbolS[\i]{S-\i-ID}[below]
      \fill (S-\i-ID) circle (\pradius);
    }
    \draw[line width=0.2pt] (NW-ID) 
      to [bend left=60] node [fill=white, midway] {hlen} (NE-ID);
    \draw[line width=0.2pt] (NW-ID) 
      to [bend right=60] node [fill=white, midway] {vlen} (SW-ID);
    \draw [red, <->] (C-ID -| W-ID)
      -- node [midway, auto, font=\footnotesize] {0.5} (C-ID -| S-1-ID);
    \draw [red, <->] (C-ID -| S-4-ID)
      -- node [midway, auto, font=\footnotesize] {0.5} (C-ID -| E-ID);
    \qwire[arrowtype={loosely dotted}, dom={s-1-ID}, cod={n-1-ID}]
    \qwire[arrowtype={loosely dotted}, dom={s-4-ID}, cod={n-3-ID}]
    \node (O1prime) at ([shift={(0.25,0.25)}]O-1-ID){O-1-ID};
    \draw[->,red] (O1prime) to ([shift={(0.05,0.05)}]O-1-ID);
    \node (I1prime) at ([shift={(0.5,-0.5)}]I-1-ID){I-1-ID};
    \node (I2prime) at ([shift={(0.5,-0.5)}]I-2-ID) {I-2-ID};
    \draw[->,red](I1prime) to ([shift={(0.05,-0.05)}]I-1-ID);
    \draw[->,red](I2prime) to ([shift={(0.05,-0.05)}]I-2-ID);
  }
\end{CODEBOX}
The \verb|\qwire| \verb|arrowtype| key, as well as the \verb|dom| and \verb|cod| keys, are explained in section \ref{subsubsec:wirecustomization} on page \pageref{subsubsec:wirecustomization}.

\paragraph{Label (\texttt{\textbackslash symbol})}
\begin{verbatim}
  \symbolI[<number>]{<label>}[<options>]
\end{verbatim}
For example, \verb|\symbolI[2]{text}[below right, id=ID]| places the label "text" at the bottom right of the second input point (I-2-ID) of \verb|\q{\qbox[p=3, id=ID]}| (\(\q[scale=0.5]{\qbox[p=3, id=ID]}\)). 
When no number or options are specified, the default values \(1\), below, and \verb|id=<previous>| are applied, respectively. 
Other label display commands include:
\begin{verbatim}
  \symbolS[<number>]{<label>}[<options>]
\end{verbatim}
\begin{verbatim}
  \symbols[<number>]{<label>}[<options>]
\end{verbatim}
\begin{verbatim}
  \symbolO[<number>]{<label>}[<options>]
\end{verbatim}
\begin{verbatim}
  \symbolN[<number>]{<label>}[<options>]
\end{verbatim}
\begin{verbatim}
  \symboln[<number>]{<label>}[<options>]
\end{verbatim}
\verb|\symbolS| and \verb|\symbols| place the label \textless label\textgreater at points (S-\(i\)-ID) and (s-\(i\)-ID), respectively. 
The default number \(i\) is \(1\), and the default option is below. 
\verb|\symbolO|, \verb|\symbolN|, and \verb|\symboln| place the label \textless label\textgreater at points (O-\(i\)-ID), (N-\(i\)-ID), and (n-\(i\)-ID), respectively. 
The default number \(i\) is \(1\), and the default option is above.
\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{Ex:20250311}
  \q{
    \qbox[p=5, S={1,4,5}, id=ID]
    \symbolO{A}
    \symbolN[3]{B}
    \symboln[5]{C}[below left]
    \symbolS[2]{D}
    \symbols[3]{E}
    \symbolI[2]{F}
    \symbolI[3]{G}[below right]
  }
\end{codebox}
\begin{CODEBOX}{}{Ex:20250310}
  \q{
    \qbox[p=10,N={1,2,5,6,9,10}, id=ID]
    \foreach\i in {1,...,10}
    {
      \symbolI[\i]{\(x_{\i}\)}
    }
    \foreach\j in {1,...,6}
    {
      \symbolO[\j]{\(y_{\j}\)}
    }
  }
\end{CODEBOX}

\subsubsection{Repetition}
\label{subsub:forloop}
\begin{verbatim}
  \qloop[<number of repetitions>]{<command>}
\end{verbatim}
By using the \verb|\qloop| command, you can repeat a command the specified number of times:
\begin{CODEBOX}{}{Ex:20250305}
  \q{ \qloop[10]{\qbox} }
\end{CODEBOX}
The \verb|\qloop| command can also be used outside of \verb|\q|:
\begin{codebox}[center lower,listing side text,righthand width=5.5cm,bicolor,colbacklower=white]{}{Ex:202503220930}
  \qloop[30]{I AM BOB}
\end{codebox}

\subsubsection{Displaying Identification Numbers}
\label{subsub:show id}
Commands inside \verb|\q{...}| are automatically assigned identification numbers. 
If \texttt{show id=true} is specified, those identification numbers will be displayed.
\begin{CODEBOX}{}{Ex:20250303}
  \q{
    \qbox[show id={true}] \qbox[show id={true}] \qbox[show id={true}]\n
    \qbox[show id={true}] \qbox[show id={true}] \qbox[show id={true}]
  }
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:20250302}
  \q
  {
    \qloop[10]
    {
      \qloop[10]
      {
        \qbox[show id={true}]
      }\n
    }\n
  }
\end{CODEBOX}

\subsubsection{Color}
You can specify colors for the boxes:
\begin{itemize}
  \item \texttt{color}
    \iitem The color inside the box, for example, \texttt{color=green} will produce \q[scale=0.5]{\qbox[color={green}]}.
  \item \texttt{frame color}
    \iitem The color of the box's frame, for example, \texttt{frame color=cyan}will produce \q[scale=0.5]{\qbox[frame color={cyan}]}.
  \item \texttt{morphism color}
    \iitem The color of the morphisms inside the box, for example, \texttt{morphism color=red} will produce \q[scale=0.5]{\qbox[morphism color={red}, name={\(f\)}]}.
\end{itemize}
\begin{CODEBOX}{}{Ex:20250259}
    \q
    {
      \qbox
      [
        name={\(f\)},
        color=green,
        frame color=cyan,
        morphism color=red
      ]
    }
\end{CODEBOX}

\paragraph{\texttt{N}, \texttt{S}, Arithmetic Sequence}
\qworldname loads the \texttt{pgffor} package, so the shorthand notation using \verb|...| can be used for lists:
\begin{itemize}
  \item \(1,...,10\): An arithmetic sequence with a common difference of \(1\)
  \item \(1,3,...,11\): An arithmetic sequence based on the first two terms with a common difference
\end{itemize}
\begin{CODEBOX}{}{Ex:20250258}
   \q{
     \qbox[N={1,...,10}, S={1,3,...,11}]
   }
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:20250257}
  \q{
    \qbox[N={1,...,4,6,8,...,20}, S={1,...,20}, hlen=10]
  }
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:20250256}
  \q{
    \qbox[N={1,...,4,7,10,...,19,20,21,...,25}, S={1,...,25}, hlen=10]
  }
\end{CODEBOX}
\subsubsection{Relative Coordinates}
This is a command for specifying the position of elements relative to a given point. 
Note that \(x\) and \(y\) do not have to be integers; expressions evaluable by \verb|\fpeval|, 
such as \verb|2^1.5|, \verb|cos(pi)|, and \verb|sprt(2)|, are valid.
\begin{itemize}
  \item \texttt{\textbackslash qmv[\(x\),\(y\)]}
    \iitem Translates by (\(x\), \(y\)).
    \iitem The default is \(x=y=0\).
  \item \texttt{\textbackslash n[\(y\)]}
    \iitem Moves vertically by \(y\) (\(Y\mapsto Y-y\)), and sets the X coordinate to \(0\).
    \iitem The default is \(y=1\) , which behaves like a line break.
  \item \texttt{\textbackslash qspace[\(x\)]}
    \iitem Moves Horizontally by \(x\). 
    \iitem The default is \(x=1\), which behaves like the spacebar.
    \iitem This is equivalent to \texttt{\textbackslash qmv[\(x\),0]}.
  \item \texttt{\textbackslash qreset[\(x\),\(y\)]}
    \iitem Moves to the point (\(x\),\(y\)).
\end{itemize}
  \q[scale=2.35]{
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (I) at (qworldat);
    \qbox
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (II) at (qworldat);
    \n
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (III) at (qworldat);
    \qspace
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (IV) at (qworldat);
    \qspace[0.5]
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (V) at (qworldat);
    \n[2]
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (VI) at (qworldat);
    \qmv[-2,-1]
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (VII) at (qworldat);
    \n
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (VIII) at (qworldat);
    \qspace[-3]
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (IX) at (qworldat);
    \qreset
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (X) at (qworldat);
    \qreset[-2,1]
      \fill[blue] (qworldat) circle (1pt);
      \coordinate (XI) at (qworldat); 
    \qbball
    \qwireup[dom={I}, cod={II},
             label={Auto-update}, label side={below},
             label at={midway}, color=cyan]
    \qwireup[dom={II},cod={III},
             label={\texttt{\textbackslash n}},
             label side={below}, color=cyan]
    \qwireup[dom={III},cod={IV},
             label={\texttt{\textbackslash qspace}},
             label side={below}, color=cyan]
    \qwireup[dom={IV},cod={V},
             label={\texttt{\textbackslash qspace[0.5]}},
             label at={at end}, label side={above right}, color=cyan]
    \qwireup[dom={V},cod={VI},
             label={\texttt{\textbackslash n[2]}},color=cyan]
    \qwireup[dom={VI},cod={VII},
             label={\texttt{\textbackslash qmv[-2,-1]}},color=cyan]
    \qwireup[dom={VII},cod={VIII},
             label={\texttt{\textbackslash n}},color=cyan]
    \qwireup[dom={VIII},cod={IX},
             label={\texttt{\textbackslash qspace[-3]}}, 
             label side={below},color=cyan]
    \qwireup[dom={IX},cod={X},
             label={\texttt{\textbackslash qreset}},color=cyan]
    \qwireup[dom={X},cod={XI},
             label={\texttt{\textbackslash qreset[-2,1]}},color=cyan]
    \draw[help lines] (-4,-6) grid (2,2);
    }

\subsubsection{Absolute Coordinates}
By using the \texttt{at} key, positions can be specified with absolute coordinates. 
\verb|\q{\qbox[at={2,3}]}| is equivalent to \verb|\q{\qreset[2,3]\qbox}|.
\begin{CODEBOX}{Absolute Coordinates}{Ex:20250254}
  \q{
    \coordinate (a) at (0,{\fpeval{2*sqrt(3)}});
    \qbox[at=a]
    \qbox[at={-2,0}]
    \qbox[at={2,0}]
    \fill[red] (a) circle (2pt);
    \fill[red] (-2,0) circle (2pt);
    \fill[red] (2,0) circle (2pt);
    \node[below left] at (a) {a};
    \node[below left] at (-2,0) {(-2,0)};
    \node[below left] at (2,0) {(2,0)};
  }
\end{CODEBOX}
The \TeX\ language is Turing complete\footnote{For example, the ability to simulate a Turing machine is demonstrated in the example from LiteratePrograms\cite{literateprograms}. Additionally, an article on Overleaf introduces a method to compute Fibonacci numbers using \TeX, illustrating the  practical utility of its Turing completeness \cite{overleaf}}. 
In other words, every algorithm that exists in the world can be expressed in \TeX. 
Phisical simulations (such as weather forecasting or chemical reaction prediction), 
economic simulations (such as investment strategies), 
and even artificial intelligence learning algorithms (such as image recognition or natural language processing)------\par
all of these can be implemented in \TeX.\par
However, how many people would actually want to do that? 
I for one, wouldn't want to write even a sorting algorithm in \TeX. 
That's like tring to create Super Mario in spreadsheet.\par
However, there is a twist.\par
I had a ``revelation''\footnote{Original source: On January 20,  2011, an algorithm called "Sleep Sort" was posted on the anonymous message board 4chan \cite{geniussorting, gfxhatena}. This algorithm uses a \texttt{Bash} script to execute each input value as a thread asynchronously, sorting the list by the timing of each thread’s completion (the specified "sleep" time).}.
And with the \texttt{at} key, I created a sorting algorithm.
\begin{codebox}{}{Ex:genius}
  \newcommand{\AtSort}[1][1]{
    \q
    {
      \foreach \i in {#1}
      {
        \qbox[name={\i}, at={0, -\i}]\n
      }
    }
  }
  \AtSort[4,1,3,-1,6,2]
\end{codebox}
It works. Indeed, it works.\par
But there is one problem.
\textbf{If the list contains elements with large absolute values, the output will overflow the page}.
\subsubsection{Wire Customization}
\label{subsubsec:wirecustomization}
Among the keys of the box \(\q[scale=0.5]{\qbox}\) introduced in section \ref{subsubsec:boxcustomization}, \texttt{id} and \texttt{vlen} are also valid for wires. 
The basic keys specific to wires are as follows:
\begin{itemize}
  \item \texttt{dom}: input point. 
  \item \texttt{cod}: output point.
      \iitem Default value is the position obtained by moving \texttt{dom} \(1\) unit vertically to the north.
  \item \texttt{label}: Label for the wire. 
  \item \texttt{label at}: Position of the label on the wire.
      \iitem The default is midway.
  \item \texttt{label side}: Relationship between the label and the wire.
      \iitem The default is right.
\end{itemize}
\begin{codebox}{}{ex:202503260951}
  \q{
    \qbox[n=3,hlen=1.5]
    \qbox[at={1,2}, s=2, hlen=1.5]
    \qbox[at={-1,4}, s=2, hlen=1.5]
    \qwire[dom={N-1-1}, cod={S-1-3}]
    \qwire[dom={N-2-1}, cod={S-1-2}]
    \qwire[dom={N-3-1}, cod={S-2-2}]
    \qwire[dom={N-1-2}, cod={S-2-3}]
  }
\end{codebox}
The bounding box of the wire \q[scale=0.6]{\qwire} is the same as that of \q[scale=0.5]{\qbox}:
\begin{codebox}{}{ex:202503220926}
  \q
  {
    \qwire\qbox\qwire\n
    \qbox\qwire\qbox
    \qbball
  }
\end{codebox}
The bounding box of the wire matches that of a box with \texttt{dom} as the input point and \texttt{cod} as the output point:
\begin{itemize}
  \item \(\q[scale=0.5]{\qwire}\) and \(\q[scale=0.5]{\qbox}\)
  \item \(\q[scale=0.5]{\qwire[dom={0,0},cod={1,1}]}\) and \(\q[scale=0.5]{\qbox[p=2,S={1},N={2}]}\)
\end{itemize}

\begin{CODEBOX}{}{Ex:20250309}
  \q[scale=3]{
    \coordinate (A) at (0,0);
    \coordinate (B) at (2,3);
    \qwire[dom=A, cod={1,1}, label={wire1}, label side={left}]
    \qwire[dom={1,1}, cod=B, label={wire2}, label at={near end}]
    \node[fill=red, circle] at (A) {A};
    \node[fill=green, circle] at (B) {B};
    \node[fill=yellow, circle] at (1,1) {(1,1)};
    \qbball
  }
\end{CODEBOX}

\begin{CODEBOX}{}{Ex:20250301}
  \q{
    \qloop[5]{
      \qloop[10]{
        \qbox[show id={true}]
      }\n
    }\n
    \qspace[3]\qbox[s=2,show id={true},id={ego1}]\n\n
    \qspace[6]\qbox[n=2,show id={true},id={ego2}]\n\n
    \qloop[5]{
      \qloop[10]{
        \qbox[show id={true}]
      }\n
    }
    \qwire[dom={O-1-55},cod={I-1-51}]
    \qwire[dom={O-1-60},cod={I-1-52}]
    \qwire[dom={O-1-51},cod={I-1-45}]
    \qwire[dom={O-1-52},cod={I-2-51}]
    \qwire[dom={O-2-52},cod={I-1-48}]
  }
\end{CODEBOX}

\paragraph{arrowtype}
The wire style is specified using the \texttt{arrowtype} key.
\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{wirearrowtype}
  \q{
    \qwire[arrowtype=dotted]
    \qwire[arrowtype=dashed]
    \qwire[arrowtype={dash dot}]
    \qwire[arrowtype={dash dot dot}]
    \qwire[arrowtype={densely dotted}]
    \qwire[arrowtype={loosely dotted}]
  }
\end{codebox}

\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{boxarrowtype}
  \q{
    \qbox[dom arrowtype={dotted}]
    \qbox[cod arrowtype={dotted}]
    \qbox[arrowtype={dotted}]
  }
\end{codebox}

\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{}{spiderarrowtype}
  \q{
    \qspider[dom arrowtype={dotted}]
    \qspider[cod arrowtype={dotted}]
    \qspider[arrowtype={dotted}]
  }
\end{codebox}

\subsubsection{Canvas}
\begin{verbatim}
  \q[option]
  {
    command 1
    command 2
    ...
  }
\end{verbatim}
The entire diagram can be transformed useing canvas options.
\begin{codebox}{}{Ex:20250253}
  \q[scale=2,rotate=30]{\qbox}
\end{codebox}
It is also possible to \textbf{slant} the canvas.
\begin{CODEBOX}{}{Ex:20250252}
  \def\anglerot{-55}
  \tikzset
  {
    my slant style/.style={
      yslant=-cot(\anglerot), 
      xscale=sin(-\anglerot)
      }
  }
  \q[my slant style]
  {
    \qcaprev\qcap\n
    \qwire\qbraidinv\qwiredown\n
    \qwiredown\qbraidinv\qwire\n
    \qcup\qcuprev
    \qBBall
  }
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:20250251}
  \def\anglerot{-60}
  \tikzset
  {
    my slant style/.style={
      yslant=-cot(\anglerot), 
      xscale=sin(-\anglerot)
      }
  }
  \[\q[my slant style]
  {
    \qbraid\qwire\n
    \qwire\qbraid\n
    \qbraid\qwire
  }
  =\q[my slant style]
  {
    \qbraid\qwire\n
    \qwire\qwire\qwire\n
    \qbraid[num R=2]
    \qbb[red][1]
    \qbb[cyan][6]
  }
  =\q[my slant style]
  {
    \qbraid[ num R=2]\n
    \qwire\qwire\qwire\n
    \qwire\qbraid
    \qbb[red][6]
    \qbb[cyan][1]
  }
  =\q[my slant style]
  {
    \qwire\qbraid\n
    \qbraid\qwire\n
    \qwire\qbraid
  }\]
\end{CODEBOX}

\section{Monoidal Categories and \qworldname}
In this section, we explore how to typeset graphical calculus using the \qworldname package, examining its different applications and practical usage.\par
While \qworldname can handle diagrams independently, it is often beneficial to combine it with packages like \texttt{amsmath}, \texttt{amssymb}, and \texttt{mathtools} for more flexible mathematical expressions. 
This section demonstrates how to typeset actual graphical calculus in \TeX\ while introducing the functionalities of \qworldname.\par
To reproduce the examples in this section, please ensure that the following packages are loaded:
\begin{verbatim}
  \usepackage{amsmath, amssymb, mathtools}
  \usepackage{qworld}
\end{verbatim}

\begin{codebox}{Domain}{ex:dom2}
  \[
    \operatorname{dom}\left(
      \q{
        \qbox[name={\(f\)}]
        \symbolI{\(x\)}
        \symbolO{\(y\)}
      }
    \right)=\q{\qwire[label={\(x\)}]}
  \]
\end{codebox}
\begin{codebox}{Codomain}{ex:cod2}
  \[
    \operatorname{cod}\left(
      \q{
        \qbox[name={\(f\)}]
        \symbolI{\(x\)}
        \symbolO{\(y\)}
      }
    \right)=\q{\qwire[label={\(y\)}]}
  \]
\end{codebox}

\begin{codebox}{(Vertical) Compositon}{def:composite}
  \[
    \q{
      \qbox[name={\(f\)}]\qcirc\qbox[name={\(g\)}]
    }=\q{\qbox[name={\(f\circ g\)}]}
  \]
\end{codebox}
\begin{CODEBOX}{Associativity}{Ex:20250250}
  \[
    \forall\q{\qbox[name={\(h\)}] \symbolI{\(z\)} \symbolO{\(w\)}},
           \q{\qbox[name={\(g\)}] \symbolI{\(y\)} \symbolO{\(z\)}},
           \q{\qbox[name={\(f\)}] \symbolI{\(x\)} \symbolO{\(y\)}}:
    \q{
        \qbox[name={\(h\)}]\qcirc\qbox[name={\(g\)}]\qcirc\qbox[name={\(f\)}]
        \qbb[2,3]
    }
    =
    \q{
        \qbox[name={\(h\)}]\qcirc\qbox[name={\(g\)}]\qcirc\qbox[name={\(f\)}]
        \qbb[1,2]
    }
  \]
\end{CODEBOX}
\begin{CODEBOX}{Identity Law}{IdentityLaw}
  \begin{equation}
    \label{law:identity}
    \forall\q
    {
      \qbox[name={\(f\)}]
      \symbolS{\(x\)}
      \symbolN{\(y\)}
    }\colon
    \q{
      \qwire[label={\(y\)}]\n
      \qbox[name={\(f\)}]
    }=\q{
      \qbox[name={\(f\)}]
    }=\q{
      \qbox[name={\(f\)}]\n
      \qwire[label={\(x\)}]
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{Tensor Product, Horizontal (Parallel) Compositon}{monoidalproduct}
  \[
    \q
    {
      \qbox[name={\(f\)}] \qbox[name={\(g\)}]
      \symbolO{\(Y_1\)}[id=1] \symbolO{\(Y_2\)}
      \symbolI{\(X_1\)}[id=1] \symbolI{\(X_2\)}
    }
    =\q
    {
      \qbox[name={\(f\otimes g\)}, p=2]
      \symbolO{\(Y_1\)} \symbolO[2]{\(Y_2\)}
      \symbolI{\(X_1\)} \symbolI[2]{\(X_2\)}
    }
    =\q
    {
      \qbox[name={\(f\otimes g\)}]
      \symbolO{\(Y_1\otimes Y_2\)}
      \symbolI{\(X_1\otimes X_2\)}
    }
  \]
\end{CODEBOX}

\begin{CODEBOX}{Interchange Law (Covariant Functoriality of \(\bigotimes\))}{InterchangeLaw}
  \begin{equation}
    \label{law:interchange}
    \q
    {
      \qbox[name={\(f_2\)}]\qbox[name={\(g_2\)}]\n
      \qbox[name={\(f_1\)}]\qbox[name={\(g_1\)}]
      \qbb[1,2]
      \qbb[3,4]
    }
    =\q
    {
      \qbox[name={\(f_2\)}]\qbox[name={\(g_2\)}]\n
      \qbox[name={\(f_1\)}]\qbox[name={\(g_1\)}]
      \qbb[2,4]
      \qbb[1,3]
    }
  \end{equation}
\end{CODEBOX}

\begin{CODEBOX}{Unit Object}{Ex:20250244}
  \begin{gather}
    \q{ \qwire[arrowtype=dotted]}
    =\q{ \qunitob \qbball }\\
    \q{ \qunitob \qbox[name={\(f\)}] \qbball }
    =\q{ \qbox[name={\(f\)}] }
    =\q{ \qbox[name={\(f\)}] \qunitob \qbball }\label{cond:unitob}
  \end{gather}
\end{CODEBOX}
\begin{CODEBOX}{}{Ex:20250243}
  \[
    \q{\qunitob\qbball}
    =\q{\qloop[2]{\qunitob}\qbball}
    =\q{\qloop[3]{\qunitob}\qbball}
    =\cdots
  \]
\end{CODEBOX}

\subsection{Special Boxes}

\begin{itemize}
  \item \texttt{\textbackslash qstate}: \(\q[scale=0.5]{\qstate}\) (Zero Input).
  \item \texttt{\textbackslash qeffect}: \(\q[scale=0.5]{\qeffect}\) (Zero Output).
  \item \texttt{\textbackslash qscalar}: \(\q[scale=0.5]{\qscalar}\) (Zero Input, Zero Output).
  \item \texttt{\textbackslash qasym}: \(\q[scale=0.5]{\qasym}\) (Asymmetric Box). 
  \item \texttt{\textbackslash qtrans}: \(\q[scale=0.5]{\qtrans}\) (Transpose Box). Section \ref{subsub:transpose} on page \pageref{subsub:transpose}.
  \item \texttt{\textbackslash qadj}: \(\q[scale=0.5]{\qadj}\) (Adjoint Box). Section \ref{subsub:adjoint} on page \pageref{subsub:adjoint}.
  \item \texttt{\textbackslash qconj}: \(\q[scale=0.5]{\qconj}\) (Conjugate Box). Section \ref{subsub:conj} on page \pageref{subsub:conj}.
\end{itemize}
\subsubsection{Zero Input}
\label{subsub:zeroinput}
\begin{codebox}{}{def:state}
  \q{\qstate}
\end{codebox}
\subsubsection{Zero Output}
\label{subsub:zerooutput}
\begin{codebox}{}{def:effect}
  \q{\qeffect}
\end{codebox}
\subsubsection{Zero Input, Zero Output}
\label{subsub:zeroinputoutput}
\begin{codebox}{}{def:scalar}
  \q{\qscalar}
\end{codebox}
\paragraph{\(\q[scale=0.4]{\qeffect\qstate\qwire[dom={O-1-2}, cod={1,2}]\qwire[dom={1,-1}, cod={I-1-1}]}=\q[scale=0.4]{\qwire[vlen=0.5]\n\qstate\n\qeffect\n[0.5]\qwire[vlen=0.5]}=\q[scale=0.4]{\qstate\qeffect\qwire[dom={O-1-1}, cod={1,2}]\qwire[dom={1,-1}, cod={I-1-2}]}\)}
\begin{CODEBOX}{}{coherence:unitor}
  \[
    \q{
      \qeffect\qstate
      \qwire[dom={O-1-2}, cod={1,2}]
      \qwire[dom={1,-1}, cod={I-1-1}]
    }=\q{
        \qwire[arrowtype=dotted]\qwire\n
        \qeffect\qstate\n
        \qwire\qwire[arrowtype=dotted]
    }\stackrel{\text{(\ref{law:interchange}, \ref{law:identity})}}{=}\q{
        \qwire[arrowtype=dotted]\qstate\n
        \qeffect\qwire[arrowtype=dotted]
    }\stackrel{\text{(\ref{law:interchange}, \ref{cond:unitob})}}{=}\q{\qstate\n\qeffect}
  \]
\end{CODEBOX}
\begin{CODEBOX}{Matrix Representation}{matrixrepre}
  \begin{align*}
    \q{\qbox[name={\(f\)}]}
    &=\sum\limits_{i,j}
    \left(
      \q{
        \qeffect[name={\(w_j^{\dagger}\)}]\n
        \qbox[name={\(f\)}]\n
        \qstate[name={\(v_i\)}]\n
      }\q{
        \qstate[name={\(w_j\)}]\n
        \qeffect[name={\(v_i^{\dagger}\)}]
      }
    \right)
    =\sum\limits_{i,j}\left(
      \q{
        \qscalar[name={\(w_j^{\dagger}\circ f\circ v_i\)}]
      }
      \q{
        \qstate[name={\(w_j\)}]\n
        \qeffect[name={\(v_i^{\dagger}\)}]
      }
    \right)\\
    &=\begin{pmatrix}
      \q{\qscalar[name={\(w_1^{\dagger}\circ f\circ v_1\)}]}&&\cdots&&\q{\qscalar[name={\(w_1^{\dagger}\circ f\circ v_{m}\)}]}\\
      &\ddots&&&\\        
      \vdots& &\q{\qscalar[name={\(w_j^{\dagger}\circ f\circ v_i\)}]}& &\vdots\\
      &&&\ddots&\\
      \q{\qscalar[name={\(w_n^{\dagger}\circ f\circ v_1\)}]}&&\cdots&&\q{\qscalar[name={\(w_n^{\dagger}\circ f\circ v_m\)}]}
    \end{pmatrix}
  \end{align*}
\end{CODEBOX}

\subsection{Monoid Object}
\label{sub:monoid}
\begin{itemize}
  \item \texttt{\textbackslash qmul}: \(\q[scale=0.5]{\qmul}\)
    \iitem \texttt{hlen=2}: \(\q[scale=0.5]{\qmul[hlen=2]}\)
  \item \texttt{\textbackslash qcomul}: \(\q[scale=0.5]{\qcomul}\)
    \iitem \texttt{hlen=2}: \(\q[scale=0.5]{\qcomul[hlen=2]}\)
  \item \texttt{\textbackslash qunit}: \(\q[scale=0.5]{\qunit}\)
  \item \texttt{\textbackslash qcounit}: \(\q[scale=0.5]{\qcounit}\)
  \item \texttt{\textbackslash qspider}: \(\q[scale=0.5]{\qspider}\)
\end{itemize}

\begin{CODEBOX}{Associativity}{AssociateLaw}
  \begin{equation}
    \label{law:associate}
    \q{
        \qspace[0.5]\qmul[hlen=2]\n
        \qmul[hlen=2]\qspace[-0.5]\qwire
    }=\q{
        \qmul[hlen=2]\n
        \qwire\qspace[-0.5]\qmul[hlen=2]
    }
  \end{equation}
\end{CODEBOX}
  \begin{CODEBOX}{Unitality}{UnitLaw}
  \begin{equation}
    \label{law:unit}
    \q{
        \qmul[hlen=2]\n
        \qwire\qunit
    }=\q{\qwire[vlen=2]}
    =\q
    {
        \qmul[hlen=2]\n
        \qunit\qwire
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{Coassociativity}{CoassociateLaw}
  \begin{equation}
    \label{law:coassociate}
    \q{
        \qcomul[hlen=2]\qspace[-0.5]\qwire\n
        \qspace[0.5]\qcomul[hlen=2]
        }
    =\q{
        \qwire\qspace[-0.5]\qcomul[hlen=2]\n
        \qcomul[hlen=2]
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{Counitality}{CounitLaw}
  \begin{equation}
    \label{law:counit}
    \q{
        \qcounit\qwire\n
        \qcomul[hlen=2]
        }
    =\q{\qwire[vlen=2]}
    =\q{
        \qwire\qcounit\n
        \qcomul[hlen=2]
    }
  \end{equation}
\end{CODEBOX}

\subsubsection{Frobenius Law}
\begin{FCODEBOX}{Frobenius Law}{FrobeniusLaw}
    \[
      \q{
        \qwire\qmul[color=black]\n
        \qcomul\qwire
      }=\q{
        \qcomul\n
        \qmul[color=black]
      }=\q{
        \qmul[color=black]\qwire\n
        \qwire\qcomul
      }
    \]
  \end{FCODEBOX}
  Although it is mentioned as a ``Failure Example'', in reality, the Frobenius law is accurately described. 
  Rather, since the spacing between all the wires is maintained as integer values, adjustment during vertical composition becomes easier, and in some cases, no adjustment may be necessary. 
  This is merely a matter of preference. 
  The default drawing results of \verb|\qmul| and \verb|\qcomul|, which are \q[scale=0.5]{\qmul} and \q[scale=0.5]{\qcomul}, are remnants of the default drawing results of \verb|\qbox[s=2]| and \verb|\qbox[n=2]|, which are \q[scale=0.5]{\qbox[s=2]} and \q[scale=0.5]{\qbox[n=2]}. 
  For adjustments in such cases, the adjustment key \verb|hlen| is available:
  \begin{CODEBOX}{Frobenius Law}{FrobeniusLaw2}
    \[
      \q{
        \qwire\qmul[hlen=2,color=black]\n
        \qcomul[hlen=2]\qwire
      }=\q{
        \qcomul[hlen=2]\n
        \qmul[hlen=2,color=black]
      }=\q{
        \qmul[hlen=2,color=black]\qwire\n
        \qwire\qcomul[hlen=2]
      }
    \]
  \end{CODEBOX}
  The command \verb|\qspider| is the same as \verb|\qbox|, except that the nodes are circles rather than boxes.
  \begin{codebox}{}{spider202503240521}
    \[\q{\qspider}\]
    \[\q{\qspider[n=0]}\]
    \[\q{\qspider[n=0,s=4]}\]
    \[\q{\qspider[n=2,s=4]}\]
    \[\q{\qspider[N={1,4},s=4]}\]
    \[\q{\qspider[N={2,3},s=4]}\]
    \[\q{\qspider[p=3,N={2},S={1,3}]}\]
    \[\q{\qspider[p=3,N={2},S={1,3},hlen=2]}\]
    \[\q{\qspider[n=1,s=2,hlen=2]}\]
  \end{codebox}

  \begin{CODEBOX}{}{spider202503270738}
    \[
      \q{
        \qspider[n=2, s=4, hlen=4]\qwire\qwire\n
        \qwire\qwire\qspider[n=4, s=2, hlen=4]
      }
      =\q{\qspider[p=4]}\]
  \end{CODEBOX}

\subsection{Braiding}
\label{sub:braidedcategory}
\begin{itemize}
  \item \texttt{\textbackslash qbraid}: \(\q[scale=0.5]{\qbraid}\)
  \item \texttt{\textbackslash qbraidinv}: \(\q[scale=0.5]{\qbraidinv}\)
  \item \texttt{\textbackslash qsym}: \(\q[scale=0.5]{\qsym}\)
\end{itemize}

\paragraph{\texttt{num L} and \texttt{num R}}

For the commands \verb|\qbraid|, \verb|\qbraidinv|, and \verb|\qsym|, \texttt{num L} specifies the number of wires on the left side, and \texttt{num R} specifies the number of wires on the right side. 
For example, specifies \texttt{num L=3} and \texttt{num R=2} will result in the diagram \q{\qbraid[num L=3, num R=2]}. 
The default value for both is \(1\).

\begin{CODEBOX}{Hexagon Equations}{hexagon}
  \begin{equation}
    \label{eq:hexagon}
    \q
    {
      \qbraid[num R=2,,hlen=2,vlen=2]
    }
    =
    \q
    {
      \qwire\qbraid\n
      \qbraid\qwire
    }
    \qquad
    \q
    {
      \qbraid[num L=2,,hlen=2,vlen=2]
    }
    =
    \q
    {
      \qbraid\qwire\n
      \qwire\qbraid
    }
  \end{equation}
\end{CODEBOX}
\paragraph{\({\q[scale=0.5]{\qbraid}}^{-1}=\q[scale=0.5]{\qbraidinv}\)}
\begin{CODEBOX}{}{braidisom2}
  \begin{equation}
    \label{eq:inverse:braid}
    \q
    {
      \qbraidinv\n
      \qbraid
    }
    =
    \q
    {
      \qwire[vlen=2]\qwire[vlen=2]
    }
    \qquad
    \q
    {
      \qbraid\n
      \qbraidinv
    }
    =
    \q
    {
      \qwire[vlen=2]\qwire[vlen=2]
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{Naturality of the Braid (Being a Natural Transformation)}{braidnatural}
  \begin{equation}
    \label{cond:naturality:braid}
    \q
    {
      \qbraid\n
      \qbox[name={\(f\)}]\qbox[name={\(g\)}]
    }
    =
    \q
    {
      \qbox[name={\(g\)}]\qbox[name={\(f\)}]\n
      \qbraid
    }
    \qquad
    \q
    {
      \qbraidinv\n
      \qbox[name={\(f\)}]\qbox[name={\(g\)}]
    }
    =
    \q
    {
      \qbox[name={\(g\)}]\qbox[name={\(f\)}]\n
      \qbraidinv
    }
  \end{equation}
\end{CODEBOX}

For the commands \verb|\qbraid|, \verb|\qbraidinv|, and \verb|\qasym|, specifying \texttt{num R=0} results in a dashed line for the right wire, as shown in \q[scale=0.65]{\qbraid[num R=0]}. 
Similarly, specifying \texttt{num L=0} results in a dashed line for the left wire, as shown in \q[scale=0.65]{\qbraid[num L=0]}. 
This is due to representing the unit object as an empty diagrams, i.e., a diagram with \(0\) wires.
\begin{CODEBOX}{}{stateeffect3dimbraid}
  \begin{gather}
    \q{
      \qwire\qstate\n
      \qwire
    }
    =\q{
      \qwire\qstate\n
      \qbraid[num L=0]
    }\stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q{
      \qbraid\n
      \qstate\qwire
    }\label{iso:u:state}\\
    \q{
      \qunitob\qwire\n
      \qeffect\qwire
    }
    =\q{
      \qbraid[num L=0]\n
      \qeffect\qwire
    }\stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q{
      \qwire\qeffect\n
      \qbraid
    }\label{iso:u:effect}
  \end{gather}
\end{CODEBOX}
\begin{CODEBOX}{}{iso:spatial:scalar}
  \begin{equation}
    \label{iso:spatial}
    \q{\qscalar\qmv[0,-1]\qwire[vlen=3]}
    =\q{\qbraid[num L=0]\n\qscalar\qmv[0,-1]\qwire[vlen=2]}
    \stackrel{\text{(\ref{cond:naturality:braid})}}{=}
    \q{\qwire[vlen=2]\qscalar\n\qbraid[num L=0]}
    =\q{\qscalar\qmv[-2,-1]\qwire[vlen=3]}
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{}{iso:spatial:state.effect}
  \[
    \q{\qscalar\qmv[0,-1]\qwire[vlen=3]}
    =\q{\qeffect\n\qstate\qmv[0,-0.5]\qwire[vlen=3]}
    \stackrel{\text{(\ref{iso:u:effect})}}{=}
    \q{\qwire\qeffect\n\qbraid\n\qstate\qwire}
    \stackrel{\text{(\ref{iso:u:state})}}{=}
    \q{\qeffect\n\qstate\qmv[-2,-0.5]\qwire[vlen=3]}
    =\q{\qscalar\qmv[-2,-1]\qwire[vlen=3]}
  \]
\end{CODEBOX}
\paragraph{\(\q[scale=0.5]{\qbraid\qwire\n\qwire\qstate[n=2]}=\q[scale=0.5]{\qwire\qbraidinv\n\qstate[n=2]\qwire}\)}
\begin{CODEBOX}{}{dashedbraid}
  \begin{align}
    \q
    {
      \qbraid\qwire\n
      \qwire\qstate[n=2]
    }
    &=\q
    {
      \qbraid\qwire\n
      \qwire\qstate[n=2]\n\n
      \qbraidinv[num L=0,vlen=2,hlen=2.5]
    }
    \stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q
    {
      \qbraid\qwire\n\n
      \qbraidinv[num L=2,vlen=2]\n
      \qstate[n=2]\qwire\n
      \qspace[0.5]\qwire[arrowtype={densely dotted}]\qspace[0.5]\qwire
    }\\
    &=\q
    {
      \qbraid\qwire\n\n
      \qbraidinv[num L=2,vlen=2]\n
      \qstate[n=2]\qwire\n
      \qspace[2]\qwire
      \qbb[green][3]
    }\stackrel{\text{(\ref{eq:hexagon})}}{=}\q
    {
      \qbraid\qwire\n
      \qbraidinv\qwire\n
      \qwire\qbraidinv\n
      \qstate[n=2]\qwire\n
      \qspace[2]\qwire
      \qbb[green][3,...,6]
    }\\
    &=\q
    {
      \qbraid\qwire\n
      \qbraidinv\qwire\n
      \qwire\qbraidinv\n
      \qstate[n=2]\qwire\n
      \qspace[2]\qwire
      \qbb[orange][1,3]
    }
    \stackrel{\text{(\ref{eq:inverse:braid})}}{=}\q
    {
      \qloop[2]{\qloop[3]{\qwire}\n}
      \qwire\qbraidinv\n
      \qstate[n=2]\qwire\n
      \qspace[2]\qwire
      \qbb[orange][1,2,4,5]
    }
  \end{align}
\end{CODEBOX}

\begin{CODEBOX}{Yang-Baxer Equation}{YangBaxer}
  \[
    \q
    {
      \qbraid\qwire\n
      \qwire\qbraid\n
      \qbraid\qwire
    }=\q
    {
      \qwire\qbraid\n
      \qbraid\qwire\n
      \qwire\qbraid
    }
  \]
\end{CODEBOX}

\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{Commutativity}{def:cmt}
  \begin{equation}
    \label{cond:cmt}
    \q{\qmul[hlen=2]}=\q{\qmul[hlen=2]\n\qbraid}
  \end{equation}
\end{codebox}
\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{Cocommutativity}{def:ccmt}
  \begin{equation}
    \label{cond:ccmt}
    \q{\qcomul[hlen=2]}=\q{\qbraid\n\qcomul[hlen=2]}
  \end{equation}
\end{codebox}
\subsubsection{Bialgebra}
\begin{CODEBOX}{Bialgebra Law}{law:bialgebra}
  \begin{gather}
    \q{\qcomul[hlen=2]\qcirc\qmul[hlen=2, color=black]}
    =\q{
      \qmul[hlen=2, color=black]\qmul[hlen=2, color=black]\n
      \qwire\qbraid\qwire\n\qcomul[hlen=2]\qcomul[hlen=2]
      }\\
    \q{\qspace[0.5]\qcounit\qcirc\qmul[hlen=2, color=black]}
    =\q{\qcounit\qcounit}\\
    \q{\qcomul[hlen=2]\qcirc\qspace[0.5]\qunit[color=black]}
    =\q{\qunit[color=black]\qunit[color=black]}\\
    \q{\qcounit\n\qunit[color=black]}
    =\q{\qunitob}
  \end{gather}
\end{CODEBOX}
\subsubsection{Hopf Algebra}
\begin{CODEBOX}{Antipode and Hopf Algebra}{law:hopf}
  \begin{equation}
    \q{
      \qmul[hlen=2, color=black]\n
      \qwire\qbox[name={\(s\)}]\n
      \qcomul[hlen=2]
    }
    =\q{\qunit[color=black]\qcirc\qcounit}
    =\q{
      \qmul[hlen=2, color=black]\n
      \qbox[name={\(s\)}]\qwire\n
      \qcomul[hlen=2]
    }
  \end{equation}
\end{CODEBOX}
\subsubsection{Balanced Structure}
\label{subsub:balancedcategory}
\begin{CODEBOX}{Twist}{def:twist}
  \begin{gather}
    \q{
      \qbox[name={\(\theta_{X\otimes Y}\)}, p=2]
      \symbolI{\(X\)}\symbolI[2]{\(Y\)}
      \symbolO{\(X\)}\symbolO[2]{\(Y\)}
    }
    =\q{
      \qbox[name={\(\theta_X\)}]\qbox[name={\(\theta_Y\)}]\n
      \qbraid\n\qbraid
    }\label{cond:twist}\\
    \q{\qbox[name={\(\theta_I\)}]}=\q{\qunitob}\label{cond:i:twist}\\
    \forall\q{\qbox[name={\(f\)}]}\colon
    \q{
      \qbox[name={\(\theta_{\operatorname{cod}(f)}\)}, hlen=1.5]\n
      \qbox[name={\(f\)}, hlen=1.5]
    }=\q{
      \qbox[name={\(f\)}, hlen=1.5]\n
      \qbox[name={\(\theta_{\operatorname{dom}(f)}\)}, hlen=1.5]
    }\label{cond:naturality:twist}
  \end{gather}
\end{CODEBOX}
\subsubsection{Trivial Balanced Structure, Symmetric Monoidal Category}
\label{subsub:symmetry}
\begin{codebox}[center lower,listing side text,righthand width=5cm,bicolor,colbacklower=white]{Symmetry}{defeq:sym}
  \begin{equation}
    \label{cond:symmetry}
    \q
    {
      \qbraid\n
      \qbraid
    }
    =\q{\qloop[2]{\qwire[vlen=2]}}
  \end{equation}
\end{codebox}
\begin{codebox}{}{wowsym}
  \[\q{\qbraid}=\q{\qbraidinv}\]
\end{codebox}
\begin{codebox}{Symmetry}{def:sym}
  \q{\qsym}
\end{codebox}

\subsection{Duality}
\label{subsub:duality}
\begin{itemize}
  \item \texttt{\textbackslash qcap}: \(\q[scale=0.6]{\qcap}\)
  \item \texttt{\textbackslash qcup}: \(\q[scale=0.6]{\qcup}\)
  \item \texttt{\textbackslash qcaprev}: \(\q[scale=0.6]{\qcaprev}\)
  \item \texttt{\textbackslash qcuprev}: \(\q[scale=0.6]{\qcuprev}\)
\end{itemize}

\begin{CODEBOX}{Snake Equations}{Snake}
  \begin{equation}
    \label{eq:snake}
    \q{
      \qcap\qwireup\n
      \qwireup\qcup
    }
    =\q{
      \qwireup[vlen=2]
    }
    \qquad\land\qquad
    \q{
      \qwiredown\qcap\n
      \qcup\qwiredown
    }
    =\q{
      \qwiredown[vlen=2]
    }
  \end{equation}        
\end{CODEBOX}

\subsubsection{Transpose Box}
\label{subsub:transpose}
\begin{CODEBOX}{Transpose}{Transpose}
  \[
    \left(\q{\qwire\n\qasym[name={\(f\)}]\n\qwire}\right)^T
    =\q{
      \qwire\n
      \qtrans[name={\(f\)}]\n
      \qwire
    }\coloneq\q{
      \qwire\qcap\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qcup\qwire
    }
  \]
\end{CODEBOX}

\begin{CODEBOX}{}{ex:202504021826}
  \begin{equation}
    \label{eq:wirerev}
    \left(\q{\qwireup}\right)^T=\q{\qwiredown}
  \end{equation}
\end{CODEBOX}

\begin{CODEBOX}{Sliding}{Sliding}
  \begin{equation}
    \label{eq:sliding}
    \q
    {
      \qcap \n
      \qasym \qwire
    }
    =
    \q
    {
      \qcap \n
      \qwire \qtrans
    }
    \qquad
    \q
    {
      \qwire\qasym \n
      \qcup
    }
    =
    \q
    {
      \qtrans \qwire \n
      \qcup
    }
  \end{equation}
\end{CODEBOX}

\begin{CODEBOX}{}{MapStateDuality}
  \begin{equation}
    \begin{array}{rccc}
      \operatorname{NAME}\colon & \operatorname{Hom}(X,Y)
      & \to & \operatorname{Hom}(I,X^T\otimes Y)\\
      & \rotatebox{90}{\(\in\)} && \rotatebox{90}{\(\in\)}\\
      & \q{
        \qasym
        \symbolI{\(X\)}
        \symbolO{\(Y\)}
      } & \mapsto 
      & \q{
        \qwire[label={\(X^T\)}, label at={at end}, label side={above}] \qasym \n
        \qcup
        \symbolO{\(Y\)}[id=2]
      }
    \end{array}
  \end{equation}
\end{CODEBOX}

\begin{CODEBOX}{}{MapEffectDuality}
  \begin{equation}
    \begin{array}{rccc}
      \operatorname{CONAME}\colon & \operatorname{Hom}(X,Y) 
      & \to & \operatorname{Hom}(X\otimes Y^T,I)\\
      & \rotatebox{90}{\(\in\)}&&\rotatebox{90}{\(\in\)}\\
      & \q{
        \qasym
        \symbolI{\(X\)}
        \symbolO{\(Y\)}
      } & \mapsto 
      & \q{
        \qcap \n
        \qasym \qwire[label={\(Y^T\)}, label at={at start}, label side={below}]
        \symbolI{\(X\)}[id=2]
      }
    \end{array}
  \end{equation}
\end{CODEBOX}

\subsubsection{No Cloning Theorem}
\label{subsub:nocopy}
\begin{CODEBOX}{Uniform Copying}{def:copy}
  \begin{gather}
    \q{
      \qwire\qbraid\qwire\n
      \qcomul[hlen=2, name={\(\operatorname{copy}_X\)}]\qcomul[hlen=2, name={\(\operatorname{copy}_Y\)}]
      \symbolI{\(X\)}[id=4]\symbolI{\(Y\)}[id=5]
      \symbolO{\(X\)}[id=1]\symbolO{\(Y\)}[id=2]
      \symbolO[2]{\(X\)}[id=2]\symbolO{\(Y\)}[id=3]
    }=\q{
      \qcomul[hlen=3, vlen=2, name={\(\operatorname{copy}_{X\otimes Y}\)}]\symbolI{\(X\otimes Y\)}
      \symbolO{\(X\otimes Y\)}\symbolO[2]{\(X\otimes Y\)}
    }\label{cond:copy}\\
    \forall\q{\qbox[name={\(f\)}]\symbolI{\(X\)}\symbolO{\(Y\)}}\colon
    \q{
      \qbox[name={\(f\)}]\qbox[name={\(f\)}]\n
      \qcomul[hlen=2, name={\(\operatorname{copy}_X\)}]
    }=\q{
      \qcomul[hlen=2, name={\(\operatorname{copy}_Y\)}]\n
      \qspace[0.5]\qbox[name={\(f\)}]
    }\label{cond:morcopy}\\
    \q{
      \qcomul[hlen=2, name={\(\operatorname{copy}_I\)}]\symbolI{\(I\)}
      \symbolO{\(I\)}\symbolO[2]{\(I\)}
    }=\q{\qunitob}\label{cond:i:copy}
  \end{gather}
\end{CODEBOX}

\begin{CODEBOX}{Copyable State}{def:copyablestate}
  \[
    \q{
      \qcomul[hlen=2, name={\(\operatorname{copy}\)}]\n
      \qspace[0.5]\qstate[name={\(a\)}]
    }=\q{
      \qstate[name={\(a\)}]\qstate[name={\(a\)}]
    }
  \]
\end{CODEBOX}
\begin{CODEBOX}{}{len:copycupcup}
  \begin{align*}
    \q{\qcup\qcup}&\stackrel{\text{(\ref{cond:i:copy})}}{=}
    \q{
      \qcup\qcup\n\qmv[0.5,0.4]
      \qcomul[dom arrowtype=dotted, cod arrowtype=dotted, hlen=3, name={\(\operatorname{copy}\)}]
    }\stackrel{\text{(\ref{cond:morcopy})}}{=}
    \q{
      \qspider[
        name={\(\operatorname{copy}\)}, 
        N={1,2,4,5}, 
        s=2, 
        hlen=2
      ]\n\qcup
    }\\
    &\stackrel{\text{(\ref{cond:copy})}}{=}\q{
        \qwire\qbraid\qwire\n
        \qloop[4]{\qwire}\n
        \qcomul[hlen=2, name={\(\operatorname{copy}\)}]\qcomul[hlen=2]\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[red][4,8]
    }\stackrel{\text{(\ref{cond:ccmt})}}{=}\q{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n
        \qcomul[hlen=2]\qcomul[hlen=2]\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[red][4,7]
      }\\
      &=\q{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n[2]
        \qloop[4]{\qwire[vlen=2]}\n
        \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[blue][8,9]
      }
      \stackrel{\text{(\ref{eq:inverse:braid})}}{=}
      \q{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n
        \qwire\qbraidinv\qwire\n
        \qwire\qbraid\qwire\n
        \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[blue][8,11]
      }\\
      &=\q{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n
        \qwire\qbraidinv\qwire\n
        \qwire\qbraid\qwire\n
        \qloop[2]{\qcomul[hlen=2, name={\(\operatorname{copy}\)}]}\n
        \qspace[0.5]\qcup[hlen=3]
        \qbb[yellow][10,14,15]
      }\stackrel{\text{(\ref{cond:copy}, \ref{cond:morcopy}, \ref{cond:i:copy})}}{=}
      \q{
        \qwire\qbraid\qwire\n
        \qbraidinv\qwire\qwire\n
        \qwire\qbraidinv\qwire\n
        \qcup\qcup
        \qbb[yellow][10,11]
      }\\
      &=\q{
        \qwire\qbraid\qwire\n
        \qcup[n=4]
      }
  \end{align*}
\end{CODEBOX}
\begin{CODEBOX}{}{len:copybraid}
  \begin{align*}
    \q{
      \qbraid
      \symbolI{\(X\)}\symbolO{\(X\)}
      \symbolI[2]{\(X\)}\symbolO[2]{\(X\)}
    }&\stackrel{\text{(\ref{eq:snake})}}{=}\q{
      \qwire\qspace[2]\qcap\qwire\n
      \qbraid[hlen=4]\qwire\qwire\n
      \qwire\qcap\qwire\qcup\n
      \qwire\qwire\qcup
      \qbb[blue][1,5]
    }\\
    &=\q{
      \qcap[hlen=4]\qwire\n
      \qwire\qspace[2]\qbraidinv\n
      \qwire\qcap\qwire\qwire\qwire[vlen=3]\n
      \qwire\qwire\qcup\qcup
      \qbb[blue][1,4]
      \qbb[yellow][12,13]
    }\\
    &\stackrel{\text{Example \ref{len:copycupcup}}}{=}\q{
      \qcap[hlen=4]\qwire\n
      \qwire\qspace[2]\qbraidinv\n
      \qwire\qcap\qwire\qwire\qwire[vlen=3]\n
      \qwire\qwire\qwire\qbraid\qwire\n
      \qwire\qwire\qcup[n=4]
      \qbb[yellow][12,14,17]
    }\\
    &=\q{
      \qcap[s=4]\qwire\n
      \qloop[3]{\qwire}\qbraidinv\n
      \qloop[3]{\qwire}\qbraid\qwire[vlen=3]\n
      \qwire\qwire\qcup[n=4]
      \qbb[green][6,10]
    }\\
    &\stackrel{\text{(\ref{eq:inverse:braid})}}{=}\q{
      \qcap[s=4]\qwire\qwire\n[2]
      \qloop[6]{\qwire[vlen=2]}\n
      \qwire\qwire\qcup[n=4]
      \qbb[green][7,8]
    }\\
    &\stackrel{\text{(\ref{eq:snake})}}{=}\q{
      \qwire\qwire
      \symbolI{\(X\)}[id=1]\symbolO{\(X\)}[id=1]
      \symbolI{\(X\)}\symbolO{\(X\)}
    }
  \end{align*}
\end{CODEBOX}

\begin{CODEBOX}{No Cloning Theorem}{thm:nocopy}
  \begin{align*}
    \q{
      \qasym[name={\(f\)}]
      \symbolI{\(X\)}\symbolO{\(X\)}
    }&\stackrel{\text{(\ref{eq:snake})}}{=}
    \q{
      \qcap\qasym[name={\(f\)}]\n
      \qwire\qcup
    }\stackrel{\text{(\ref{eq:inverse:braid})}}{=}\q{
      \qcap\qasym[name={\(f\)}]\n
      \qwire\qbraidinv\n
      \qwire\qbraid\n
      \qwire\qcup
    }\\
    &\stackrel{\text{(\ref{cond:naturality:braid})}}{=}\q{
      \qcap\qwire\n
      \qwire\qbraidinv\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qwire\qbraid\n
      \qwire\qcup
      \qbb[red][1,4]
    }=\q{
      \qwire\qcap\n
      \qbraid\qwire\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qwire\qbraid\n
      \qwire\qcup
      \qbb[red][1,4]
    }\\
    &=\q{
      \qwire\qcap\n
      \qbraid\qwire\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qwire\qbraid\n
      \qwire\qcup
      \qbb[blue][3]
    }\stackrel{\text{Example \ref{len:copybraid}}}{=}\q{
      \qwire\qcap\n
      \qwire\qwire\qwire\n
      \qwire\qasym[name={\(f\)}]\qwire\n
      \qwire\qbraid\n
      \qwire\qcup
      \qbb[blue][3,4]
    }
  \end{align*}
\end{CODEBOX}
\subsection{Pivotal Category}
\label{sub:pivotal}
\begin{CODEBOX}{}{struct:Pivotal}
  \begin{equation}
    \label{cond:naturality:pivotal}
    \forall\q{\qasym[name={\(f\)}]\symbolI{\(X\)}\symbolO{\(Y\)}}\colon
    \q[scale=0.5]{
      \qwire\qcap[s=4]\n
      \qwire\qwire\qasym[name={\(f\)}]\qwire\qwire\n
      \qcup[n=4]\qwire\qmv[-1,-1]\qasym[name={\(\pi_X\)}]
    }=\q{
        \qasym[name={\(\pi_Y\)}]\n
        \qasym[name={\(f\)}]
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{}{dualrev}
  \begin{equation}
    \label{def:dualrev}
    \q{
      \qcaprev\n
      \symbolI{\(X^T\)}\symbolI[2]{\(X\)}
    }\coloneq\q
    {
      \qcap \n
      \qwire \qwireupup \n
      \qwire \qasym[name={\(\pi_x\)}] \n
    }\qquad\q{
      \qcuprev
      \symbolO{\(X\)}\symbolO[2]{\(X^T\)}
    }\coloneq\q
    {
      \qasym[name={\(\pi_X^{-1}\)}]\qwire\n
      \qwireupup\qwire\n
      \qcup
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{}{revSliding}
  \begin{equation}
    \label{eq:sliding:rev}
    \q{
      \qcaprev\n
      \qtrans\qwire\n
    }=\q{
      \qcaprev\n
      \qwire\qasym
    }\qquad\q{
      \qwire\qtrans\n
      \qcuprev
    }=\q{
      \qasym\qwire\n
      \qcuprev
    }
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{}{corr:pivotal:twist}
  \begin{gather}
    \q{
      \qwireuu[label={\(X^{**}\)}]\n
      \qasym[name={\(\pi_X\)}]\n
      \qwireup[label={\(X\)}]
    }=\q{
      \qwireuu[label={\(X^{**}\)}]\qcap\n
      \qbraid\qwired[label={\(X^T\)}]\n
      \qasym[name={\(\theta_X^{-1}\)}]\qcuprev\n
      \qwireup[label={\(X\)}]
    }\label{twist:pivotal}\\
    \q{
      \qwireup[label={\(X\)}]\n
      \qasym[name={\(\theta_X\)}]\n
      \qwireup[label={\(X\)}]
    }=\q{
      \qwireup[label={\(X\)}]\n
      \qasym[name={\(\pi_X^{-1}\)}]\n
      \qwireuu[label={\(X^{**}\)}]\qcap\n
      \qbraid\qwired[label={\(X^T\)}]\n
      \qwire[label={\(X\)}]\qcuprev
    }\label{pivotal:twist}
  \end{gather}
\end{CODEBOX}

\subsubsection{Trace}
\label{subsub:trace}
\begin{CODEBOX}{Trace}{Trdef}
  \[
    \begin{array}{rccc}
      \operatorname{Tr}\colon & \operatorname{Hom}(X,X) & \to &\operatorname{Hom}(I,I)\\
      &\rotatebox{90}{\(\in\)}&&\rotatebox{90}{\(\in\)}\\
      &\q{
        \qasym[name={\(f\)}]
      } & \mapsto & \q{
        \qcap\n
        \qasym[name={\(f\)}]\qwire\n
        \qcuprev
      }
    \end{array}
  \]
\end{CODEBOX}
\begin{CODEBOX}{Commutativity of the Trace}{Cotr}
  \begin{equation}
    \label{cmt:trace}
    \operatorname{Tr}\left(\q{
      \qasym[name={\(g\)}]\n
      \qasym[name={\(f\)}]
      }\right)
    =\q{
      \qcap\n
      \qasym[name={\(g\)}]\qwire\n
      \qasym[name={\(f\)}]\qwire\n
      \qcuprev
      }
    \stackrel{\text{(\ref{eq:sliding})}}{=}\q{
      \qcap\n
      \qasym[name={\(f\)}]\qtrans[name={\(g\)}]\n
      \qcuprev
    }\stackrel{\text{(\ref{eq:sliding:rev})}}{=}\q{
      \qcap\n
      \qasym[name={\(f\)}]\qwire\n
      \qasym[name={\(g\)}]\qwire\n
      \qcuprev
    }=\operatorname{Tr}\left(\q{
      \qasym[name={\(f\)}]\n
      \qasym[name={\(g\)}]
      }\right)
  \end{equation}
\end{CODEBOX}
\begin{CODEBOX}{Dimension}{def:dim}
  \[
    \q{\qscalar[name={\(\operatorname{dim}(X)\)}]}
    \coloneq\q{\qscalar[name={\(\operatorname{Tr}(\operatorname{id}_X)\)}]}
    =\q{\qcap\n\qcuprev}
  \]
\end{CODEBOX}
\subsection{Dagger}
\label{sub:dagger}
\subsubsection{Adjoint Box}
\label{subsub:adjoint}
\begin{CODEBOX}{Adjoint}{def:adj}
  \begin{gather}
    \left(
      \q{
        \qasym[name={\(f\)}]
        \symbolI{\(X\)}\symbolO{\(Y\)}
      }
    \right)^{\dagger}
    \coloneq
    \q{
      \qadj[name={\(f\)}]
      \symbolI{\(Y\)}\symbolO{\(X\)}
    }\\
    \left(\q{\qasym[name={\(f\)}]}\right)^{\dagger\dagger}
    =\left(\q{\qadj[name={\(f\)}]}\right)^{\dagger}
    =\q{\qasym[name={\(f\)}]}\\
    \left(\q{\qwire}\right)^{\dagger}=\q{\qwire}\\
    \q{
      \qadj[name={\(f\)}]\n
      \qadj[name={\(g\)}]
    }=\q{
      \qadj[name={\(g\circ f\)}]
    }
\end{gather}
\end{CODEBOX}
\subsubsection{Conjugate Box}
\label{subsub:conj}
\begin{CODEBOX}{}{prep:conj}
  \begin{align*}
    \left(\q{\qadj}\right)^T
    &=\q{
      \qwire\qcap\n
      \qwire\qadj\qwire\n
      \qcup\qwire
    }=\q{
      \qcaprev\qwire\n
      \qwire\qadj\qwire\n
      \qwire\qcuprev
    }=\left(
      \q{
        \qwire\qcap\n
        \qwire\qasym\qwire\n
        \qcup\qwire
      }
    \right)^{\dagger}=\left(\q{\qtrans}\right)^{\dagger}
  \end{align*}
\end{CODEBOX}
\section{List of Primitive Diagrams}
\label{sec:fcommands}
      \begin{tcbraster}[raster columns=4,raster equal height=rows,fonttitle=\bfseries,
        colframe=cyan!90,coltitle=cyan!50,colbacktitle=black,
        subtitle style={boxrule=0.4pt,
        colback=black!70,
        colupper=cyan!50}
        ]
        \def\mortype{射}
        \def\AoE{舞台}
        \def\RMK{備考}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qwire}]
          \[\q{\qwire}\]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qbox}]
          \[
            \q{
              \qbox
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qstate}]
          \[
            \q{
              \qstate
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qeffect}]
          \[
            \q{
              \qeffect
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qscalar}]
          \[
            \q{
              \qscalar
              }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qunitob}]
          \[
            \q{
              \qunitob
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qmul}]
          \[
            \q{
              \qmul[hlen=2]
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qcomul}]
          \[
            \q{
              \qcomul[hlen=2]
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qunit}]
          \[
            \q{
              \qunit
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qcounit}]
          \[
            \q{
              \qcounit
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qspider}]
          \[
            \q{
              \qspider[p=4,hlen=2]
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qbraid}]
          \[
            \q{
                \qbraid
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qbraidinv}]
          \[
            \q{
              \qbraidinv
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qsym}]
          \[
            \q{
              \qsym
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qcap}]
          \[
            \q{
              \qcap
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qcup}]
          \[
            \q{
              \qcup
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qwireu}]
          \[\q{\qwireup}\]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qwired}]
          \[\q{\qwiredown}\]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qwireuu}]
          \[\q{\qwireuu}\]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qwiredd}]
          \[\q{\qwiredd}\]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qasym}]
          \[
            \q{
              \qasym
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qtrans}]
          \[
            \q{
              \qtrans
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash adj}]
          \[
            \q{
              \qadj
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qconj}]
          \[
            \q{
              \qconj
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qcaprev}]
          \[
            \q{
              \qcaprev
            }
          \]
        \end{tcolorbox}
        \begin{tcolorbox}[adjusted title=\texttt{\textbackslash qcuprev}]
          \[
            \q{
              \qcuprev
            }
          \]
        \end{tcolorbox}
      \end{tcbraster}
      \addcontentsline{toc}{section}{References}
      \begin{thebibliography}{99}
        \bibitem{tikz-manual}
        Till Tantau,
        \textit{The TikZ and PGF Packages Manual for Version 3.1.10},
        Institut für Theoretische Informatik, Universität zu Lübeck,
        n.d.,
        \url{https://github.com/pgf-tikz/pgf}
        (retrieved March 22, 2025).
        \bibitem{geniussorting}
        Anonymous,
        \textit{Genius Sorting Algorithm},
        4chan Programming Board,
        January 20, 2011,
        \url{https://dis.4chan.org/read/prog/1295544154}
        (accessed January 20, 2011; link currently inactive).
        \bibitem{gfxhatena}
        gfx,
        \textit{Joushiki wo kutsugaesu so-to arugorizumu! Sono na mo "sleep sort"!},
        Hatena Diary,
        May 19, 2011,
        \url{https://gfx.hatenadiary.org/entry/20110519/1305810786}.
        \bibitem{literateprograms}
        LiteratePrograms,
        \textit{Turing Machine Simulator in \LaTeX},
        \url{https://literateprograms.org/turing_machine_simulator__latex_.html},
        n.d.,
        retrieved March 22, 2025.
        \bibitem{overleaf}
        Overleaf,
        \textit{\LaTeX\ is More Powerful than You Think: Computing the Fibonacci Numbers and Turing Completeness},
        \url{https://www.overleaf.com/learn/latex/Articles/LaTeX_is_More_Powerful_than_you_Think_-_Computing_the_Fibonacci_Numbers_and_Turing_Completeness},
        n.d.,
        retrieved March 22, 2025.
      \end{thebibliography}
      \section*{Change Log}
      \subsection*{1.1.0 (2025-04-03)}
      \paragraph{The following commands have been updated.}
      \begin{itemize}
        \item \texttt{\textbackslash symbolI}
        \item \texttt{\textbackslash symbols}
        \item \texttt{\textbackslash symbolS}
        \item \texttt{\textbackslash symbolO}
        \item \texttt{\textbackslash symboln}
        \item \texttt{\textbackslash symbolN}
      \end{itemize}
      The ID, which was previously a required argument for these commands, has been made optional. 
      Users can now specify the ID via an optional key, allowing for more flexible usage of the commands.
      \begin{itemize}
        \item Old format: \texttt{\textbackslash symbolI[i]\{ID\}\{text\}[above right]}
        \item New format: \texttt{\textbackslash symbolI[i]\{text\}[above right, id=ID]}
      \end{itemize}
      \paragraph{English documentation has been added to the package.}
      \subsection*{1.0.0 (2025-04-01)}
      \paragraph{Initial release.}
      \section*{License and Copyright}

      This package is distributed under the \textbf{LaTeX Project Public License (LPPL)}, version 1.3c or later.  
      For details, see \url{https://www.latex-project.org/lppl.txt}.
      
      Copyright \textcopyright 2025 Niina Ryota
      
      You are free to distribute and modify this package under the terms of LPPL.  
      However, any modified versions \textbf{must not} be distributed under the original name, and the original author must be credited.
\end{document}
