24

Here is my problematic code:

\begin{tikzpicture}
\draw  (0,0)  to [bend left=20] (3,3) node[midway] {midway label};
\end{tikzpicture}

I wanted to put a label midway of the line, but instead the label is at (0,0).

If I remove [bend left=20], the line is not bent, and the label still misplaced. If I remove to and replace it by --, then it works fine, but my line is not bent any more.

\begin{tikzpicture}
\draw (0,0) -- (3,3) node[midway] {midway label};
\end{tikzpicture}

Works fine.

The problem occurs with MacTeX 2011 and MacTeX 2012.

  • Hi Loick, welcome to TeX.sx! It's generally preferred to post full compilable examples instead of just snippets. And a tip: Inline code (like the [bend left=20] in your post) can be formatted by enclosing them in backticks. – Jake Jul 22 '12 at 9:29
30

You should move node[midway] {midway label} before the last coordinate.

Some examples:

\documentclass[11pt,a4paper]{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw  (0,0)  to [bend left=20] node[midway] {midway label}(3,3) ;
\draw[xshift=4cm]  (0,0)  to [bend left=20] node[midway,left] {midway label}(3,3) ;
\draw[xshift=6cm]  (0,0)  to [bend left=20] node[midway,right] {midway label}(3,3) ;
\end{tikzpicture}

\begin{tikzpicture}
\draw  (0,0)  to [bend left=20] node[sloped,midway,above] {midway label}(3,3) ;
\end{tikzpicture}
\end{document}

enter image description here

16

You can also use the pos=<value from 0 to 1> key (see manual section 16.8) to specify where on your curve the node should be. A little example illustrating this for 0.1 increments from 0 to 1:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm,landscape]{geometry}
\usepackage{tikz}

\begin{document}

\foreach \x in {0,0.1,...,1}
{   \begin{tikzpicture}[scale=0.2]
    \draw  (0,0)  to [bend left=20] node[pos=\x,fill=red,circle,inner sep=2pt] {} (3,3) ;
    \end{tikzpicture}
}

\end{document}

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.