5

In equations (2) and (3), both of which use TikZ, how do I get the arrow tips to be the same as those produced as in equation (1) by the math font in use?

\documentclass[12pt]{article}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta,decorations.markings}

\usepackage{newtxtext,newtxmath}

\begin{document}

\begin{equation}    % eq 1
  A \longrightarrow B \rightarrow C
\end{equation}
%
\begin{equation}    % eq 2
  \begin{tikzcd}
    A \arrow[r]{$f$} & B
  \end{tikzcd}
\end{equation}
%
\begin{equation}    % eq 3
  \begin{tikzpicture}[
      middlearrow/.style 2 args={
          thick,
          decoration={
              markings, 
              mark=at position 0.5 with {\arrow{>}, \node[#1]{#2};}
          },
          postaction={decorate}
      },
  ]
  \draw[middlearrow={below}{$\sigma$}]  (0,0) -- (2,0);
  \draw[thick,->=-latex] (0, -1) -- (2, -1);
  \end{tikzpicture}
\end{equation}

\end{document}

[![Want TikZ arrow tips to match tips of math font's arrows][1]][1]

Note: I am not asking the reverse question! That is, I am not asking how to modify the arrows produced by \rightarrow, etc., to match those produced by TikZ.

Addition: I have the same question — just about matching the arrow heads, not about the syntax — but for using TeX Gyre Termes Math font (with XeLaTeX) instead of newtxmath. See: How make TikZ arrow tips match arrows with TeX Gyre Termes Math font? [1]: https://i.sstatic.net/bfm2P.png

1
  • @JohnKormylo: Please tell me the exact syntax for specifying that arrow style in each of the two arrows created for equation (3). [For the 2nd arrow of that, I tried \draw[thick,->=-Straight Barb] (0, -1) -- (2, -1); but get no change! And I haven't a clue to the correct syntax to get it in the middlearrow construction.]
    – murray
    Commented Oct 2, 2020 at 16:33

2 Answers 2

2

If you set in the preamble:

\tikzset{>=Straight Barb, commutative diagrams/arrow style=tikz}

you say to TikZ which arrows to use by default, and to tikz-cd to follow that decision.

You then remove all specific diagram styles and you obtain this:

enter image description here

Code:

\documentclass[12pt]{article}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta,decorations.markings}

\usepackage{newtxtext,newtxmath}

\tikzset{>=Straight Barb, commutative diagrams/arrow style=tikz}
\begin{document}

\begin{equation}    % eq 1
  A \longrightarrow B \rightarrow C
\end{equation}
%
\begin{equation}    % eq 2
  \begin{tikzcd}
    A \arrow[r]{$f$} & B
  \end{tikzcd}
\end{equation}
%
\begin{equation}    % eq 3
  \begin{tikzpicture}[
      middlearrow/.style 2 args={
          thick,
          decoration={
              markings, 
              mark=at position 0.5 with {\arrow{>}, \node[#1]{#2};}
          },
          postaction={decorate}
      },
  ]
  \draw[middlearrow={below}{$\sigma$}]  (0,0) -- (2,0);
  \draw[thick,->] (0, -1) -- (2, -1);
  \end{tikzpicture}
\end{equation}

\end{document}


4
  • This answered all my questions about the matter, thank you! You forgot to include the \tikzset command in the code you show. Also, the =-latex phrase should now be omitted from the final \draw once the globael \tikzset command has been included.
    – murray
    Commented Oct 2, 2020 at 17:14
  • Pasted wrong buffer ;-) --- now it's ok
    – Rmano
    Commented Oct 2, 2020 at 17:23
  • Probably you should apply @Zarko idea too to use [scale=0.8] to match sizes...
    – Rmano
    Commented Oct 2, 2020 at 17:30
  • Yes, [scale=0.8]
    – murray
    Commented Oct 2, 2020 at 19:42
4

it seems that to rightarrow using ,newtxmath package is Straight Barb arrows:

\documentclass[12pt]{article}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta,
                decorations.markings}

\usepackage{newtxtext,newtxmath}

\begin{document}

\begin{equation}    % eq 1
  A \longrightarrow B \rightarrow C
\end{equation}

\begin{equation}    % eq 2
\tikzcdset{
arrow style=tikz,
diagrams={>={Straight Barb[scale=0.8]}}
          }
  \begin{tikzcd}
A \ar[r]{$f$} & B
  \end{tikzcd}
\end{equation}
%
\begin{equation}    % eq 3
  \begin{tikzpicture}[>={Straight Barb[scale=0.8]},
      middlearrow/.style 2 args={
          thick,
          decoration={
              markings,
              mark=at position 0.5 with {\arrow{>}, \node[#1]{#2};}
          },
          postaction={decorate}
      },
  ]
  \draw[middlearrow={below}{$\sigma$}]  (0,0) -- (2,0);
  \draw[thick,->] (0, -1) -- (2, -1);
  \end{tikzpicture}
\end{equation}

\end{document}

enter image description here

Edit: Tipe of arrows head you can set globaly by placing tikzset and \tikzcdset in document preamble. Foe example:

\documentclass[12pt]{article}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta,
                decorations.markings}
\tikzset{>={Straight Barb[scale=0.8]}}% if you not bear that 
                                      % arrows head hasn't equal size as in math,
                                      % just remove `scale` option
\tikzcdset{
    arrow style=tikz,
    diagrams={>={Straight Barb[scale=0.8]}}
          }

\usepackage{newtxtext,newtxmath}

\usepackage[active,tightpage]{preview}
\setlength\PreviewBorder{1em}

\begin{document}
\begin{preview}
\begin{equation}    % eq 1
  A \longrightarrow B \rightarrow C
\end{equation}

\begin{equation}    % eq 2
  \begin{tikzcd}
A \ar[r]{$f$} & B
  \end{tikzcd}
\end{equation}
%
\begin{equation}    % eq 3
  \begin{tikzpicture}[
      middlearrow/.style 2 args={
          thick,
          decoration={
              markings,
              mark=at position 0.5 with {\arrow{>}, \node[#1]{#2};}
          },
          postaction={decorate}
      },
  ]
  \draw[middlearrow={below}{$\sigma$}]  (0,0) -- (2,0);
  \draw[thick,->] (0, -1) -- (2, -1);
  \end{tikzpicture}
\end{equation}
\end{preview}
\end{document}

The result is the same as before.

Note: Let me emphasize, that this solution gives desired result if you use newtxmath fonts. At other math fonts, for example lmodern you should use Computer Modern Rightarrow[] or simple >.

2
  • That's exactly what I want. And I see how to put the \tikzset command outside the particular equation environment, so it will affect all tikzcd figures. But how can I similarly make the specification of Straight Barb to affect all tikzpicture environments?
    – murray
    Commented Oct 2, 2020 at 17:06
  • You can set arrows heads tip globally, see edited answer. Also see @Rmano answer.
    – Zarko
    Commented Oct 2, 2020 at 17:17

You must log in to answer this question.

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