I am sorry for the unspecific question title, but I didn't really know what to put there.
The question
I defined a command to make drawing arrows in Tikz easier for me, for the purpose of commutative diagrams. The syntax is supposed to look something like \arrow[ARROW OPTIONS]{src}{tgt}{label}[LABEL OPTIONS]
. The command is defined as
\NewDocumentCommand{\arrow}{ommmo}{
\IfNoValueTF{#1}{
\IfNoValueTF{#5}{
\draw[->] (#2) edge[decorate] node[font=\footnotesize] {\ensuremath{#4}} (#3);
}{
\draw[->] (#2) edge[decorate] node[#5,font=\footnotesize] {\ensuremath{#4}} (#3);
}
}{
\IfNoValueTF{#5}{
\draw[->,#1] (#2) edge[decorate,#1] node[font=\footnotesize] {\ensuremath{#4}} (#3);
}{
\draw[->,#1] (#2) edge[decorate,#1] node[#5,font=\footnotesize] {\ensuremath{#4}} (#3);
}
}
}
In most instances the code works perfectly fine, assuming I have defined nodes and use it like
\node (src) at (-1,0) {};
\node (tgt) at (1,0) {};
\arrow{src}{tgt}{}
However, if I skip defining nodes and use it like
\arrow{-1,0}{1,0}{}
suddenly a new arrow-head appears at the source of the arrow, always pointing upwards. Since the lengths of the arrows in the MWE below differ I think it has something to do with the way paths adapt to nodes. But since the background of the nodes is opaque I could not figure out why said additional arrow-head appears and I would really appreciate your help. Thank you.
MWE
% --- begin package declaration
\documentclass{article}
\usepackage{xparse} % better command definition
\usepackage{xstring} % strings
\usepackage{tikz}
\usetikzlibrary{matrix} % node placement
\usetikzlibrary{calc} % calculation
\usetikzlibrary{decorations.pathmorphing} %snaked
\usetikzlibrary{arrows} % right hook->
\usetikzlibrary{arrows.meta} % -Implies
% --- tikz styles and commands
\tikzset{diagram/.append style={
baseline={($(current bounding box.center) + (0pt,-0.15\baselineskip)$)}
}}
\tikzset{objects/.append style={
matrix of nodes,
ampersand replacement=\&, % replaces the column indicator from & to \&
text height=1.75ex, text depth=0.5ex, % fixes some text alignment issues with nodes
column sep={5em,between origins}, row sep={4.5em,between origins} % width of node does not influence column spacing
}}
\tikzset{equals/.append style={
-,
double,
double distance=0.2em
}}
\tikzset{incl/.append style={right hook->}}
\tikzset{epi/.append style={->>}}
\tikzset{mono/.append style={>->}}
\tikzset{mapsto/.append style={|->}}
\tikzset{implies/.append style={
arrows={-Implies},
double,
double distance=0.2em
}}
\tikzset{snaked/.append style={
decoration={
snake,
amplitude=.4mm,
segment length=2mm,
pre length=1mm,
post length=1mm
}
}}
\tikzset{zigzaged/.append style={
decoration={
zigzag,
amplitude=.4mm,
segment length=2mm,
pre length=1mm,
post length=1mm
}
}}
\NewDocumentEnvironment{diagram}{}{
\tikzpicture[diagram]
}{
\endtikzpicture
}
\NewDocumentCommand{\arrow}{ommmo}{
\IfNoValueTF{#1}{
\IfNoValueTF{#5}{
\draw[->] (#2) edge[decorate] node[font=\footnotesize] {\ensuremath{#4}} (#3);
}{
\draw[->] (#2) edge[decorate] node[#5,font=\footnotesize] {\ensuremath{#4}} (#3);
}
}{
\IfNoValueTF{#5}{
\draw[->,#1] (#2) edge[decorate,#1] node[font=\footnotesize] {\ensuremath{#4}} (#3);
}{
\draw[->,#1] (#2) edge[decorate,#1] node[#5,font=\footnotesize] {\ensuremath{#4}} (#3);
}
}
}
\begin{document}
\begin{diagram}
\node (src) at (-1,0) {};
\node (tgt) at (1,0) {};
\arrow{src}{tgt}{}
\end{diagram}
\begin{diagram}
\arrow{-1,0}{1,0}{}
\end{diagram}
\end{document}