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

4
  • What is the problem in this diagram?
    – Bernard
    Feb 19, 2018 at 15:52
  • 1
    I'd like the left and right notes to be evenly spaced, so the diagram is roughly symmetrical through its center vertical axis. Feb 19, 2018 at 16:27
  • What do you call ‘the left and right notes’, explicitly? This is not clear to me.
    – Bernard
    Feb 19, 2018 at 18:43
  • Sorry "nodes". The column with $\hom_B(B,f)$ is much larger than the columns with the $A$s. I'd like them to be roughly the same size. Feb 19, 2018 at 21:13

2 Answers 2

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

1
  • 1
    Thanks. I didn't know about about "between origins". This looks great. Feb 20, 2018 at 15:37
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

3
  • Thanks. I like how this automatically fixes the label positions. Feb 20, 2018 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.) May 8, 2020 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 8, 2020 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .