astoff / tikz-cd

Commutative diagrams with TikZ
44 stars 3 forks source link

Provide \to and \mapsto as shortcuts #8

Open tobiasdiez opened 4 years ago

tobiasdiez commented 4 years ago

This PR enables \to and \mapsto as shortcuts for the common latex arrows. Thus, the following works

\begin{tikzcd}
    E \to[r, "L"] & F
    \\
    e \mapsto{r} & L(e).
\end{tikzcd}

Advantages:

I've marked this as a draft PR, as the following points still need to be done but I wanted to get early feedback:

astoff commented 4 years ago

This proposal would break the following, not completely unreasonable construction,

\begin{tikzcd}
A \to B \ar[r] & B \to D
\end{tikzcd}

which I would say is not acceptable.

tobiasdiez commented 4 years ago

You are right, this code would no longer work. But why do you think somebody would use normal arrows (\to) in a commutative diagram?

astoff commented 4 years ago

@tobiasdiez For instance, because some arrows don't need a label and/or should be shorter. I'm not saying it's the best (or even a good) way to do it, but it's something some people will do, with really confusing results. Consider also the possibility that an object of the diagram is A_\to, or the user in the habit of writing \overset\to v instead of \vec v; or even the possibility that some command defined in terms of \to or \mapsto is used inside {tikzcd}.

This change would make the package's behaviour less predictable.

tobiasdiez commented 4 years ago

Ok, I understand. These examples feel a bit artificial to me, but I also see that as a package maintainer you have to consider these edge cases.

Would you consider adding a package option, that enables the to shortcut or do you think it's really not something for this package? (Both would be fine for me of course. With my two recent PRs I just thought about contributing back some of my changes that I implemented to make my life easier.)