4

Possible Duplicate:
How to place a node in the middle of an arc?

A very common problem I come across drawing technical pictures is drawing zillions of angles. In general, there is no nice way to put a node to an arc, so I usually have to do this

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (0:2cm);      %rays
\draw (0,0) -- (60:2cm);

\draw (1cm,0) arc (0:60:1cm); % angle
\draw (30:1cm+20pt) node {$\alpha$};
\end{tikzpicture}
\end{document}

I wonder if there is a way to simplify last two commands. Of course I could define a \newcommand{\angle}[4] which looks very awkward. I would rather use something like that

\draw (1cm,0) arc (0:60:1cm) node[outarc=20pt] {$\alpha$};

Is it possible to define "outarc" position of the node?

enter image description here

Pygmalion
  • 6,387
  • 4
  • 34
  • 68
  • Could you add a picture of what you would like outarc to do? – Andrew Stacey Aug 17 '12 at 13:01
  • This is fixed in the CVS version. See this question and cjorssen's answer : http://tex.stackexchange.com/questions/38763/how-to-place-a-node-in-the-middle-of-an-arc – percusse Aug 17 '12 at 13:31
  • @percusse a) what means CVS version? b) Is it possible to put node by certain length away or toward the center of arc? cjorssen's answer only concerns midway. – Pygmalion Aug 17 '12 at 13:37
  • a) CVS version is the development version of the upcoming release so it's the beta version if you like. You can find it in here. b) You can also add above=1cm or pos=0.3 etc. for relative positioning with respect to the arc. – percusse Aug 17 '12 at 13:48
  • @AndrewStacey I've added picture. I want node to be put in the middle of the arc, for user-specified distance from the arc. – Pygmalion Aug 17 '12 at 13:49
  • I just tried this in the CVS version. It isn't quite as automatic as one might like. If I did node[midway,auto] {\(\alpha\)} then the node is a bit above where I would want it as it chooses the south-west anchor. To get a better position, I found that node[midway,anchor=195] was good (note that this is the correct angle). Would an answer that only works with the CVS version of PGF be acceptable? – Andrew Stacey Aug 17 '12 at 13:58
  • @AndrewStacey I have no idea how to install CVS version in the first place. Maybe I should wait for changes to become official (after drawing thousand of angles I could make yet another hundred) and I repost the question? – Pygmalion Aug 17 '12 at 14:05
  • Requiring a non-CVS solution is perfectly acceptable (I just installed the CVS version to try out the answer to this question, in fact) since it is often a while between official releases, but given that it is an upcoming feature you should explicitly say you'd rather not download the CVS. – Andrew Stacey Aug 17 '12 at 14:07
  • @AndrewStacey If it is not too much trouble I'd prefer not to install CVS (even if I knew how). – Pygmalion Aug 17 '12 at 14:09
  • Then use my answer in the question and add raise=20pt option to the decoration. So the line should read decorate={raise=20pt, – percusse Aug 17 '12 at 14:12
  • @percusse but then you cannot user-define distance from angle to angle, right? – Pygmalion Aug 17 '12 at 14:19
  • Let me cook up an example. – percusse Aug 17 '12 at 14:20
  • I just had a go at this and found that my answer was exactly the same as @percusse's in the linked question - so I now think that this should be closed as a duplicate of that and percusse's answer there modified to add the "lift". – Andrew Stacey Aug 17 '12 at 14:24
  • To make the lift configurable, simply define it as .style 2 args and pass the lift as another argument to the style. – Andrew Stacey Aug 17 '12 at 14:25
  • @percusse ... which I've taken the liberty of doing – Andrew Stacey Aug 17 '12 at 14:29
  • @AndrewStacey Oh, great! Is it possible to define arcnode globally (not only for the specific tikzpicture)? – Pygmalion Aug 17 '12 at 14:32
  • @AndrewStacey Oh thanks, perfect timing for me to get stuck on the phone :) – percusse Aug 17 '12 at 14:32
  • @Pygmalion Yes, of course! Simply shift that whole chunk into a \tikzset{arcnode/.style 2 args={...}}. Incidentally, sometimes the offset is negative. – Andrew Stacey Aug 17 '12 at 14:34
  • @Pygmalion Are you now happy to have this closed as a duplicate? (If so, I'll flag it for mod or mention it in chat to do the house-keeping quickly) – Andrew Stacey Aug 17 '12 at 14:34
  • @AndrewStacey I agree. Is it OK to start a new question when new version of TikZ becomes official? – Pygmalion Aug 17 '12 at 15:18
  • @Pygmalion Of course - follow-up questions are always okay. Sometimes it's appropriate to modify the original, but that's easier to determine at the time than lay down a general rule. – Andrew Stacey Aug 17 '12 at 15:31

0 Answers0