Remove outer padding in tikzcd

If you deem that \xrightarrow produces too short an arrow, you can patch it in order to use a minimum width (here 2.5em).

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\ext@arrow}
  {\hbox to\wd\tw@}
  {\hbox to\maybe@wd\tw@}
  {}{\ddt}
\newcommand{\maybe@wd}[1]{%
  \ifdim\wd#1<\minimum@arrow
    \minimum@arrow
  \else
    \wd#1%
  \fi
}
\newcommand{\minimum@arrow}{2.5em}
\makeatother

\begin{document}

\[
  A = \ker \left(A \xrightarrow{F} B \right)
  \qquad
  A = \ker \bigl(A \xrightarrow{F} B \bigr)
\]



\[
  A = \ker \left(
  \hspace{-\arraycolsep}
  \begin{tikzcd}
    A \arrow[r,"F"] & B
  \end{tikzcd}
  \hspace{-\arraycolsep}
  \right)
\]

\end{document}

I also added a trick to remove the padding to the tikzcd and also tried \bigl( and \bigr) to get a better output.

enter image description here

On the other hand, a simple \ker(A\xrightarrow{F}B) (with no patching) seems sufficient to me:

\[
  A = \ker \bigl(A \xrightarrow{F} B \bigr)
\]

produces

enter image description here


Using the cramped, sep=small options to tikzcd you can obtain the desired spacing

enter image description here

Code:

\documentclass[12pt]{article}
\usepackage{tikz-cd}
\usepackage{amsmath}

\begin{document}
\[
    A = \ker \left(B \xrightarrow{F} C\right)
\]
\[
    A = \ker \left(
    \begin{tikzcd}[cramped, sep=small] 
      A \rar["F"] & B
    \end{tikzcd}
    \right)
\]
\end{document}

Tags:

Tikz Cd