4

The recommended way (see Section 4.2 here) to place pullback corners in tikz-cd diagrams is using diagonal phantom arrows, as in

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amssymb}
\begin{document}
\begin{tikzcd}
    A   \arrow[r] 
        \arrow[d] 
        \arrow[dr, phantom, "\lrcorner", very near start] 
&   B   \arrow[d] 
\\  C   \arrow[r] 
&   D  
\\
\end{tikzcd}
\end{document}

However, this isn't great when the diagram deviates too far from the square shape, eg because of long labels:

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amssymb}
\begin{document}
\begin{tikzcd}
    A   \arrow[r] 
        \arrow[d] 
        \arrow[dr, phantom, "\lrcorner", very near start] 
&   B   \arrow[d] 
\\  CCCC\arrow[r] 
&   DDDD  
\\
\end{tikzcd}
\end{document}

enter image description here

The problem is that the \lrcorner is further from the left arrow than from the upper arrow.

I can adjust that manually with shift right, but I wonder if there's a method that doesn't place the corner on an invisible diagonal of the rectangle, but rather at a fixed distance at a 45 degree angle from the center of the upper left corner?

This answer seems to do something like this, but with tikzpicture instead of tikzcd, and I don't know how to adapt it to tikzcd.

1
  • 1
    If it denotes something about the A use labels, i.e. |[label=south east:$\lrcorner$]| A. Or pics placed like labels: See 2. and 3.. We could also draw a segment of the node's border if that's better. Commented Jul 2, 2023 at 1:30

2 Answers 2

4

You can place the \lrcorner symbol as a label for the node. You can set the angle and distance.

enter image description here

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amssymb}
\begin{document}
\begin{tikzcd}
    |[label={[label distance=-2mm]-45:\lrcorner}]|A   \arrow[r] 
        \arrow[d]  
&   B   \arrow[d] 
\\  CCCC\arrow[r] 
&   DDDD
\end{tikzcd}
\end{document}
0
3

You can add whatever tikz code you like with the execute at end picture hook.

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amssymb}
\begin{document}
\begin{tikzcd}[execute at end picture={\path (\tikzcdmatrixname-1-1) node[below right]{$\lrcorner$};}]
    A   \arrow[r] 
        \arrow[d] 
&   B   \arrow[d] 
\\  CCCC\arrow[r] 
&   DDDD  
\\
\end{tikzcd}
\end{document}

enter image description here

You could also use the pic from the linked answer.

You must log in to answer this question.

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