Tikzcd pullback square issue
Your approach nests tikzpicture
s. The standard way to avoid that is to use \savebox
es.
\documentclass{article}
\usepackage{tikz-cd}
\newsavebox{\pullback}
\sbox\pullback{%
\begin{tikzpicture}%
\draw (0,0) -- (1ex,0ex);%
\draw (1ex,0ex) -- (1ex,1ex);%
\end{tikzpicture}}
\begin{document}
\begin{center}
\begin{tikzcd}
F \arrow[r] \arrow[d]
\arrow[dr, phantom, "\usebox\pullback" , very near start, color=black]
& * \arrow[d] \\
X \arrow[r, "f"] & Y \\
\end{tikzcd}
\end{center}
\end{document}
You defined your command with a parameter, which you did not use. Let's assume that there is a need for such parameters. Then \savebox
es are unhandy. Therefore I add an alternative: a path picture
with as many things fixed as you can think of. E.g. -
is to say that there should not be an arrow, etc. (I understand that it is very unlikely that you want the symbol to be red, this is just to illustrate that parameters work here.)
\documentclass{article}
\usepackage{tikz-cd}
\tikzset{pullback/.style={minimum size=1.2ex,path picture={
\draw[opacity=1,black,-,#1] (-0.5ex,-0.5ex) -- (0.5ex,-0.5ex) -- (0.5ex,0.5ex);%
}}}
\begin{document}
\begin{center}
\begin{tikzcd}
F \arrow[r] \arrow[d]
\arrow[dr, phantom," " {pullback=red}, very near start, color=black]
& * \arrow[d] \\
X \arrow[r, "f"] & Y \\
\end{tikzcd}
\end{center}
\end{document}
Why don't you simply insert the \lrcorner
symbol?
\documentclass[svgnames]{article}
\usepackage{tikz-cd, amsmath, amssymb}%
\begin{document}
\begin{center}
\begin{tikzcd}
F \arrow[r] \arrow[d]
\arrow[dr, phantom, "\scalebox{1.5}{\color{IndianRed}$\lrcorner$}" , very near start, color=black]
& * \arrow[d] \\
X \arrow[r, "f"] & Y \\
\end{tikzcd}
\end{center}
\end{document}
Inside a tikzpicture
, along a path
, you can put not only node
but also pic
.
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[bmr/.pic={
\draw (2mm,0)--++(-90:2mm)--++(180:2mm);
}]
\path
(0,0) node (F) {$F$}
+(-45:.2) pic[scale=.8,red]{bmr}
+(0:1.5) node (star) {$*$}
++(-90:1) node (X) {$X$}
+(0:1.5) node (Y) {$Y$};
\draw[->] (F)--(star);
\draw[->] (F)--(X);
\draw[->] (X)--(Y) node[midway,above,scale=.6]{$f$};
\draw[->] (star)--(Y);
\end{tikzpicture}
\end{document}