1

There is this handy way of positioning anode relative to a path : I set the node sigma half-way through. but if I add a "to" component to the path, the node does not move accordingly.

How to position sigma halfway through the complete path ?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.markings,positioning}
\begin{document}

\tikzset{
  nat/.style     = {fill=white,draw,ellipse,minimum size=0.5cm,inner sep=1pt},
}
\begin{tikzpicture} -- OK
  \draw (0,4) -- (0,2)
      node[pos= 0.5,nat] (s) {$\sigma$}
      node[pos=0,above] {$k$};
\end{tikzpicture}

\begin{tikzpicture} -- NOT OK
  \draw (0,4) -- (0,2) to[out=-90, in=90]  (2,0)
      node[pos= 0.5,nat] (s) {$\sigma$}
      node[pos=0,above] {$k$};
\end{tikzpicture}
\end{document}

OK enter image description here

Not ok enter image description here

Hackish correct :

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.markings,positioning,decorations.text}
\begin{document}
\tikzset{
  nat/.style     = {fill=white,draw,ellipse,minimum size=0.5cm,inner sep=1pt},
}

\begin{tikzpicture}
  \draw(0,4) -- (0,2) to[out=-90, in=90]  (2,0)
      node[pos=0,above] {$k$};
  \draw[draw=none] (0,2) -- (2,0)
      node[midway,nat] (s) {$\sigma$};
\end{tikzpicture}
\end{document}

enter image description here

nicolas
  • 329
  • 1
    Related, but not fully answering the question: https://tex.stackexchange.com/questions/235360/how-can-i-set-the-position-of-text-along-path-in-tikz-more-precisely – Torbjørn T. Jun 19 '17 at 09:20

1 Answers1

3

Changing at position 0.5 you can choose whichever position you want.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.markings,positioning}
\begin{document}

\tikzset{
  nat/.style     = {fill=white,draw,ellipse,minimum size=0.5cm,inner sep=1pt},
}

\begin{tikzpicture}
  \draw[postaction={decorate, decoration={markings,mark=at position 0.5 with {\node[nat] {$\sigma$};}}}]
 (0,4) node[above] {$k$} -- (0,2) to[out=-90, in=90] (2,0);
\end{tikzpicture}

\end{document}

enter image description here

CarLaTeX
  • 62,716