4

I am using Linux Libertine as a font, and therefore decided to typeset all mathematical formulas with newtxmath. I noticed that the package redefines the arrowheads.

However, I am also using tikz and tikzcd, which use the original arrowheads.

I slightly prefer the original arrowheads with their curly tips. Is there a way to redefine all arrows, but keeping the math font from newtxmath otherwise?

I checked in the documentation of the package, but couldn't find anything like that...

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usepackage[libertine]{newtxmath}

\begin{document}
$A\to B,  a\mapsto b$

\begin{tikzcd}A\arrow[r] & B \end{tikzcd}
\end{document}

Arrow heads with newtxmath

  • Are you familiar with the old-arrows package? (Load it after newtxmath.) – Mico Apr 9 at 7:55
  • One thing you always can do (I think) is to import the standard arrows one by one using this post. Hopefully there is some better way. – user194703 Apr 9 at 7:57
4

To get curly-shaped arrowheads while using the newtxmath package, you may want to load the old-arrows package.

The following screenshots show the output of an MWE without and with the old-arrows package loaded.

enter image description here enter image description here

\documentclass[border=2pt]{standalone}
\usepackage{newtxtext}
\usepackage[libertine]{newtxmath}
%\usepackage{old-arrows} % uncomment as desired
\begin{document}
$A\to B$, $a\mapsto b$, $c\gets d$, $u\leftrightarrow v$
\end{document}

Addendum: Just for completeness, here are a couple of screenshots that show the effect that loading the old-arrows package has if no font package is loaded, i.e., if the Computer Modern font is employed. The main effect is a noticeable reduction in the size of the arrowheads (back to their pre-1992 sizes, according to the user guide of the old-arrows package).

enter image description here enter image description here

\documentclass[border=2pt]{standalone}
%\usepackage{old-arrows} % uncomment as desired
\begin{document}
$A\to B$, $a\mapsto b$, $c\gets d$, $u\longleftrightarrow v$
\end{document}
| improve this answer | |
  • Hi @Mico, this works great! Did you notice that newtxmath also changes the size of the arrowheads in tikz? Somehow, they got bigger, which cannot be altered by old-arrows, apparently. – Lukas Apr 9 at 8:10
  • @Lukas - I'm afraid I'm not all that familiar with tikz. It should be noted that while the old-arrows package manages to reintroduce curly-tipped arrowheads, the size of the arrowheads is also reduced somewhat. – Mico Apr 9 at 8:13
  • 1
    Ah ha! That must mean they give really old arrows, imitating early Computer Modern arrows from before DEK enlarged the arrowheads (without altering the character bounding boxes, so the new arrows hang out of the box). I liked the originals more. – Donald Arseneau Apr 9 at 9:30
  • @DonaldArseneau - Indeed, the arrowheads produced by the old-arrows package are those from pre-1992. Like you, I prefer the older, smaller arrowheads. :-) – Mico Apr 9 at 9:44
4

Here is how you can adjust the arrows in tikz-cd, regardless of whether or not you load old-arrows (as suggested in Mico's answer). tikz-cd comes with the option to get the arrow head from a glyph. So we can just use the rightarrow glyph to get

\documentclass{article}
\usepackage{newtxtext}
\usepackage[libertine]{newtxmath}
\usepackage{tikz-cd}
\usepackage{old-arrows} % uncomment as desired
\tikzset{
math to/.tip={Glyph[glyph math command=rightarrow]}}
\begin{document}
$A\to B,  a\mapsto b$

\begin{tikzcd}
A\arrow[r,-math to] & B \end{tikzcd}
\end{document}

enter image description here

When you comment out the \usepackage{old-arrows}

enter image description here

What if you wish to install this globally for "ordinary" arrows? Just redefine the rightarrow style.

\documentclass{article}
\usepackage{newtxtext}
\usepackage[libertine]{newtxmath}
\usepackage{tikz-cd}
%\usepackage{old-arrows} 
\tikzset{
math to/.tip={Glyph[glyph math command=rightarrow]}}
\tikzcdset{rightarrow/.code={\pgfsetarrows{tikzcd cap-math to}}}

\begin{document}
$A\to B,  a\mapsto b$

\begin{tikzcd}
A\arrow[r] & B \end{tikzcd}
\end{document}

You can emulate more and more of these arrows. This essentially amounts to copying the code from tikzlibrarycd.code.tex and replacing the arrow heads as described above. Here are a few more.

\documentclass{article}
\usepackage{newtxtext}
\usepackage[libertine]{newtxmath}
\usepackage{tikz-cd}
%\usepackage{old-arrows} 
\tikzset{
ambient rightarrow/.tip={Glyph[glyph math command=rightarrow]},
ambient Rightarrow/.tip={Glyph[glyph math command=Rightarrow]},
}

\tikzcdset{ambient arrows/.code={
\tikzcdset{rightarrow/.code={\pgfsetarrows{tikzcd cap-ambient rightarrow}},
  Rightarrow/.code={\tikzcdset{double line}\pgfsetarrows{tikzcd implies cap-ambient Rightarrow}},
  leftarrow/.code={\pgfsetarrows{ambient rightarrow-tikzcd cap}},
  Leftarrow/.code={\tikzcdset{double line}\pgfsetarrows{ambient Rightarrow-tikzcd implies cap}},
  leftrightarrow/.code={\pgfsetarrows{ambient rightarrow-ambient rightarrow}},
  Leftrightarrow/.code={\tikzcdset{double line}\pgfsetarrows{ambient Rightarrow-ambient Rightarrow}},
  mapsto/.code={\pgfsetarrows{tikzcd bar-ambient rightarrow}},
  mapsfrom/.code={\pgfsetarrows{ambient rightarrow-tikzcd bar}},
  Mapsto/.code={\tikzcdset{double line}\pgfsetarrows{tikzcd implies bar-ambient Rightarrow}},
  Mapsfrom/.code={\tikzcdset{double line}\pgfsetarrows{ambient Rightarrow-tikzcd implies bar}},
  }}}
\begin{document}
$A\to B,  a\mapsto b,C\Rightarrow D$

\begin{tikzcd}[ambient arrows]
A\arrow[d,mapsto]\arrow[r] & B \\
C & \arrow[l,Rightarrow] D\arrow[u,Rightarrow]
\end{tikzcd} 
\end{document}

enter image description here

One should, however, also mention that, while these glyphs are really great, they are not perfect nor quite as versatile as the arrows from arrows.meta. So you should not expect to be able to bend them arbitrarily and your may find viewer-dependent glitches. If you want this, then you probably need to declare arrow heads on your own. This is not particularly difficult but somewhat tedious. For details look up \pgfdeclarearrow in the pgf manual (and look for posts using this command). (Ironically a couple of hours ago I believe to have found that the Implies arrow head might be somewhat less versatile than one may think it is.)

| improve this answer | |
  • Very kind. If you do a zoom in the last image there are the little edges (the color is gray peraphs). This is a "famous" problem between tikz-cd and tikz: tex.stackexchange.com/questions/535921/…. – Sebastiano Apr 9 at 11:22
  • 2
    @Sebastiano Yes, they are. They are also viewer dependent. The reason is basically that a double line is not a double line but a thicker black line with a somewhat thinner while line on top. The arrow heads have additional, viewer dependent problems. There is not too much one can do at this point. – user194703 Apr 9 at 11:25
  • Don't worry +1...Is there somebody that can solved the problem between two packages? – Sebastiano Apr 9 at 11:31
  • 1
    @Sebastiano I think in some years from now viewers will get even better, computers faster, and new decorations in TikZ or a successor will solve this problem, either in LaTeX or a successor thereof. – user194703 Apr 9 at 11:33
0

Following Schrödinger's cat's suggestion, I designed an arrowhead very similar to the arrowhead of \to in [libertine]newtxmath using the command \pgfdeclarearrow. In the example, I included an overlay of the custom arrowhead with \to in order to compare the two. You can tell that they are very similar, yet not precisely the same.


\usepackage[libertine]{newtxmath}

\usepackage{tikz}
\usepackage{tikz-cd}

% Declaration of the new arrowhead
\pgfdeclarearrow{
name = newtxlibertine-right-style,
setup code = {
% The different end values:
\pgfarrowssettipend{0pt}
\pgfarrowssetlineend{-.3pt}
\pgfarrowssetvisualbackend{-0.85pt}
\pgfarrowssetbackend{-2.28pt}
% The hull
\pgfarrowshullpoint{0pt}{0pt}
\pgfpathlineto{\pgfqpoint{-1.97pt}{2.04pt}}
\pgfpathlineto{\pgfqpoint{-2.28pt}{1.71pt}}
\pgfpathlineto{\pgfqpoint{-2.28pt}{-1.71pt}}
\pgfpathlineto{\pgfqpoint{-1.97pt}{-2.04pt}}
},
% Drawing of the arrow tip
drawing code = {
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{-1.97pt}{2.04pt}}
\pgfpathlineto{\pgfqpoint{-2.28pt}{1.71pt}}
\pgfpathlineto{\pgfqpoint{-0.85pt}{0pt}}
\pgfpathlineto{\pgfqpoint{-2.28pt}{-1.71pt}}
\pgfpathlineto{\pgfqpoint{-1.97pt}{-2.04pt}}
\pgfpathclose
\pgfusepathqfill
}
}

% Setting this arrowhead as standard for every diagram
% Setting line width that fits the \to arrow
\tikzset{
every picture/.style={>=newtxlibertine-right-style,line width=0.56pt}
}
\tikzcdset{arrow style = tikz}

\begin{document}~\\
\begin{tikzcd}
A\arrow[r]& B
\end{tikzcd}

$A\to B$

$A$\begin{tikzpicture}
\filldraw[help lines,step=1pt,line width=0.1pt]  (0pt,-5pt) grid (10pt,5pt);
%\draw (4.5pt,4.7pt) node {$\to$};
\draw [->] (0,0) -- (9pt,0);
\draw[red] (4.5pt,-0.305pt) node {$\to$};
\end{tikzpicture}$B$

\end{document}

Custom arrowhead in the style of newtxmath libertine

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.