I am trying to create a vertical timeline. After looking around I decided using tikz to draw a line and use the nodes and their labels was my best option. Now I'm thinking
\tabular
would be better... either way, I'd like to know the answer to the following problem. I am a beginner to LaTeX, so I would appreciate a lot of definitions in replies. 
After looking in the documentation I have found that the text for labels is stored in an hbox. I did not find any commands relating to the height, depth or width of an hbox, but I would assume they are the same for all boxes. I also learned the definitions of baseline (e.g. "p" the baseline is under the circle part), height (would be from top of "p" to baseline), and depth (would be from baseline to bottom of "p"). Width is self-explanatory. Is this correct?
My problem:
My problem is that the labels line-up vertically at their baseline (I think) with their respective node. My labels will be more than one line of text and I want the label to line up at the top, e.g.
Code: Select all
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\draw [cyan] (0,0) --(0,10);
\draw [fill, cyan] (0,9.75) circle [radius=0.075]{};
\node [left] (1) at (-0.25,9.75){Left side 1 };
\node [right, align=left, text width=3cm, yshift=-6ex] (1t) at (0.25,9.75) {Sample text header goes here. The text on this side will be multiple lines long};
\end{tikzpicture}
\end{document}
\yshift
is indeed what I want to do, I don't want to play a guessing game for each hbox (and to be honest, I just hate the way that code looks). Instead, I would like to yshift the hbox negatively by it's height. I thought I found a solution to this problem in another forum post, here:Code: Select all
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[baseline={([yshift={-\ht\strutbox}]current bounding box.north)},outer sep=0pt,inner sep=0pt];
\draw [cyan] (0,0) --(0,10);
\draw [fill, cyan] (0,9.75) circle [radius=0.075]{};
\node [left] (1) at (-0.25,9.75){Left side 1 };
\node [right, align=left, text width=3cm] (1t) at (0.25,9.75) {\strut Sample text header goes here. The text on this side will be multiple lines long};
\end{tikzpicture}
\end{document}
\strutbox
as a command; as you can see the hbox is lined up at, what I assume is, it's baseline. And after searching for days I have no idea what current bounding box
actually is. In the second example I am not thrown any errors, however \ht\strutbox
is hightlighted orange. I am using TeXstudio in Windows. After learning that the text is stored in an hbox, I changed the above code to reflect that, e.g.
yshift={-\ht\hbox}
, but to no avail. Here though, I am actually thrown an error: "Missing number, treated as zero." on the \end{tikzpicture}
line.In short: Can I have
\tikzpicture
determine the height of each hbox and define a dynamic yshift based on this result? I feel like variables need to be defined... but I'm sure there is a simpler way. Like I said, I'm a beginner!
