paolobrasolin / commutative-diagrams

CoDi: Commutative Diagrams for TeX
https://paolobrasolin.github.io/commutative-diagrams/
MIT License
30 stars 3 forks source link

Explain how to name arrow labels in the manual #34

Closed paolobrasolin closed 1 year ago

paolobrasolin commented 4 years ago

I totally overlooked this piece of useful info. It might be obvious for a TikZ power-user but it's tricky for anyone else. This must be mentioned in the manual.

The simplest way to do it is

\documentclass{article}
\usepackage{commutative-diagrams}
\begin{document}
  \begin{codi}[prompter]
    \obj{ A & B \\ };
    \mor A [name=foo,"f"]:-> B;
    \draw [red] (foo) circle (1em);
  \end{codi}
\end{document}

which yields

image

Note the prompter attached no generated name to the arrow's label. This is due to the default behaviour being /codi/overwrite=false (i.e. if a name exists keep it and don't bother generating one). Since the name key comes before the label contents "f", the latter does not generate a name because one already exists.

The smart name generation behaviours for arrows and object are exactly the same, but the interfaces to override them are a bit different despite amounting to standard TikZ trickery. Let's clarify that!

Thanks to @khjlai for pointing this out. ❤️