Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convenient syntax for inclusion arrows #32

Closed
leahneukirchen opened this issue Jun 22, 2020 · 2 comments
Closed

Convenient syntax for inclusion arrows #32

leahneukirchen opened this issue Jun 22, 2020 · 2 comments
Assignees
Labels

Comments

@leahneukirchen
Copy link

I tried to do the equivalent of A\arrow[hookrightarrow]B in CoDi (which is great, btw!) and it was quite tricky. The hook is provided in arrows.meta, but I couldn't figure out the syntax to use Hooks[right] inline. Instead, I had to define a key:

\pgfkeys{C /.tip = {Hooks[right]}}

Then I can use \mor A C-> B;.

As this notation is quite common, do you think it makes sense to include this or a similar shortcut?

@paolobrasolin
Copy link
Owner

CoDi (which is great, btw!)

Thanks @leahneukirchen! ❤️

couldn't figure out the syntax to use Hooks[right] inline

You can use it inline like this --even if I wouldn't recommend it except for one-off usage:

\documentclass{article}
\usepackage{commutative-diagrams}
\usetikzlibrary{arrows.meta}
\begin{document}
  \begin{codi}
    \obj{ A & B \\ C & D \\ };
    \mor A f:{{Hooks[right]}->} B; % i.e. wrap the key in a group
    \mor C f:[{Hooks[right]}->] D; % i.e. wrap the key in a keylist
  \end{codi}
\end{document}

As this notation is quite common, do you think it makes sense to include this or a similar shortcut?

It definitely makes sense.

Right now CoDi encodes almost no shortcuts implying stylistic preferences because i want to keep it very pliable, a framework almost. Of course it's not "ready for daily use" like this and it needs some readily available style packs for the occasional user.

I'm not saying defaults because I'd rather have the occasional user ask for \usetikzpackage{codi.starterpack} than have the power user dance around defaults. In fact I took care to build some facilities to let users easily define their own styles in perfect isolation. The "neat" way of implementing your solution as your own style pack would be:

% This file is tikzlibrarycommutative-diagrams.styles.leah.code.tex

\usetikzlibrary{arrows.meta}

\pgfqkeys{/codi/arrows}{
  C/.tip = {Hooks[right]},
}
% This file is main.tex

\documentclass{article}
\usepackage{commutative-diagrams}
\usetikzlibrary{commutative-diagrams.styles.leah}

\begin{document}
  \begin{codi}
    \obj{ A & B \\ };
    \mor A f:C-> B;
  \end{codi}
\end{document}

This should get you started on building your own reusable stylesheet!

Unfortunately I'm not doing CT in my day-to-day right now so I doubt I can grok what would be "reasonable defaults for everyone" to put in a starter pack included in CoDi.

I was hoping that perhaps some consensus could be reached collaborating with early adopters.
On that note, I'm opening #35 and adding your suggestion there.

@leahneukirchen
Copy link
Author

Thanks, this works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants