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

Drawing commutative diagrams with TikZ #214

Closed
platipo opened this issue Sep 12, 2019 · 16 comments · May be fixed by #219
Closed

Drawing commutative diagrams with TikZ #214

platipo opened this issue Sep 12, 2019 · 16 comments · May be fixed by #219

Comments

@platipo
Copy link

platipo commented Sep 12, 2019

The images are quite nice but sometimes they feel kinda cheap. It would be nice if they could be redrawn with TikZ.
This would give a touch of class to a book that is already beautiful.

Example:
scanned diagram

Simple solution:
TikZ-diagram-simple

\begin{tikzcd}[commutative diagrams/every, column sep=small, cells={nodes={inner color=blue!20!white,outer color=white}}]
    & & Arr\otimes Arr \arrow[dr] \arrow[dl] \arrow[d, phantom, "\vee", very near start,font=\Large] & & \\
    & Arr \arrow[dl, swap, "dom"] \arrow[dr, swap, "cod"] & & Arr \arrow[dl, swap, "dom"] \arrow[dr, swap, "cod"] & \\
    Ob & & Ob & & Ob \\
\end{tikzcd}

And a more complex one:
TikZ-diagram-complex

\begin{tikzpicture}[commutative diagrams/every, column sep=small, cells={nodes={inner color=blue!20!white,outer color=white}}]
    \def\colspace{1.2}
    \def\rowspace{1.5}
    \node[inner color=purple!50!blue!20!white,outer color=white] (P0) at (2*\rowspace, 2*\colspace) {$Arr\otimes Arr$};
    \node[inner color=purple!50!blue!20!white,outer color=white] (P1) at (1*\rowspace, 1*\colspace) {$Arr$};
    \node[inner color=purple!50!blue!20!white,outer color=white] (P2) at (3*\rowspace, 1*\colspace) {$Arr$};
    \node[inner color=blue!30!white,outer color=white] (P3) at (0*\rowspace, 0*\colspace) {$Ob$};
    \node[inner color=blue!30!white,outer color=white] (P4) at (2*\rowspace, 0*\colspace) {$Ob$};
    \node[inner color=blue!30!white,outer color=white] (P5) at (4*\rowspace, 0*\colspace) {$Ob$};
    \node (P0b) at (2*\rowspace, 1.7*\colspace) {\rotatebox[origin=c]{180}{ $\mathbf{\widehat{}}$}};

    \path[commutative diagrams/.cd,every arrow, every label]
        (P0) edge node {} (P1)
        (P0) edge node {} (P2)
        (P1) edge node[swap] {$dom$} (P3)
        (P1) edge node[swap] {$cod$} (P4)
        (P2) edge node[swap] {$dom$} (P4)
        (P2) edge node[swap] {$cod$} (P5)
\end{tikzpicture}
@BartoszMilewski
Copy link
Collaborator

In principle, I like TikZ. In this case I would get rid of the coloring and try to come up with a better symbol for pullback. In normal orientation, a pullback can be written like this:
\begin{tikzcd}
a
\arrow[r, "f"]
\arrow[d, "g"']
\arrow[rd, phantom, "\lrcorner", very near start]
& b
\arrow[d, "k"] \
c
\arrow[r, "j"]
& d
\end{tikzcd}
but I don't know how to rotate it 45 deg.

@mseri
Copy link
Contributor

mseri commented Sep 12, 2019

FWIW at the time of doing the other diagrams in Tikz, there was a discussion that ended with an agreement to leave all the diagrams with hand drawn colora out to preserve their unique feel and style.

@XVilka
Copy link

XVilka commented Sep 12, 2019

The second variant is clearly better.

@platipo
Copy link
Author

platipo commented Sep 12, 2019

In this case I would get rid of the coloring and try to come up with a better symbol for pullback.

In the more complex case I resolved the issue via \rotatebox[origin=c]{-45}{$\lrcorner$}

fixed-TikZ-diagram-complex

FWIW at the time of doing the other diagrams in Tikz, there was a discussion that ended with an agreement to leave all the diagrams with hand drawn colora out to preserve their unique feel and style.

I would gladly do it, there are only 35 diagrams in the whole book!

@BartoszMilewski
Copy link
Collaborator

Esthetically, it doesn't look as good as the original. I can't put my finger on it though.

@platipo
Copy link
Author

platipo commented Sep 13, 2019

What could be done to improve the diagram? What is it missing from the original one?

@platipo
Copy link
Author

platipo commented Sep 13, 2019

Removed the colors this is how it appears in the book:

TikZ-page

and this is the original:

original-page

@XVilka
Copy link

XVilka commented Sep 13, 2019

This way it looks more professional, indeed. But the point of highlighting the Arr is lost. Maybe use the bold font for this?

@platipo
Copy link
Author

platipo commented Sep 13, 2019

I tried some alternatives:

  • Coloured colored

  • Various bold style, just for testing (for clarity I added the bold style in gray)
    bold

  • Both the previous solutions (bold styles order is preserved) bold-colored

  • Single bold style (\symbf)
    singleBold

  • For completeness, colored and single bod style
    colored-singleBold

@BartoszMilewski
Copy link
Collaborator

I like the simplest one (no color, no bold) best. Go ahead and make the change.

@platipo
Copy link
Author

platipo commented Sep 13, 2019

Do you prefer to embed \tikzpictures instead of \includegraphics or to write external \tikzpictures and insert them with \input?

@BartoszMilewski
Copy link
Collaborator

Igal, what do you think?

@platipo
Copy link
Author

platipo commented Sep 14, 2019

Using the \input seems more organized to me, but since all the chapters are included with \subfile relative imports don't work indeed you have to type \input{content/N.M/images/image.tizk} in file content/N.M/chapter.tex.

So I'll insert the \tikzpictures directly into chapters.

@platipo
Copy link
Author

platipo commented Oct 4, 2019

The work has started, but just to see if we all agree I made a list of all possible images to redraw:

@BartoszMilewski
Copy link
Collaborator

Some of these diagrams are just standard diagrams and can be redrawn. But a lot of them don't fit in the mold. The rule of thumb should be that the ones that look 3-dimensional, with shading and little clouds, should be left alone.

@platipo
Copy link
Author

platipo commented Oct 4, 2019

Thank you @BartoszMilewski!

I've opened a draft pull request with 17 diagrams and I'll upload others shortly.

Repository owner deleted a comment from gosciufka Jan 14, 2020
@platipo platipo closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants