% Typed atom extension and document house style.
\section{Custom Atoms and Typographic Style}\label{ch:house}

Good typography depends upon a disciplined visual vocabulary.  In \pkg{}, the
standard tensor nodes are shared consistently across all layout frames: a
\tnval{dot} represents an unnamed tensor site; a \tnval{box} or \tnval{pill}
encloses an inscribed tensor label; an \tnval{mpo} provides facing physical input
and output ports for local operators or MPO nodes; and a \tnval{ring} denotes a
single-site operator or gauge matrix seated upon an existing wire.  Always
remember that a tensor's semantic kind, its typed ports (physical vs. virtual),
and its visual skin are three independent concepts.

\subsection{Declaring a custom atom}

When should you extend the node vocabulary?  The command \tncmd{tndeclare}
exists for those occasions when the built-in skins cannot express a specialized
quantum many-body entity (such as a multi-legged projector $P$, an isometry
$W$, or a disentangler $U$):

\cmdsig{\textbackslash tndeclare\{atom\}\{\meta{command}\}\\
\{skin=\meta{dot|box|pill|mpo},\\
\hspace*{2em}ports=\{\meta{face:type},\ldots\}\}}

\begin{Verbatim}[fontsize=\small,frame=leftline]
\tndeclare{atom}{\tnprojector}{
  skin=box,
  ports={180:virtual, 0:virtual, 90:physical}
}
\begin{tenkz}[cols=1] \tnprojector{P} \end{tenkz}
\end{Verbatim}

Each port face is specified as an angle in the atom's internal coordinate axes:
\tnval{180} and \tnval{0} are the western and eastern ends of the wire, while
\tnval{90} points north and \tnval{270} south.  The allowed types are
\tnval{virtual} and \tnval{physical}.  The declaration defines a one-label atom
command that accepts optional per-cell keys.  Notice that the port specification
must be exhaustive: in \pkg{}, a geometric anchor without a mathematical type
does not constitute a valid extension contract.

\whynote{Declaring an atom introduces a new mathematical entity and therefore a
new word in the atom grammatical class.  By contrast, changing the skin or role
of an existing atom is done through options.}

To abbreviate repeated structures in a paper, use ordinary \TeX{} definitions
whose expansions produce the public \pkg{} syntax.  Keep benchmark examples
expanded so that each source states the topology it draws.

\subsection{Criteria for language extensions}

To protect the language from creeping bloat, \pkg{} enforces a strict gate for
new features.  A proposed key must demonstrate at least three distinct,
manifested consumers in the published literature; a new command must represent a
genuinely new grammatical class.  Furthermore, every accepted feature requires a
registry entry, a standalone example, a coded diagnostic, a negative test case,
and a teachability review.

\subsection{House style and typography}

Consistent style is an art that rewards restraint.  Use \tncmd{tnset} in your
preamble to declare document-wide metrics or semantic themes, and use picture
options for local policies.  Document themes may adjust colors and typography,
but they never alter topology.  Use semantic roles to convey function, and
textual labels to establish mathematical identity.  Never resort to arbitrary
rainbow colors merely to tell identical tensors apart!

In \pkg{}, labels dwell in reserved bands outside measured silhouettes.  If a
diagram feels crowded, increase the documented metric spacing or layer
separation.  Manual coordinate nudging is an emergency measure of last resort,
and has no place in canonical benchmark code.  The layout engine measures
occupied ink automatically, but authored routes and label stations can still
overlap.  Inspect the resulting figure and adjust the documented placement
options when needed.
