2

When using the \draw let ... in syntax to construct an arc between 2 lines, the arc is placed in the correct location even if the arc's focal point isn't the origin. However, this isn't the case with the node placement.

For example, consider this code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
  \coordinate (F) at (2, 0);

  \draw (F) -- ++(30:1cm and 2cm) coordinate (A);
  \draw (F) -- ++(100:1cm) coordinate (P3);

  \draw let
      \p0 = (F),
      \p1 = (A),
      \p2 = (P3),
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
      \n3 = {1cm},
      \n4 = {(\n2 - \n1) / 2}
    in (F) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
    node[scale = .75, fill = white, inner sep = 0cm] at
    (\n4:\n3) {\(\nu_A\)};
\end{tikzpicture}
\end{document}

This produces:

enter image description here

If I xshift = 2 the node, I get:

enter image description here

I don't understand why the node placement isn't along the arc since I specified the placement at (\n4:\n3) which is half the arc angle with the same radius. That is, it should be along the arc equidistant from both lines.

If add to the node options pos = .5, the node is still not placed where one would anticipate.

enter image description here

What is the correct nodal syntax for this situation with \draw let .. in?

  • 1
    Perhaps you are trying to do this? \draw let \p0 = (F), \p1 = (A), \p2 = (P3), \n1 = {atan2(\x1 - \x0, \y1 - \y0)}, \n2 = {atan2(\x2 - \x0, \y2 - \y0)}, \n3 = {1cm}, \n4 = {(\n2 + \n1) / 2} in (F) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2] node[fill = white, inner sep = 0cm,xshift=2cm,font=\small] at (\n4:\n3) {\(\nu_A\)};. The scale option in your code affects shifting; it's better to use font= to change the font (if that was your intent in the first place). – Gonzalo Medina Jul 8 '13 at 1:18
  • 1
    Nodes do not work very good along of arcs, see How to place a node in the middle of an arc?. The coordinate (\n4:\n3) is relative to the origin of the coordinate system, not the center of the arc, you will need to use at ([shift=(F)] \n4:\n3) or (F)+(\n4:\n3) node … (while \n4 = {(\n2 + \n1) / 2} of course). – Qrrbrbirlbel Jul 8 '13 at 1:28
  • @dustin if scale is used before the shifting, then the shifting also gets scaled. If scale is used after the shifting, then the shifting is not scaled. – Gonzalo Medina Jul 8 '13 at 1:31
  • I don't know; perhaps @Qrrbrbirlbel is writing an answer already? If not, I'll do it. – Gonzalo Medina Jul 8 '13 at 1:37
  • @dustin using my xshift=2cm and his shift=(F) are basically the same (but I prefer his solution). – Gonzalo Medina Jul 8 '13 at 1:52
3

Unfortunately and as already discussed in How to place a node in the middle of an arc? nodes cannot placed along arcs. So simply using no at and adding pos=.5 (or any other position for that matter) will place the node at the origin, TikZ just doesn’t know better.

Then there are two problems in your code: Firstly you define \n4 as the half of \n2 - \n1, though the angle bisector is .5*(\n2+\n1).
Then, the node is placed at (\n4:\n3) which is an absolute coordinate is not taken in any relation to the center of the arc (F). We could use at +(\n4:\n3) here, but the last coordinate from which the relative coordinate is located is the end of the arc, but not still (F).

We need to use at ([shift=(F)] \n4:\n3) or (F) +(\n4:\n3) node … here (→ TikZ: trouble with node placement when I want to reference from a point other than the origin).

As already commented by Gonzalo Medina in his comment it is always better to use font to change the font-size of the nodes text instead of the scale option.

You are also already familiar with the decorations.markings library which might be preferable in different cases.

Code

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{calc,decorations.markings}
\begin{document}
\begin{tikzpicture}
  \coordinate (F) at (2, 0);

  \draw (F) -- ++(30:1cm and 2cm) coordinate (A);
  \draw (F) -- ++(100:1cm) coordinate (P3);

  \draw let
      \p0 = (F),
      \p1 = (A),
      \p2 = (P3),
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
      \n3 = {1cm},
      \n4 = {(\n2 + \n1) / 2}
    in (F) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
    node[fill = white, inner sep = 0cm, font=\small] at ([shift=(F)] \n4:\n3) {\(\nu_A\)}
%    [decoration={name=markings,mark=at position .5 with {\node [inner sep=+0cm,font=\small,fill=white] {$\nu_A$};}},postaction=decorate]
   ;
\end{tikzpicture}
\end{document}

Output

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.