Here's a cramped* style that sets the right sep settings so that the resulting CD resembles A \to B as close as possible.
This means:
- No
seps for the internal TikZ \matrix.
- No
seps for the cells' nodes (labels along an arrow are a different thing).
- The
outer sep of the cells' nodes should be the width of \thickmuskip (≈ \;, the pading around \to) but something goes wrong there hence the correction factor of 1.25.
- A
column sep that's the width of \to including the padding.
- Round line cap (as with the
\to symbol).
- Arrows that do not contribute to the bounding box.
The last one is probably unnecessary for most cases and might be a bad idea for CDs but then again, more complex arrows won't look good inside math-mode anyway, I guess.
Code
\documentclass[varwidth,convert]{standalone}
\usepackage{tikz-cd}
\tikzcdset{
cramped*/.style={
arrows=overlay, line cap=round,
every matrix/.append style={
every outer matrix/.append style={inner sep=+0pt}},
every cell/.append style={inner sep=+0pt, outer sep=1.25*width("$\;$")},
column sep/.evaluated=width("${}\to{}$")}}
\begin{document}
Let $A \to B$ be a map. (\texttt{\textbackslash to})\par
Let \begin{tikzcd}[column sep=small] A \arrow[r] & B \end{tikzcd}
be a map. (\texttt{column sep=small})\par
Let \begin{tikzcd}[column sep=small, cramped] A \arrow[r] & B \end{tikzcd}
be a map. (\texttt{column sep=small, cramped})\par
Let $A \to B$ be a map. (\texttt{\textbackslash to})\par
Let \begin{tikzcd}[cramped*] A \arrow[r] & B \end{tikzcd}
be a map. (\texttt{cramped*})\par
Let \begin{tikzcd}[cramped*]
A \ar[r, bend left] \ar[r, bend right, <-] & B
\end{tikzcd} be a map.\par
[\sin( \begin{tikzcd}[cramped*]
A \ar[r, bend left] \ar[r, bend right, <-]
& B
\end{tikzcd})]
[\sin( \begin{tikzcd}[cramped*] A \rar & B \end{tikzcd})]
[\sin(A \to B)]
\end{document}
Output

\begin{tikzcd}[cramped]is the official option for spacing inline tikz-cd. – Symbol 1 Aug 07 '21 at 01:24tikz-cdfor this to begin with? – egreg Aug 07 '21 at 08:05