Graphics, Figures & Tablespgf/tikZ | Rotated Text

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
dheanes
Posts: 1
Joined: Fri Jul 31, 2009 4:24 pm

pgf/tikZ | Rotated Text

Post by dheanes »

Dear All,

This is my first post on any kind of internet forum. I'm writing a report with LaTeX and would like to use TikZ for some diagrams, including a timeline with labels attached. I would like to have branches coming off the main, horizontal, line at an angle of 30deg or so, and to label each with one or two words of text PARALLEL to the branch, i.e. also rotated.

Using the following lines I can draw a timeline with an angled branch, labelled in the middle, but the text is not properly rotated:

Code: Select all

\documentclass{article}
\usepackage{tikz}

\begin{document}

% draw a timeline
\begin{tikzpicture}

% draw horizontal line
\draw (0,0) --(10,0);

% draw vertical lines
\foreach \x in {0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.
0,8.5,9.0,9.5,10.0}
\draw(\x cm,3pt) -- (\x cm,-3pt);

% put in dates
\draw (0,0) node[below=3pt] {$ 1990 $} node[above=3pt] {$ $};
\draw (2.5,0) node[below=3pt] {$ 1995 $} node[above=3pt] {$ $};
\draw (5,0) node[below=3pt] {$ 2000 $} node[above=3pt] {$ $};
\draw (7.5,0) node[below=3pt] {$ 2005 $} node[above=3pt] {$ $};
\draw (10,0) node[below=3pt] {$ 2010 $} node[above=3pt] {$ $};

% have a go at attaching lines, and rotating them
\draw [rotate around={30:(0,0)}] (0,0) -- (1.5,0) node {first paper} -- (3,0);

\end{tikzpicture}
\end{document}
I can't find any examples of rotated text in Till Tantau's "The TikZ and PGF Packages", and I can't see anything in there that I could use to tie the branch and text togther so that they can be rotated as one. Does anyone know how to make the text end up rotated?

Best,
Daniel.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

pgf/tikZ | Rotated Text

Post by localghost »

dheanes wrote:[...] I can't find any examples of rotated text in Till Tantau's "The TikZ and PGF Packages", and I can't see anything in there that I could use to tie the branch and text togther so that they can be rotated as one. Does anyone know how to make the text end up rotated? [...]
I think that Section 15.8 of the pgf/tikZ manual is very clear in that point.

Code: Select all

\documentclass{minimal}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    % draw horizontal line
    \draw (0,0) -- (10,0);

    % draw vertical lines
    \foreach \x in {0,0.5,...,10}
      \draw(\x cm,3pt) -- (\x cm,-3pt);

    % put in dates
    \foreach \x/\xtext in {0/1990,2.5/1995,5/2000,7.5/2005,10/2010}
      \draw (\x,0) node[below=3pt]{\xtext};

    % have a go at attaching lines, and rotating them
    \foreach \x/\text in {0/{First Paper},2.5/{Second Paper}}
      \draw (\x,0) -- +(30:3) node[midway,sloped,above]{\text};
  \end{tikzpicture}
\end{document}
I added a second branch just to give you a hint how to continue with other branches.


Best regards and welcome to the board
Thorsten
Post Reply