17

I like arrowheads in my TikZ diagrams to match the math font arrowheads. For Computer Modern, this is no problem: the TikZ arrows library provides matching arrowheads.

But I often use other fonts that have very different arrowheads. Now, I can (and have) defined new PGF arrow tips that approximate the font arrowheads. But I thought a more elegant and general solution when using a unicode math font would be to use the arrowheads that should be available at U+2303 ("UP ARROWHEAD") and U+2304 ("DOWN ARROWHEAD").

Here is my first attempt at defining such an arrowhead:

\documentclass{article}

\usepackage{unicode-math}
\setmathfont{Asana Math}

\usepackage{tikz}

\pgfarrowsdeclare{mathfont to}{mathfont to}
{
  \pgfarrowsleftextend{0\pgflinewidth}
  \pgfarrowsrightextend{0\pgflinewidth}
}
{
  \pgfpathmoveto{\pgfpointorigin}
  \pgftext[rotate=90,bottom]{$\char"2304$}
}

\tikzset{
  >=mathfont to,
}

\begin{document}
Test:
\begin{tikzpicture}
%
\draw[->] (1,0)--(2,0);
\draw[->] (1,0.5)--(1,1.5);
%
\end{tikzpicture}
\end{document}

My expectation was that this arrowhead definition would place the bottom of the down arrowhead symbol (more or less where the tip of the arrowhead is) at the end of the arrow, rotated to match the direction of the arrow, as per the discussion of \pgftext in the manual -- essentially what I wanted to achieve, except for some tweaking and setting \pgfarrowsleftextend and \pgfarrowsrightextend.

The result has three problems: the bottom of the down arrowhead symbol is not in the correct place; the arrowhead symbol is unrotated; and (very strangely) it only appears next to the first of the two test arrows. These problems occur under both XeLaTeX and LuaLaTeX. (Not that I expected any difference in the output.)

Are these fixable problems, and if so, how? Or do they reflect some deep feature in the design of PGF/TikZ that makes this idea unworkable? (I can easily imagine that calling \pgftext in arrowhead code is supposed to be forbidden, like \pgfusepath.)

UPDATE: After updating the pgf package, I now get a slightly different result: the arrowhead symbol is now rotated to point to the right, but is positioned at (0,0) rather than at the ends of the arrow. I can't tell if both arrowheads are now being drawn in that position or just one.

  • I tried this as a workaround, however, that's not a solution to your question: \draw (1,0)--(2,0) node[xshift=-1pt, rotate=90]{$\char"2304$}; \draw (1,0.5)--(1,1.5) node[yshift=-1pt, rotate=180]{$\char"2304$}; – Malipivo Apr 5 '14 at 8:07
4

I dont think that an arrow type is good for this. An arrow should be "styleable" (we can set the length, the fill and draw colors, ...). For me you have to use markings for this.

Here is an example of how to do it :

\documentclass[tikz,border=10, convert=none]{standalone}
\usepackage{unicode-math}
\setmathfont{Asana Math}

\usetikzlibrary{decorations.markings}
\tikzset{
  -math/.style={
    shorten >=1.4\pgflinewidth,
    postaction=decorate,
    decoration={markings, mark=at position 1 with {
        \node[scale=1.4\pgflinewidth, xshift=-1.7pt,transform shape,rotate=90]{$\char"2304$}; }}}
}

\begin{document}
  \begin{tikzpicture}
    \draw[line width=.1pt, -math] (1,0.5)--+(45:1);
    \draw (1,0) edge[bend right,thick,red,-math] +(45:1);
  \end{tikzpicture}
\end{document}

And the result compiled with XeLaTeX is

enter image description here

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.