6

I've been drawing commutative diagrams using tikzcd in which one entry is dramatically larger than the others. I'd like for the entry sizes to be "normalized" somehow so the display is not too uneven and I want to be able to adjust them locally for each diagram individually. Here's a typical example:

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

\usetikzlibrary{matrix}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{trees}
\usetikzlibrary{backgrounds}
\usetikzlibrary{graphs}
\usetikzlibrary{graphdrawing}
\usegdlibrary{force}

\tikzset{
  commutative diagrams/.cd, 
  arrow style=tikz, 
  diagrams={>={Straight Barb[scale=0.9]}, semithick}
}

\begin{document}

\[
\begin{tikzcd}
A \arrow[rr, bend right, dashed, "i"'] \arrow[dr, equals] \arrow[rr, phantom, "\bot"] & & \hom_B(B,f) \arrow[dl, two heads, "p_1"] \arrow[ll, bend right, two heads, "p_1"'] \\ & A
\end{tikzcd}
\]
\end{document}

a poorly spaced adjunction

2 Answers2

5

You can fine tune the position of the label with pos=<fraction>:

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

\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}

\tikzset{
  commutative diagrams/.cd, 
  arrow style=tikz, 
  diagrams={>={Straight Barb[scale=0.9]}, semithick}
}

\begin{document}

\[
\begin{tikzcd}[column sep={4em,between origins}]
A
  \arrow[rr, bend right, dashed, "i"' pos=0.57]
  \arrow[dr, equals]
& \bot &
\hom_B(B,f)
  \arrow[dl, two heads, "p_1"]
  \arrow[ll, bend right, two heads, "p_1"' pos=0.43]
\\
& A
\end{tikzcd}
\]

\end{document}

enter image description here

egreg
  • 1,121,712
3

Like this? I use the \makebox* command from the small makebox package to make the rightmost node the width of the leftmost with a simple syntax.

Unrelated: needless to load tikz if you load tikz-cd.

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

\usetikzlibrary{matrix}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{trees}
\usetikzlibrary{backgrounds}
\usetikzlibrary{graphs}
\usetikzlibrary{graphdrawing}
\usegdlibrary{force}

\tikzset{
  commutative diagrams/.cd,
  arrow style=tikz,
  diagrams={>={Straight Barb[scale=0.9]}, semithick}
}

\usepackage{makebox} 
\begin{document}

\[
\begin{tikzcd}
A \arrow[rr, bend right, dashed, "i"'] \arrow[dr, equals] \arrow[rr, phantom, "\bot"] & &\makebox*{$A$}{$ \hom_B(B,f) $} \arrow[dl, two heads, "p_1"] \arrow[ll, bend right, two heads, "p_1"'] \\ & A
\end{tikzcd}
\]
\end{document} 

enter image description here

Bernard
  • 271,350
  • Thanks. I like how this automatically fixes the label positions. – Emily Riehl Feb 20 '18 at 15:37
  • I've been using this solution to normalize entry sizes but now I sometimes have an issue with the lengths of the arrows. If, as in the example above, I use \makebox{fake small entry}{actual oversized entry} the arrows to and from the right node might be too long while if I use \makebox{fake large entry}{actual small entry}, for instance in the node above left, the arrows to and from it will be too short. Is there an easy way to modify the starting and ending points of an arrow in tikzcd while keeping its default trajectory? (I'm not trying to shift/bend the arrow left or right.) – Emily Riehl May 08 '20 at 18:41
  • Unfortunately, I don't know TiKZ well enough to see how to do that. I hope some real specialist will tell you. Just in case: I would know how to do it with pstricks and its psmatrix environment. – Bernard May 08 '20 at 18:52