6

When making commutative diagrams, I prefer using tikz-cd with the arrow style=math font option, in order to let the arrow tips match that of the document font, which is kpfonts in the below MWE. That sometimes works fine and sometimes breaks, like in the below example, where the equality signs look “broken,” both on screen and print.

enter image description here

Removing the option math font yields the following. Now the equalities look just fine, but the arrow tips do not match the kpfonts arrows anymore. Can this somehow be fixed, for instance by letting the arrows use the math font option, but not the equalities? So far, I have only been able to switch the two options globally.

enter image description here

\documentclass{article}

\usepackage{amsmath,kpfonts,tikz-cd}

\tikzcdset{arrow style=math font}

\begin{document}

\begin{tikzcd}[row sep=small]
H_n(S^n)
\arrow[r,"i_*"]
\arrow[d,equal]
& H_n(X)
\arrow[r,"q_*"]
\arrow[d,equal]
&
H_n(X/S^n)
\arrow[d,equal]
\\
\mathbb{Z}
&
\mathbb{Z}/m
&
0
\end{tikzcd}

\end{document}
14
  • 2
    Actually, it turns out that on screen, the equalities in the second example have a small grey line on the bottom, which does not look very good, despite being barely visible.
    – Gaussler
    Mar 22, 2016 at 17:10
  • 1
    This is surely a rendering bug that your pdf viewer is responsible for. I guess you are using Apple's PDFkit renderer (used in preview.app, skim,…), cause those artefacts look quite familiar to me :D As far as I know there is nothing you can do about that, except using a different pdf viewer hoping it does a better job. Adobe Reader has a sharper rendering for example (accompanied with a lot of drawbacks unfortunately). The important thing is: a print won't have those grey lines!
    – JBantje
    Mar 22, 2016 at 23:39
  • The grey lines, yes. Even the breaks, although those are not specific to Apple's renderer. (I can't see the grey lines, but the breaks with math font are quite obvious and I'm not using Apple's PDFkit, for sure!)
    – cfr
    Mar 22, 2016 at 23:45
  • 1
    The grey lines are due to the fact that the “equality arrows” are made as a black rectangle with a white one over it.
    – egreg
    Mar 22, 2016 at 23:55
  • @egreg Isn’t that a very strange way to render equalities? What if the background were yellow?
    – Gaussler
    Mar 23, 2016 at 8:00

1 Answer 1

5

This is partly a rendering issue (the grey lines) and people will tell you not to worry if it prints fine. If your document is to be printed, this is OK. However, if your document will be viewed electronically, it is more of an issue.

For the arrows, the best solutions I can think of there are either to pick different fonts or to use an alternative arrow style. One way to do this would be to make the tips obviously different. The other would be to try to match the KP arrow tips.

I take it the first is straightforward. For the second, my first thought was Straight Barb:

Straight Barb

This is better than the default, I think, but a customised Stealth might be a closer match:

custom Stealth

\documentclass[tikz,multi,border=10pt]{standalone}
\usepackage{amsmath,kpfonts,tikz-cd}
\usetikzlibrary{arrows.meta}
\tikzcdset{arrow style=tikz}
\begin{document}
\tikzset{%
  >/.tip={Straight Barb[angle=90:2pt 1]}
}
\begin{tikzcd}[row sep=small]
  H_n(S^n)
  \arrow[r,"i_*"]
  \arrow[d,equal]
  & H_n(X)
  \arrow[r,"q_*"]
  \arrow[d,equal]
  &
  H_n(X/S^n)
  \arrow[d,equal]
  \\
  \mathbb{Z}
  &
  \mathbb{Z}/m
  &
  0
\end{tikzcd}
\tikzset{%
  >/.tip={Stealth[length=3pt, width=4pt, inset=1.8pt]}
}
\begin{tikzcd}[row sep=small]
  H_n(S^n)
  \arrow[r,"i_*"]
  \arrow[d,equal]
  & H_n(X)
  \arrow[r,"q_*"]
  \arrow[d,equal]
  &
  H_n(X/S^n)
  \arrow[d,equal]
  \\
  \mathbb{Z}
  &
  \mathbb{Z}/m
  &
  0
\end{tikzcd}
\end{document}
6
  • 1
    In fact, as I explicitly noted in the descripton, it is not simply a rendering issue on screen. It appears in print as well. Try printing out the page; the equality signs are clearly broken.
    – Gaussler
    Mar 23, 2016 at 7:53
  • Sorry, you're right. I was thinking of the grey lines when I wrote that.
    – cfr
    Mar 23, 2016 at 12:24
  • Is it possible to do something similar with hooked arrows? Now that I am not using the math font option anymore, the hooks on the arrows do not match those of the math font.
    – Gaussler
    May 10, 2016 at 15:22
  • @Gaussler Take a look through arrows.meta and note that most of the possibilities there can be customised. For example, the default Stealth arrow doesn't look promising, but the one I customised seemed a much better match. There are different kinds of hooks and you can customise things further to match what you need. Or at least get something closer to your desired result.
    – cfr
    May 10, 2016 at 21:37
  • @Gaussler I suggest asking a follow-up question with an example. I don't know enough about tikz-cd to really understand what you're asking just from the comments and it seems like a somewhat different, albeit related, problem. (You can link to you question here for context.)
    – cfr
    Nov 5, 2016 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .