18

I know that the TikZ Arrow Tip Library (arrows) defines a circle arrow [-o], however this circle is too large for me. Is there any way I can control the size of the circle on the end of line?

Corentin
  • 9,981
Pygmalion
  • 6,387
  • 4
  • 34
  • 68
  • I am interested at a solution too. What I do at this point is to define a circular node manually: \begin{tikzpicture} \def\radius{2pt} \draw (0,0) -- (1,0) node [circle,radius=\radius,draw,fill=white,inner sep=\radius] {}; \end{tikzpicture} – hpesoj626 Oct 26 '12 at 14:48
  • @Pygmalion Do you had checked the pgflibraryarrows.code.tex? If you change there the line \pgfpathcircle{\pgfqpoint{4.5\pgfutil@tempdima}{0bp}}{4.5\pgfutil@tempdima} by other with a value less than 4.5 you will obtain what you want. – rafaeldf Oct 26 '12 at 15:24
  • @rafaeldf I was thinking of that too, but I do not know where to find tikz codes. – Pygmalion Oct 26 '12 at 16:15
  • @Pygmalion Try look at ...\tex\generic\pgf\libraries inside the folder that you had selected for installation (e.g., C:\Program Files...). – rafaeldf Oct 26 '12 at 16:29
  • 2
    it would be great to see a solution using \tikzset{o=<options go here>}, similar to how one can change the arrows easily using \tikzset{>=stealth} for example – cmhughes Oct 26 '12 at 19:26
  • @cmhughes I've seen it and seems too complicated to adapt it to my problem. If everything else fails, I might start cracking the code myself. I posted the question in hope (from my previous experiences) that someone will have a solution as a piece of cake. – Pygmalion Oct 26 '12 at 21:01
  • @cmhughes: That would be nice indeed, or even better, to have a general arrow size key. I've posted a bounty to that effect at http://tex.stackexchange.com/questions/5461/is-it-possible-to-change-size-of-arrowhead-in-tikz-pgf – Jake Oct 26 '12 at 21:48

1 Answers1

17

You can use the decorations.markings library to define a style (say, o) that takes an optional argument for changing the size:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}

\tikzset{
    o/.style={
        shorten >=#1,
        decoration={
            markings,
            mark={
                at position 1
                with {
                    \draw circle [radius=#1];
                }
            }
        },
        postaction=decorate
    },
    o/.default=2pt
}
\begin{tikzpicture}    
\draw [o] (0,1) -- (4,3);
\draw [o=1pt] (1,1) -- (4,2);
\end{tikzpicture}
\end{document}
Jake
  • 232,450
  • This is not exaclty the same as [-o]. In [-o] circle touches the end of the path, while [o] draws circle on the end of the path... I know that I have to add 2* befor #1 on line 3 of the definition, but I do not know how to calculate new position... – Pygmalion Oct 29 '12 at 19:07
  • You can use shorten >=2*#1 together with \draw circle [xshift=-#1,radius=#1];. The local coordinate system is rotated, so that xshift moves the mark in the direction of the line. – Jake Oct 29 '12 at 19:31
  • Hello Jake. I don't find how to get the circles at both tips of the line. Please could you help ? – Stéphane Laurent Feb 10 '16 at 14:33
  • Sorry I get it now. Just add a new mark with position=0. Thanks! – Stéphane Laurent Feb 10 '16 at 14:46
  • One problem is, it draws two arrow tips with option -> – hola Aug 27 '17 at 10:50