Need help with a timeline using Tikz

tikz-pgftimeline

I am new to LaTeX and TikZ.

I need to draw a timeline with text written in different colors representing different parallel steps of my project.

Here's my code:

\documentclass{standalone}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[%
    every node/.style={
        font=\scriptsize,
        % Better alignment, see https://tex.stackexchange.com/questions/315075
        text height=1ex,
        text depth=.25ex,
    },
]

% draw horizontal line   
\draw[-] (0,0) -- (15,0);

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

\foreach \x in {0,5,...,15}{
    \draw (\x cm,3pt) -- (\x cm,8pt);
}

% place axis labels
\node[anchor=north] at (0,0) {Sep. 2024};
\node[anchor=north] at (2.5,0) {T3};
\node[anchor=north] at (5,0) {Sep. 2025};
\node[anchor=north] at (7.5,0) {T7};
\node[anchor=north] at (10,0) {Sep. 2026};
\node[anchor=north] at (12.5,0) {T11};
\node[anchor=north] at (15,0) {Sep. 2027};

% Text markers
\draw[color=black, thick] (0,0.4) -- (0,0.7) node[above, text=blue] {Step 1};
\draw[color=black, thick] (7.5,0.2) -- (7.5,0.5) node[above, text=orange] {Example};
\draw[color=black, thick] (12.5,0.2) -- (12.5,0.5) node[above, text=ForestGreen] {Enseignement};
\draw[color=black, thick] (1.25, -0.2) -- (1.25, -0.5) node[below, text=blue] {I would like a list here With different colors};


% Legend
\node[draw, circle, fill=blue, inner sep=1pt, label={right:Valorisation}] at (4,-2) {};
\node[draw, circle, fill=orange, inner sep=1pt, label={right:Recherche}] at (6.5,-2) {};
\node[draw, circle, fill=ForestGreen, inner sep=1pt, label={right:Enseignement}] at (9,-2) {};

\end{tikzpicture}
\end{document}

I have two issues.

First, for each tick I would be able to write several entries presented as a list, but I don't know how to break a line. For example in the second tick I would like to have

"I would like a list here   
 With different colors"

I tried using the "\\" within the braces but TeX doesn't recognize it.

Also, for different entries of my lsit I would like to be able to use different colors, but I feel like I can only enter one color. For instance, I would like the expression "I would like a list here" to be blue whereas "With different colors" to be orange.

Is it possible to do so?

Best Answer

If you use align=center you can use \\ in your node text.

To differentiate the colors, use \textcolor{<color>}{<text>} inside the node instead to use the text option.

\documentclass{standalone}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[%
    every node/.style={
        font=\scriptsize,
        % Better alignment, see https://tex.stackexchange.com/questions/315075
        text height=1ex,
        text depth=.25ex,
    },
]

% draw horizontal line   
\draw[-] (0,0) -- (15,0);

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

\foreach \x in {0,5,...,15}{
    \draw (\x cm,3pt) -- (\x cm,8pt);
}

% place axis labels
\node[anchor=north] at (0,0) {Sep. 2024};
\node[anchor=north] at (2.5,0) {T3};
\node[anchor=north] at (5,0) {Sep. 2025};
\node[anchor=north] at (7.5,0) {T7};
\node[anchor=north] at (10,0) {Sep. 2026};
\node[anchor=north] at (12.5,0) {T11};
\node[anchor=north] at (15,0) {Sep. 2027};

% Text markers
\draw[color=black, thick] (0,0.4) -- (0,0.7) node[above, text=blue] {Step 1};
\draw[color=black, thick] (7.5,0.2) -- (7.5,0.5) node[above, text=orange] {Example};
\draw[color=black, thick] (12.5,0.2) -- (12.5,0.5) node[above, text=ForestGreen] {Enseignement};
\draw[color=black, thick] (1.25, -0.2) -- (1.25, -0.5) node[below=3.5mm, align=center] {\textcolor{blue}{I would like a list here}\\ \textcolor{orange}{With different colors}};


% Legend
\node[draw, circle, fill=blue, inner sep=1pt, label={right:Valorisation}] at (4,-2) {};
\node[draw, circle, fill=orange, inner sep=1pt, label={right:Recherche}] at (6.5,-2) {};
\node[draw, circle, fill=ForestGreen, inner sep=1pt, label={right:Enseignement}] at (9,-2) {};

\end{tikzpicture}
\end{document}

enter image description here

Related Question