2

I want to draw a curved line and put a tensor above and below a node on it, something like this: enter image description here

I tried this:

\documentclass{scrartcl}
\usepackage{tensor}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=0.8]

\draw[line width=4pt] (0,0) ..controls (2,2) and (5,-1) .. (10,2); node[pos=0.5,below right, inner xsep=-1ex] {$\tensor{g}{_a_b}$} \end{tikzpicture}

\end{document}

I know that I'm mixing it up with something else, but I do not enough time. Thanks!

Astrolabe
  • 265

1 Answers1

4

I'm surprised that even worked. You're ending the \draw path with the semicolon before you add the node. Move the semicolon to after the node and it's fine.

\documentclass{scrartcl}
\usepackage{tensor}    
\usepackage{tikz}    
\begin{document}    
\begin{tikzpicture}    
\draw[line width=4pt] (0,0) ..controls (2,2) and (5,-1) .. (10,2)
    node[pos=0.5,below] {$\tensor{g}{_a_b}$} ;
\end{tikzpicture}
\end{document}

Something closer to your sketch:

enter image description here

\documentclass{scrartcl}
\usepackage{tensor}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[line width=2pt] (0,0) ..controls (2,2) and (5,-1) .. (10,2)
    node[fill,circle,minimum size=8pt,inner sep=0pt,pos=0.4,label=below:{$\tensor{g}{_a_b}$},label=above:{$t=0$}] {}
    node[fill,circle,minimum size=8pt,inner sep=0pt,pos=0.8,label=below:{$\tensor{g}{_a_b}$},label=above:{$t$}] {};
\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688
  • Thanks a lot. But I do not understand "minimum size=4pt". That has no influence on result. – Astrolabe Oct 08 '15 at 21:45
  • @H.B. Sorry, a small glitch on my side. It does have an effect, for sufficiently large values. However, by default you have an inner sep that is larger (0.333em), so the node will be larger than 4pt anyway. In the updated code I set the inner sep to zero, making this more predictable. – Torbjørn T. Oct 08 '15 at 21:49