Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I think it is a simple question, but I didn't find the answer yet. The code I'm using is the following:

\draw[->](1,0) arc(0:-30:1) node[midway]{$30$};

But in this way the node is placed at the origin intead of at the middle of the arc.

Note: it must be done with arc.

share|improve this question

4 Answers 4

As of 2012-03-01, thanks to Till Tantau, it is now possible to do it straightforwardly with the cvs version of pgf-tikz.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \draw[->](1,0) arc(0:-30:1) node[midway]{$30$};
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
What exactly means csv version - does this mean this option is going to become official at one point? –  Pygmalion Mar 23 '13 at 7:25
    
@pygmalion yes. The CVS version is the development version that will become one day the official one. –  cjorssen Mar 23 '13 at 10:11
    
Thank you for your answer. Since you are already acknowledged with the CSV version, is it possible to make node in the middle of the arc, but on left or right side of it? Like [midway] and [midway,swap] when driving lines? If not, I will open request on TikZ development. –  Pygmalion Mar 23 '13 at 19:00
    
I am sorry for bothering again, but I still don't understand. Last official version is 2.10, dated 2012-08-19, which is beyond the time you mentioned above. And this version still does not provide [midway] solution for the arcs. Am I missing something? I just don't get it. –  Pygmalion May 29 '13 at 11:27
    
@Pygmalion You need the cvs version (that is the devel version) of tikz. It's been a long time since the last official release. For the installation, see this answer. –  cjorssen May 29 '13 at 19:02

The reason why it is shown at the origin is because there is no explicit second coordinate for TikZ to interpolate via pos. One solution is to, roughly speaking, parameterize the arc path via markings library. This is simply a modification of my previous answer for marking a path with a node.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[
arcnode/.style 2 args={                
            decoration={
                        raise=#1,             
                        markings,   
                        mark=at position 0.5 with { 
                                    \node[inner sep=0] {#2};
                        }
            },
            postaction={decorate}
}
]
\draw[->, arcnode={20pt}{$30$} ] (0,0) arc (0:-30:2cm) ;
\end{tikzpicture}
\end{document}

labelled curve with offset label

For some reason, when the curved paths become too short(e.g. your example path starts working after 1.095cm for radius of the arc) it gives a Dimension too large error, so probably, there is a detail that I don't know yet here. This is not the case for straight paths.

share|improve this answer
    
When the curved paths become too short, there is a problem with pgfmath see tex.stackexchange.com/questions/20833/… –  Alain Matthes Dec 19 '11 at 11:03
    
@Altermundus Ouch! I remember reading your discussion on your question but forgot it completely. Thanks, for the reminder. I guess there is no easy way out for this. –  percusse Dec 19 '11 at 11:14
    
But is there anyway to have it push out a given radius away from the curve? –  Richard Jun 9 '12 at 6:53
    
@Richard You can use above,leftetc. options in the node to take it out of the curve but I'm not sure if I understand your question. Can you explain it a little more, if possible? If the comment box is not sufficient for it, post a new question and we can have look at it together. –  percusse Jun 9 '12 at 9:19

Problem taken from: Draw centered label above arc in TikZ


This is another approach to this problem. In this way, there is another second coordinate.

\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\begin{tikzpicture}
    \draw[green] (1,0) arc[radius = 1, start angle=0, end angle=90] node[above] {H} arc[radius = 1, start angle=90, delta angle=90];
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Wonder if there is a way to not have to repeat most of the info for the node. –  Peter Grill Oct 12 '12 at 0:48
    
@PeterGrill I tried putting all between the from arc to ; in a macro but it breaks with a lot of Missing character: There is no [ in font nullfont!. The full TikZ command is possible, but then it's an isolated path. –  Qrrbrbirlbel Oct 12 '12 at 0:56
    
Might work better as a style, but I don't have enough experience to do those, especially since this one would require a parameter. Something like @percusse's solution here of using an arcnode. Anyway, this something I need to learn so was just thinking about it. –  Peter Grill Oct 12 '12 at 1:05

Major newbie here but here is the way I did it. I was drawing arcs centered at the origin but seems like it should work for others too.

\draw (0.3,0) arc (0:30:0.3) node at (15:0.5) {$\varphi$};
share|improve this answer
5  
Hi bjd, welcome to the site! That's a nice and pragmatic approach (+1), but I think the question was concerned with finding an automatic way to place the node. By the way, you can format code snippets in a post by selecting the text and then clicking the {} button in the editor. Looking forward to seeing you around the site! –  Jake Jul 25 '13 at 22:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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