# Trace

> A morphism with its output bent around to its input: the categorical trace, a closed loop. A String diagrams example with its LaTeX source.

A String diagrams example in the TeXeR TikZ library: https://texer.org/library/string-diagrams/trace

Package: [String diagrams](https://texer.org/library/string-diagrams.md), on CTAN at https://ctan.org/pkg/pgf.

Tags: trace, loop, pivotal category

## Source

```latex
\begin{tikzpicture}[thick, baseline=(current bounding box.center)]
  \draw (0,-0.6) -- (0,0.6) arc[start angle=180, end angle=0, radius=0.6]
  -- (1.2,-0.6) arc[start angle=360, end angle=180, radius=0.6];
  \node[draw, fill=white, minimum width=8mm, minimum height=6mm] at (0,0) {$f$};
  \node[right] at (1.2,0) {$A$};
  \node at (2.6,0) {$= \operatorname{tr}(f)$};
\end{tikzpicture}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}[thick, baseline=(current bounding box.center)]
  \draw (0,-0.6) -- (0,0.6) arc[start angle=180, end angle=0, radius=0.6]
  -- (1.2,-0.6) arc[start angle=360, end angle=180, radius=0.6];
  \node[draw, fill=white, minimum width=8mm, minimum height=6mm] at (0,0) {$f$};
  \node[right] at (1.2,0) {$A$};
  \node at (2.6,0) {$= \operatorname{tr}(f)$};
\end{tikzpicture}
\end{document}
```
